forked from OSchip/llvm-project
[Hexagon] Set -ffp-contract=fast at -O3 unless explicitly specified
llvm-svn: 301361
This commit is contained in:
parent
54ba4312a3
commit
dcda945971
|
@ -402,6 +402,39 @@ Tool *HexagonToolChain::buildLinker() const {
|
|||
return new tools::hexagon::Linker(*this);
|
||||
}
|
||||
|
||||
unsigned HexagonToolChain::getOptimizationLevel(
|
||||
const llvm::opt::ArgList &DriverArgs) const {
|
||||
// Copied in large part from lib/Frontend/CompilerInvocation.cpp.
|
||||
Arg *A = DriverArgs.getLastArg(options::OPT_O_Group);
|
||||
if (!A)
|
||||
return 0;
|
||||
|
||||
if (A->getOption().matches(options::OPT_O0))
|
||||
return 0;
|
||||
if (A->getOption().matches(options::OPT_Ofast))
|
||||
return 3;
|
||||
assert(A->getNumValues() != 0);
|
||||
StringRef S(A->getValue());
|
||||
if (S == "s" || S == "z" || S.empty())
|
||||
return 2;
|
||||
if (S == "g")
|
||||
return 1;
|
||||
|
||||
unsigned OptLevel;
|
||||
if (S.getAsInteger(10, OptLevel))
|
||||
return 0;
|
||||
return OptLevel;
|
||||
}
|
||||
|
||||
void HexagonToolChain::addClangTargetOptions(const ArgList &DriverArgs,
|
||||
ArgStringList &CC1Args) const {
|
||||
if (DriverArgs.hasArg(options::OPT_ffp_contract))
|
||||
return;
|
||||
unsigned OptLevel = getOptimizationLevel(DriverArgs);
|
||||
if (OptLevel >= 3)
|
||||
CC1Args.push_back("-ffp-contract=fast");
|
||||
}
|
||||
|
||||
void HexagonToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
|
||||
ArgStringList &CC1Args) const {
|
||||
if (DriverArgs.hasArg(options::OPT_nostdinc) ||
|
||||
|
|
|
@ -61,11 +61,15 @@ protected:
|
|||
Tool *buildAssembler() const override;
|
||||
Tool *buildLinker() const override;
|
||||
|
||||
unsigned getOptimizationLevel(const llvm::opt::ArgList &DriverArgs) const;
|
||||
|
||||
public:
|
||||
HexagonToolChain(const Driver &D, const llvm::Triple &Triple,
|
||||
const llvm::opt::ArgList &Args);
|
||||
~HexagonToolChain() override;
|
||||
|
||||
void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
|
||||
llvm::opt::ArgStringList &CC1Args) const override;
|
||||
void
|
||||
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
|
||||
llvm::opt::ArgStringList &CC1Args) const override;
|
||||
|
|
|
@ -97,6 +97,22 @@
|
|||
// CHECK024: "-cc1" {{.*}} "-target-cpu" "hexagonv62"
|
||||
// CHECK024: hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v62/crt0
|
||||
|
||||
// RUN: %clang -### -target hexagon-unknown-elf \
|
||||
// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
|
||||
// RUN: -O3 \
|
||||
// RUN: %s 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=CHECK025 %s
|
||||
// CHECK025: "-ffp-contract=fast"
|
||||
// CHECK025: hexagon-link
|
||||
|
||||
// RUN: %clang -### -target hexagon-unknown-elf \
|
||||
// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
|
||||
// RUN: -O3 -ffp-contract=off \
|
||||
// RUN: %s 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=CHECK026 %s
|
||||
// CHECK026-NOT: "-ffp-contract=fast"
|
||||
// CHECK026: hexagon-link
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Test Linker related args
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue