[PATCH] Attach function attribute "disable-tail-calls"

Akira Hatanaka ahatanak at gmail.com
Thu May 28 12:17:50 PDT 2015


Hi echristo, dexonsmith,

This patch adds the code which attaches function attributes "disable-tail-calls" in CGCall.cpp. This code seems to have been dropped unintentionally in r176985.

This is the clang-side change following http://reviews.llvm.org/D10099.

http://reviews.llvm.org/D10100

Files:
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGCall.cpp
  test/CodeGen/2004-06-17-UnorderedCompares.c
  test/CodeGen/arm-interrupt-attr.c
  test/CodeGenCXX/ctor-globalopt.cpp

Index: lib/CodeGen/BackendUtil.cpp
===================================================================
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -283,7 +283,6 @@
   PMBuilder.SLPVectorize = CodeGenOpts.VectorizeSLP;
   PMBuilder.LoopVectorize = CodeGenOpts.VectorizeLoop;
 
-  PMBuilder.DisableTailCalls = CodeGenOpts.DisableTailCalls;
   PMBuilder.DisableUnitAtATime = !CodeGenOpts.UnitAtATime;
   PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops;
   PMBuilder.MergeFunctions = CodeGenOpts.MergeFunctions;
@@ -523,7 +522,6 @@
   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: lib/CodeGen/CGCall.cpp
===================================================================
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1465,6 +1465,8 @@
       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: test/CodeGen/2004-06-17-UnorderedCompares.c
===================================================================
--- test/CodeGen/2004-06-17-UnorderedCompares.c
+++ test/CodeGen/2004-06-17-UnorderedCompares.c
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1  -std=c99 %s -emit-llvm -o - | FileCheck %s
 // CHECK: @Test
-// CHECK-NOT: call
+// CHECK-NOT: call{{[ \t]+}}
 
 _Bool A, B, C, D, E, F;
 void TestF(float X, float Y) {
Index: test/CodeGen/arm-interrupt-attr.c
===================================================================
--- test/CodeGen/arm-interrupt-attr.c
+++ test/CodeGen/arm-interrupt-attr.c
@@ -28,11 +28,11 @@
   // 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]] = { nounwind alignstack=8 "disable-tail-calls"="false" {{"interrupt"[^=]}}
+// CHECK: attributes [[IRQ_ATTR]] = { nounwind alignstack=8 "disable-tail-calls"="false" "interrupt"="IRQ"
+// CHECK: attributes [[FIQ_ATTR]] = { nounwind alignstack=8 "disable-tail-calls"="false" "interrupt"="FIQ"
+// CHECK: attributes [[SWI_ATTR]] = { nounwind alignstack=8 "disable-tail-calls"="false" "interrupt"="SWI"
+// CHECK: attributes [[ABORT_ATTR]] = { nounwind alignstack=8 "disable-tail-calls"="false" "interrupt"="ABORT"
+// CHECK: attributes [[UNDEF_ATTR]] = { nounwind alignstack=8 "disable-tail-calls"="false" "interrupt"="UNDEF"
+
+// CHECK-APCS: attributes [[GENERIC_ATTR]] = { nounwind "disable-tail-calls"="false" "interrupt"
Index: test/CodeGenCXX/ctor-globalopt.cpp
===================================================================
--- test/CodeGenCXX/ctor-globalopt.cpp
+++ test/CodeGenCXX/ctor-globalopt.cpp
@@ -13,7 +13,7 @@
 
 // CHECK-LABEL: define internal void @_GLOBAL__sub_I_ctor_globalopt.cpp()
 // CHECK: call void @
-// CHECK-NOT: call
+// CHECK-NOT: call{{[ \t]+}}
 
 // O1: @llvm.global_ctors = appending global [0 x { i32, void ()*, i8* }] zeroinitializer

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10100.26722.patch
Type: text/x-patch
Size: 4014 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150528/cd6b1a18/attachment.bin>


More information about the llvm-commits mailing list