diff options
author | Florian Hahn <flo@fhahn.com> | 2021-02-12 17:45:18 +0000 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2021-02-12 19:25:49 +0000 |
commit | 51bf4c0e6d4cbc6dfa57857fc78003413cbeb17f (patch) | |
tree | 3e584387f80bf1f832c93d1c905b566164bb9575 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 4fc25573089c53804a035080739867ee3b346fdd (diff) | |
download | llvm-51bf4c0e6d4cbc6dfa57857fc78003413cbeb17f.zip llvm-51bf4c0e6d4cbc6dfa57857fc78003413cbeb17f.tar.gz llvm-51bf4c0e6d4cbc6dfa57857fc78003413cbeb17f.tar.bz2 |
[clang] Add -ffinite-loops & -fno-finite-loops options.
This patch adds 2 new options to control when Clang adds `mustprogress`:
1. -ffinite-loops: assume all loops are finite; mustprogress is added
to all loops, regardless of the selected language standard.
2. -fno-finite-loops: assume no loop is finite; mustprogress is not
added to any loop or function. We could add mustprogress to
functions without loops, but we would have to detect that in Clang,
which is probably not worth it.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D96419
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 53f90cf..b2ee11a 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1633,7 +1633,6 @@ bool CompilerInvocation::ParseCodeGenArgsImpl(CodeGenOptions &Opts, Opts.UnrollLoops = Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops, (Opts.OptimizationLevel > 1)); - Opts.BinutilsVersion = std::string(Args.getLastArgValue(OPT_fbinutils_version_EQ)); @@ -1921,6 +1920,11 @@ bool CompilerInvocation::ParseCodeGenArgsImpl(CodeGenOptions &Opts, Opts.EmitVersionIdentMetadata = Args.hasFlag(OPT_Qy, OPT_Qn, true); + if (Args.hasArg(options::OPT_ffinite_loops)) + Opts.FiniteLoops = CodeGenOptions::FiniteLoopsKind::Always; + else if (Args.hasArg(options::OPT_fno_finite_loops)) + Opts.FiniteLoops = CodeGenOptions::FiniteLoopsKind::Never; + return Success && Diags.getNumErrors() == NumErrorsBefore; } |