[llvm] r333866 - [Debugify] Add debug intrinsics before terminating musttail calls
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 3 20:33:01 PDT 2018
Author: vedantk
Date: Sun Jun 3 20:33:01 2018
New Revision: 333866
URL: http://llvm.org/viewvc/llvm-project?rev=333866&view=rev
Log:
[Debugify] Add debug intrinsics before terminating musttail calls
After r333856, opt -debugify would just stop emitting debug value
intrinsics after encountering a musttail call. This wasn't sufficient to
avoid verifier failures.
Debug value intrinicss for all instructions preceding a musttail call
must also be emitted before the musttail call.
Modified:
llvm/trunk/test/Transforms/InstCombine/musttail-thunk.ll
llvm/trunk/tools/opt/Debugify.cpp
Modified: llvm/trunk/test/Transforms/InstCombine/musttail-thunk.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/musttail-thunk.ll?rev=333866&r1=333865&r2=333866&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/musttail-thunk.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/musttail-thunk.ll Sun Jun 3 20:33:01 2018
@@ -1,4 +1,5 @@
; RUN: opt -instcombine -S < %s | FileCheck %s
+; RUN: opt -debugify-each -instcombine -S < %s | FileCheck %s
; These are both direct calls, but make sure instcombine leaves the casts
; alone.
Modified: llvm/trunk/tools/opt/Debugify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/Debugify.cpp?rev=333866&r1=333865&r2=333866&view=diff
==============================================================================
--- llvm/trunk/tools/opt/Debugify.cpp (original)
+++ llvm/trunk/tools/opt/Debugify.cpp Sun Jun 3 20:33:01 2018
@@ -91,28 +91,32 @@ bool applyDebugifyMetadata(Module &M,
if (BB.isEHPad())
continue;
+ // Debug values must be inserted before a musttail call (if one is
+ // present), or before the block terminator otherwise.
+ Instruction *LastInst = BB.getTerminatingMustTailCall();
+ if (!LastInst)
+ LastInst = BB.getTerminator();
+
// Attach debug values.
- for (Instruction &I : BB) {
+ for (auto It = BB.begin(), End = LastInst->getIterator(); It != End;
+ ++It) {
+ Instruction &I = *It;
+
// Skip void-valued instructions.
if (I.getType()->isVoidTy())
continue;
- // Skip the terminator instruction and any just-inserted intrinsics.
- if (isa<TerminatorInst>(&I) || isa<DbgValueInst>(&I))
+ // Skip any just-inserted intrinsics.
+ if (isa<DbgValueInst>(&I))
break;
- // Don't insert instructions after a musttail call.
- if (auto *Call = dyn_cast<CallInst>(&I))
- if (Call->isMustTailCall())
- break;
-
std::string Name = utostr(NextVar++);
const DILocation *Loc = I.getDebugLoc().get();
auto LocalVar = DIB.createAutoVariable(SP, Name, File, Loc->getLine(),
getCachedDIType(I.getType()),
/*AlwaysPreserve=*/true);
DIB.insertDbgValueIntrinsic(&I, LocalVar, DIB.createExpression(), Loc,
- BB.getTerminator());
+ LastInst);
}
}
DIB.finalizeSubprogram(SP);
More information about the llvm-commits
mailing list