[llvm] r344545 - [CodeExtractor] Erase debug intrinsics in outlined thunks (fix PR22900)
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 15 12:22:20 PDT 2018
Author: vedantk
Date: Mon Oct 15 12:22:20 2018
New Revision: 344545
URL: http://llvm.org/viewvc/llvm-project?rev=344545&view=rev
Log:
[CodeExtractor] Erase debug intrinsics in outlined thunks (fix PR22900)
Variable updates within the outlined function are invisible to
debuggers. This could be improved by defining a DISubprogram for the
new function. For the moment, simply erase the debug intrinsics instead.
This fixes verifier failures about function-local metadata being used in
the wrong function, seen while testing the hot/cold splitting pass.
rdar://45142482
Differential Revision: https://reviews.llvm.org/D53267
Added:
llvm/trunk/test/Transforms/HotColdSplit/split-out-dbg-val-of-arg.ll
Modified:
llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp
Modified: llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp?rev=344545&r1=344544&r2=344545&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp Mon Oct 15 12:22:20 2018
@@ -1286,6 +1286,19 @@ Function *CodeExtractor::extractCodeRegi
}
}
+ // Erase debug info intrinsics. Variable updates within the new function are
+ // invisible to debuggers. This could be improved by defining a DISubprogram
+ // for the new function.
+ for (BasicBlock &BB : *newFunction) {
+ auto BlockIt = BB.begin();
+ while (BlockIt != BB.end()) {
+ Instruction *Inst = &*BlockIt;
+ ++BlockIt;
+ if (isa<DbgInfoIntrinsic>(Inst))
+ Inst->eraseFromParent();
+ }
+ }
+
LLVM_DEBUG(if (verifyFunction(*newFunction))
report_fatal_error("verifyFunction failed!"));
return newFunction;
Added: llvm/trunk/test/Transforms/HotColdSplit/split-out-dbg-val-of-arg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/HotColdSplit/split-out-dbg-val-of-arg.ll?rev=344545&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/HotColdSplit/split-out-dbg-val-of-arg.ll (added)
+++ llvm/trunk/test/Transforms/HotColdSplit/split-out-dbg-val-of-arg.ll Mon Oct 15 12:22:20 2018
@@ -0,0 +1,51 @@
+; RUN: opt -hotcoldsplit -S < %s | FileCheck %s
+
+; CHECK-LABEL: define {{.*}}@foo_if.end
+; CHECK-NOT: llvm.dbg.value
+
+define void @foo(i32 %arg1) !dbg !6 {
+entry:
+ %var = add i32 0, 0, !dbg !11
+ br i1 undef, label %if.then, label %if.end, !dbg !12
+
+if.then: ; preds = %entry
+ unreachable, !dbg !13
+
+if.end: ; preds = %entry
+ call void @llvm.dbg.value(metadata i32 %arg1, metadata !9, metadata !DIExpression()), !dbg !11
+ br label %if.then12, !dbg !14
+
+if.then12: ; preds = %if.end
+ br label %cleanup40, !dbg !15
+
+cleanup40: ; preds = %if.then12
+ br label %return, !dbg !16
+
+return: ; preds = %cleanup40
+ ret void, !dbg !17
+}
+
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.debugify = !{!3, !4}
+!llvm.module.flags = !{!5}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
+!1 = !DIFile(filename: "<stdin>", directory: "/")
+!2 = !{}
+!3 = !{i32 7}
+!4 = !{i32 1}
+!5 = !{i32 2, !"Debug Info Version", i32 3}
+!6 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: !0, retainedNodes: !8)
+!7 = !DISubroutineType(types: !2)
+!8 = !{!9}
+!9 = !DILocalVariable(name: "1", scope: !6, file: !1, line: 1, type: !10)
+!10 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
+!11 = !DILocation(line: 1, column: 1, scope: !6)
+!12 = !DILocation(line: 2, column: 1, scope: !6)
+!13 = !DILocation(line: 3, column: 1, scope: !6)
+!14 = !DILocation(line: 4, column: 1, scope: !6)
+!15 = !DILocation(line: 5, column: 1, scope: !6)
+!16 = !DILocation(line: 6, column: 1, scope: !6)
+!17 = !DILocation(line: 7, column: 1, scope: !6)
More information about the llvm-commits
mailing list