Skip to content

Commit 3e53925

Browse files
committed
fixup! [AArch64] fix trampoline implementation: use X15
1 parent 78745ed commit 3e53925

File tree

4 files changed

+21
-22
lines changed

4 files changed

+21
-22
lines changed

flang/lib/Optimizer/CodeGen/BoxedProcedure.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,9 @@ class BoxedProcedurePass
277277
// For PPC32 and PPC64, the thunk is populated by a call to
278278
// __trampoline_setup, which is defined in
279279
// compiler-rt/lib/builtins/trampoline_setup.c and requires the
280-
// thunk size greater than 32 bytes. For AArch64, RISCV and x86_64, the
281-
// thunk setup doesn't go through __trampoline_setup and fits in 32
282-
// bytes.
280+
// thunk size greater than 32 bytes. For AArch64, RISCV and x86_64,
281+
// the thunk setup doesn't go through __trampoline_setup and fits in
282+
// 32 bytes.
283283
fir::SequenceType::Extent thunkSize = triple.getTrampolineSize();
284284
mlir::Type buffTy = SequenceType::get({thunkSize}, i8Ty);
285285
auto buffer = builder.create<AllocaOp>(loc, buffTy);

flang/test/Fir/boxproc.fir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RUN: %if powerpc-registered-target %{tco --target=powerpc64le-unknown-linux-gnu %s | FileCheck %s --check-prefixes=CHECK,CHECK-PPC %}
44

55
// CHECK-LABEL: define void @_QPtest_proc_dummy()
6-
// CHECK-AARCH64: %[[VAL_3:.*]] = alloca [36 x i8], i64 1, align 1
6+
// CHECK-AARCH64: %[[VAL_3:.*]] = alloca [32 x i8], i64 1, align 1
77
// CHECK-X86: %[[VAL_3:.*]] = alloca [32 x i8], i64 1, align 1
88
// CHECK-PPC: %[[VAL_3:.*]] = alloca [4{{[0-8]+}} x i8], i64 1, align 1
99
// CHECK: %[[VAL_1:.*]] = alloca { ptr }, i64 1, align 8
@@ -63,7 +63,7 @@ func.func @_QPtest_proc_dummy_other(%arg0: !fir.boxproc<() -> ()>) {
6363
}
6464

6565
// CHECK-LABEL: define void @_QPtest_proc_dummy_char()
66-
// CHECK-AARCH64: %[[VAL_20:.*]] = alloca [36 x i8], i64 1, align 1
66+
// CHECK-AARCH64: %[[VAL_20:.*]] = alloca [32 x i8], i64 1, align 1
6767
// CHECK-X86: %[[VAL_20:.*]] = alloca [32 x i8], i64 1, align 1
6868
// CHECK-PPC: %[[VAL_20:.*]] = alloca [4{{[0-8]+}} x i8], i64 1, align 1
6969
// CHECK: %[[VAL_2:.*]] = alloca { { ptr, i64 } }, i64 1, align 8

