diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/BackendUtil.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Driver/Tools.cpp | 11 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 12 |
3 files changed, 18 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index afcb9e5c505..5754bb63dd7 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -272,6 +272,9 @@ static void addSymbolRewriterPass(const CodeGenOptions &Opts, } void EmitAssemblyHelper::CreatePasses() { + if (CodeGenOpts.DisableLLVMPasses) + return; + unsigned OptLevel = CodeGenOpts.OptimizationLevel; CodeGenOptions::InliningMethod Inlining = CodeGenOpts.getInlining(); diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index d4a307b62a4..40643ccb67e 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -4800,7 +4800,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // Forward -Xclang arguments to -cc1, and -mllvm arguments to the LLVM option // parser. Args.AddAllArgValues(CmdArgs, options::OPT_Xclang); - bool OptDisabled = false; for (const Arg *A : Args.filtered(options::OPT_mllvm)) { A->claim(); @@ -4808,17 +4807,15 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // it and developers have been trained to spell it with -mllvm. if (StringRef(A->getValue(0)) == "-disable-llvm-optzns") { CmdArgs.push_back("-disable-llvm-optzns"); - OptDisabled = true; } else A->render(Args, CmdArgs); } // With -save-temps, we want to save the unoptimized bitcode output from the - // CompileJobAction, so disable optimizations if they are not already - // disabled. - if (C.getDriver().isSaveTempsEnabled() && !OptDisabled && - isa<CompileJobAction>(JA)) - CmdArgs.push_back("-disable-llvm-optzns"); + // CompileJobAction, use -disable-llvm-passes to get pristine IR generated + // by the frontend. + if (C.getDriver().isSaveTempsEnabled() && isa<CompileJobAction>(JA)) + CmdArgs.push_back("-disable-llvm-passes"); if (Output.getType() == types::TY_Dependencies) { // Handled with other dependency code. 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; |