1; RUN: llc -O0 %s -mtriple=aarch64 -stop-after=phi-node-elimination -o - | FileCheck %s 2 3; Test that a DEBUG_VALUE node is create for variable c after the phi has been 4; converted to a ldr. The DEBUG_VALUE must be *after* the ldr and not before it. 5 6; Created from the C code, compiled with -O0 -g and then passed through opt -mem2reg: 7; 8; int func(int a) 9; { 10; int c = 1; 11; if (a < 0 ) { 12; c = 12; 13; } 14; return c; 15; } 16; 17; Function Attrs: nounwind 18; CHECK: !14 = !DILocalVariable(name: "c" 19; CHECK-LABEL: name: func 20define i32 @func(i32 %a0) #0 !dbg !8 { 21entry: 22 call void @llvm.dbg.value(metadata i32 %a0, i64 0, metadata !12, metadata !13), !dbg !14 23 call void @llvm.dbg.value(metadata i32 1, i64 0, metadata !15, metadata !13), !dbg !16 24 %v2 = icmp slt i32 %a0, 0, !dbg !17 25 br i1 %v2, label %bb2, label %bb3, !dbg !19 26 27bb2: 28 call void @llvm.dbg.value(metadata i32 12, i64 0, metadata !15, metadata !13), !dbg !16 29 br label %bb3, !dbg !20 30 31; CHECK: bb.2.bb2: 32; CHECK: [[REG0:%[0-9]+]]:gpr32 = MOVi32imm 12 33; CHECK: [[PHIREG:%[0-9]+]]:gpr32 = COPY [[REG0]] 34 35bb3: 36; CHECK: bb.3.bb3: 37; CHECK: [[PHIDEST:%[0-9]+]]:gpr32 = COPY [[PHIREG]] 38; CHECK-NEXT: DBG_VALUE [[PHIDEST]] 39 %.0 = phi i32 [ 12, %bb2 ], [ 1, %entry ] 40 call void @llvm.dbg.value(metadata i32 %.0, i64 0, metadata !15, metadata !13), !dbg !16 41; CHECK: [[ADD:%[0-9]+]]:gpr32 = nsw ADDWrr [[PHIDEST]] 42; CHECK-NEXT: DBG_VALUE [[ADD]] 43 %v5 = add nsw i32 %.0, %a0, !dbg !22 44 call void @llvm.dbg.value(metadata i32 %v5, i64 0, metadata !15, metadata !13), !dbg !16 45 ret i32 %v5, !dbg !23 46} 47 48; Function Attrs: nounwind readnone 49declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 50 51; Function Attrs: nounwind readnone 52declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 53 54attributes #0 = { nounwind } 55attributes #1 = { nounwind readnone } 56 57!llvm.dbg.cu = !{!0} 58!llvm.module.flags = !{!3, !4, !5, !6} 59!llvm.ident = !{!7} 60 61!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) 62!1 = !DIFile(filename: "a.c", directory: "/tmp") 63!2 = !{} 64!3 = !{i32 2, !"Dwarf Version", i32 4} 65!4 = !{i32 2, !"Debug Info Version", i32 3} 66!5 = !{i32 1, !"wchar_size", i32 4} 67!6 = !{i32 1, !"min_enum_size", i32 4} 68!7 = !{!"clang"} 69!8 = distinct !DISubprogram(name: "func", scope: !1, file: !1, line: 1, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) 70!9 = !DISubroutineType(types: !10) 71!10 = !{!11, !11} 72!11 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 73!12 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !1, line: 1, type: !11) 74!13 = !DIExpression() 75!14 = !DILocation(line: 1, column: 14, scope: !8) 76!15 = !DILocalVariable(name: "c", scope: !8, file: !1, line: 3, type: !11) 77!16 = !DILocation(line: 3, column: 13, scope: !8) 78!17 = !DILocation(line: 4, column: 15, scope: !18) 79!18 = distinct !DILexicalBlock(scope: !8, file: !1, line: 4, column: 13) 80!19 = !DILocation(line: 4, column: 13, scope: !8) 81!20 = !DILocation(line: 6, column: 9, scope: !21) 82!21 = distinct !DILexicalBlock(scope: !18, file: !1, line: 4, column: 21) 83!22 = !DILocation(line: 7, column: 4, scope: !8) 84!23 = !DILocation(line: 8, column: 9, scope: !8) 85