summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/DebugInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r--llvm/lib/IR/DebugInfo.cpp34
1 files changed, 21 insertions, 13 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 18ec7cdfdba..e8c62961eba 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -247,20 +247,8 @@ bool llvm::stripDebugInfo(Function &F) {
Changed = true;
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.
- // 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() == Declare ||
- CI->getCalledFunction() == DbgVal)) {
- CI->eraseFromParent();
- Changed = true;
- }
+ for (Instruction &I : BB) {
if (I.getDebugLoc()) {
Changed = true;
I.setDebugLoc(DebugLoc());
@@ -273,6 +261,26 @@ bool llvm::stripDebugInfo(Function &F) {
bool llvm::StripDebugInfo(Module &M) {
bool Changed = false;
+ // Remove all of the calls to the debugger intrinsics, and remove them from
+ // the module.
+ if (Function *Declare = M.getFunction("llvm.dbg.declare")) {
+ while (!Declare->use_empty()) {
+ CallInst *CI = cast<CallInst>(Declare->user_back());
+ CI->eraseFromParent();
+ }
+ Declare->eraseFromParent();
+ Changed = true;
+ }
+
+ if (Function *DbgVal = M.getFunction("llvm.dbg.value")) {
+ while (!DbgVal->use_empty()) {
+ CallInst *CI = cast<CallInst>(DbgVal->user_back());
+ CI->eraseFromParent();
+ }
+ DbgVal->eraseFromParent();
+ Changed = true;
+ }
+
for (Module::named_metadata_iterator NMI = M.named_metadata_begin(),
NME = M.named_metadata_end(); NMI != NME;) {
NamedMDNode *NMD = &*NMI;
OpenPOWER on IntegriCloud