llvm.org GIT mirror llvm / 0a2a30e
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344545 91177308-0d34-0410-b5e6-96231b3b80d8 Vedant Kumar 1 year, 1 month ago
2 changed file(s) with 64 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
12851285 }
12861286 }
12871287
1288 // Erase debug info intrinsics. Variable updates within the new function are
1289 // invisible to debuggers. This could be improved by defining a DISubprogram
1290 // for the new function.
1291 for (BasicBlock &BB : *newFunction) {
1292 auto BlockIt = BB.begin();
1293 while (BlockIt != BB.end()) {
1294 Instruction *Inst = &*BlockIt;
1295 ++BlockIt;
1296 if (isa(Inst))
1297 Inst->eraseFromParent();
1298 }
1299 }
1300
12881301 LLVM_DEBUG(if (verifyFunction(*newFunction))
12891302 report_fatal_error("verifyFunction failed!"));
12901303 return newFunction;
0 ; RUN: opt -hotcoldsplit -S < %s | FileCheck %s
1
2 ; CHECK-LABEL: define {{.*}}@foo_if.end
3 ; CHECK-NOT: llvm.dbg.value
4
5 define void @foo(i32 %arg1) !dbg !6 {
6 entry:
7 %var = add i32 0, 0, !dbg !11
8 br i1 undef, label %if.then, label %if.end, !dbg !12
9
10 if.then: ; preds = %entry
11 unreachable, !dbg !13
12
13 if.end: ; preds = %entry
14 call void @llvm.dbg.value(metadata i32 %arg1, metadata !9, metadata !DIExpression()), !dbg !11
15 br label %if.then12, !dbg !14
16
17 if.then12: ; preds = %if.end
18 br label %cleanup40, !dbg !15
19
20 cleanup40: ; preds = %if.then12
21 br label %return, !dbg !16
22
23 return: ; preds = %cleanup40
24 ret void, !dbg !17
25 }
26
27 declare void @llvm.dbg.value(metadata, metadata, metadata)
28
29 !llvm.dbg.cu = !{!0}
30 !llvm.debugify = !{!3, !4}
31 !llvm.module.flags = !{!5}
32
33 !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
34 !1 = !DIFile(filename: "", directory: "/")
35 !2 = !{}
36 !3 = !{i32 7}
37 !4 = !{i32 1}
38 !5 = !{i32 2, !"Debug Info Version", i32 3}
39 !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)
40 !7 = !DISubroutineType(types: !2)
41 !8 = !{!9}
42 !9 = !DILocalVariable(name: "1", scope: !6, file: !1, line: 1, type: !10)
43 !10 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
44 !11 = !DILocation(line: 1, column: 1, scope: !6)
45 !12 = !DILocation(line: 2, column: 1, scope: !6)
46 !13 = !DILocation(line: 3, column: 1, scope: !6)
47 !14 = !DILocation(line: 4, column: 1, scope: !6)
48 !15 = !DILocation(line: 5, column: 1, scope: !6)
49 !16 = !DILocation(line: 6, column: 1, scope: !6)
50 !17 = !DILocation(line: 7, column: 1, scope: !6)