summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorSteven Wu <stevenwu@apple.com>2015-07-17 20:09:56 +0000
committerSteven Wu <stevenwu@apple.com>2015-07-17 20:09:56 +0000
commit546a19628bc0d1e1e6b2f50d029df4b08e64dfa5 (patch)
treede33d42a65db7410c59f7987a5f2ff2c873eb8db /clang/lib/Frontend/CompilerInvocation.cpp
parent76c2f2c9dae885fd51971ba8d3b9709355adeade (diff)
downloadbcm5719-llvm-546a19628bc0d1e1e6b2f50d029df4b08e64dfa5.tar.gz
bcm5719-llvm-546a19628bc0d1e1e6b2f50d029df4b08e64dfa5.zip
Fix -save-temp when using objc-arc, sanitizer and profiling
Currently, -save-temp will cause ObjCARC optimization to be dropped, sanitizer pass to run early in the pipeline, and profiling instrumentation to run twice. Fix the issue by properly disable all passes in the optimization pipeline when generating bitcode output and parse some of the Language Options even when the input is bitcode so the passes can be setup correctly. llvm-svn: 242565
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index f325144fd08..e4cfba3b544 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -426,6 +426,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.EmitLLVMUseLists = A->getOption().getID() == OPT_emit_llvm_uselists;
Opts.DisableLLVMOpts = Args.hasArg(OPT_disable_llvm_optzns);
+ Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
Opts.ForbidGuardVariables = Args.hasArg(OPT_fforbid_guard_variables);
Opts.UseRegisterSizedBitfieldAccess = Args.hasArg(
@@ -1887,7 +1888,16 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
Success &= ParseCodeGenArgs(Res.getCodeGenOpts(), Args, DashX, Diags,
Res.getTargetOpts());
ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args);
- if (DashX != IK_AST && DashX != IK_LLVM_IR) {
+ if (DashX == IK_AST || DashX == IK_LLVM_IR) {
+ // ObjCAAutoRefCount and Sanitize LangOpts are used to setup the
+ // PassManager in BackendUtil.cpp. They need to be initializd no matter
+ // what the input type is.
+ if (Args.hasArg(OPT_fobjc_arc))
+ Res.getLangOpts()->ObjCAutoRefCount = 1;
+ parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
+ Diags, Res.getLangOpts()->Sanitize);
+ } else {
+ // Other LangOpts are only initialzed when the input is not AST or LLVM IR.
ParseLangArgs(*Res.getLangOpts(), Args, DashX, Diags);
if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
Res.getLangOpts()->ObjCExceptions = 1;
OpenPOWER on IntegriCloud