summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-07-25 00:34:29 +0000
committerBill Wendling <isanbard@gmail.com>2013-07-25 00:34:29 +0000
commitf245ae5a4a78d5a02b3b9e2dae819077a56d81e7 (patch)
tree517ee29a63e853faa1a41509e465915e597ad8fc
parent9b344d920f6b3496885094bd2f364453cb8d968f (diff)
downloadllvm-f245ae5a4a78d5a02b3b9e2dae819077a56d81e7.tar.gz
llvm-f245ae5a4a78d5a02b3b9e2dae819077a56d81e7.tar.bz2
llvm-f245ae5a4a78d5a02b3b9e2dae819077a56d81e7.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187093 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/CodeGen/CommandFlags.h5
-rw-r--r--include/llvm/Target/TargetOptions.h8
-rw-r--r--lib/CodeGen/TargetOptionsImpl.cpp4
-rw-r--r--lib/IR/Attributes.cpp4
-rw-r--r--lib/Target/TargetMachine.cpp1
-rw-r--r--test/CodeGen/X86/fp-elim.ll74
-rw-r--r--test/CodeGen/X86/leaf-fp-elim.ll4
-rw-r--r--test/DebugInfo/2010-05-03-DisableFramePtr.ll4
-rw-r--r--tools/llc/llc.cpp1
-rw-r--r--tools/lto/LTOModule.cpp6
-rw-r--r--tools/opt/opt.cpp1
11 files changed, 59 insertions, 53 deletions
diff --git a/include/llvm/CodeGen/CommandFlags.h b/include/llvm/CodeGen/CommandFlags.h
index fd1d67bdcd..22bea34d78 100644
--- a/include/llvm/CodeGen/CommandFlags.h
+++ b/include/llvm/CodeGen/CommandFlags.h
@@ -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));
diff --git a/include/llvm/Target/TargetOptions.h b/include/llvm/Target/TargetOptions.h
index 04b2080106..feba3408f8 100644
--- a/include/llvm/Target/TargetOptions.h
+++ b/include/llvm/Target/TargetOptions.h
@@ -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;
diff --git a/lib/CodeGen/TargetOptionsImpl.cpp b/lib/CodeGen/TargetOptionsImpl.cpp
index b5d4160f93..7a39a4c273 100644
--- a/lib/CodeGen/TargetOptionsImpl.cpp
+++ b/lib/CodeGen/TargetOptionsImpl.cpp
@@ -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();
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp
index c8e2f6be5c..48743fae69 100644
--- a/lib/IR/Attributes.cpp
+++ b/lib/IR/Attributes.cpp
@@ -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();
diff --git a/lib/Target/TargetMachine.cpp b/lib/Target/TargetMachine.cpp
index e7282519d5..df4a03c9e8 100644
--- a/lib/Target/TargetMachine.cpp
+++ b/lib/Target/TargetMachine.cpp
@@ -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");
diff --git a/test/CodeGen/X86/fp-elim.ll b/test/CodeGen/X86/fp-elim.ll
index d43ee36143..583388cc71 100644
--- a/test/CodeGen/X86/fp-elim.ll
+++ b/test/CodeGen/X86/fp-elim.ll
@@ -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
}
diff --git a/test/CodeGen/X86/leaf-fp-elim.ll b/test/CodeGen/X86/leaf-fp-elim.ll
index 607dc72e2f..7eebf8d292 100644
--- a/test/CodeGen/X86/leaf-fp-elim.ll
+++ b/test/CodeGen/X86/leaf-fp-elim.ll
@@ -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
diff --git a/test/DebugInfo/2010-05-03-DisableFramePtr.ll b/test/DebugInfo/2010-05-03-DisableFramePtr.ll
index ec734f65cc..7e07067f42 100644
--- a/test/DebugInfo/2010-05-03-DisableFramePtr.ll
+++ b/test/DebugInfo/2010-05-03-DisableFramePtr.ll
@@ -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]
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp
index b62f41aec8..c66106b594 100644
--- a/tools/llc/llc.cpp
+++ b/tools/llc/llc.cpp
@@ -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;
diff --git a/tools/lto/LTOModule.cpp b/tools/lto/LTOModule.cpp
index 6626eaac47..7aeadc3da4 100644
--- a/tools/lto/LTOModule.cpp
+++ b/tools/lto/LTOModule.cpp
@@ -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(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;
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 23acefafbe..68fca83c96 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -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;