-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[M68k] fix call frame destruction elimination #107579
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
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-backend-m68k Author: Janis Heims (TechnoElf) ChangesFixes #106213. This adjusts Full diff: https://github.com/llvm/llvm-project/pull/107579.diff 2 Files Affected:
diff --git a/llvm/lib/Target/M68k/M68kFrameLowering.cpp b/llvm/lib/Target/M68k/M68kFrameLowering.cpp
index 1445bac0b92e85..0512037986cb18 100644
--- a/llvm/lib/Target/M68k/M68kFrameLowering.cpp
+++ b/llvm/lib/Target/M68k/M68kFrameLowering.cpp
@@ -33,6 +33,8 @@
using namespace llvm;
+#define DEBUG_TYPE "M68k-frame"
+
M68kFrameLowering::M68kFrameLowering(const M68kSubtarget &STI, Align Alignment)
: TargetFrameLowering(StackGrowsDown, Alignment, -4), STI(STI),
TII(*STI.getInstrInfo()), TRI(STI.getRegisterInfo()) {
@@ -231,8 +233,8 @@ MachineBasicBlock::iterator M68kFrameLowering::eliminateCallFramePseudoInstr(
unsigned Opcode = I->getOpcode();
bool IsDestroy = Opcode == TII.getCallFrameDestroyOpcode();
DebugLoc DL = I->getDebugLoc();
- uint64_t Amount = !ReserveCallFrame ? I->getOperand(0).getImm() : 0;
- uint64_t InternalAmt = (IsDestroy && Amount) ? I->getOperand(1).getImm() : 0;
+ uint64_t Amount = I->getOperand(0).getImm();
+ uint64_t InternalAmt = (IsDestroy || Amount) ? I->getOperand(1).getImm() : 0;
I = MBB.erase(I);
if (!ReserveCallFrame) {
diff --git a/llvm/test/CodeGen/M68k/multiple-return.ll b/llvm/test/CodeGen/M68k/multiple-return.ll
index f52f422b194f59..8e97908324f057 100644
--- a/llvm/test/CodeGen/M68k/multiple-return.ll
+++ b/llvm/test/CodeGen/M68k/multiple-return.ll
@@ -1,8 +1,8 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=m68k-linux -verify-machineinstrs | FileCheck %s
-define { i32, i32, i32, i32 } @test() {
-; CHECK-LABEL: test:
+define { i32, i32, i32, i32 } @test0() {
+; CHECK-LABEL: test0:
; CHECK: .cfi_startproc
; CHECK-NEXT: ; %bb.0: ; %start
; CHECK-NEXT: move.l (4,%sp), %a0
@@ -18,3 +18,73 @@ define { i32, i32, i32, i32 } @test() {
start:
ret { i32, i32, i32, i32 } { i32 13, i32 17, i32 19, i32 23 }
}
+
+define void @call_test0() {
+; CHECK-LABEL: call_test0:
+; CHECK: .cfi_startproc
+; CHECK-NEXT: ; %bb.0: ; %start
+; CHECK-NEXT: suba.l #20, %sp
+; CHECK-NEXT: .cfi_def_cfa_offset -24
+; CHECK-NEXT: lea (4,%sp), %a0
+; CHECK-NEXT: move.l %a0, (%sp)
+; CHECK-NEXT: jsr test0
+; CHECK-NEXT: adda.l #16, %sp
+; CHECK-NEXT: rts
+start:
+ %val = call { i32, i32, i32, i32 } @test0()
+ ret void
+}
+
+define void @test1(ptr sret({ i32, i32, i32, i32 }) %ret_val) {
+; CHECK-LABEL: test1:
+; CHECK: .cfi_startproc
+; CHECK-NEXT: ; %bb.0: ; %start
+; CHECK-NEXT: move.l (4,%sp), %d0
+; CHECK-NEXT: move.l (%sp), %a1
+; CHECK-NEXT: adda.l #4, %sp
+; CHECK-NEXT: move.l %a1, (%sp)
+; CHECK-NEXT: rts
+start:
+ ret void
+}
+
+define void @call_test1() {
+; CHECK-LABEL: call_test1:
+; CHECK: .cfi_startproc
+; CHECK-NEXT: ; %bb.0: ; %start
+; CHECK-NEXT: suba.l #20, %sp
+; CHECK-NEXT: .cfi_def_cfa_offset -24
+; CHECK-NEXT: lea (4,%sp), %a0
+; CHECK-NEXT: move.l %a0, (%sp)
+; CHECK-NEXT: jsr test1
+; CHECK-NEXT: adda.l #16, %sp
+; CHECK-NEXT: rts
+start:
+ %ret_val = alloca { i32, i32, i32, i32 }
+ call void @test1(ptr %ret_val)
+ ret void
+}
+
+define i32 @test2() {
+; CHECK-LABEL: test2:
+; CHECK: .cfi_startproc
+; CHECK-NEXT: ; %bb.0: ; %start
+; CHECK-NEXT: moveq #13, %d0
+; CHECK-NEXT: rts
+start:
+ ret i32 13
+}
+
+define void @call_test2() {
+; CHECK-LABEL: call_test2:
+; CHECK: .cfi_startproc
+; CHECK-NEXT: ; %bb.0: ; %start
+; CHECK-NEXT: suba.l #4, %sp
+; CHECK-NEXT: .cfi_def_cfa_offset -8
+; CHECK-NEXT: jsr test2
+; CHECK-NEXT: adda.l #4, %sp
+; CHECK-NEXT: rts
+start:
+ %0 = call i32 @test2()
+ ret void
+}
|
ping @mshockwave (sorry for the wave of pings ^^) |
Ping @0x59616e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I would suggest to be a little more explicit in the commit message about the original issue, for instance "fix call frame destruction elimination when returning structs"
315c273
to
05b9e91
Compare
@mshockwave That commit message looks good now, I guess? |
If using Github's web interface to merge, it actually uses the PR description. (@TechnoElf FYI) |
@TechnoElf Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/52/builds/3623 Here is the relevant piece of the build log for the reference
|
…lvm#107579) Fixes llvm#106213. This adjusts `eliminateCallFramePseudoInstr` to match the behaviour of the X86 backend.
Fixes #106213.
This adjusts
eliminateCallFramePseudoInstr
to match the behaviour of the X86 backend.