Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move assertion for AdjustsStack from PEI to MachineVerifier. #85698

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions llvm/lib/CodeGen/MachineVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3697,6 +3697,9 @@ void MachineVerifier::verifyStackFrame() {
if (I.getOpcode() == FrameSetupOpcode) {
if (BBState.ExitIsSetup)
report("FrameSetup is after another FrameSetup", &I);
if (!MRI->isSSA() && !MF->getFrameInfo().adjustsStack())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should have something better than isSSA. I've thought before we needed a FrameFinalized MachineFunction Property

report("AdjustsStack not set in presence of a frame pseudo "
"instruction.", &I);
BBState.ExitValue -= TII->getFrameTotalSize(I);
BBState.ExitIsSetup = true;
}
Expand All @@ -3712,6 +3715,9 @@ void MachineVerifier::verifyStackFrame() {
errs() << "FrameDestroy <" << Size << "> is after FrameSetup <"
<< AbsSPAdj << ">.\n";
}
if (!MRI->isSSA() && !MF->getFrameInfo().adjustsStack())
report("AdjustsStack not set in presence of a frame pseudo "
"instruction.", &I);
BBState.ExitValue += Size;
BBState.ExitIsSetup = false;
}
Expand Down
2 changes: 0 additions & 2 deletions llvm/lib/CodeGen/PrologEpilogInserter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,6 @@ void PEI::calculateCallFrameInfo(MachineFunction &MF) {
MFI.computeMaxCallFrameSize(MF, &FrameSDOps);
assert(MFI.getMaxCallFrameSize() <= MaxCFSIn &&
"Recomputing MaxCFS gave a larger value.");
assert((FrameSDOps.empty() || MF.getFrameInfo().adjustsStack()) &&
"AdjustsStack not set in presence of a frame pseudo instruction.");

if (TFI->canSimplifyCallFramePseudos(MF)) {
// If call frames are not being included as part of the stack frame, and
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/CodeGen/AArch64/clear-dead-implicit-def-impdef.mir
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# RUN: llc -mtriple=arm64-apple-macosx -mcpu=apple-m1 -verify-regalloc -run-pass=greedy -o - %s | FileCheck %s
---
name: func
frameInfo:
adjustsStack: true
tracksRegLiveness: true
body: |
bb.0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
name: inst_stores_to_dead_spill_implicit_def_impdef
tracksRegLiveness: true
frameInfo:
adjustsStack: true
hasCalls: true
body: |
bb.0:
Expand Down Expand Up @@ -59,6 +60,7 @@ body: |
name: inst_stores_to_dead_spill_movimm_impdef
tracksRegLiveness: true
frameInfo:
adjustsStack: true
hasCalls: true
body: |
bb.0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

---
name: widget
frameInfo:
adjustsStack: true
tracksRegLiveness: true
jumpTable:
kind: label-difference32
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/CodeGen/AMDGPU/fold-restore-undef-use.mir
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

---
name: restore_undef_copy_use
frameInfo:
adjustsStack: true
tracksRegLiveness: true
machineFunctionInfo:
maxKernArgAlign: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
name: greedy_fail_alloc_sgpr1024_spill
tracksRegLiveness: true
frameInfo:
adjustsStack: true
hasCalls: true
machineFunctionInfo:
explicitKernArgSize: 16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ registers:
- { id: 10, class: sreg_64_xexec, preferred-register: '$vcc' }
frameInfo:
maxAlignment: 1
adjustsStack: true
hasCalls: true
machineFunctionInfo:
maxKernArgAlign: 1
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/CodeGen/AMDGPU/sched-crash-dbg-value.mir
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ exposesReturnsTwice: false
legalized: false
regBankSelected: false
selected: false
frameInfo:
adjustsStack: true
tracksRegLiveness: true
liveins:
- { reg: '$vgpr0', virtual-reg: '%0' }
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/AMDGPU/sgpr-spill-wrong-stack-id.mir
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
name: sgpr_spill_wrong_stack_id
tracksRegLiveness: true
frameInfo:
adjustsStack: true
hasCalls: true
machineFunctionInfo:
scratchRSrcReg: $sgpr0_sgpr1_sgpr2_sgpr3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
name: kernel
tracksRegLiveness: true
frameInfo:
adjustsStack: true
hasCalls: true
machineFunctionInfo:
isEntryFunction: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ name: undef_identity_copy
tracksRegLiveness: true
frameInfo:
maxAlignment: 4
adjustsStack: true
hasCalls: true
machineFunctionInfo:
isEntryFunction: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
---
name: main
exposesReturnsTwice: true
frameInfo:
adjustsStack: true
stack:
- { id: 0, name: P0, size: 80, alignment: 8, local-offset: -80 }
- { id: 1, name: jb1, size: 160, alignment: 8, local-offset: -240 }
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/Hexagon/regalloc-bad-undef.mir
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ frameInfo:
stackSize: 0
offsetAdjustment: 0
maxAlignment: 0
adjustsStack: false
adjustsStack: true
hasCalls: true
maxCallFrameSize: 0
hasOpaqueSPAdjustment: false
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/CodeGen/SystemZ/RAbasic-invalid-LR-update.mir
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
---
name: autogen_SD21418
alignment: 4
frameInfo:
adjustsStack: true
tracksRegLiveness: true
registers:
- { id: 0, class: vr128bit }
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/SystemZ/clear-liverange-spillreg.mir
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ registers:
- { id: 129, class: grx32bit }
- { id: 130, class: fp64bit }
frameInfo:
adjustsStack: true
hasCalls: true
body: |
bb.0:
Expand Down
4 changes: 4 additions & 0 deletions llvm/test/CodeGen/SystemZ/int-cmp-56.mir
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ liveins:
- { reg: '$r2d', virtual-reg: '%0' }
frameInfo:
maxAlignment: 1
adjustsStack: true
hasCalls: true
machineFunctionInfo: {}
body: |
Expand Down Expand Up @@ -125,6 +126,7 @@ liveins:
- { reg: '$r2d', virtual-reg: '%0' }
frameInfo:
maxAlignment: 1
adjustsStack: true
hasCalls: true
machineFunctionInfo: {}
body: |
Expand Down Expand Up @@ -202,6 +204,7 @@ liveins:
- { reg: '$r2d', virtual-reg: '%0' }
frameInfo:
maxAlignment: 1
adjustsStack: true
hasCalls: true
machineFunctionInfo: {}
body: |
Expand Down Expand Up @@ -279,6 +282,7 @@ liveins:
- { reg: '$r2d', virtual-reg: '%0' }
frameInfo:
maxAlignment: 1
adjustsStack: true
hasCalls: true
machineFunctionInfo: {}
body: |
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/CodeGen/SystemZ/regcoal-subranges-update.mir
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ body: |
# represented for the value carried by %7.
---
name: segfault
frameInfo:
adjustsStack: true
tracksRegLiveness: true
liveins: []
body: |
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/X86/callbr-asm-kill.mir
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ liveins:
- { reg: '$rsi', virtual-reg: '%3' }
frameInfo:
maxAlignment: 1
adjustsStack: true
hasCalls: true
machineFunctionInfo: {}
body: |
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/X86/regalloc-copy-hints.mir
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ registers:
- { id: 82, class: gr32 }
frameInfo:
maxAlignment: 4
adjustsStack: true
hasCalls: true
fixedStack:
- { id: 0, size: 4, alignment: 4, stack-id: default, isImmutable: true }
Expand Down
4 changes: 4 additions & 0 deletions llvm/test/CodeGen/X86/statepoint-fastregalloc.mir
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# Tied def/use must be assigned to the same register.
---
name: test_relocate
frameInfo:
adjustsStack: true
tracksRegLiveness: true
body: |
bb.0.entry:
Expand All @@ -24,6 +26,8 @@ body: |
# These regmasks have no real meaning and chosen to allow only single register to be assignable ($rbp)
---
name: test_relocate_multi_regmasks
frameInfo:
adjustsStack: true
tracksRegLiveness: true
body: |
bb.0.entry:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ frameInfo:
stackSize: 0
offsetAdjustment: 0
maxAlignment: 1
adjustsStack: false
adjustsStack: true
hasCalls: true
stackProtector: ''
maxCallFrameSize: 4294967295
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ frameInfo:
stackSize: 0
offsetAdjustment: 0
maxAlignment: 1
adjustsStack: false
adjustsStack: true
hasCalls: true
stackProtector: ''
maxCallFrameSize: 4294967295
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ frameInfo:
stackSize: 0
offsetAdjustment: 0
maxAlignment: 4
adjustsStack: false
adjustsStack: true
hasCalls: true
stackProtector: ''
maxCallFrameSize: 4294967295
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ frameInfo:
stackSize: 0
offsetAdjustment: 0
maxAlignment: 4
adjustsStack: false
adjustsStack: true
hasCalls: true
stackProtector: ''
maxCallFrameSize: 4294967295
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/X86/statepoint-invoke-ra.mir
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ frameInfo:
stackSize: 0
offsetAdjustment: 0
maxAlignment: 4
adjustsStack: false
adjustsStack: true
hasCalls: true
stackProtector: ''
maxCallFrameSize: 4294967295
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/X86/statepoint-vreg-folding.mir
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ frameInfo:
stackSize: 0
offsetAdjustment: 0
maxAlignment: 8
adjustsStack: false
adjustsStack: true
hasCalls: true
stackProtector: ''
maxCallFrameSize: 4294967295
Expand Down
1 change: 1 addition & 0 deletions llvm/test/DebugInfo/MIR/InstrRef/phi-coalescing.mir
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ liveins:
- { reg: '$rsi', virtual-reg: '%5' }
frameInfo:
maxAlignment: 1
adjustsStack: true
hasCalls: true
machineFunctionInfo: {}
body: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
---
name: fn2
alignment: 4
frameInfo:
adjustsStack: true
tracksRegLiveness: true
registers:
- { id: 0, class: gpr32, preferred-register: '' }
Expand Down
26 changes: 26 additions & 0 deletions llvm/test/MachineVerifier/test_adjustsstack.mir
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# RUN: not --crash llc -o - -start-before=twoaddressinstruction -verify-machineinstrs %s 2>&1 \
# RUN: | FileCheck %s
# REQUIRES: aarch64-registered-target
--- |
target triple = "aarch64-unknown-linux"
declare i32 @bar(i32) nounwind
define i32 @foo() nounwind {
call i32 @bar(i32 0)
ret i32 0
}
...
---
name: foo
registers:
- { id: 0, class: gpr32 }
body: |
bb.0 (%ir-block.0):
ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
%0 = COPY $wzr
$w0 = COPY %0
BL @bar, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $w0, implicit-def $sp, implicit-def $w0
ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
$w0 = COPY killed %0
RET_ReallyLR implicit $w0
...
# CHECK-LABEL: Bad machine code: AdjustsStack not set in presence of a frame pseudo instruction.
Loading