summaryrefslogtreecommitdiffstats
path: root/llvm/tools/opt/Debugify.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2018-06-05 00:56:07 +0000
committerVedant Kumar <vsk@apple.com>2018-06-05 00:56:07 +0000
commit800255f9f1da61f65ab483f2c5aaaf870bdfa862 (patch)
treead78f8aa410902c7dd829636d92c96e6ef7518bc /llvm/tools/opt/Debugify.cpp
parentab112b8e9965b409b53ff14792384111641004b9 (diff)
downloadbcm5719-llvm-800255f9f1da61f65ab483f2c5aaaf870bdfa862.tar.gz
bcm5719-llvm-800255f9f1da61f65ab483f2c5aaaf870bdfa862.zip
[Debugify] Don't insert debug values after terminating deopts
As is the case with musttail calls, the IR does not allow for instructions inserted after a terminating deopt. llvm-svn: 333976
Diffstat (limited to 'llvm/tools/opt/Debugify.cpp')
-rw-r--r--llvm/tools/opt/Debugify.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/llvm/tools/opt/Debugify.cpp b/llvm/tools/opt/Debugify.cpp
index aa967a72aa0..f12eabfa895 100644
--- a/llvm/tools/opt/Debugify.cpp
+++ b/llvm/tools/opt/Debugify.cpp
@@ -39,6 +39,19 @@ bool isFunctionSkipped(Function &F) {
return F.isDeclaration() || !F.hasExactDefinition();
}
+/// Find a suitable insertion point for debug values intrinsics.
+///
+/// These must be inserted before the terminator. Special care is needed to
+/// handle musttail and deopt calls, as these behave like (but are in fact not)
+/// terminators.
+Instruction *findDebugValueInsertionPoint(BasicBlock &BB) {
+ if (auto *I = BB.getTerminatingMustTailCall())
+ return I;
+ if (auto *I = BB.getTerminatingDeoptimizeCall())
+ return I;
+ return BB.getTerminator();
+}
+
bool applyDebugifyMetadata(Module &M,
iterator_range<Module::iterator> Functions,
StringRef Banner) {
@@ -91,11 +104,7 @@ 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();
+ Instruction *LastInst = findDebugValueInsertionPoint(BB);
// Attach debug values.
for (auto It = BB.begin(), End = LastInst->getIterator(); It != End;
OpenPOWER on IntegriCloud