llvm/lib/Target/AArch64/AArch64FrameLowering.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,12 +2047,11 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
20472047
// Find an available register to store value of VG to.
20482048
unsigned X15Scratch = AArch64::NoRegister;
20492049
const AArch64Subtarget &STI = MF.getSubtarget<AArch64Subtarget>();
2050-
if (llvm::any_of(
2051-
MBB.liveins(),
2052-
[&STI](const MachineBasicBlock::RegisterMaskPair &LiveIn) {
2053-
return STI.getRegisterInfo()->isSuperOrSubRegisterEq(
2054-
AArch64::X15, LiveIn.PhysReg);
2055-
})) {
2050+
if (llvm::any_of(MBB.liveins(),
2051+
[&STI](const MachineBasicBlock::RegisterMaskPair &LiveIn) {
2052+
return STI.getRegisterInfo()->isSuperOrSubRegisterEq(
2053+
AArch64::X15, LiveIn.PhysReg);
2054+
})) {
20562055
X15Scratch = findScratchNonCalleeSaveRegister(&MBB);
20572056
assert(X15Scratch != AArch64::NoRegister);
20582057
#ifndef NDEBUG

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7296,7 +7296,7 @@ SDValue AArch64TargetLowering::LowerADJUST_TRAMPOLINE(SDValue Op,
72967296
SDValue AArch64TargetLowering::LowerINIT_TRAMPOLINE(SDValue Op,
72977297
SelectionDAG &DAG) const {
72987298
SDValue Chain = Op.getOperand(0);
7299-
SDValue Trmp = Op.getOperand(1); // trampoline, 36 bytes
7299+
SDValue Trmp = Op.getOperand(1); // trampoline, >=32 bytes
73007300
SDValue FPtr = Op.getOperand(2); // nested function
73017301
SDValue Nest = Op.getOperand(3); // 'nest' parameter value
73027302

@@ -7311,7 +7311,7 @@ SDValue AArch64TargetLowering::LowerINIT_TRAMPOLINE(SDValue Op,
73117311
SDValue OutChains[5];
73127312

73137313
const Function *Func =
7314-
cast<Function>(cast<SrcValueSDNode>(Op.getOperand(5))->getValue());
7314+
cast<Function>(cast<SrcValueSDNode>(Op.getOperand(5))->getValue());
73157315
CallingConv::ID CC = Func->getCallingConv();
73167316
unsigned NestReg;
73177317

@@ -7330,15 +7330,15 @@ SDValue AArch64TargetLowering::LowerINIT_TRAMPOLINE(SDValue Op,
73307330
SDValue Addr = Trmp;
73317331

73327332
SDLoc dl(Op);
7333-
OutChains[0] =
7334-
DAG.getStore(Chain, dl, DAG.getConstant(0x58000080u | NestReg, dl, MVT::i32), Addr,
7335-
MachinePointerInfo(TrmpAddr));
7333+
OutChains[0] = DAG.getStore(
7334+
Chain, dl, DAG.getConstant(0x58000080u | NestReg, dl, MVT::i32), Addr,
7335+
MachinePointerInfo(TrmpAddr));
73367336

73377337
Addr = DAG.getNode(ISD::ADD, dl, MVT::i64, Trmp,
73387338
DAG.getConstant(4, dl, MVT::i64));
7339-
OutChains[1] =
7340-
DAG.getStore(Chain, dl, DAG.getConstant(0x580000b0u | FptrReg, dl, MVT::i32), Addr,
7341-
MachinePointerInfo(TrmpAddr, 4));
7339+
OutChains[1] = DAG.getStore(
7340+
Chain, dl, DAG.getConstant(0x580000b0u | FptrReg, dl, MVT::i32), Addr,
7341+
MachinePointerInfo(TrmpAddr, 4));
73427342

73437343
Addr = DAG.getNode(ISD::ADD, dl, MVT::i64, Trmp,
73447344
DAG.getConstant(8, dl, MVT::i64));
@@ -7359,11 +7359,11 @@ SDValue AArch64TargetLowering::LowerINIT_TRAMPOLINE(SDValue Op,
73597359
SDValue StoreToken = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, OutChains);
73607360

73617361
SDValue EndOfTrmp = DAG.getNode(ISD::ADD, dl, MVT::i64, Trmp,
7362-
DAG.getConstant(12, dl, MVT::i64));
7362+
DAG.getConstant(12, dl, MVT::i64));
73637363

73647364
// Call clear cache on the trampoline instructions.
7365-
return DAG.getNode(ISD::CLEAR_CACHE, dl, MVT::Other, StoreToken,
7366-
Trmp, EndOfTrmp);
7365+
return DAG.getNode(ISD::CLEAR_CACHE, dl, MVT::Other, StoreToken, Trmp,
7366+
EndOfTrmp);
73677367
}
73687368

73697369
SDValue AArch64TargetLowering::LowerOperation(SDValue Op,

0 commit comments

Comments
 (0)