llvm.org GIT mirror llvm / 37676b5
[EarlyCSE] If DI can't be salvaged, mark it as unavailable. Fixes PR39874. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349323 91177308-0d34-0410-b5e6-96231b3b80d8 Davide Italiano 9 months ago
2 changed file(s) with 71 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
811811 LLVM_DEBUG(dbgs() << "Skipping due to debug counter\n");
812812 continue;
813813 }
814 salvageDebugInfo(*Inst);
814 if (!salvageDebugInfo(*Inst))
815 replaceDbgUsesWithUndef(Inst);
815816 removeMSSA(Inst);
816817 Inst->eraseFromParent();
817818 Changed = true;
0 ; RUN: opt -S %s -early-cse | FileCheck %s
1
2 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
3
4 @a = global i8 25, align 1, !dbg !0
5
6 define signext i16 @b() !dbg !12 {
7 entry:
8 call void @llvm.dbg.value(metadata i16 23680, metadata !17, metadata !DIExpression()), !dbg !18
9 %0 = load i8, i8* @a, align 1, !dbg !19, !tbaa !20
10 %conv = sext i8 %0 to i16, !dbg !19
11
12 ; CHECK: call void @llvm.dbg.value(metadata i16 undef, metadata !17, metadata !DIExpression()), !dbg !18
13 ; CHECK-NEXT: call i32 (...) @optimize_me_not()
14
15 call void @llvm.dbg.value(metadata i16 %conv, metadata !17, metadata !DIExpression()), !dbg !18
16 %call = call i32 (...) @optimize_me_not(), !dbg !23
17 %1 = load i8, i8* @a, align 1, !dbg !24, !tbaa !20
18 %conv1 = sext i8 %1 to i16, !dbg !24
19 ret i16 %conv1, !dbg !25
20 }
21
22 declare void @llvm.dbg.declare(metadata, metadata, metadata)
23 declare i32 @optimize_me_not(...)
24
25 define i32 @main() !dbg !26 {
26 entry:
27 %call = call signext i16 @b(), !dbg !30
28 ret i32 0, !dbg !31
29 }
30
31 declare void @llvm.dbg.value(metadata, metadata, metadata)
32
33 !llvm.dbg.cu = !{!2}
34 !llvm.module.flags = !{!7, !8, !9, !10}
35 !llvm.ident = !{!11}
36
37 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
38 !1 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
39 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 8.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: GNU)
40 !3 = !DIFile(filename: "patatino.c", directory: "/Users/davide/llvm-monorepo/llvm-mono/build/bin")
41 !4 = !{}
42 !5 = !{!0}
43 !6 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
44 !7 = !{i32 2, !"Dwarf Version", i32 4}
45 !8 = !{i32 2, !"Debug Info Version", i32 3}
46 !9 = !{i32 1, !"wchar_size", i32 4}
47 !10 = !{i32 7, !"PIC Level", i32 2}
48 !11 = !{!"clang version 8.0.0 "}
49 !12 = distinct !DISubprogram(name: "b", scope: !3, file: !3, line: 2, type: !13, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !16)
50 !13 = !DISubroutineType(types: !14)
51 !14 = !{!15}
52 !15 = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed)
53 !16 = !{!17}
54 !17 = !DILocalVariable(name: "i", scope: !12, file: !3, line: 3, type: !15)
55 !18 = !DILocation(line: 3, column: 9, scope: !12)
56 !19 = !DILocation(line: 4, column: 7, scope: !12)
57 !20 = !{!21, !21, i64 0}
58 !21 = !{!"omnipotent char", !22, i64 0}
59 !22 = !{!"Simple C/C++ TBAA"}
60 !23 = !DILocation(line: 5, column: 3, scope: !12)
61 !24 = !DILocation(line: 6, column: 10, scope: !12)
62 !25 = !DILocation(line: 6, column: 3, scope: !12)
63 !26 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 8, type: !27, scopeLine: 8, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4)
64 !27 = !DISubroutineType(types: !28)
65 !28 = !{!29}
66 !29 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
67 !30 = !DILocation(line: 8, column: 14, scope: !26)
68 !31 = !DILocation(line: 8, column: 19, scope: !26)