aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorYusuke MINATO <minato.yusuke@fujitsu.com>2024-05-16 13:16:07 +0900
committerGitHub <noreply@github.com>2024-05-16 13:16:07 +0900
commit526553b25131a69d9d6426e17c7b69c2ba27144f (patch)
treeb55815216ab07a5310d1f97853a38e1b9b81f170 /flang/lib/Frontend/CompilerInvocation.cpp
parentb11a6607cb6522c58dfbd5f54239e7daa281368e (diff)
downloadllvm-526553b25131a69d9d6426e17c7b69c2ba27144f.zip
llvm-526553b25131a69d9d6426e17c7b69c2ba27144f.tar.gz
llvm-526553b25131a69d9d6426e17c7b69c2ba27144f.tar.bz2
[flang] Add nsw flag to do-variable increment with a new option (#91579)
This patch adds nsw flag to the increment of do-variables when a new option is enabled. NOTE 11.10 in the Fortran 2018 standard says they never overflow. See also the discussion in #74709 and the following discourse post. https://discourse.llvm.org/t/rfc-add-nsw-flags-to-arithmetic-integer-operations-using-the-option-fno-wrapv/77584/5
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--flang/lib/Frontend/CompilerInvocation.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index e8a8c90..50c3e8b 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -1206,6 +1206,12 @@ bool CompilerInvocation::createFromArgs(
invoc.loweringOpts.setNoPPCNativeVecElemOrder(true);
}
+ // -flang-experimental-integer-overflow
+ if (args.hasArg(
+ clang::driver::options::OPT_flang_experimental_integer_overflow)) {
+ invoc.loweringOpts.setNSWOnLoopVarInc(true);
+ }
+
// Preserve all the remark options requested, i.e. -Rpass, -Rpass-missed or
// -Rpass-analysis. This will be used later when processing and outputting the
// remarks generated by LLVM in ExecuteCompilerInvocation.cpp.