StripDebugInfo: uses isa<DbgInfoIntrinsic> instead of matching against llvm.dbg.* (NFC)

Suggested by Adrian. This is NFC right now but is more clean and
robust against future potential new debug info intrinsics.

From: mehdi_amini <mehdi_amini@91177308-0d34-0410-b5e6-96231b3b80d8>
llvm-svn: 269540
This commit is contained in:
Mehdi Amini 2016-05-14 04:58:35 +00:00
parent bbf95a6299
commit cd8ee7b56a

View File

@ -248,18 +248,11 @@ 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.
// 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();
if (isa<DbgInfoIntrinsic>(&I)) {
I.eraseFromParent();
Changed = true;
continue;
}