1; Test that alloca merging in the inliner places dbg.declare calls after the 2; merged alloca, but does not otherwise reorder them. 3; 4; clang -g -S -emit-llvm -Xclang -disable-llvm-optzns 5; 6;__attribute__((always_inline)) void f() { 7; char aaa[100]; 8; aaa[10] = 1; 9;} 10; 11;__attribute__((always_inline)) void g() { 12; char bbb[100]; 13; bbb[20] = 1; 14;} 15; 16;void h() { 17; f(); 18; g(); 19;} 20; 21; RUN: opt -always-inline -S -enable-new-pm=0 < %s | FileCheck %s 22 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. 25; 26; CHECK: define void @h() 27; CHECK-NEXT: entry: 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]+]] 30; CHECK-NEXT: bitcast 31; CHECK-NEXT: llvm.lifetime.start 32; CHECK-NEXT: call void @llvm.dbg.declare(metadata [100 x i8]* %[[AI]], metadata [[AAA:![0-9]+]] 33 34; CHECK: [[AAA]] = !DILocalVariable(name: "aaa" 35; CHECK: [[BBB]] = !DILocalVariable(name: "bbb" 36 37target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 38target triple = "x86_64-unknown-linux-gnu" 39 40; Function Attrs: alwaysinline nounwind uwtable 41define void @f() #0 !dbg !4 { 42entry: 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 47 ret void, !dbg !21 48} 49 50; Function Attrs: nounwind readnone 51declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 52 53; Function Attrs: alwaysinline nounwind uwtable 54define void @g() #0 !dbg !7 { 55entry: 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 60 ret void, !dbg !26 61} 62 63; Function Attrs: nounwind uwtable 64define void @h() #2 !dbg !8 { 65entry: 66 call void @f(), !dbg !27 67 call void @g(), !dbg !28 68 ret void, !dbg !29 69} 70 71attributes #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" } 72attributes #1 = { nounwind readnone } 73attributes #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" } 74 75!llvm.dbg.cu = !{!0} 76!llvm.module.flags = !{!9, !10} 77!llvm.ident = !{!11} 78 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") 81!2 = !{} 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) 84!6 = !{null} 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) 93!15 = !{!16} 94!16 = !DISubrange(count: 100) 95!17 = !DIExpression() 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) 108