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
This commit is contained in:
Bill Wendling 2013-07-25 00:34:29 +00:00
parent 9b344d920f
commit f245ae5a4a
11 changed files with 56 additions and 50 deletions

View 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"),

View 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;

View 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();

View 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();

View 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");

View 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
; 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
; 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
; 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
; 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
}
; NON-LEAF-LABEL: t2:
; NON-LEAF-NEXT: pushl %ebp
; NON-LEAF: popl %ebp
; NON-LEAF-NEXT: ret
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
}

View 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

View 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]

View 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;

View 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;

View 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;