]> granicus.if.org Git - clang/commitdiff
Attach attribute "disable-tail-calls" to the functions in the IR.
authorAkira Hatanaka <ahatanaka@apple.com>
Tue, 9 Jun 2015 19:04:36 +0000 (19:04 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Tue, 9 Jun 2015 19:04:36 +0000 (19:04 +0000)
This commit adds back the code that seems to have been dropped unintentionally
in r176985.

rdar://problem/13752163

Differential Revision: http://reviews.llvm.org/D10100

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239426 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/BackendUtil.cpp
lib/CodeGen/CGCall.cpp
test/CodeGen/2004-06-17-UnorderedCompares.c
test/CodeGen/arm-interrupt-attr.c
test/CodeGen/attr-disable-tail-calls.c [new file with mode: 0644]
test/CodeGenCXX/ctor-globalopt.cpp

index 8cece0d126f517896c10db13e2670f246a5b2d4f..671518170aa7c5ba1456550e71afe5f6f2be4482 100644 (file)
@@ -283,7 +283,6 @@ void EmitAssemblyHelper::CreatePasses() {
   PMBuilder.SLPVectorize = CodeGenOpts.VectorizeSLP;
   PMBuilder.LoopVectorize = CodeGenOpts.VectorizeLoop;
 
-  PMBuilder.DisableTailCalls = CodeGenOpts.DisableTailCalls;
   PMBuilder.DisableUnitAtATime = !CodeGenOpts.UnitAtATime;
   PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops;
   PMBuilder.MergeFunctions = CodeGenOpts.MergeFunctions;
@@ -521,7 +520,6 @@ TargetMachine *EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) {
   Options.NoZerosInBSS = CodeGenOpts.NoZeroInitializedInBSS;
   Options.UnsafeFPMath = CodeGenOpts.UnsafeFPMath;
   Options.StackAlignmentOverride = CodeGenOpts.StackAlignment;
-  Options.DisableTailCalls = CodeGenOpts.DisableTailCalls;
   Options.TrapFuncName = CodeGenOpts.TrapFuncName;
   Options.PositionIndependentExecutable = LangOpts.PIELevel != 0;
   Options.FunctionSections = CodeGenOpts.FunctionSections;
index e77539c63236c80176024df8cf2caec3a35e442d..c2e1e57463ad156d0d4e599113582f234cb4c080 100644 (file)
@@ -1465,6 +1465,8 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
       FuncAttrs.addAttribute("no-frame-pointer-elim-non-leaf");
     }
 
+    FuncAttrs.addAttribute("disable-tail-calls",
+                           llvm::toStringRef(CodeGenOpts.DisableTailCalls));
     FuncAttrs.addAttribute("less-precise-fpmad",
                            llvm::toStringRef(CodeGenOpts.LessPreciseFPMAD));
     FuncAttrs.addAttribute("no-infs-fp-math",
index 2c80180d2c8623cdfea893f207e66d4eeb99dd90..38eafd0d5455230f6a79da1ae6711b671a3a70f4 100644 (file)
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1  -std=c99 %s -emit-llvm -o - | FileCheck %s
 // CHECK: @Test
-// CHECK-NOT: call
+// CHECK-NOT: call{{ }}
 
 _Bool A, B, C, D, E, F;
 void TestF(float X, float Y) {
index 73f1cfee0502199c40e9e84413fc1444fc140865..fcbf1c721bd16c40ef860277c67c9e1eb5a18ef2 100644 (file)
@@ -28,11 +28,11 @@ __attribute__((interrupt("UNDEF"))) void test_undef_interrupt() {
   // CHECK: define arm_aapcscc void @test_undef_interrupt() [[UNDEF_ATTR:#[0-9]+]]
 }
 
-// CHECK: attributes [[GENERIC_ATTR]] = { nounwind alignstack=8 {{"interrupt"[^=]}}
-// CHECK: attributes [[IRQ_ATTR]] = { nounwind alignstack=8 "interrupt"="IRQ"
-// CHECK: attributes [[FIQ_ATTR]] = { nounwind alignstack=8 "interrupt"="FIQ"
-// CHECK: attributes [[SWI_ATTR]] = { nounwind alignstack=8 "interrupt"="SWI"
-// CHECK: attributes [[ABORT_ATTR]] = { nounwind alignstack=8 "interrupt"="ABORT"
-// CHECK: attributes [[UNDEF_ATTR]] = { nounwind alignstack=8 "interrupt"="UNDEF"
-
-// CHECK-APCS: attributes [[GENERIC_ATTR]] = { nounwind "interrupt"
+// CHECK: attributes [[GENERIC_ATTR]] = { {{.*}} {{"interrupt"[^=]}}
+// CHECK: attributes [[IRQ_ATTR]] = { {{.*}} "interrupt"="IRQ"
+// CHECK: attributes [[FIQ_ATTR]] = { {{.*}} "interrupt"="FIQ"
+// CHECK: attributes [[SWI_ATTR]] = { {{.*}} "interrupt"="SWI"
+// CHECK: attributes [[ABORT_ATTR]] = { {{.*}} "interrupt"="ABORT"
+// CHECK: attributes [[UNDEF_ATTR]] = { {{.*}} "interrupt"="UNDEF"
+
+// CHECK-APCS: attributes [[GENERIC_ATTR]] = { {{.*}} "interrupt"
diff --git a/test/CodeGen/attr-disable-tail-calls.c b/test/CodeGen/attr-disable-tail-calls.c
new file mode 100644 (file)
index 0000000..8141349
--- /dev/null
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm -mdisable-tail-calls -o - | FileCheck %s -check-prefix=CHECK -check-prefix=DISABLE
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm -o - | FileCheck %s -check-prefix=CHECK -check-prefix=ENABLE
+
+// CHECK: define i32 @f1() [[ATTR:#[0-9]+]] {
+
+int f1() {
+  return 0;
+}
+
+// DISABLE: attributes [[ATTR]] = { {{.*}} "disable-tail-calls"="true" {{.*}} }
+// ENABLE: attributes [[ATTR]] = { {{.*}} "disable-tail-calls"="false" {{.*}} }
index 672fc90675274171000180f5951c45e1f5834152..26ec523c553b8406c2822cfda338cdc505f1d06d 100644 (file)
@@ -13,7 +13,7 @@
 
 // CHECK-LABEL: define internal void @_GLOBAL__sub_I_ctor_globalopt.cpp()
 // CHECK: call void @
-// CHECK-NOT: call
+// CHECK-NOT: call{{ }}
 
 // O1: @llvm.global_ctors = appending global [0 x { i32, void ()*, i8* }] zeroinitializer