[llvm] r333856 - [Debugify] Skip dbg.value placement for EH pads, musttail

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 3 15:50:22 PDT 2018


Author: vedantk
Date: Sun Jun  3 15:50:22 2018
New Revision: 333856

URL: http://llvm.org/viewvc/llvm-project?rev=333856&view=rev
Log:
[Debugify] Skip dbg.value placement for EH pads, musttail

Placing meta-instructions into EH pads breaks certain IR invariants, as
does placing instructions after a musttail call.

Modified:
    llvm/trunk/test/CodeGen/X86/block-placement.ll
    llvm/trunk/test/DebugInfo/debugify.ll
    llvm/trunk/tools/opt/Debugify.cpp

Modified: llvm/trunk/test/CodeGen/X86/block-placement.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/block-placement.ll?rev=333856&r1=333855&r2=333856&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/block-placement.ll (original)
+++ llvm/trunk/test/CodeGen/X86/block-placement.ll Sun Jun  3 15:50:22 2018
@@ -1,4 +1,5 @@
 ; RUN: llc -mtriple=i686-linux -pre-RA-sched=source < %s | FileCheck %s
+; RUN: opt -disable-output -debugify < %s
 
 declare void @error(i32 %i, i32 %a, i32 %b)
 

Modified: llvm/trunk/test/DebugInfo/debugify.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/debugify.ll?rev=333856&r1=333855&r2=333856&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/debugify.ll (original)
+++ llvm/trunk/test/DebugInfo/debugify.ll Sun Jun  3 15:50:22 2018
@@ -49,6 +49,14 @@ define weak_odr zeroext i1 @baz() {
   ret i1 false
 }
 
+; CHECK-LABEL: define i32 @boom
+define i32 @boom() {
+; CHECK: [[result:%.*]] = musttail call i32 @bar(), !dbg ![[musttail:.*]]
+  %retval = musttail call i32 @bar()
+; CHECK-NEXT: ret i32 [[result]], !dbg ![[musttailRes:.*]]
+  ret i32 %retval
+}
+
 ; CHECK-DAG: !llvm.dbg.cu = !{![[CU:.*]]}
 ; CHECK-DAG: !llvm.debugify = !{![[NUM_INSTS:.*]], ![[NUM_VARS:.*]]}
 ; CHECK-DAG: "Debug Info Version"
@@ -63,13 +71,15 @@ define weak_odr zeroext i1 @baz() {
 ; CHECK-DAG: ![[CALL1]] = !DILocation(line: 2, column: 1
 ; CHECK-DAG: ![[ADD1]] = !DILocation(line: 3, column: 1
 ; CHECK-DAG: ![[RET2]] = !DILocation(line: 4, column: 1
+; CHECK-DAG: ![[musttail]] = !DILocation(line: 5, column: 1
+; CHECK-DAG: ![[musttailRes]] = !DILocation(line: 6, column: 1
 
 ; --- DILocalVariables
 ; CHECK-DAG: ![[TY32:.*]] = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
 ; CHECK-DAG: !DILocalVariable(name: "1", scope: {{.*}}, file: {{.*}}, line: 3, type: ![[TY32]])
 
 ; --- Metadata counts
-; CHECK-DAG: ![[NUM_INSTS]] = !{i32 4}
+; CHECK-DAG: ![[NUM_INSTS]] = !{i32 6}
 ; CHECK-DAG: ![[NUM_VARS]] = !{i32 1}
 
 ; --- Repeat case

Modified: llvm/trunk/tools/opt/Debugify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/Debugify.cpp?rev=333856&r1=333855&r2=333856&view=diff
==============================================================================
--- llvm/trunk/tools/opt/Debugify.cpp (original)
+++ llvm/trunk/tools/opt/Debugify.cpp Sun Jun  3 15:50:22 2018
@@ -87,6 +87,10 @@ bool applyDebugifyMetadata(Module &M,
       for (Instruction &I : BB)
         I.setDebugLoc(DILocation::get(Ctx, NextLine++, 1, SP));
 
+      // Inserting debug values into EH pads can break IR invariants.
+      if (BB.isEHPad())
+        continue;
+
       // Attach debug values.
       for (Instruction &I : BB) {
         // Skip void-valued instructions.
@@ -97,6 +101,11 @@ bool applyDebugifyMetadata(Module &M,
         if (isa<TerminatorInst>(&I) || 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(),




More information about the llvm-commits mailing list