1 ; RUN: opt < %s -simplifycfg -S | FileCheck %s 2 3 ; Check that the debug location for the hoisted store for "ret = 0" is a 4 ; line-0 location. 5 ; 6 ; int foo(int x) { 7 ; int ret = 1; 8 ; if (x) 9 ; ret = 0; 10 ; return ret; 11 ; } 12 ; 13 ; CHECK: store i32 1,{{.+}}!dbg ![[DLOC1:[0-9]+]] 14 ; CHECK: icmp ne {{.+}}!dbg ![[DLOC2:[0-9]+]] 15 ; CHECK: [[VREG:%[^ ]+]] = select 16 ; CHECK: store i32 [[VREG]],{{.*}} !dbg [[storeLoc:![0-9]+]] 17 ; CHECK: ret {{.+}}!dbg ![[DLOC3:[0-9]+]] 18 ; CHECK: ![[DLOC1]] = !DILocation(line: 2 19 ; CHECK: ![[DLOC2]] = !DILocation(line: 3 20 ; CHECK: [[storeLoc]] = !DILocation(line: 0 21 ; CHECK: ![[DLOC3]] = !DILocation(line: 5 22 23 target triple = "x86_64-unknown-linux-gnu" 24 25 ; Function Attrs: noinline nounwind uwtable 26 define i32 @foo(i32) !dbg !6 { 27 %2 = alloca i32, align 4 28 %3 = alloca i32, align 4 29 store i32 %0, i32* %2, align 4 30 store i32 1, i32* %3, align 4, !dbg !14 31 %4 = load i32, i32* %2, align 4, !dbg !15 32 %5 = icmp ne i32 %4, 0, !dbg !15 33 br i1 %5, label %6, label %7, !dbg !17 34 35 ; <label>:6: ; preds = %1 36 store i32 0, i32* %3, align 4, !dbg !18 37 br label %7, !dbg !19 38 39 ; <label>:7: ; preds = %6, %1 40 %8 = load i32, i32* %3, align 4, !dbg !20 41 ret i32 %8, !dbg !21 42 } 43 44 !llvm.dbg.cu = !{!0} 45 !llvm.module.flags = !{!3, !4} 46 47 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1) 48 !1 = !DIFile(filename: "foo.c", directory: "b/") 49 !2 = !{} 50 !3 = !{i32 2, !"Dwarf Version", i32 4} 51 !4 = !{i32 2, !"Debug Info Version", i32 3} 52 !5 = !{} 53 !6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) 54 !7 = !DISubroutineType(types: !8) 55 !8 = !{!9, !9} 56 !9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 57 !10 = !DILocalVariable(name: "x", arg: 1, scope: !6, file: !1, line: 1, type: !9) 58 !11 = !DIExpression() 59 !12 = !DILocation(line: 1, column: 13, scope: !6) 60 !13 = !DILocalVariable(name: "ret", scope: !6, file: !1, line: 2, type: !9) 61 !14 = !DILocation(line: 2, column: 7, scope: !6) 62 !15 = !DILocation(line: 3, column: 7, scope: !16) 63 !16 = distinct !DILexicalBlock(scope: !6, file: !1, line: 3, column: 7) 64 !17 = !DILocation(line: 3, column: 7, scope: !6) 65 !18 = !DILocation(line: 4, column: 9, scope: !16) 66 !19 = !DILocation(line: 4, column: 5, scope: !16) 67 !20 = !DILocation(line: 5, column: 10, scope: !6) 68 !21 = !DILocation(line: 5, column: 3, scope: !6) 69