Skip to content

Commit c9b89f7

Browse files
committed
Check for all frame instructions in finalize isel.
1 parent 5fb2797 commit c9b89f7

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

llvm/lib/CodeGen/FinalizeISel.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ bool FinalizeISel::runOnMachineFunction(MachineFunction &MF) {
5959

6060
// Set AdjustsStack to true if the instruction selector emits a stack
6161
// frame setup instruction or a stack aligning inlineasm.
62-
if (MI.getOpcode() == TII->getCallFrameSetupOpcode() ||
63-
MI.isStackAligningInlineAsm())
62+
if (TII->isFrameInstr(MI) || MI.isStackAligningInlineAsm())
6463
MF.getFrameInfo().setAdjustsStack(true);
6564

6665
// If MI is a pseudo, expand it.

llvm/lib/CodeGen/PrologEpilogInserter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ void PEI::calculateCallFrameInfo(MachineFunction &MF) {
372372
MFI.computeMaxCallFrameSize(MF, &FrameSDOps);
373373
assert(MFI.getMaxCallFrameSize() <= MaxCFSIn &&
374374
"Recomputing MaxCFS gave a larger value.");
375+
assert((FrameSDOps.empty() || MF.getFrameInfo().adjustsStack()) &&
376+
"AdjustsStack not set in presence of a frame pseudo instruction.");
375377

376378
if (TFI->canSimplifyCallFramePseudos(MF)) {
377379
// If call frames are not being included as part of the stack frame, and
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; RUN: llc < %s -mtriple=s390x-linux-gnu -verify-machineinstrs | FileCheck %s
2+
;
3+
; Test that inserting a new MBB near a call during finalize isel custom
4+
; insertion does not cause all frame instructions to be missed. That would
5+
; result in a missing to set the AdjustsStack flag.
6+
7+
; CHECK-LABEL: fun
8+
define void @fun(i1 %cc) {
9+
%sel = select i1 %cc, i32 5, i32 0
10+
tail call void @input_report_abs(i32 %sel)
11+
%sel2 = select i1 %cc, i32 6, i32 1
12+
tail call void @input_report_abs(i32 %sel2)
13+
ret void
14+
}
15+
16+
declare void @input_report_abs(i32)

0 commit comments

Comments
 (0)