[llvm] b4b5e82 - Check for all frame instructions in finalize isel. (#85945)

via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 21 08:00:12 PDT 2024


Author: Jonas Paulsson
Date: 2024-03-21T11:00:08-04:00
New Revision: b4b5e8277a86d441830dbba54917bf22b0ad8608

URL: https://github.com/llvm/llvm-project/commit/b4b5e8277a86d441830dbba54917bf22b0ad8608
DIFF: https://github.com/llvm/llvm-project/commit/b4b5e8277a86d441830dbba54917bf22b0ad8608.diff

LOG: Check for all frame instructions in finalize isel. (#85945)

Check for all frame instructions in finalize isel, not just for the
frame setup opcode. This was proven necessary, see #78001 
for discussion.

Added: 
    llvm/test/CodeGen/SystemZ/frame-adjstack.ll

Modified: 
    llvm/lib/CodeGen/FinalizeISel.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/FinalizeISel.cpp b/llvm/lib/CodeGen/FinalizeISel.cpp
index 978355f8eb1bbf..bf967eac22f177 100644
--- a/llvm/lib/CodeGen/FinalizeISel.cpp
+++ b/llvm/lib/CodeGen/FinalizeISel.cpp
@@ -59,8 +59,7 @@ bool FinalizeISel::runOnMachineFunction(MachineFunction &MF) {
 
       // Set AdjustsStack to true if the instruction selector emits a stack
       // frame setup instruction or a stack aligning inlineasm.
-      if (MI.getOpcode() == TII->getCallFrameSetupOpcode() ||
-          MI.isStackAligningInlineAsm())
+      if (TII->isFrameInstr(MI) || MI.isStackAligningInlineAsm())
         MF.getFrameInfo().setAdjustsStack(true);
 
       // If MI is a pseudo, expand it.

diff  --git a/llvm/test/CodeGen/SystemZ/frame-adjstack.ll b/llvm/test/CodeGen/SystemZ/frame-adjstack.ll
new file mode 100644
index 00000000000000..7edacaa3d7d714
--- /dev/null
+++ b/llvm/test/CodeGen/SystemZ/frame-adjstack.ll
@@ -0,0 +1,16 @@
+; RUN: llc < %s -mtriple=s390x-linux-gnu -verify-machineinstrs | FileCheck %s
+;
+; Test that inserting a new MBB near a call during finalize isel custom
+; insertion does not cause all frame instructions to be missed. That would
+; result in a missing to set the AdjustsStack flag.
+
+; CHECK-LABEL: fun
+define void @fun(i1 %cc) {
+  %sel = select i1 %cc, i32 5, i32 0
+  tail call void @input_report_abs(i32 %sel)
+  %sel2 = select i1 %cc, i32 6, i32 1
+  tail call void @input_report_abs(i32 %sel2)
+  ret void
+}
+
+declare void @input_report_abs(i32)


        


More information about the llvm-commits mailing list