Files
clang-p2996/llvm/test/DebugInfo/MIR/InstrRef/phi-regallocd-to-stack.mir
Stephen Tozer c383f4d655 [DebugInfo] Allow non-stack_value variadic expressions and use in DBG_INSTR_REF
Prior to this patch, variadic DIExpressions (i.e. ones that contain
DW_OP_LLVM_arg) could only be created by salvaging debug values to create
stack value expressions, resulting in a DBG_VALUE_LIST being created. As of
the previous patch in this patch stack, DBG_INSTR_REF's syntax has been
changed to match DBG_VALUE_LIST in preparation for supporting variadic
expressions. This patch adds some minor changes needed to allow variadic
expressions that aren't stack values to exist, and allows variadic expressions
that are trivially reduceable to non-variadic expressions to be handled
similarly to non-variadic expressions.

Reviewed by: jmorse

Differential Revision: https://reviews.llvm.org/D133926
2023-01-06 19:31:10 +00:00

150 lines
5.9 KiB
YAML

# RUN: llc %s -o - -mtriple=x86_64-unknown-unknown \
# RUN: -experimental-debug-variable-locations \
# RUN: -run-pass=phi-node-elimination,livedebugvars,greedy,virtregrewriter \
# RUN: | FileCheck %s
#
# Like phi-through-regalloc.mir, pass a PHI node into register allocation, and
# test that it correctly comes out, in a stack slot. Fifteen spurious PHIs have
# been added to force the register allocator to spill one.
--- |
; ModuleID = 'promoted.ll'
source_filename = "test.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define dso_local i32 @foo(i32 %bar, i32 %baz) !dbg !7 {
entry:
ret i32 0, !dbg !19
}
declare dso_local i32 @ext(i32)
; Function Attrs: nounwind readnone speculatable willreturn
declare void @llvm.dbg.value(metadata, metadata, metadata)
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5}
!llvm.ident = !{!6}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "test.c", directory: ".")
!2 = !{}
!3 = !{i32 7, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 4}
!6 = !{!"."}
!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
!8 = !DISubroutineType(types: !9)
!9 = !{!10, !10, !10}
!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!11 = !DILocalVariable(name: "bar", arg: 1, scope: !7, file: !1, line: 2, type: !10)
!12 = !DILocation(line: 0, scope: !7)
!13 = !DILocalVariable(name: "baz", arg: 2, scope: !7, file: !1, line: 2, type: !10)
!14 = !DILocalVariable(name: "either", scope: !7, file: !1, line: 3, type: !10)
!15 = !DILocation(line: 4, column: 7, scope: !16)
!16 = distinct !DILexicalBlock(scope: !7, file: !1, line: 4, column: 7)
!17 = !DILocation(line: 4, column: 7, scope: !7)
!18 = !DILocation(line: 0, scope: !16)
!19 = !DILocation(line: 9, column: 3, scope: !7)
...
---
name: foo
alignment: 16
tracksRegLiveness: true
registers:
- { id: 0, class: gr32 }
- { id: 1, class: gr32 }
- { id: 2, class: gr32 }
- { id: 3, class: gr32 }
- { id: 4, class: gr32 }
liveins:
- { reg: '$edi', virtual-reg: '%1' }
- { reg: '$esi', virtual-reg: '%2' }
frameInfo:
maxAlignment: 1
hasCalls: true
machineFunctionInfo: {}
body: |
; CHECK-LABEL: bb.0:
; CHECK: renamable $ebp = COPY $edi
; CHECK: MOV32mr %stack.1, 1, $noreg, 0, $noreg, killed renamable $ebp
bb.0:
successors: %bb.2(0x50000000), %bb.1(0x30000000)
liveins: $edi, $esi
DBG_VALUE $edi, $noreg, !11, !DIExpression(), debug-location !12
DBG_VALUE $esi, $noreg, !13, !DIExpression(), debug-location !12
%2:gr32 = COPY killed $esi
%1:gr32 = COPY killed $edi
ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !15
%3:gr32 = MOV32r0 implicit-def dead $eflags
$edi = COPY killed %3, debug-location !15
CALL64pcrel32 @ext, csr_64, implicit $rsp, implicit $ssp, implicit killed $edi, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !15
ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !15
%4:gr32 = COPY killed $eax, debug-location !15
%10:gr32 = MOV32ri 0
%11:gr32 = MOV32ri 1
%12:gr32 = MOV32ri 2
%13:gr32 = MOV32ri 3
%14:gr32 = MOV32ri 4
%15:gr32 = MOV32ri 5
%16:gr32 = MOV32ri 6
%17:gr32 = MOV32ri 7
%18:gr32 = MOV32ri 8
%19:gr32 = MOV32ri 9
%20:gr32 = MOV32ri 10
%21:gr32 = MOV32ri 11
%22:gr32 = MOV32ri 12
%23:gr32 = MOV32ri 13
%24:gr32 = MOV32ri 14
TEST32rr killed %4, %4, implicit-def $eflags, debug-location !15
JCC_1 %bb.2, 5, implicit killed $eflags, debug-location !17
JMP_1 %bb.1, debug-location !17
bb.1:
%30:gr32 = MOV32ri 0
%31:gr32 = MOV32ri 1
%32:gr32 = MOV32ri 2
%33:gr32 = MOV32ri 3
%34:gr32 = MOV32ri 4
%35:gr32 = MOV32ri 5
%36:gr32 = MOV32ri 6
%37:gr32 = MOV32ri 7
%38:gr32 = MOV32ri 8
%39:gr32 = MOV32ri 9
%40:gr32 = MOV32ri 10
%41:gr32 = MOV32ri 11
%42:gr32 = MOV32ri 12
%43:gr32 = MOV32ri 13
%44:gr32 = MOV32ri 14
; CHECK-LABEL: bb.2:
bb.2:
%0:gr32 = PHI %1, %bb.0, %2, %bb.1, debug-instr-number 1, debug-location !18
%50:gr32 = PHI %10, %bb.0, %30, %bb.1, debug-location !18
%51:gr32 = PHI %11, %bb.0, %31, %bb.1, debug-location !18
%52:gr32 = PHI %12, %bb.0, %32, %bb.1, debug-location !18
%53:gr32 = PHI %13, %bb.0, %33, %bb.1, debug-location !18
%54:gr32 = PHI %14, %bb.0, %34, %bb.1, debug-location !18
%55:gr32 = PHI %15, %bb.0, %35, %bb.1, debug-location !18
%56:gr32 = PHI %16, %bb.0, %36, %bb.1, debug-location !18
%57:gr32 = PHI %17, %bb.0, %37, %bb.1, debug-location !18
%58:gr32 = PHI %18, %bb.0, %38, %bb.1, debug-location !18
%59:gr32 = PHI %19, %bb.0, %39, %bb.1, debug-location !18
%60:gr32 = PHI %20, %bb.0, %40, %bb.1, debug-location !18
%61:gr32 = PHI %21, %bb.0, %41, %bb.1, debug-location !18
%62:gr32 = PHI %22, %bb.0, %42, %bb.1, debug-location !18
%63:gr32 = PHI %23, %bb.0, %43, %bb.1, debug-location !18
%64:gr32 = PHI %24, %bb.0, %44, %bb.1, debug-location !18
DBG_INSTR_REF !14, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0), debug-location !12
; CHECK: DBG_PHI %stack.1, 1, 32
; CHECK: renamable $eax = MOV32rm %stack.1,
; CHECK: DBG_INSTR_REF {{.+}}, dbg-instr-ref(1, 0)
$eax = COPY killed %0, debug-location !19
RET 0, killed $eax, debug-location !19
...