1 ; RUN: opt -instcombine -S < %s | FileCheck %s 2 ; 3 ; Generated with: 4 ; 5 ; clang -S -gmlt -emit-llvm test.c -o 1.ll 6 ; opt -sroa -S 1.ll -o test.ll 7 ; 8 ; extern int bar(int i); 9 ; extern int bar2(int i); 10 ; 11 ; int foo(int a, int *d) { 12 ; if(a) { 13 ; *d = bar(a); 14 ; } else { 15 ; *d = bar2(a); 16 ; } 17 ; 18 ; return a; 19 ; } 20 ; 21 ; CHECK: define {{.*}}@foo 22 ; CHECK: if.end: 23 ; CHECK-NEXT: %storemerge = phi 24 ; 25 ; The debug location on the store should be a line-0 location. 26 ; CHECK-NEXT: store i32 %storemerge{{.*}}, align 4, !dbg [[storeLoc:![0-9]+]] 27 ; CHECK: [[storeLoc]] = !DILocation(line: 0 28 ; 29 ; ModuleID = 'test1.ll' 30 source_filename = "test.c" 31 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 32 target triple = "x86_64-unknown-linux-gnu" 33 34 ; Function Attrs: noinline nounwind uwtable 35 define i32 @foo(i32 %a, i32* %d) !dbg !6 { 36 entry: 37 %tobool = icmp ne i32 %a, 0, !dbg !8 38 br i1 %tobool, label %if.then, label %if.else, !dbg !8 39 40 if.then: ; preds = %entry 41 %call = call i32 @bar(i32 %a), !dbg !9 42 store i32 %call, i32* %d, align 4, !dbg !10 43 br label %if.end, !dbg !11 44 45 if.else: ; preds = %entry 46 %call1 = call i32 @bar2(i32 %a), !dbg !12 47 store i32 %call1, i32* %d, align 4, !dbg !13 48 br label %if.end 49 50 if.end: ; preds = %if.else, %if.then 51 ret i32 %a, !dbg !14 52 } 53 54 declare i32 @bar(i32) 55 56 declare i32 @bar2(i32) 57 58 !llvm.dbg.cu = !{!0} 59 !llvm.module.flags = !{!3, !4} 60 61 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2) 62 !1 = !DIFile(filename: "test.c", directory: "/home/probinson/projects/scratch") 63 !2 = !{} 64 !3 = !{i32 2, !"Dwarf Version", i32 4} 65 !4 = !{i32 2, !"Debug Info Version", i32 3} 66 !6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, type: !7, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) 67 !7 = !DISubroutineType(types: !2) 68 !8 = !DILocation(line: 5, column: 6, scope: !6) 69 !9 = !DILocation(line: 6, column: 12, scope: !6) 70 !10 = !DILocation(line: 6, column: 10, scope: !6) 71 !11 = !DILocation(line: 7, column: 3, scope: !6) 72 !12 = !DILocation(line: 8, column: 12, scope: !6) 73 !13 = !DILocation(line: 8, column: 10, scope: !6) 74 !14 = !DILocation(line: 10, column: 3, scope: !6) 75