Restore -disable-fp-elim option for LLVM 8+

This commit is contained in:
Martin Kinkelin 2019-02-23 17:08:10 +01:00
parent 306bda36fd
commit 6015278dfa
2 changed files with 13 additions and 7 deletions

View file

@ -23,6 +23,12 @@ static cl::opt<bool>
DisableRedZone("disable-red-zone", cl::ZeroOrMore, DisableRedZone("disable-red-zone", cl::ZeroOrMore,
cl::desc("Do not emit code that uses the red zone.")); cl::desc("Do not emit code that uses the red zone."));
#if LDC_LLVM_VER >= 800
static cl::opt<bool>
disableFPElim("disable-fp-elim", cl::ZeroOrMore,
cl::desc("Disable frame pointer elimination optimization"));
#endif
// Now expose the helper functions (with static linkage) via external wrappers // Now expose the helper functions (with static linkage) via external wrappers
// in the opts namespace, including some additional helper functions. // in the opts namespace, including some additional helper functions.
namespace opts { namespace opts {
@ -39,10 +45,11 @@ CodeModel::Model getCodeModel() { return ::CMModel; }
#if LDC_LLVM_VER >= 800 #if LDC_LLVM_VER >= 800
llvm::Optional<llvm::FramePointer::FP> framePointerUsage() { llvm::Optional<llvm::FramePointer::FP> framePointerUsage() {
if (::FramePointerUsage.getNumOccurrences() == 0) if (::FramePointerUsage.getNumOccurrences() > 0)
return llvm::None;
else
return ::FramePointerUsage.getValue(); return ::FramePointerUsage.getValue();
if (disableFPElim.getNumOccurrences() > 0)
return disableFPElim ? llvm::FramePointer::All : llvm::FramePointer::None;
return llvm::None;
} }
#else #else
cl::boolOrDefault disableFPElim() { cl::boolOrDefault disableFPElim() {

View file

@ -128,11 +128,10 @@ bool willCrossModuleInline() {
#if LDC_LLVM_VER >= 800 #if LDC_LLVM_VER >= 800
llvm::FramePointer::FP whichFramePointersToEmit() { llvm::FramePointer::FP whichFramePointersToEmit() {
auto option = opts::framePointerUsage(); if (auto option = opts::framePointerUsage())
if (option)
return *option; return *option;
else return isOptimizationEnabled() ? llvm::FramePointer::None
return isOptimizationEnabled() ? llvm::FramePointer::None : llvm::FramePointer::All; : llvm::FramePointer::All;
} }
#else #else
bool willEliminateFramePointer() { bool willEliminateFramePointer() {