Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -simplifycfg -S | FileCheck %s |
| 2 | |
| 3 | ; TODO: Track the acutal DebugLoc of the hoisted instruction when no-line |
| 4 | ; DebugLoc is supported (https://reviews.llvm.org/D24180) |
| 5 | |
| 6 | ; Checks if the debug info for hoisted "x = i" is removed and |
| 7 | ; the debug info for hoisted "bar()" is set as line 0 |
| 8 | ; int x; |
| 9 | ; void bar(); |
| 10 | ; void baz(); |
| 11 | ; |
| 12 | ; void foo(int i) { |
| 13 | ; if (i == 0) { |
| 14 | ; x = i; |
| 15 | ; bar(); |
| 16 | ; } else { |
| 17 | ; x = i; |
| 18 | ; bar(); |
| 19 | ; baz(); |
| 20 | ; } |
| 21 | ; } |
| 22 | |
| 23 | target triple = "x86_64-unknown-linux-gnu" |
| 24 | |
| 25 | @x = global i32 0, align 4 |
| 26 | |
| 27 | ; Function Attrs: uwtable |
| 28 | define void @_Z3fooi(i32) #0 !dbg !6 { |
| 29 | ; CHECK: load i32, i32* %2, align 4, !dbg ![[LOAD:[0-9]+]], !tbaa |
| 30 | ; CHECK: store i32 %5, i32* @x, align 4, !dbg ![[BAR:[0-9]+]], !tbaa |
| 31 | ; CHECK: call void @_Z3barv(), !dbg ![[BAR]] |
| 32 | ; CHECK: call void @_Z3bazv(), !dbg ![[BAZ:[0-9]+]] |
| 33 | %2 = alloca i32, align 4 |
| 34 | store i32 %0, i32* %2, align 4, !tbaa !8 |
| 35 | %3 = load i32, i32* %2, align 4, !dbg !12, !tbaa !8 |
| 36 | %4 = icmp eq i32 %3, 0, !dbg !13 |
| 37 | br i1 %4, label %5, label %7, !dbg !12 |
| 38 | |
| 39 | ; <label>:5: |
| 40 | %6 = load i32, i32* %2, align 4, !dbg !14, !tbaa !8 |
| 41 | store i32 %6, i32* @x, align 4, !dbg !15, !tbaa !8 |
| 42 | call void @_Z3barv(), !dbg !16 |
| 43 | br label %9, !dbg !17 |
| 44 | |
| 45 | ; <label>:7: |
| 46 | %8 = load i32, i32* %2, align 4, !dbg !18, !tbaa !8 |
| 47 | store i32 %8, i32* @x, align 4, !dbg !19, !tbaa !8 |
| 48 | call void @_Z3barv(), !dbg !20 |
| 49 | call void @_Z3bazv(), !dbg !21 |
| 50 | br label %9 |
| 51 | |
| 52 | ; <label>:9: |
| 53 | ret void, !dbg !21 |
| 54 | } |
| 55 | |
| 56 | declare void @_Z3barv() #1 |
| 57 | |
| 58 | declare void @_Z3bazv() #1 |
| 59 | |
| 60 | !llvm.dbg.cu = !{!0} |
| 61 | !llvm.module.flags = !{!3, !4} |
| 62 | |
| 63 | ; CHECK: ![[LOAD]] = !DILocation(line: 6, column: 7 |
| 64 | ; CHECK: ![[BAR]] = !DILocation(line: 0 |
| 65 | ; CHECK: ![[BAZ]] = !DILocation(line: 12, column: 5 |
| 66 | !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1) |
| 67 | !1 = !DIFile(filename: "a", directory: "b/") |
| 68 | !2 = !{} |
| 69 | !3 = !{i32 2, !"Dwarf Version", i32 4} |
| 70 | !4 = !{i32 2, !"Debug Info Version", i32 3} |
| 71 | !5 = !{} |
| 72 | !6 = distinct !DISubprogram(unit: !0) |
| 73 | !7 = !DISubroutineType(types: !2) |
| 74 | !8 = !{!9, !9, i64 0} |
| 75 | !9 = !{!"int", !10, i64 0} |
| 76 | !10 = !{!"omnipotent char", !11, i64 0} |
| 77 | !11 = !{!"Simple C++ TBAA"} |
| 78 | !12 = !DILocation(line: 6, column: 7, scope: !6) |
| 79 | !13 = !DILocation(line: 6, column: 9, scope: !6) |
| 80 | !14 = !DILocation(line: 7, column: 9, scope: !6) |
| 81 | !15 = !DILocation(line: 7, column: 7, scope: !6) |
| 82 | !16 = !DILocation(line: 8, column: 5, scope: !6) |
| 83 | !17 = !DILocation(line: 9, column: 3, scope: !6) |
| 84 | !18 = !DILocation(line: 10, column: 9, scope: !6) |
| 85 | !19 = !DILocation(line: 10, column: 7, scope: !6) |
| 86 | !20 = !DILocation(line: 11, column: 5, scope: !6) |
| 87 | !21 = !DILocation(line: 12, column: 5, scope: !6) |
| 88 | !22 = !DILocation(line: 14, column: 1, scope: !6) |