Skip to content

Commit 25e67ed

Browse files
committed
Merge 99620 from mainline.
Do not sibcall if stack needs to be dynamically aligned. llvm-svn: 99955
1 parent 1df1d40 commit 25e67ed

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,6 +2307,7 @@ X86TargetLowering::IsEligibleForTailCallOptimization(SDValue Callee,
23072307
return false;
23082308

23092309
// If -tailcallopt is specified, make fastcc functions tail-callable.
2310+
const MachineFunction &MF = DAG.getMachineFunction();
23102311
const Function *CallerF = DAG.getMachineFunction().getFunction();
23112312
if (GuaranteedTailCallOpt) {
23122313
if (IsTailCallConvention(CalleeCC) &&
@@ -2318,6 +2319,11 @@ X86TargetLowering::IsEligibleForTailCallOptimization(SDValue Callee,
23182319
// Look for obvious safe cases to perform tail call optimization that does not
23192320
// requite ABI changes. This is what gcc calls sibcall.
23202321

2322+
// Can't do sibcall if stack needs to be dynamically re-aligned. PEI needs to
2323+
// emit a special epilogue.
2324+
if (RegInfo->needsStackRealignment(MF))
2325+
return false;
2326+
23212327
// Do not sibcall optimize vararg calls for now.
23222328
if (isVarArg)
23232329
return false;

llvm/test/CodeGen/X86/sibcall.ll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,16 @@ entry:
216216
}
217217

218218
declare fastcc %struct.ns* @foo7(%struct.cp* byval align 4, i8 signext) nounwind ssp
219+
220+
221+
222+
define void @t19() alignstack(32) nounwind {
223+
entry:
224+
; CHECK: t19:
225+
; CHECK: andl $-32
226+
; CHECK: call {{_?}}foo
227+
tail call void @foo() nounwind
228+
ret void
229+
}
230+
231+
declare void @foo()

0 commit comments

Comments
 (0)