Skip to content

Commit 0523c33

Browse files
bors[bot]vext01
andauthored
24: Add a switch to disable tail call optimisations on x86_64. r=ltratt a=vext01 Co-authored-by: Edd Barrett <[email protected]>
2 parents afd1c99 + e8239fa commit 0523c33

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ static cl::opt<bool> ExperimentalUnorderedISEL(
100100
"stores respectively."),
101101
cl::Hidden);
102102

103+
static cl::opt<bool> YkDisableTailCallCodegen(
104+
"yk-disable-tail-call-codegen", cl::init(false),
105+
cl::desc("Do not optimise tail calls"),
106+
cl::Hidden);
107+
103108
/// Call this when the user attempts to do something unsupported, like
104109
/// returning a double without SSE2 enabled on x86_64. This is not fatal, unlike
105110
/// report_fatal_error, so calling code should attempt to recover without
@@ -3918,6 +3923,16 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
39183923
bool isVarArg = CLI.IsVarArg;
39193924
const auto *CB = CLI.CB;
39203925

3926+
// Tail call optimisations interfere with the trace compiler's inlining
3927+
// stack, as we never see the return for the caller (the caller's frame is
3928+
// reused, and the callee's return returns from both the caller and the
3929+
// callee).
3930+
//
3931+
// YKFIXME: https://github.com/ykjit/yk/issues/502
3932+
// We should find a way to allow tail calls.
3933+
if (YkDisableTailCallCodegen)
3934+
isTailCall = false;
3935+
39213936
MachineFunction &MF = DAG.getMachineFunction();
39223937
bool Is64Bit = Subtarget.is64Bit();
39233938
bool IsWin64 = Subtarget.isCallingConvWin64(CallConv);

0 commit comments

Comments
 (0)