blob: 9fa614c770827de6258f75062b816007efd9b232 [file] [log] [blame]
Alexey Samsonovb7f02d32015-06-09 22:10:29 +00001; Check that LoopSimplify creates debug locations in synthesized basic blocks.
2; RUN: opt -loop-simplify %s -S -o - | FileCheck %s
3
4%union.anon = type { i32 }
5%"Length" = type <{ %union.anon, i8, i8, i8, i8 }>
6declare void @bar(%"Length"*) #3
7@catchtypeinfo = external unnamed_addr constant { i8*, i8*, i8* }
8declare i32 @__gxx_personality_v0(...)
9declare void @f1()
10declare void @f2()
11declare void @f3()
12
13; CHECK-LABEL: @foo
14; CHECK: for.body.preheader:
15; CHECK-NEXT: br label %for.body, !dbg [[PREHEADER_LOC:![0-9]+]]
16; CHECK: for.end.loopexit:
17; CHECK-NEXT: br label %for.end, !dbg [[LOOPEXIT_LOC:![0-9]+]]
18
Peter Collingbourned4bff302015-11-05 22:03:56 +000019define linkonce_odr hidden void @foo(%"Length"* %begin, %"Length"* %end) nounwind ssp uwtable align 2 !dbg !6 {
Alexey Samsonovb7f02d32015-06-09 22:10:29 +000020entry:
21 %cmp.4 = icmp eq %"Length"* %begin, %end, !dbg !7
22 br i1 %cmp.4, label %for.end, label %for.body, !dbg !8
23
24for.body: ; preds = %entry, %length.exit
25 %begin.sink5 = phi %"Length"* [ %incdec.ptr, %length.exit ], [ %begin, %entry ]
Adrian Prantlabe04752017-07-28 20:21:02 +000026 tail call void @llvm.dbg.value(metadata %"Length"* %begin.sink5, metadata !15, metadata !16), !dbg !17
Alexey Samsonovb7f02d32015-06-09 22:10:29 +000027 %m_type.i.i.i = getelementptr inbounds %"Length", %"Length"* %begin.sink5, i64 0, i32 2, !dbg !9
28 %0 = load i8, i8* %m_type.i.i.i, align 1, !dbg !9
29 %cmp.i.i = icmp eq i8 %0, 9, !dbg !7
30 br i1 %cmp.i.i, label %if.then.i, label %length.exit, !dbg !8
31
32if.then.i: ; preds = %for.body
33 tail call void @bar(%"Length"* %begin.sink5) #7, !dbg !10
34 br label %length.exit, !dbg !10
35
36length.exit: ; preds = %for.body, %if.then.i
37 %incdec.ptr = getelementptr inbounds %"Length", %"Length"* %begin.sink5, i64 1, !dbg !11
38 %cmp = icmp eq %"Length"* %incdec.ptr, %end, !dbg !7
39 br i1 %cmp, label %for.end, label %for.body, !dbg !8
40
41for.end: ; preds = %length.exit, %entry
42 ret void, !dbg !12
43}
44
45; CHECK-LABEL: @with_landingpad
46; CHECK: catch.preheader:
47; CHECK: br label %catch, !dbg [[LPAD_PREHEADER_LOC:![0-9]+]]
48; CHECK: catch.preheader.split-lp:
49; CHECK: br label %catch, !dbg [[LPAD_PREHEADER_LOC]]
50
David Majnemer7fddecc2015-06-17 20:52:32 +000051define void @with_landingpad() uwtable ssp personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
Alexey Samsonovb7f02d32015-06-09 22:10:29 +000052entry:
53 invoke void @f1() to label %try.cont19 unwind label %catch, !dbg !13
54
55catch: ; preds = %if.else, %entry
David Majnemer7fddecc2015-06-17 20:52:32 +000056 %0 = landingpad { i8*, i32 }
Alexey Samsonovb7f02d32015-06-09 22:10:29 +000057 catch i8* bitcast ({ i8*, i8*, i8* }* @catchtypeinfo to i8*), !dbg !13
58 invoke void @f3() to label %if.else unwind label %eh.resume, !dbg !13
59
60if.else: ; preds = %catch
61 invoke void @f2() to label %try.cont19 unwind label %catch, !dbg !13
62
63try.cont19: ; preds = %if.else, %entry
64 ret void, !dbg !13
65
66eh.resume: ; preds = %catch
David Majnemer7fddecc2015-06-17 20:52:32 +000067 %1 = landingpad { i8*, i32 }
Alexey Samsonovb7f02d32015-06-09 22:10:29 +000068 cleanup catch i8* bitcast ({ i8*, i8*, i8* }* @catchtypeinfo to i8*), !dbg !13
69 resume { i8*, i32 } undef, !dbg !13
70}
71
Taewook Oh2e945eb2017-02-14 21:10:40 +000072; Function Attrs: nounwind readnone
Adrian Prantlabe04752017-07-28 20:21:02 +000073declare void @llvm.dbg.value(metadata, metadata, metadata)
Taewook Oh2e945eb2017-02-14 21:10:40 +000074
Alexey Samsonovb7f02d32015-06-09 22:10:29 +000075; CHECK-DAG: [[PREHEADER_LOC]] = !DILocation(line: 73, column: 27, scope: !{{[0-9]+}})
76; CHECK-DAG: [[LOOPEXIT_LOC]] = !DILocation(line: 75, column: 9, scope: !{{[0-9]+}})
77; CHECK-DAG: [[LPAD_PREHEADER_LOC]] = !DILocation(line: 85, column: 1, scope: !{{[0-9]+}})
78
79!llvm.module.flags = !{!0, !1, !2}
Davide Italianoea040262016-04-05 23:37:08 +000080!llvm.dbg.cu = !{!14}
Alexey Samsonovb7f02d32015-06-09 22:10:29 +000081!0 = !{i32 2, !"Dwarf Version", i32 4}
82!1 = !{i32 2, !"Debug Info Version", i32 3}
83!2 = !{i32 1, !"PIC Level", i32 2}
84
85!3 = !{}
86!4 = !DISubroutineType(types: !3)
87!5 = !DIFile(filename: "Vector.h", directory: "/tmp")
Adrian Prantl75819ae2016-04-15 15:57:41 +000088!6 = distinct !DISubprogram(name: "destruct", scope: !5, file: !5, line: 71, type: !4, isLocal: false, isDefinition: true, scopeLine: 72, flags: DIFlagPrototyped, isOptimized: false, unit: !14, variables: !3)
Alexey Samsonovb7f02d32015-06-09 22:10:29 +000089!7 = !DILocation(line: 73, column: 38, scope: !6)
90!8 = !DILocation(line: 73, column: 13, scope: !6)
91!9 = !DILocation(line: 73, column: 27, scope: !6)
92!10 = !DILocation(line: 74, column: 17, scope: !6)
93!11 = !DILocation(line: 73, column: 46, scope: !6)
94!12 = !DILocation(line: 75, column: 9, scope: !6)
95!13 = !DILocation(line: 85, column: 1, scope: !6)
Davide Italianoea040262016-04-05 23:37:08 +000096!14 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
97 file: !5,
98 isOptimized: true, flags: "-O2",
Adrian Prantl75819ae2016-04-15 15:57:41 +000099 splitDebugFilename: "abc.debug", emissionKind: 2)
Taewook Oh2e945eb2017-02-14 21:10:40 +0000100!15 = !DILocalVariable(name: "begin", arg: 1, scope: !6, file: !5, line: 71)
101!16 = !DIExpression()
102!17 = !DILocation(line: 71, column: 32, scope: !6)