BackendUtil: Pass through -mdisable-tail-calls

The frontend option -fno-optimize-sibling-calls resolves to -cc1's
-mdisable-tail-calls, which is passed to the TargetMachine in the
backend.  PassManagerBuilder was adding the -tailcallelim pass anyway.

Use a new DisableTailCalls option in PassManagerBuilder to disable tail
calls harder.

Requires the matching commit in LLVM that adds DisableTailCalls.

<rdar://problem/16050591>

llvm-svn: 206543
This commit is contained in:
Duncan P. N. Exon Smith 2014-04-18 01:05:25 +00:00
parent 49f3ec80c2
commit 85e349fd2c
2 changed files with 17 additions and 0 deletions

View File

@ -247,6 +247,7 @@ void EmitAssemblyHelper::CreatePasses() {
PMBuilder.SLPVectorize = CodeGenOpts.VectorizeSLP;
PMBuilder.LoopVectorize = CodeGenOpts.VectorizeLoop;
PMBuilder.DisableTailCalls = CodeGenOpts.DisableTailCalls;
PMBuilder.DisableUnitAtATime = !CodeGenOpts.UnitAtATime;
PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops;
PMBuilder.RerollLoops = CodeGenOpts.RerollLoops;

View File

@ -0,0 +1,16 @@
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9.0 -emit-llvm -O1 -mdisable-tail-calls -o - < %s | FileCheck %s
typedef struct List {
struct List *next;
int data;
} List;
// CHECK-LABEL: define %struct.List* @find
List *find(List *head, int data) {
if (!head)
return 0;
if (head->data == data)
return head;
// CHECK: call %struct.List* @find
return find(head->next, data);
}