diff options
| -rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 11 | 
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index 7a91b662388..82ce8c95e78 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -248,11 +248,18 @@ bool llvm::stripDebugInfo(Function &F) {      F.setSubprogram(nullptr);    } +  Function *Declare = F.getParent()->getFunction("llvm.dbg.declare"); +  Function *DbgVal = F.getParent()->getFunction("llvm.dbg.value");    for (BasicBlock &BB : F) {      for (auto II = BB.begin(), End = BB.end(); II != End;) {        Instruction &I = *II++; // We may delete the instruction, increment now. -      if (dyn_cast<DbgInfoIntrinsic>(&I)) { -        I.eraseFromParent(); +      // Remove all of the calls to the debugger intrinsics, and remove them +      // from the module. +      CallInst *CI = dyn_cast<CallInst>(&I); +      if (CI && CI->getCalledFunction() && +          (CI->getCalledFunction() == Declare || +           CI->getCalledFunction() == DbgVal)) { +        CI->eraseFromParent();          Changed = true;          continue;        }  | 

