]> granicus.if.org Git - clang/commitdiff
Driver: Fix '... -O4 -O0 ...', which was generating bitcode.
authorDaniel Dunbar <daniel@zuster.org>
Wed, 23 Dec 2009 00:47:42 +0000 (00:47 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 23 Dec 2009 00:47:42 +0000 (00:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91962 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Driver.cpp
test/Driver/emit-llvm.c

index c7eaad338c84c9bf0e4ba4f777693ddbd07f16e1..9ba5095aa8662f4118b761bcbf9848043fc68baa 100644 (file)
@@ -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);
index e0cc0b5dc2194379c0c436f9f9bc588083e85503..3439b58d85d7afb66ac50521c88807d24a8fad00 100644 (file)
@@ -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.
+// <rdar://problem/7046672> 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