Replace the "NoFramePointerElimNonLeaf" target option with a function attribute.
authorBill Wendling <isanbard@gmail.com>
Thu, 25 Jul 2013 00:34:29 +0000 (00:34 +0000)
committerBill Wendling <isanbard@gmail.com>
Thu, 25 Jul 2013 00:34:29 +0000 (00:34 +0000)
There's no need to specify a flag to omit frame pointer elimination on non-leaf
nodes...(Honestly, I can't parse that option out.) Use the function attribute
stuff instead.

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

include/llvm/CodeGen/CommandFlags.h
include/llvm/Target/TargetOptions.h
lib/CodeGen/TargetOptionsImpl.cpp
lib/IR/Attributes.cpp
lib/Target/TargetMachine.cpp
test/CodeGen/X86/fp-elim.ll
test/CodeGen/X86/leaf-fp-elim.ll
test/DebugInfo/2010-05-03-DisableFramePtr.ll
tools/llc/llc.cpp
tools/lto/LTOModule.cpp
tools/opt/opt.cpp

index fd1d67bdcd1569b17d9d1d98cfac2a428b523e69..22bea34d78d6dbfb3aa835522bf7413f9d7f74a6 100644 (file)
@@ -109,11 +109,6 @@ DisableFPElim("disable-fp-elim",
               cl::desc("Disable frame pointer elimination optimization"),
               cl::init(false));
 
-cl::opt<bool>
-DisableFPElimNonLeaf("disable-non-leaf-fp-elim",
-  cl::desc("Disable frame pointer elimination optimization for non-leaf funcs"),
-  cl::init(false));
-
 cl::opt<bool>
 EnableUnsafeFPMath("enable-unsafe-fp-math",
                 cl::desc("Enable optimizations that may decrease FP precision"),
index 04b208010660a5a8aa1dc5f69af2ef3d181187f5..feba3408f8a6234eaaaffc6276b695f9647b54ad 100644 (file)
@@ -42,7 +42,7 @@ namespace llvm {
   public:
     TargetOptions()
         : PrintMachineCode(false), NoFramePointerElim(false),
-          NoFramePointerElimNonLeaf(false), LessPreciseFPMADOption(false),
+          LessPreciseFPMADOption(false),
           UnsafeFPMath(false), NoInfsFPMath(false),
           NoNaNsFPMath(false), HonorSignDependentRoundingFPMathOption(false),
           UseSoftFloat(false), NoZerosInBSS(false),
@@ -64,12 +64,6 @@ namespace llvm {
     /// elimination optimization, this option should disable it.
     unsigned NoFramePointerElim : 1;
 
-    /// NoFramePointerElimNonLeaf - This flag is enabled when the
-    /// -disable-non-leaf-fp-elim is specified on the command line. If the
-    /// target supports the frame pointer elimination optimization, this option
-    /// should disable it for non-leaf functions.
-    unsigned NoFramePointerElimNonLeaf : 1;
-
     /// DisableFramePointerElim - This returns true if frame pointer elimination
     /// optimization should be disabled for the given machine function.
     bool DisableFramePointerElim(const MachineFunction &MF) const;
index b5d4160f9393b4e52fc19b3afeaf79143be07ecd..7a39a4c27374c9e8180c969860c43b9b8d6791f3 100644 (file)
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "llvm/IR/Function.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/Target/TargetOptions.h"
@@ -21,6 +22,9 @@ using namespace llvm;
 bool TargetOptions::DisableFramePointerElim(const MachineFunction &MF) const {
   // Check to see if we should eliminate non-leaf frame pointers and then
   // check to see if we should eliminate all frame pointers.
+  bool NoFramePointerElimNonLeaf =
+    MF.getFunction()->getFnAttribute("no-frame-pointer-elim-non-leaf")
+      .getValueAsString() == "true";
   if (NoFramePointerElimNonLeaf && !NoFramePointerElim) {
     const MachineFrameInfo *MFI = MF.getFrameInfo();
     return MFI->hasCalls();
index c8e2f6be5c0e4803c3e5c2d6cf3f42314236d999..48743fae692d52122c691a2b7f5ca4e2674e5f77 100644 (file)
@@ -104,24 +104,28 @@ bool Attribute::isStringAttribute() const {
 }
 
 Attribute::AttrKind Attribute::getKindAsEnum() const {
+  if (!pImpl) return None;
   assert((isEnumAttribute() || isAlignAttribute()) &&
          "Invalid attribute type to get the kind as an enum!");
   return pImpl ? pImpl->getKindAsEnum() : None;
 }
 
 uint64_t Attribute::getValueAsInt() const {
+  if (!pImpl) return 0;
   assert(isAlignAttribute() &&
          "Expected the attribute to be an alignment attribute!");
   return pImpl ? pImpl->getValueAsInt() : 0;
 }
 
 StringRef Attribute::getKindAsString() const {
+  if (!pImpl) return StringRef();
   assert(isStringAttribute() &&
          "Invalid attribute type to get the kind as a string!");
   return pImpl ? pImpl->getKindAsString() : StringRef();
 }
 
 StringRef Attribute::getValueAsString() const {
+  if (!pImpl) return StringRef();
   assert(isStringAttribute() &&
          "Invalid attribute type to get the value as a string!");
   return pImpl ? pImpl->getValueAsString() : StringRef();
index e7282519d597f5d0b5e9b6ecf026c77852d91871..df4a03c9e8ba964e1a6fcc78de06ee735f6557f7 100644 (file)
@@ -78,7 +78,6 @@ void TargetMachine::resetTargetOptions(const MachineFunction *MF) const {
   } while (0)
 
   RESET_OPTION(NoFramePointerElim, "no-frame-pointer-elim");
-  RESET_OPTION(NoFramePointerElimNonLeaf, "no-frame-pointer-elim-non-leaf");
   RESET_OPTION(LessPreciseFPMADOption, "less-precise-fpmad");
   RESET_OPTION(UnsafeFPMath, "unsafe-fp-math");
   RESET_OPTION(NoInfsFPMath, "no-infs-fp-math");
index d43ee36143bc2354d95e7227d70803870d0688a1..583388cc7132d18f3a49bdc7be5a89e37562edce 100644 (file)
@@ -1,42 +1,60 @@
 ; RUN: llc < %s -march=x86 -asm-verbose=false                           | FileCheck %s -check-prefix=FP-ELIM
 ; RUN: llc < %s -march=x86 -asm-verbose=false -disable-fp-elim          | FileCheck %s -check-prefix=NO-ELIM
-; RUN: llc < %s -march=x86 -asm-verbose=false -disable-non-leaf-fp-elim | FileCheck %s -check-prefix=NON-LEAF
 
 ; Implement -momit-leaf-frame-pointer
 ; rdar://7886181
 
-define i32 @t1() nounwind readnone {
+define i32 @t1() "no-frame-pointer-elim-non-leaf"="false" nounwind readnone {
 entry:
-; FP-ELIM-LABEL:      t1:
-; FP-ELIM-NEXT: movl
-; FP-ELIM-NEXT: ret
-
-; NO-ELIM-LABEL:      t1:
-; NO-ELIM-NEXT: pushl %ebp
-; NO-ELIM:      popl %ebp
-; NO-ELIM-NEXT: ret
-
-; NON-LEAF-LABEL:      t1:
-; NON-LEAF-NEXT: movl
-; NON-LEAF-NEXT: ret
+; FP-ELIM-LABEL:  t1:
+; FP-ELIM-NEXT:     movl
+; FP-ELIM-NEXT:     ret
+
+; NO-ELIM-LABEL:  t1:
+; NO-ELIM-NEXT:     pushl %ebp
+; NO-ELIM:          popl %ebp
+; NO-ELIM-NEXT:     ret
   ret i32 10
 }
 
-define void @t2() nounwind {
+define void @t2() "no-frame-pointer-elim-non-leaf"="false" nounwind {
 entry:
-; FP-ELIM-LABEL:     t2:
-; FP-ELIM-NOT: pushl %ebp
-; FP-ELIM:     ret
-
-; NO-ELIM-LABEL:      t2:
-; NO-ELIM-NEXT: pushl %ebp
-; NO-ELIM:      popl %ebp
-; NO-ELIM-NEXT: ret
-
-; NON-LEAF-LABEL:      t2:
-; NON-LEAF-NEXT: pushl %ebp
-; NON-LEAF:      popl %ebp
-; NON-LEAF-NEXT: ret
+; FP-ELIM-LABEL:  t2:
+; FP-ELIM-NOT:      pushl %ebp
+; FP-ELIM:          ret
+
+; NO-ELIM-LABEL:  t2:
+; NO-ELIM-NEXT:     pushl %ebp
+; NO-ELIM:          popl %ebp
+; NO-ELIM-NEXT:     ret
+  tail call void @foo(i32 0) nounwind
+  ret void
+}
+
+define i32 @t3() "no-frame-pointer-elim-non-leaf"="true" nounwind readnone {
+entry:
+; FP-ELIM-LABEL:  t3:
+; FP-ELIM-NEXT:     movl
+; FP-ELIM-NEXT:     ret
+
+; NO-ELIM-LABEL:  t3:
+; NO-ELIM-NEXT:     pushl %ebp
+; NO-ELIM:          popl %ebp
+; NO-ELIM-NEXT:     ret
+  ret i32 10
+}
+
+define void @t4() "no-frame-pointer-elim-non-leaf"="true" nounwind {
+entry:
+; FP-ELIM-LABEL:  t4:
+; FP-ELIM-NEXT:     pushl %ebp
+; FP-ELIM:          popl %ebp
+; FP-ELIM-NEXT:     ret
+
+; NO-ELIM-LABEL:  t4:
+; NO-ELIM-NEXT:     pushl %ebp
+; NO-ELIM:          popl %ebp
+; NO-ELIM-NEXT:     ret
   tail call void @foo(i32 0) nounwind
   ret void
 }
index 607dc72e2fa3012c4002e0df92db0cc27130b4ca..7eebf8d292434778f853dd22aa6593b8cc75ff14 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc < %s -disable-non-leaf-fp-elim -relocation-model=pic -mtriple=x86_64-apple-darwin | FileCheck %s
+; RUN: llc < %s -relocation-model=pic -mtriple=x86_64-apple-darwin | FileCheck %s
 ; <rdar://problem/8170192>
 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"
 target triple = "x86_64-apple-darwin11.0"
@@ -6,7 +6,7 @@ target triple = "x86_64-apple-darwin11.0"
 @msg = internal global i8* null                   ; <i8**> [#uses=1]
 @.str = private constant [2 x i8] c"x\00", align 1 ; <[2 x i8]*> [#uses=1]
 
-define void @test(i8* %p) nounwind optsize ssp {
+define void @test(i8* %p) "no-frame-pointer-elim-non-leaf"="true" nounwind optsize ssp {
 
 ; No stack frame, please.
 ; CHECK:     _test
index ec734f65cc3f8d32a805956a32302fbc395d7393..7e07067f42fbaf58bfb1ac66ef20d3935ea1f610 100644 (file)
@@ -1,8 +1,8 @@
-; RUN: llc  -o /dev/null -disable-non-leaf-fp-elim < %s
+; RUN: llc  -o /dev/null < %s
 ; Radar 7937664
 %struct.AppleEvent = type opaque
 
-define void @DisposeDMNotificationUPP(void (%struct.AppleEvent*)* %userUPP) nounwind ssp {
+define void @DisposeDMNotificationUPP(void (%struct.AppleEvent*)* %userUPP) "no-frame-pointer-elim-non-leaf"="true" nounwind ssp {
 entry:
   %userUPP_addr = alloca void (%struct.AppleEvent*)* ; <void (%struct.AppleEvent*)**> [#uses=1]
   %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
index b62f41aec8a00d97153777cb0f801f618f885540..c66106b59475c711f8ffa276eb0d0ddbf3a200b9 100644 (file)
@@ -262,7 +262,6 @@ static int compileModule(char **argv, LLVMContext &Context) {
   TargetOptions Options;
   Options.LessPreciseFPMADOption = EnableFPMAD;
   Options.NoFramePointerElim = DisableFPElim;
-  Options.NoFramePointerElimNonLeaf = DisableFPElimNonLeaf;
   Options.AllowFPOpFusion = FuseFPOps;
   Options.UnsafeFPMath = EnableUnsafeFPMath;
   Options.NoInfsFPMath = EnableNoInfsFPMath;
index 6626eaac47a8a7ab44d206cc1a0ecda04cb7bbf4..7aeadc3da4303ae027c7b47499ecade1bc07312b 100644 (file)
@@ -49,11 +49,6 @@ DisableFPElim("disable-fp-elim",
   cl::desc("Disable frame pointer elimination optimization"),
   cl::init(false));
 
-static cl::opt<bool>
-DisableFPElimNonLeaf("disable-non-leaf-fp-elim",
-  cl::desc("Disable frame pointer elimination optimization for non-leaf funcs"),
-  cl::init(false));
-
 static cl::opt<bool>
 EnableUnsafeFPMath("enable-unsafe-fp-math",
   cl::desc("Enable optimizations that may decrease FP precision"),
@@ -236,7 +231,6 @@ LTOModule *LTOModule::makeLTOModule(const void *mem, size_t length,
 void LTOModule::getTargetOptions(TargetOptions &Options) {
   Options.LessPreciseFPMADOption = EnableFPMAD;
   Options.NoFramePointerElim = DisableFPElim;
-  Options.NoFramePointerElimNonLeaf = DisableFPElimNonLeaf;
   Options.AllowFPOpFusion = FuseFPOps;
   Options.UnsafeFPMath = EnableUnsafeFPMath;
   Options.NoInfsFPMath = EnableNoInfsFPMath;
index 23acefafbeefece57afcb28ac50e80eaf7f6ef96..68fca83c96a708eb378ea024edc1eac15b8b194e 100644 (file)
@@ -491,7 +491,6 @@ static TargetOptions GetTargetOptions() {
   TargetOptions Options;
   Options.LessPreciseFPMADOption = EnableFPMAD;
   Options.NoFramePointerElim = DisableFPElim;
-  Options.NoFramePointerElimNonLeaf = DisableFPElimNonLeaf;
   Options.AllowFPOpFusion = FuseFPOps;
   Options.UnsafeFPMath = EnableUnsafeFPMath;
   Options.NoInfsFPMath = EnableNoInfsFPMath;