From: Daniel Dunbar Date: Wed, 23 Dec 2009 00:47:42 +0000 (+0000) Subject: Driver: Fix '... -O4 -O0 ...', which was generating bitcode. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=73ba9a6337c7879021976949a2dad9476a4f0abb;p=clang Driver: Fix '... -O4 -O0 ...', which was generating bitcode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91962 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index c7eaad338c..9ba5095aa8 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -739,6 +739,10 @@ Action *Driver::ConstructPhaseAction(const ArgList &Args, phases::ID Phase, case phases::Precompile: return new PrecompileJobAction(Input, types::TY_PCH); case phases::Compile: { + bool HasO4 = false; + if (const Arg *A = Args.getLastArg(options::OPT_O_Group)) + HasO4 = A->getOption().matches(options::OPT_O4); + if (Args.hasArg(options::OPT_fsyntax_only)) { return new CompileJobAction(Input, types::TY_Nothing); } else if (Args.hasArg(options::OPT__analyze, options::OPT__analyze_auto)) { @@ -746,8 +750,7 @@ Action *Driver::ConstructPhaseAction(const ArgList &Args, phases::ID Phase, } else if (Args.hasArg(options::OPT_emit_ast)) { return new CompileJobAction(Input, types::TY_AST); } else if (Args.hasArg(options::OPT_emit_llvm) || - Args.hasArg(options::OPT_flto) || - Args.hasArg(options::OPT_O4)) { + Args.hasArg(options::OPT_flto) || HasO4) { types::ID Output = Args.hasArg(options::OPT_S) ? types::TY_LLVMAsm : types::TY_LLVMBC; return new CompileJobAction(Input, Output); diff --git a/test/Driver/emit-llvm.c b/test/Driver/emit-llvm.c index e0cc0b5dc2..3439b58d85 100644 --- a/test/Driver/emit-llvm.c +++ b/test/Driver/emit-llvm.c @@ -1,3 +1,13 @@ // RUN: not %clang -ccc-host-triple i386-pc-linux-gnu -emit-llvm -o %t %s 2> %t.log // RUN: grep 'unable to pass LLVM bit-code files to linker' %t.log +// Check that -O4 is only honored as the effective -O option. +// clang/loader problem + +// RUN: %clang -ccc-print-phases -c -O4 -O0 %s 2> %t +// RUN: FileCheck --check-prefix=O4_AND_O0 %s < %t + +// O4_AND_O0: 0: input, "{{.*}}", c +// O4_AND_O0: 1: preprocessor, {0}, cpp-output +// O4_AND_O0: 2: compiler, {1}, assembler +// O4_AND_O0: 3: assembler, {2}, object