[llvm] r187093 - Replace the "NoFramePointerElimNonLeaf" target option with a function attribute.

Bill Wendling isanbard at gmail.com
Wed Jul 24 17:34:30 PDT 2013


Author: void
Date: Wed Jul 24 19:34:29 2013
New Revision: 187093

URL: http://llvm.org/viewvc/llvm-project?rev=187093&view=rev
Log:
Replace the "NoFramePointerElimNonLeaf" target option with a function attribute.

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.

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

Modified: llvm/trunk/include/llvm/CodeGen/CommandFlags.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/CommandFlags.h?rev=187093&r1=187092&r2=187093&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/CommandFlags.h (original)
+++ llvm/trunk/include/llvm/CodeGen/CommandFlags.h Wed Jul 24 19:34:29 2013
@@ -110,11 +110,6 @@ DisableFPElim("disable-fp-elim",
               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"),
                 cl::init(false));

Modified: llvm/trunk/include/llvm/Target/TargetOptions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetOptions.h?rev=187093&r1=187092&r2=187093&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetOptions.h (original)
+++ llvm/trunk/include/llvm/Target/TargetOptions.h Wed Jul 24 19:34:29 2013
@@ -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;

Modified: llvm/trunk/lib/CodeGen/TargetOptionsImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetOptionsImpl.cpp?rev=187093&r1=187092&r2=187093&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetOptionsImpl.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetOptionsImpl.cpp Wed Jul 24 19:34:29 2013
@@ -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();

Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=187093&r1=187092&r2=187093&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Wed Jul 24 19:34:29 2013
@@ -104,24 +104,28 @@ bool Attribute::isStringAttribute() cons
 }
 
 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();

Modified: llvm/trunk/lib/Target/TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachine.cpp?rev=187093&r1=187092&r2=187093&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/TargetMachine.cpp Wed Jul 24 19:34:29 2013
@@ -78,7 +78,6 @@ void TargetMachine::resetTargetOptions(c
   } 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");

Modified: llvm/trunk/test/CodeGen/X86/fp-elim.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fp-elim.ll?rev=187093&r1=187092&r2=187093&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fp-elim.ll (original)
+++ llvm/trunk/test/CodeGen/X86/fp-elim.ll Wed Jul 24 19:34:29 2013
@@ -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
 }

Modified: llvm/trunk/test/CodeGen/X86/leaf-fp-elim.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/leaf-fp-elim.ll?rev=187093&r1=187092&r2=187093&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/leaf-fp-elim.ll (original)
+++ llvm/trunk/test/CodeGen/X86/leaf-fp-elim.ll Wed Jul 24 19:34:29 2013
@@ -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

Modified: llvm/trunk/test/DebugInfo/2010-05-03-DisableFramePtr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2010-05-03-DisableFramePtr.ll?rev=187093&r1=187092&r2=187093&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/2010-05-03-DisableFramePtr.ll (original)
+++ llvm/trunk/test/DebugInfo/2010-05-03-DisableFramePtr.ll Wed Jul 24 19:34:29 2013
@@ -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]

Modified: llvm/trunk/tools/llc/llc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=187093&r1=187092&r2=187093&view=diff
==============================================================================
--- llvm/trunk/tools/llc/llc.cpp (original)
+++ llvm/trunk/tools/llc/llc.cpp Wed Jul 24 19:34:29 2013
@@ -262,7 +262,6 @@ static int compileModule(char **argv, LL
   TargetOptions Options;
   Options.LessPreciseFPMADOption = EnableFPMAD;
   Options.NoFramePointerElim = DisableFPElim;
-  Options.NoFramePointerElimNonLeaf = DisableFPElimNonLeaf;
   Options.AllowFPOpFusion = FuseFPOps;
   Options.UnsafeFPMath = EnableUnsafeFPMath;
   Options.NoInfsFPMath = EnableNoInfsFPMath;

Modified: llvm/trunk/tools/lto/LTOModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=187093&r1=187092&r2=187093&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOModule.cpp (original)
+++ llvm/trunk/tools/lto/LTOModule.cpp Wed Jul 24 19:34:29 2013
@@ -50,11 +50,6 @@ DisableFPElim("disable-fp-elim",
   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"),
   cl::init(false));
@@ -236,7 +231,6 @@ LTOModule *LTOModule::makeLTOModule(cons
 void LTOModule::getTargetOptions(TargetOptions &Options) {
   Options.LessPreciseFPMADOption = EnableFPMAD;
   Options.NoFramePointerElim = DisableFPElim;
-  Options.NoFramePointerElimNonLeaf = DisableFPElimNonLeaf;
   Options.AllowFPOpFusion = FuseFPOps;
   Options.UnsafeFPMath = EnableUnsafeFPMath;
   Options.NoInfsFPMath = EnableNoInfsFPMath;

Modified: llvm/trunk/tools/opt/opt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=187093&r1=187092&r2=187093&view=diff
==============================================================================
--- llvm/trunk/tools/opt/opt.cpp (original)
+++ llvm/trunk/tools/opt/opt.cpp Wed Jul 24 19:34:29 2013
@@ -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;





More information about the llvm-commits mailing list