1 ; Test that alloca merging in the inliner places dbg.declare calls after the
2 ; merged alloca, but does not otherwise reorder them.
4 ; clang -g -S -emit-llvm -Xclang -disable-llvm-optzns
6 ;__attribute__((always_inline)) void f() {
11 ;__attribute__((always_inline)) void g() {
21 ; RUN: opt -always-inline -S -enable-new-pm=0 < %s | FileCheck %s
23 ; FIXME: Why does the dbg.declare for "aaa" occur later in @h than the
24 ; dbg.declare for "bbb"? I'd expect the opposite, given @f is inlined earlier.
26 ; CHECK: define void @h()
28 ; CHECK-NEXT: %[[AI:.*]] = alloca [100 x i8]
29 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata [100 x i8]* %[[AI]], metadata [[BBB:![0-9]+]]
31 ; CHECK-NEXT: llvm.lifetime.start
32 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata [100 x i8]* %[[AI]], metadata [[AAA:![0-9]+]]
34 ; CHECK: [[AAA]] = !DILocalVariable(name: "aaa"
35 ; CHECK: [[BBB]] = !DILocalVariable(name: "bbb"
37 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
38 target triple = "x86_64-unknown-linux-gnu"
40 ; Function Attrs: alwaysinline nounwind uwtable
41 define void @f() #0 !dbg !4 {
43 %aaa = alloca [100 x i8], align 16
44 call void @llvm.dbg.declare(metadata [100 x i8]* %aaa, metadata !12, metadata !17), !dbg !18
45 %arrayidx = getelementptr inbounds [100 x i8], [100 x i8]* %aaa, i64 0, i64 10, !dbg !19
46 store i8 1, i8* %arrayidx, align 2, !dbg !20
50 ; Function Attrs: nounwind readnone
51 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
53 ; Function Attrs: alwaysinline nounwind uwtable
54 define void @g() #0 !dbg !7 {
56 %bbb = alloca [100 x i8], align 16
57 call void @llvm.dbg.declare(metadata [100 x i8]* %bbb, metadata !22, metadata !17), !dbg !23
58 %arrayidx = getelementptr inbounds [100 x i8], [100 x i8]* %bbb, i64 0, i64 20, !dbg !24
59 store i8 1, i8* %arrayidx, align 4, !dbg !25
63 ; Function Attrs: nounwind uwtable
64 define void @h() #2 !dbg !8 {
66 call void @f(), !dbg !27
67 call void @g(), !dbg !28
71 attributes #0 = { alwaysinline nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
72 attributes #1 = { nounwind readnone }
73 attributes #2 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
76 !llvm.module.flags = !{!9, !10}
79 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0 (trunk 248518) (llvm/trunk 248512)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
80 !1 = !DIFile(filename: "../1.c", directory: "/code/llvm-git/build")
82 !4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, unit: !0, retainedNodes: !2)
83 !5 = !DISubroutineType(types: !6)
85 !7 = distinct !DISubprogram(name: "g", scope: !1, file: !1, line: 6, type: !5, isLocal: false, isDefinition: true, scopeLine: 6, isOptimized: false, unit: !0, retainedNodes: !2)
86 !8 = distinct !DISubprogram(name: "h", scope: !1, file: !1, line: 11, type: !5, isLocal: false, isDefinition: true, scopeLine: 11, isOptimized: false, unit: !0, retainedNodes: !2)
87 !9 = !{i32 2, !"Dwarf Version", i32 4}
88 !10 = !{i32 2, !"Debug Info Version", i32 3}
89 !11 = !{!"clang version 3.8.0 (trunk 248518) (llvm/trunk 248512)"}
90 !12 = !DILocalVariable(name: "aaa", scope: !4, file: !1, line: 2, type: !13)
91 !13 = !DICompositeType(tag: DW_TAG_array_type, baseType: !14, size: 800, align: 8, elements: !15)
92 !14 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
94 !16 = !DISubrange(count: 100)
96 !18 = !DILocation(line: 2, column: 8, scope: !4)
97 !19 = !DILocation(line: 3, column: 3, scope: !4)
98 !20 = !DILocation(line: 3, column: 11, scope: !4)
99 !21 = !DILocation(line: 4, column: 1, scope: !4)
100 !22 = !DILocalVariable(name: "bbb", scope: !7, file: !1, line: 7, type: !13)
101 !23 = !DILocation(line: 7, column: 8, scope: !7)
102 !24 = !DILocation(line: 8, column: 3, scope: !7)
103 !25 = !DILocation(line: 8, column: 11, scope: !7)
104 !26 = !DILocation(line: 9, column: 1, scope: !7)
105 !27 = !DILocation(line: 12, column: 3, scope: !8)
106 !28 = !DILocation(line: 13, column: 3, scope: !8)
107 !29 = !DILocation(line: 14, column: 1, scope: !8)