Skip to content
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
6 changes: 4 additions & 2 deletions llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,9 +842,11 @@ bool AArch64ExpandPseudo::expandCALL_BTI(MachineBasicBlock &MBB,
unsigned Opc = CallTarget.isGlobal() ? AArch64::BL : AArch64::BLR;
MachineInstr *Call =
BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(Opc)).getInstr();
Call->addOperand(CallTarget);

for (const MachineOperand &MO : MI.operands())
Call->addOperand(MO);

Call->setCFIType(*MBB.getParent(), MI.getCFIType());
Call->copyImplicitOps(*MBB.getParent(), MI);

MachineInstr *BTI =
BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(AArch64::HINT))
Expand Down
24 changes: 24 additions & 0 deletions llvm/test/CodeGen/AArch64/blr-bti-preserves-operands.mir
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# RUN: llc -mtriple=aarch64-none-linux-gnu -run-pass=aarch64-expand-pseudo -o - %s | FileCheck %s

# When expanding a BLR_BTI, we should copy all the operands to the branch in the
# bundle. Otherwise we could end up using a register after the BL which was
# clobbered by the function that was called, or overwriting an argument to that
# function before we make the call.
# CHECK: BUNDLE implicit-def $lr, implicit-def $w30, implicit-def $sp, implicit-def $wsp, implicit $x0, implicit $w1, implicit $sp {
# CHECK: BL @_setjmp, $x0, $w1, csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit-def dead $lr, implicit $sp, implicit-def $sp
# CHECK: HINT 36
# CHECK: }

--- |
define void @a() {
ret void
}

declare void @_setjmp(...)
...
---
name: a
body: |
bb.0:
BLR_BTI @_setjmp, $x0, $w1, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp
...
23 changes: 0 additions & 23 deletions llvm/test/CodeGen/AArch64/blr-bti-preserves-regmask.mir

This file was deleted.