brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.4 KiB · 9e188fa Raw
134 lines · plain
1# RUN: llc %s -o - -mtriple=x86_64-unknown-unknown \2# RUN:    -experimental-debug-variable-locations \3# RUN:    -run-pass=phi-node-elimination,livedebugvars,greedy,virtregrewriter \4# RUN:    | FileCheck %s5#6# This test checks that for a very simple PHI, we produce a corresponding7# DBG_PHI instruction, that a DBG_INSTR_REF refers to. Tests the path through8# phi-node-elimination, live debug variables, and then placement after register9# allocation.10#11# Original code, compiled with only -mem2reg, then fed to llc -stop-before...12#13#    int ext(int);14#    int foo(int bar, int baz) {15#      int either = 0;16#      if (ext(0))17#        either = bar;18#      else19#        either = baz;20#21#      return either;22#    }23#24 25--- |26  ; ModuleID = 'promoted.ll'27  source_filename = "test.c"28  target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"29  target triple = "x86_64-unknown-linux-gnu"30 31  define dso_local i32 @foo(i32 %bar, i32 %baz) !dbg !7 {32  entry:33    call void @llvm.dbg.value(metadata i32 %bar, metadata !11, metadata !DIExpression()), !dbg !1234    call void @llvm.dbg.value(metadata i32 %baz, metadata !13, metadata !DIExpression()), !dbg !1235    call void @llvm.dbg.value(metadata i32 0, metadata !14, metadata !DIExpression()), !dbg !1236    %call = call i32 @ext(i32 0), !dbg !1537    %tobool = icmp ne i32 %call, 0, !dbg !1538    br i1 %tobool, label %if.end, label %if.else, !dbg !1739 40  if.else:                                          ; preds = %entry41    call void @llvm.dbg.value(metadata i32 %baz, metadata !14, metadata !DIExpression()), !dbg !1242    br label %if.end43 44  if.end:                                           ; preds = %entry, %if.else45    %either.0 = phi i32 [ %baz, %if.else ], [ %bar, %entry ], !dbg !1846    call void @llvm.dbg.value(metadata i32 %either.0, metadata !14, metadata !DIExpression()), !dbg !1247    ret i32 %either.0, !dbg !1948  }49 50  declare dso_local i32 @ext(i32)51 52  ; Function Attrs: nounwind readnone speculatable willreturn53  declare void @llvm.dbg.value(metadata, metadata, metadata)54 55  !llvm.dbg.cu = !{!0}56  !llvm.module.flags = !{!3, !4, !5}57  !llvm.ident = !{!6}58 59  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)60  !1 = !DIFile(filename: "test.c", directory: ".")61  !2 = !{}62  !3 = !{i32 7, !"Dwarf Version", i32 4}63  !4 = !{i32 2, !"Debug Info Version", i32 3}64  !5 = !{i32 1, !"wchar_size", i32 4}65  !6 = !{!"."}66  !7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)67  !8 = !DISubroutineType(types: !9)68  !9 = !{!10, !10, !10}69  !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)70  !11 = !DILocalVariable(name: "bar", arg: 1, scope: !7, file: !1, line: 2, type: !10)71  !12 = !DILocation(line: 0, scope: !7)72  !13 = !DILocalVariable(name: "baz", arg: 2, scope: !7, file: !1, line: 2, type: !10)73  !14 = !DILocalVariable(name: "either", scope: !7, file: !1, line: 3, type: !10)74  !15 = !DILocation(line: 4, column: 7, scope: !16)75  !16 = distinct !DILexicalBlock(scope: !7, file: !1, line: 4, column: 7)76  !17 = !DILocation(line: 4, column: 7, scope: !7)77  !18 = !DILocation(line: 0, scope: !16)78  !19 = !DILocation(line: 9, column: 3, scope: !7)79 80...81---82name:            foo83alignment:       1684tracksRegLiveness: true85debugInstrRef: true86registers:87  - { id: 0, class: gr32 }88  - { id: 1, class: gr32 }89  - { id: 2, class: gr32 }90  - { id: 3, class: gr32 }91  - { id: 4, class: gr32 }92liveins:93  - { reg: '$edi', virtual-reg: '%1' }94  - { reg: '$esi', virtual-reg: '%2' }95frameInfo:96  maxAlignment:    197  adjustsStack:    true98  hasCalls:        true99machineFunctionInfo: {}100body:             |101  bb.0.entry:102    successors: %bb.2(0x50000000), %bb.1(0x30000000)103    liveins: $edi, $esi104 105    DBG_VALUE $edi, $noreg, !11, !DIExpression(), debug-location !12106    DBG_VALUE $esi, $noreg, !13, !DIExpression(), debug-location !12107    %2:gr32 = COPY killed $esi108    %1:gr32 = COPY killed $edi109    DBG_VALUE 0, $noreg, !14, !DIExpression(), debug-location !12110    ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !15111    %3:gr32 = MOV32r0 implicit-def dead $eflags112    $edi = COPY killed %3, debug-location !15113    CALL64pcrel32 @ext, csr_64, implicit $rsp, implicit $ssp, implicit killed $edi, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !15114    ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !15115    %4:gr32 = COPY killed $eax, debug-location !15116    TEST32rr killed %4, %4, implicit-def $eflags, debug-location !15117    JCC_1 %bb.2, 5, implicit killed $eflags, debug-location !17118    JMP_1 %bb.1, debug-location !17119 120  bb.1.if.else:121 122    ; CHECK-LABEL: bb.2.if.end:123  bb.2.if.end:124    %0:gr32 = PHI %1, %bb.0, %2, %bb.1, debug-instr-number 1, debug-location !18125    DBG_INSTR_REF !14, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0), debug-location !12126    ; CHECK:      DBG_PHI $ebp, 1127    ; CHECK:      DBG_INSTR_REF {{.+}}, dbg-instr-ref(1, 0)128    $eax = COPY killed %0, debug-location !19129    ; Confirm that %0 is allocated in $ebp,130    ; CHECK:      $eax = COPY killed renamable $ebp131    RET 0, killed $eax, debug-location !19132 133...134