Skip to content

[ARM] Fix expansion of ABS in a call sequence #147270

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

Merged
merged 1 commit into from
Jul 7, 2025
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
5 changes: 5 additions & 0 deletions llvm/lib/Target/ARM/ARMISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12359,6 +12359,11 @@ ARMTargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
Fn->insert(BBI, RSBBB);
Fn->insert(BBI, SinkBB);

// Set the call frame size on entry to the new basic blocks.
unsigned CallFrameSize = TII->getCallFrameSizeAt(MI);
RSBBB->setCallFrameSize(CallFrameSize);
SinkBB->setCallFrameSize(CallFrameSize);

Register ABSSrcReg = MI.getOperand(1).getReg();
Register ABSDstReg = MI.getOperand(0).getReg();
bool ABSSrcKIll = MI.getOperand(1).isKill();
Expand Down
25 changes: 25 additions & 0 deletions llvm/test/CodeGen/ARM/iabs.ll
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,28 @@ define i64 @test3(i64 %a) {
%abs = select i1 %b, i64 %a, i64 %tmp1neg
ret i64 %abs
}

declare void @callee(...)

define void @testcallframe(i32 %a) {
; CHECK-LABEL: testcallframe:
; CHECK: @ %bb.0: @ %bb
; CHECK-NEXT: .save {r11, lr}
; CHECK-NEXT: push {r11, lr}
; CHECK-NEXT: .pad #8
; CHECK-NEXT: sub sp, sp, #8
; CHECK-NEXT: cmp r0, #0
; CHECK-NEXT: mov r1, #0
; CHECK-NEXT: rsbmi r0, r0, #0
; CHECK-NEXT: mov r2, #0
; CHECK-NEXT: mov r3, #0
; CHECK-NEXT: str r1, [sp]
; CHECK-NEXT: bl callee
; CHECK-NEXT: add sp, sp, #8
; CHECK-NEXT: pop {r11, lr}
; CHECK-NEXT: bx lr
bb:
%i = tail call i32 @llvm.abs.i32(i32 %a, i1 false)
tail call void @callee(i32 %i, i32 0, i32 0, i32 0, i32 0)
ret void
}
Loading