1; RUN: llc -O0 %s -mtriple=aarch64 -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 18define i32 @func(i32) #0 !dbg !8 { 19 call void @llvm.dbg.value(metadata i32 %0, i64 0, metadata !12, metadata !13), !dbg !14 20 call void @llvm.dbg.value(metadata i32 1, i64 0, metadata !15, metadata !13), !dbg !16 21 %2 = icmp slt i32 %0, 0, !dbg !17 22 br i1 %2, label %3, label %4, !dbg !19 23 24; <label>:3: ; preds = %1 25 call void @llvm.dbg.value(metadata i32 12, i64 0, metadata !15, metadata !13), !dbg !16 26 br label %4, !dbg !20 27 28; <label>:4: ; preds = %3, %1 29 %.0 = phi i32 [ 12, %3 ], [ 1, %1 ] 30; CHECK: ldr w[[REG:[0-9]+]], [sp, #8] 31; CHECK-NEXT: .Ltmp 32 call void @llvm.dbg.value(metadata i32 %.0, i64 0, metadata !15, metadata !13), !dbg !16 33; CHECK-NEXT: //DEBUG_VALUE: func:c <- $w[[REG]] 34 %5 = add nsw i32 %.0, %0, !dbg !22 35 call void @llvm.dbg.value(metadata i32 %5, i64 0, metadata !15, metadata !13), !dbg !16 36 ret i32 %5, !dbg !23 37} 38 39; Function Attrs: nounwind readnone 40declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 41 42; Function Attrs: nounwind readnone 43declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 44 45attributes #0 = { nounwind } 46attributes #1 = { nounwind readnone } 47 48!llvm.dbg.cu = !{!0} 49!llvm.module.flags = !{!3, !4, !5, !6} 50!llvm.ident = !{!7} 51 52!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) 53!1 = !DIFile(filename: "a.c", directory: "/tmp") 54!2 = !{} 55!3 = !{i32 2, !"Dwarf Version", i32 4} 56!4 = !{i32 2, !"Debug Info Version", i32 3} 57!5 = !{i32 1, !"wchar_size", i32 4} 58!6 = !{i32 1, !"min_enum_size", i32 4} 59!7 = !{!"clang"} 60!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) 61!9 = !DISubroutineType(types: !10) 62!10 = !{!11, !11} 63!11 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 64!12 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !1, line: 1, type: !11) 65!13 = !DIExpression() 66!14 = !DILocation(line: 1, column: 14, scope: !8) 67!15 = !DILocalVariable(name: "c", scope: !8, file: !1, line: 3, type: !11) 68!16 = !DILocation(line: 3, column: 13, scope: !8) 69!17 = !DILocation(line: 4, column: 15, scope: !18) 70!18 = distinct !DILexicalBlock(scope: !8, file: !1, line: 4, column: 13) 71!19 = !DILocation(line: 4, column: 13, scope: !8) 72!20 = !DILocation(line: 6, column: 9, scope: !21) 73!21 = distinct !DILexicalBlock(scope: !18, file: !1, line: 4, column: 21) 74!22 = !DILocation(line: 7, column: 4, scope: !8) 75!23 = !DILocation(line: 8, column: 9, scope: !8) 76