summaryrefslogtreecommitdiffstats
path: root/llvm/tools/opt/Debugify.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2018-06-04 03:33:01 +0000
committerVedant Kumar <vsk@apple.com>2018-06-04 03:33:01 +0000
commit7dda22115ed335fc1de0f03520547a54fba19b8d (patch)
treec34bb6d231ef9b11157c94771fdd3b17c2249f45 /llvm/tools/opt/Debugify.cpp
parentae5f0a8a78ecac872ab4a02dc387402263812bf5 (diff)
downloadbcm5719-llvm-7dda22115ed335fc1de0f03520547a54fba19b8d.tar.gz
bcm5719-llvm-7dda22115ed335fc1de0f03520547a54fba19b8d.zip
[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. llvm-svn: 333866
Diffstat (limited to 'llvm/tools/opt/Debugify.cpp')
-rw-r--r--llvm/tools/opt/Debugify.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/llvm/tools/opt/Debugify.cpp b/llvm/tools/opt/Debugify.cpp
index f26a95f2ba1..0a900a520ab 100644
--- a/llvm/tools/opt/Debugify.cpp
+++ b/llvm/tools/opt/Debugify.cpp
@@ -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);
OpenPOWER on IntegriCloud