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