[llvm] r333976 - [Debugify] Don't insert debug values after terminating deopts
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 4 17:56:08 PDT 2018
Author: vedantk
Date: Mon Jun 4 17:56:07 2018
New Revision: 333976
URL: http://llvm.org/viewvc/llvm-project?rev=333976&view=rev
Log:
[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.
Modified:
llvm/trunk/test/CodeGen/X86/deopt-intrinsic-cconv.ll
llvm/trunk/tools/opt/Debugify.cpp
Modified: llvm/trunk/test/CodeGen/X86/deopt-intrinsic-cconv.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/deopt-intrinsic-cconv.ll?rev=333976&r1=333975&r2=333976&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/deopt-intrinsic-cconv.ll (original)
+++ llvm/trunk/test/CodeGen/X86/deopt-intrinsic-cconv.ll Mon Jun 4 17:56:07 2018
@@ -1,5 +1,6 @@
; RUN: llc < %s | FileCheck %s
; RUN: llc -debug-only=stackmaps < %s 2>&1 | FileCheck --check-prefix=STACKMAPS %s
+; RUN: opt -disable-output -debugify < %s
; REQUIRES: asserts
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
Modified: llvm/trunk/tools/opt/Debugify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/Debugify.cpp?rev=333976&r1=333975&r2=333976&view=diff
==============================================================================
--- llvm/trunk/tools/opt/Debugify.cpp (original)
+++ llvm/trunk/tools/opt/Debugify.cpp Mon Jun 4 17:56:07 2018
@@ -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;
More information about the llvm-commits
mailing list