blob: d4b2373ebf82a7c5fbd7d2c421eb7422e2e19b9c [file] [log] [blame]
Dehao Chen87823f82016-09-08 21:53:33 +00001; 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; CHECK: line: 6
6; CHECK-NOT: line: 7
7; CHECK: line: 8
8; CHECK: line: 9
9; CHECK-NOT: line: 10
10; CHECK: line: 11
11
12; Checks if the debug info for hoisted "x = i" is removed
13; int x;
14; void bar();
15; void baz();
16;
17; void foo(int i) {
18; if (i == 0) {
19; x = i;
20; bar();
21; } else {
22; x = i;
23; baz();
24; }
25; }
26
27target triple = "x86_64-unknown-linux-gnu"
28
29@x = global i32 0, align 4
30
31; Function Attrs: uwtable
32define void @_Z3fooi(i32) #0 !dbg !6 {
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 @_Z3bazv(), !dbg !20
49 br label %9
50
51; <label>:9:
52 ret void, !dbg !21
53}
54
55declare void @_Z3barv() #1
56
57declare void @_Z3bazv() #1
58
59!llvm.dbg.cu = !{!0}
60!llvm.module.flags = !{!3, !4}
61
62!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1)
63!1 = !DIFile(filename: "a", directory: "b/")
64!2 = !{}
65!3 = !{i32 2, !"Dwarf Version", i32 4}
66!4 = !{i32 2, !"Debug Info Version", i32 3}
67!5 = !{}
68!6 = distinct !DISubprogram(unit: !0)
69!7 = !DISubroutineType(types: !2)
70!8 = !{!9, !9, i64 0}
71!9 = !{!"int", !10, i64 0}
72!10 = !{!"omnipotent char", !11, i64 0}
73!11 = !{!"Simple C++ TBAA"}
74!12 = !DILocation(line: 6, column: 7, scope: !6)
75!13 = !DILocation(line: 6, column: 9, scope: !6)
76!14 = !DILocation(line: 7, column: 9, scope: !6)
77!15 = !DILocation(line: 7, column: 7, scope: !6)
78!16 = !DILocation(line: 8, column: 5, scope: !6)
79!17 = !DILocation(line: 9, column: 3, scope: !6)
80!18 = !DILocation(line: 10, column: 9, scope: !6)
81!19 = !DILocation(line: 10, column: 7, scope: !6)
82!20 = !DILocation(line: 11, column: 5, scope: !6)
83!21 = !DILocation(line: 13, column: 1, scope: !6)