mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-02 08:01:11 +03:00
Don't eliminate frame pointer by default at -O0 (#2483)
Fixes issue #2480.
This commit is contained in:
parent
a4043a4bcc
commit
ca6472c3b0
7 changed files with 33 additions and 21 deletions
|
@ -35,7 +35,11 @@ Reloc::Model getRelocModel() { return ::RelocModel; }
|
||||||
|
|
||||||
CodeModel::Model getCodeModel() { return ::CMModel; }
|
CodeModel::Model getCodeModel() { return ::CMModel; }
|
||||||
|
|
||||||
bool disableFPElim() { return ::DisableFPElim; }
|
cl::boolOrDefault disableFPElim() {
|
||||||
|
return ::DisableFPElim.getNumOccurrences() == 0
|
||||||
|
? cl::BOU_UNSET
|
||||||
|
: ::DisableFPElim ? cl::BOU_TRUE : cl::BOU_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
bool disableRedZone() { return ::DisableRedZone; }
|
bool disableRedZone() { return ::DisableRedZone; }
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ llvm::Optional<llvm::Reloc::Model> getRelocModel();
|
||||||
llvm::Reloc::Model getRelocModel();
|
llvm::Reloc::Model getRelocModel();
|
||||||
#endif
|
#endif
|
||||||
llvm::CodeModel::Model getCodeModel();
|
llvm::CodeModel::Model getCodeModel();
|
||||||
bool disableFPElim();
|
llvm::cl::boolOrDefault disableFPElim();
|
||||||
bool disableRedZone();
|
bool disableRedZone();
|
||||||
bool printTargetFeaturesHelp();
|
bool printTargetFeaturesHelp();
|
||||||
|
|
||||||
|
|
|
@ -459,9 +459,8 @@ void applyTargetMachineAttributes(llvm::Function &func,
|
||||||
func.addFnAttr("no-infs-fp-math", TO.NoInfsFPMath ? "true" : "false");
|
func.addFnAttr("no-infs-fp-math", TO.NoInfsFPMath ? "true" : "false");
|
||||||
func.addFnAttr("no-nans-fp-math", TO.NoNaNsFPMath ? "true" : "false");
|
func.addFnAttr("no-nans-fp-math", TO.NoNaNsFPMath ? "true" : "false");
|
||||||
|
|
||||||
// Frame pointer elimination
|
|
||||||
func.addFnAttr("no-frame-pointer-elim",
|
func.addFnAttr("no-frame-pointer-elim",
|
||||||
opts::disableFPElim() ? "true" : "false");
|
willEliminateFramePointer() ? "false" : "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
|
@ -120,6 +120,12 @@ bool willCrossModuleInline() {
|
||||||
return enableCrossModuleInlining == llvm::cl::BOU_TRUE;
|
return enableCrossModuleInlining == llvm::cl::BOU_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool willEliminateFramePointer() {
|
||||||
|
const llvm::cl::boolOrDefault disableFPElimEnum = opts::disableFPElim();
|
||||||
|
return disableFPElimEnum == llvm::cl::BOU_FALSE ||
|
||||||
|
(disableFPElimEnum == llvm::cl::BOU_UNSET && isOptimizationEnabled());
|
||||||
|
}
|
||||||
|
|
||||||
bool isOptimizationEnabled() { return optimizeLevel != 0; }
|
bool isOptimizationEnabled() { return optimizeLevel != 0; }
|
||||||
|
|
||||||
llvm::CodeGenOpt::Level codeGenOptLevel() {
|
llvm::CodeGenOpt::Level codeGenOptLevel() {
|
||||||
|
|
|
@ -35,6 +35,8 @@ bool willInline();
|
||||||
|
|
||||||
bool willCrossModuleInline();
|
bool willCrossModuleInline();
|
||||||
|
|
||||||
|
bool willEliminateFramePointer();
|
||||||
|
|
||||||
unsigned optLevel();
|
unsigned optLevel();
|
||||||
|
|
||||||
bool isOptimizationEnabled();
|
bool isOptimizationEnabled();
|
||||||
|
|
|
@ -1,26 +1,27 @@
|
||||||
// Tests that our TargetMachine options are added as function attributes
|
// Tests that our TargetMachine options are added as function attributes
|
||||||
|
|
||||||
// RUN: %ldc -c -output-ll -of=%t.ll %s && FileCheck %s --check-prefix=DEFAULT < %t.ll
|
// RUN: %ldc -c -output-ll -of=%t.ll %s
|
||||||
// RUN: %ldc -c -output-ll -of=%t.ll %s -disable-fp-elim && FileCheck %s --check-prefix=FRAMEPTR < %t.ll
|
// RUN: FileCheck %s --check-prefix=COMMON --check-prefix=WITH_FP < %t.ll
|
||||||
// RUN: %ldc -c -output-ll -of=%t.ll %s -mattr=test && FileCheck %s --check-prefix=ATTR < %t.ll
|
// RUN: %ldc -c -output-ll -of=%t.ll %s -O2
|
||||||
|
// RUN: FileCheck %s --check-prefix=COMMON --check-prefix=NO_FP < %t.ll
|
||||||
|
// RUN: %ldc -c -output-ll -of=%t.ll %s -O2 -disable-fp-elim
|
||||||
|
// RUN: FileCheck %s --check-prefix=COMMON --check-prefix=WITH_FP < %t.ll
|
||||||
|
// RUN: %ldc -c -output-ll -of=%t.ll %s -disable-fp-elim=false -mattr=test
|
||||||
|
// RUN: FileCheck %s --check-prefix=COMMON --check-prefix=NO_FP --check-prefix=ATTR < %t.ll
|
||||||
|
|
||||||
// DEFAULT: define{{.*}} @{{.*}}3fooFZv{{.*}} #[[KEYVALUE:[0-9]+]]
|
// COMMON: define{{.*}} @{{.*}}3fooFZv{{.*}} #[[KEYVALUE:[0-9]+]]
|
||||||
// FRAMEPTR: define{{.*}} @{{.*}}3fooFZv{{.*}} #[[KEYVALUE:[0-9]+]]
|
|
||||||
// ATTR: define{{.*}} @{{.*}}3fooFZv{{.*}} #[[KEYVALUE:[0-9]+]]
|
|
||||||
void foo()
|
void foo()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEFAULT: attributes #[[KEYVALUE]]
|
// COMMON: attributes #[[KEYVALUE]]
|
||||||
// DEFAULT-DAG: "target-cpu"=
|
// COMMON-DAG: "target-cpu"=
|
||||||
// DEFAULT-DAG: "no-frame-pointer-elim"="false"
|
// COMMON-DAG: "unsafe-fp-math"="false"
|
||||||
// DEFAULT-DAG: "unsafe-fp-math"="false"
|
// COMMON-DAG: "less-precise-fpmad"="false"
|
||||||
// DEFAULT-DAG: "less-precise-fpmad"="false"
|
// COMMON-DAG: "no-infs-fp-math"="false"
|
||||||
// DEFAULT-DAG: "no-infs-fp-math"="false"
|
// COMMON-DAG: "no-nans-fp-math"="false"
|
||||||
// DEFAULT-DAG: "no-nans-fp-math"="false"
|
|
||||||
|
|
||||||
// FRAMEPTR: attributes #[[KEYVALUE]]
|
// WITH_FP-DAG: "no-frame-pointer-elim"="true"
|
||||||
// FRAMEPTR-DAG: "no-frame-pointer-elim"="true"
|
// NO_FP-DAG: "no-frame-pointer-elim"="false"
|
||||||
|
|
||||||
// ATTR: attributes #[[KEYVALUE]]
|
|
||||||
// ATTR-DAG: "target-features"="{{.*}}+test{{.*}}"
|
// ATTR-DAG: "target-features"="{{.*}}+test{{.*}}"
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 5e9ab8e37b6d435f6cfba4cfd87b3c6651e9e562
|
Subproject commit 9e3d6271d78ac959a42c48fd9ca15e8d7a8ba531
|
Loading…
Add table
Add a link
Reference in a new issue