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

Fixme: Stack #85014

Closed
wants to merge 1 commit into from
Closed

Fixme: Stack #85014

wants to merge 1 commit into from

Conversation

AreaZR
Copy link
Contributor

@AreaZR AreaZR commented Mar 13, 2024

No description provided.

@llvmbot
Copy link

llvmbot commented Mar 13, 2024

@llvm/pr-subscribers-backend-arm

Author: AtariDreams (AtariDreams)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/85014.diff

1 Files Affected:

  • (modified) llvm/lib/Target/ARM/Thumb1FrameLowering.cpp (+20-8)
diff --git a/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp b/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
index 0f4ece64bff532..2c4019f2acfa44 100644
--- a/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
+++ b/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
@@ -1049,16 +1049,28 @@ static void popRegsFromStack(MachineBasicBlock &MBB,
         continue;
 
       if (Reg == ARM::LR) {
-        if (!MBB.succ_empty() ||
-            MI->getOpcode() == ARM::TCRETURNdi ||
-            MI->getOpcode() == ARM::TCRETURNri)
-          // LR may only be popped into PC, as part of return sequence.
-          // If this isn't the return sequence, we'll need emitPopSpecialFixUp
-          // to restore LR the hard way.
-          // FIXME: if we don't pass any stack arguments it would be actually
+        if (!MBB.succ_empty() || MI->getOpcode() == ARM::TCRETURNdi ||
+            MI->getOpcode() == ARM::TCRETURNri) {
+          
+          // If we don't pass any stack arguments it would be actually
           // advantageous *and* correct to do the conversion to an ordinary call
           // instruction here.
-          continue;
+
+          // Get the MachineFrameInfo.
+          const MachineFrameInfo &MFI = MF.getFrameInfo();
+
+          // Check if there are any stack arguments.
+          bool hasStackArgs = MFI.hasStackObjects();
+
+          // If we have stack args, then LR may only be popped into PC,
+          // as part of the return sequence.
+          //
+          // If this isn't the return sequence, and we have the stack to deal
+          // with, we'll need emitPopSpecialFixUp to restore LR the hard way.
+          if (hasStackArgs)
+            continue;
+        }
+
         // Special epilogue for vararg functions. See emitEpilogue
         if (IsVarArg)
           continue;

Copy link

github-actions bot commented Mar 13, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@AreaZR AreaZR marked this pull request as draft May 16, 2024 00:17
@AreaZR AreaZR closed this Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants