mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Add a TargetOption for disabling tail calls.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148442 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9b159710eb
commit
22de16dc75
@ -43,8 +43,9 @@ namespace llvm {
|
|||||||
NoNaNsFPMath(false), HonorSignDependentRoundingFPMathOption(false),
|
NoNaNsFPMath(false), HonorSignDependentRoundingFPMathOption(false),
|
||||||
UseSoftFloat(false), NoZerosInBSS(false), JITExceptionHandling(false),
|
UseSoftFloat(false), NoZerosInBSS(false), JITExceptionHandling(false),
|
||||||
JITEmitDebugInfo(false), JITEmitDebugInfoToDisk(false),
|
JITEmitDebugInfo(false), JITEmitDebugInfoToDisk(false),
|
||||||
GuaranteedTailCallOpt(false), StackAlignmentOverride(0),
|
GuaranteedTailCallOpt(false), DisableTailCalls(false),
|
||||||
RealignStack(true), DisableJumpTables(false), EnableFastISel(false),
|
StackAlignmentOverride(0), RealignStack(true),
|
||||||
|
DisableJumpTables(false), EnableFastISel(false),
|
||||||
EnableSegmentedStacks(false), TrapFuncName(""),
|
EnableSegmentedStacks(false), TrapFuncName(""),
|
||||||
FloatABIType(FloatABI::Default)
|
FloatABIType(FloatABI::Default)
|
||||||
{}
|
{}
|
||||||
@ -147,6 +148,10 @@ namespace llvm {
|
|||||||
/// as their parent function, etc.), using an alternate ABI if necessary.
|
/// as their parent function, etc.), using an alternate ABI if necessary.
|
||||||
unsigned GuaranteedTailCallOpt : 1;
|
unsigned GuaranteedTailCallOpt : 1;
|
||||||
|
|
||||||
|
/// DisableTailCalls - This flag controls whether we will use tail calls.
|
||||||
|
/// Disabling them may be useful to maintain a correct call stack.
|
||||||
|
unsigned DisableTailCalls : 1;
|
||||||
|
|
||||||
/// StackAlignmentOverride - Override default stack alignment for target.
|
/// StackAlignmentOverride - Override default stack alignment for target.
|
||||||
unsigned StackAlignmentOverride;
|
unsigned StackAlignmentOverride;
|
||||||
|
|
||||||
|
@ -1732,7 +1732,7 @@ static bool IsTailCallConvention(CallingConv::ID CC) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool X86TargetLowering::mayBeEmittedAsTailCall(CallInst *CI) const {
|
bool X86TargetLowering::mayBeEmittedAsTailCall(CallInst *CI) const {
|
||||||
if (!CI->isTailCall())
|
if (!CI->isTailCall() || getTargetMachine().Options.DisableTailCalls)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CallSite CS(CI);
|
CallSite CS(CI);
|
||||||
@ -2133,6 +2133,9 @@ X86TargetLowering::LowerCall(SDValue Chain, SDValue Callee,
|
|||||||
bool IsStructRet = CallIsStructReturn(Outs);
|
bool IsStructRet = CallIsStructReturn(Outs);
|
||||||
bool IsSibcall = false;
|
bool IsSibcall = false;
|
||||||
|
|
||||||
|
if (MF.getTarget().Options.DisableTailCalls)
|
||||||
|
isTailCall = false;
|
||||||
|
|
||||||
if (isTailCall) {
|
if (isTailCall) {
|
||||||
// Check if it's really possible to do a tail call.
|
// Check if it's really possible to do a tail call.
|
||||||
isTailCall = IsEligibleForTailCallOptimization(Callee, CallConv,
|
isTailCall = IsEligibleForTailCallOptimization(Callee, CallConv,
|
||||||
|
40
test/CodeGen/X86/tailcall-disable.ll
Normal file
40
test/CodeGen/X86/tailcall-disable.ll
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
; RUN: llc -disable-tail-calls < %s | FileCheck --check-prefix=CALL %s
|
||||||
|
; RUN: llc < %s | FileCheck --check-prefix=JMP %s
|
||||||
|
|
||||||
|
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
|
||||||
|
target triple = "x86_64-unknown-linux-gnu"
|
||||||
|
|
||||||
|
define i32 @helper() nounwind {
|
||||||
|
entry:
|
||||||
|
ret i32 7
|
||||||
|
}
|
||||||
|
|
||||||
|
define i32 @test1() nounwind {
|
||||||
|
entry:
|
||||||
|
%call = tail call i32 @helper()
|
||||||
|
ret i32 %call
|
||||||
|
}
|
||||||
|
|
||||||
|
;CALL: test1:
|
||||||
|
;CALL-NOT: ret
|
||||||
|
;CALL: callq helper
|
||||||
|
;CALL: ret
|
||||||
|
|
||||||
|
;JMP: test1:
|
||||||
|
;JMP-NOT: ret
|
||||||
|
;JMP: jmp helper # TAILCALL
|
||||||
|
|
||||||
|
define i32 @test2() nounwind {
|
||||||
|
entry:
|
||||||
|
%call = tail call i32 @test2()
|
||||||
|
ret i32 %call
|
||||||
|
}
|
||||||
|
|
||||||
|
;CALL: test2:
|
||||||
|
;CALL-NOT: ret
|
||||||
|
;CALL: callq test2
|
||||||
|
;CALL: ret
|
||||||
|
|
||||||
|
;JMP: test2:
|
||||||
|
;JMP-NOT: ret
|
||||||
|
;JMP: jmp test2 # TAILCALL
|
@ -237,6 +237,11 @@ EnableGuaranteedTailCallOpt("tailcallopt",
|
|||||||
cl::desc("Turn fastcc calls into tail calls by (potentially) changing ABI."),
|
cl::desc("Turn fastcc calls into tail calls by (potentially) changing ABI."),
|
||||||
cl::init(false));
|
cl::init(false));
|
||||||
|
|
||||||
|
static cl::opt<bool>
|
||||||
|
DisableTailCalls("disable-tail-calls",
|
||||||
|
cl::desc("Never emit tail calls"),
|
||||||
|
cl::init(false));
|
||||||
|
|
||||||
static cl::opt<unsigned>
|
static cl::opt<unsigned>
|
||||||
OverrideStackAlignment("stack-alignment",
|
OverrideStackAlignment("stack-alignment",
|
||||||
cl::desc("Override default stack alignment"),
|
cl::desc("Override default stack alignment"),
|
||||||
@ -462,6 +467,7 @@ int main(int argc, char **argv) {
|
|||||||
Options.JITEmitDebugInfo = EmitJitDebugInfo;
|
Options.JITEmitDebugInfo = EmitJitDebugInfo;
|
||||||
Options.JITEmitDebugInfoToDisk = EmitJitDebugInfoToDisk;
|
Options.JITEmitDebugInfoToDisk = EmitJitDebugInfoToDisk;
|
||||||
Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
|
Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
|
||||||
|
Options.DisableTailCalls = DisableTailCalls;
|
||||||
Options.StackAlignmentOverride = OverrideStackAlignment;
|
Options.StackAlignmentOverride = OverrideStackAlignment;
|
||||||
Options.RealignStack = EnableRealignStack;
|
Options.RealignStack = EnableRealignStack;
|
||||||
Options.DisableJumpTables = DisableSwitchTables;
|
Options.DisableJumpTables = DisableSwitchTables;
|
||||||
|
Loading…
Reference in New Issue
Block a user