Index: test/Driver/lto.c
===================================================================
--- test/Driver/lto.c	(revision 70390)
+++ test/Driver/lto.c	(working copy)
@@ -4,20 +4,14 @@
 // RUN: grep '2: compiler, {1}, llvm-bc' %t.log &&
 // RUN: clang -ccc-print-phases -c %s -O4 2> %t.log &&
 // RUN: grep '2: compiler, {1}, llvm-bc' %t.log &&
-
-// and -emit-llvm doesn't alter pipeline (unfortunately?).
-// RUN: clang -ccc-print-phases %s -emit-llvm 2> %t.log &&
-// RUN: grep '0: input, ".*lto.c", c' %t.log &&
-// RUN: grep '1: preprocessor, {0}, cpp-output' %t.log &&
+// RUN: clang -ccc-print-phases -c %s -emit-llvm 2> %t.log &&
 // RUN: grep '2: compiler, {1}, llvm-bc' %t.log &&
-// RUN: grep '3: linker, {2}, image' %t.log &&
 
 // llvm-bc and llvm-ll outputs need to match regular suffixes
 // (unfortunately).
 // RUN: clang %s -emit-llvm -save-temps -### 2> %t.log &&
 // RUN: grep '"-o" ".*lto\.i" "-x" "c" ".*lto\.c"' %t.log &&
 // RUN: grep '"-o" ".*lto\.o" .*".*lto\.i"' %t.log &&
-// RUN: grep '".*a.out" .*".*lto\.o"' %t.log &&
 
 // RUN: clang %s -emit-llvm -S -### 2> %t.log &&
 // RUN: grep '"-o" ".*lto\.s" "-x" "c" ".*lto\.c"' %t.log &&
Index: test/Driver/emit_llvm.c
===================================================================
--- test/Driver/emit_llvm.c	(revision 0)
+++ test/Driver/emit_llvm.c	(revision 0)
@@ -0,0 +1,7 @@
+// Check whether compilation under -emit-llvm succeeds. On Linux, this used to
+// invoke gcc on the LLVM bitcode, which failed.
+// RUN: clang -emit-llvm %s &&
+
+// Verify that -emit-llvm -S produces LLVM IR instead of bitcode.
+// RUN: clang -emit-llvm -S %s -o %t &&
+// RUN: grep "target triple" %t
Index: include/clang/Driver/Options.def
===================================================================
--- include/clang/Driver/Options.def	(revision 70390)
+++ include/clang/Driver/Options.def	(working copy)
@@ -343,6 +343,8 @@
 OPTION("-dynamic", dynamic, Flag, INVALID, INVALID, "q", 0, 0, 0)
 OPTION("-d", d_Flag, Flag, d_Group, INVALID, "", 0, 0, 0)
 OPTION("-d", d_Joined, Joined, d_Group, INVALID, "", 0, 0, 0)
+OPTION("-emit-llvm-bc", emit_llvm_bc, Flag, INVALID, INVALID, "", 0, 
+       "Use the LLVM bitcode for assembler and object files", 0)
 OPTION("-emit-llvm", emit_llvm, Flag, INVALID, INVALID, "", 0, 
        "Use the LLVM representation for assembler and object files", 0)
 OPTION("-exported_symbols_list", exported__symbols__list, Separate, INVALID, INVALID, "", 0, 0, 0)
Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp	(revision 70390)
+++ lib/Driver/Driver.cpp	(working copy)
@@ -659,9 +659,12 @@
       (FinalPhaseArg = Args.getLastArg(options::OPT_MM))) {
     FinalPhase = phases::Preprocess;
     
-    // -{fsyntax-only,-analyze,emit-llvm,S} only run up to the compiler.
+    // -{fsyntax-only,-analyze,emit-llvm,emit-llvm-bc,S} only run up to the
+    // compiler.
   } else if ((FinalPhaseArg = Args.getLastArg(options::OPT_fsyntax_only)) ||
              (FinalPhaseArg = Args.getLastArg(options::OPT__analyze)) ||
+             (FinalPhaseArg = Args.getLastArg(options::OPT_emit_llvm)) ||
+             (FinalPhaseArg = Args.getLastArg(options::OPT_emit_llvm_bc)) ||
              (FinalPhaseArg = Args.getLastArg(options::OPT_S))) {
     FinalPhase = phases::Compile;
 
@@ -764,6 +767,8 @@
       return new CompileJobAction(Input, types::TY_Nothing);
     } else if (Args.hasArg(options::OPT__analyze)) {
       return new AnalyzeJobAction(Input, types::TY_Plist);
+    } else if (Args.hasArg(options::OPT_emit_llvm_bc)) {
+        return new CompileJobAction(Input, types::TY_LLVMBC);
     } else if (Args.hasArg(options::OPT_emit_llvm) ||
                Args.hasArg(options::OPT_flto) ||
                Args.hasArg(options::OPT_O4)) {
