Skip to content

Commit b75b8d5

Browse files
committed
[AArch64] Fix the size passed to __trampoline_setup
The trampoline size is 36 bytes on AArch64. The runtime function __trampoline_setup aborts as it expects the trampoline size of at least 36 bytes, and the size passed is 20 bytes. Fix the inconsistency in AArch64TargetLowering::LowerINIT_TRAMPOLINE.
1 parent 2c6ed5f commit b75b8d5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7281,9 +7281,16 @@ SDValue AArch64TargetLowering::LowerINIT_TRAMPOLINE(SDValue Op,
72817281
Entry.Ty = IntPtrTy;
72827282
Entry.Node = Trmp;
72837283
Args.push_back(Entry);
7284-
Entry.Node = DAG.getConstant(20, dl, MVT::i64);
7285-
Args.push_back(Entry);
72867284

7285+
if (auto *FI = dyn_cast<FrameIndexSDNode>(Trmp.getNode())) {
7286+
MachineFunction &MF = DAG.getMachineFunction();
7287+
MachineFrameInfo &MFI = MF.getFrameInfo();
7288+
Entry.Node =
7289+
DAG.getConstant(MFI.getObjectSize(FI->getIndex()), dl, MVT::i64);
7290+
} else
7291+
Entry.Node = DAG.getConstant(36, dl, MVT::i64);
7292+
7293+
Args.push_back(Entry);
72877294
Entry.Node = FPtr;
72887295
Args.push_back(Entry);
72897296
Entry.Node = Nest;

llvm/test/CodeGen/AArch64/trampoline.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ define i64 @main() {
1212
%val = alloca i64
1313
%nval = bitcast ptr %val to ptr
1414
%tramp = alloca [36 x i8], align 8
15+
; CHECK: mov w1, #36
1516
; CHECK: bl __trampoline_setup
1617
call void @llvm.init.trampoline(ptr %tramp, ptr @f, ptr %nval)
1718
%fp = call ptr @llvm.adjust.trampoline(ptr %tramp)

0 commit comments

Comments
 (0)