summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-03-27 23:58:37 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-03-27 23:58:37 +0000
commit8b4140d71203e9c02bd8089b6847ca9765aab1ab (patch)
tree7b1a36002e4a16ef855c2fe3839015b436f92d7f /clang/lib/Frontend/CompilerInvocation.cpp
parent958708624cbaba82ad334445153ad4ad5d90e73d (diff)
downloadbcm5719-llvm-8b4140d71203e9c02bd8089b6847ca9765aab1ab.tar.gz
bcm5719-llvm-8b4140d71203e9c02bd8089b6847ca9765aab1ab.zip
Move the emission of strict enum range metadata behind a flag (the same
flag as GCC uses: -fstrict-enums). There is a *lot* of code making unwarranted assumptions about the underlying type of enums, and it doesn't seem entirely reasonable to eagerly break all of it. Much more importantly, the current state of affairs is *very* good at optimizing based upon this information, which causes failures that are very distant from the actual enum. Before we push for enabling this by default, I think we need to implement -fcatch-undefined-behavior support for instrumenting and trapping whenever we store or load a value outside of the range. That way we can track down the misbehaving code very quickly. I discussed this with Rafael, and currently the only important cases he is aware of are the bool range-based optimizations which are staying hard enabled. We've not seen any issue with those either, and they are much more important for performance. llvm-svn: 153550
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 0f68591c963..48b8049cd09 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -286,6 +286,8 @@ static void CodeGenOptsToArgs(const CodeGenOptions &Opts, ToArgsList &Res) {
Res.push_back("-fno-dwarf-directory-asm");
if (Opts.SoftFloat)
Res.push_back("-msoft-float");
+ if (Opts.StrictEnums)
+ Res.push_back("-fstrict-enums");
if (Opts.UnwindTables)
Res.push_back("-munwind-tables");
if (Opts.RelocationModel != "pic")
@@ -1135,6 +1137,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.NoDwarf2CFIAsm = Args.hasArg(OPT_fno_dwarf2_cfi_asm);
Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm);
Opts.SoftFloat = Args.hasArg(OPT_msoft_float);
+ Opts.StrictEnums = Args.hasArg(OPT_fstrict_enums);
Opts.UnsafeFPMath = Args.hasArg(OPT_menable_unsafe_fp_math) ||
Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
Args.hasArg(OPT_cl_fast_relaxed_math);
OpenPOWER on IntegriCloud