diff options
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Driver/Driver.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Driver/ToolChain.cpp | 23 | ||||
| -rw-r--r-- | clang/lib/Driver/Tools.cpp | 7 |
3 files changed, 17 insertions, 17 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index c318b60a938..5cc19f5f8e6 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -2049,3 +2049,7 @@ std::pair<unsigned, unsigned> Driver::getIncludeExcludeOptionFlagMasks() const { return std::make_pair(IncludedFlagsBitmask, ExcludedFlagsBitmask); } + +bool clang::driver::isOptimizationLevelFast(const llvm::opt::ArgList &Args) { + return Args.hasFlag(options::OPT_Ofast, options::OPT_O_Group, false); +} diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 4103914d297..9f756f7c63d 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -341,16 +341,19 @@ void ToolChain::AddCCKextLibArgs(const ArgList &Args, bool ToolChain::AddFastMathRuntimeIfAvailable(const ArgList &Args, ArgStringList &CmdArgs) const { - // Check if -ffast-math or -funsafe-math is enabled. - Arg *A = Args.getLastArg(options::OPT_ffast_math, - options::OPT_fno_fast_math, - options::OPT_funsafe_math_optimizations, - options::OPT_fno_unsafe_math_optimizations); - - if (!A || A->getOption().getID() == options::OPT_fno_fast_math || - A->getOption().getID() == options::OPT_fno_unsafe_math_optimizations) - return false; - + // Do not check for -fno-fast-math or -fno-unsafe-math when -Ofast passed + // (to keep the linker options consistent with gcc and clang itself). + if (!isOptimizationLevelFast(Args)) { + // Check if -ffast-math or -funsafe-math. + Arg *A = + Args.getLastArg(options::OPT_ffast_math, options::OPT_fno_fast_math, + options::OPT_funsafe_math_optimizations, + options::OPT_fno_unsafe_math_optimizations); + + if (!A || A->getOption().getID() == options::OPT_fno_fast_math || + A->getOption().getID() == options::OPT_fno_unsafe_math_optimizations) + return false; + } // If crtfastmath.o exists add it to the arguments. std::string Path = GetFilePath("crtfastmath.o"); if (Path == "crtfastmath.o") // Not found. diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index ef3e00329dd..c90fb81f030 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -2034,13 +2034,6 @@ static void SplitDebugInfo(const ToolChain &TC, Compilation &C, C.addCommand(new Command(JA, T, Exec, StripArgs)); } -static bool isOptimizationLevelFast(const ArgList &Args) { - if (Arg *A = Args.getLastArg(options::OPT_O_Group)) - if (A->getOption().matches(options::OPT_Ofast)) - return true; - return false; -} - /// \brief Vectorize at all optimization levels greater than 1 except for -Oz. static bool shouldEnableVectorizerAtOLevel(const ArgList &Args) { if (Arg *A = Args.getLastArg(options::OPT_O_Group)) { |

