Index: lib/Driver/Driver.cpp =================================================================== --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -1746,8 +1746,15 @@ } case phases::Backend: { if (isUsingLTO()) { - types::ID Output = - Args.hasArg(options::OPT_S) ? types::TY_LTO_IR : types::TY_LTO_BC; + // -flto in conjunction with -S will still produce + // assembler, unless -emit-llvm is also specified. + // In that case, LLVM IR is produced instead. + types::ID Output; + if (Args.hasArg(options::OPT_S)) + Output = (Args.hasArg(options::OPT_emit_llvm)) ? types::TY_LLVM_IR : + types::TY_PP_Asm; + else + Output = types::TY_LTO_BC; return C.MakeAction(Input, Output); } if (Args.hasArg(options::OPT_emit_llvm)) { Index: test/CodeGen/2009-10-20-GlobalDebug.c =================================================================== --- test/CodeGen/2009-10-20-GlobalDebug.c +++ test/CodeGen/2009-10-20-GlobalDebug.c @@ -1,5 +1,6 @@ // REQUIRES: x86-registered-target -// RUN: %clang -target i386-apple-darwin10 -flto -S -g %s -o - | FileCheck %s +// RUN: %clang -target i386-apple-darwin10 -flto -emit-llvm -S -g %s -o - |\ +// RUN: FileCheck %s int global; int main() { static int localstatic; @@ -8,9 +9,9 @@ // CHECK: !DIGlobalVariable(name: "localstatic" // CHECK-NOT: linkageName: -// CHECK-SAME: line: 5, +// CHECK-SAME: line: 6, // CHECK-SAME: variable: i32* @main.localstatic // CHECK: !DIGlobalVariable(name: "global" // CHECK-NOT: linkageName: -// CHECK-SAME: line: 3, +// CHECK-SAME: line: 4, // CHECK-SAME: variable: i32* @global Index: test/CodeGen/emit-asm.c =================================================================== --- test/CodeGen/emit-asm.c +++ test/CodeGen/emit-asm.c @@ -0,0 +1,15 @@ +// Make sure ASM is emitted instead of LLVM IR. +// RUN: %clang_cc1 %s -S -flto -o - | FileCheck %s + +int foo(int goo) { return goo + 42; } + +// CHECK: .section __TEXT,__text,regular,pure_instructions +// CHECK: .macosx_version_min 10, 11 +// CHECK: .globl _foo +// CHECK: .p2align 4, 0x90 +// CHECK: _foo: +// CHECK: movl %edi, -4(%rsp) +// CHECK: movl -4(%rsp), %edi +// CHECK: addl $42, %edi +// CHECK: movl %edi, %eax +// CHECK: retq Index: test/CodeGenCXX/cxx-apple-kext.cpp =================================================================== --- test/CodeGenCXX/cxx-apple-kext.cpp +++ test/CodeGenCXX/cxx-apple-kext.cpp @@ -1,7 +1,7 @@ -// RUN: %clangxx -target x86_64-apple-darwin10 %s -flto -S -o - |\ +// RUN: %clangxx -target x86_64-apple-darwin10 %s -flto -S -emit-llvm -o - |\ // RUN: FileCheck --check-prefix=CHECK-NO-KEXT %s -// RUN: %clangxx -target x86_64-apple-darwin10 %s -fapple-kext -flto -S -o - |\ -// RUN: FileCheck --check-prefix=CHECK-KEXT %s +// RUN: %clangxx -target x86_64-apple-darwin10 %s -fapple-kext -flto -S \ +// RUN: -emit-llvm -o - | FileCheck --check-prefix=CHECK-KEXT %s // CHECK-NO-KEXT-NOT: _GLOBAL__D_a // CHECK-NO-KEXT: @is_hosted = global Index: test/Driver/darwin-iphone-defaults.m =================================================================== --- test/Driver/darwin-iphone-defaults.m +++ test/Driver/darwin-iphone-defaults.m @@ -1,4 +1,4 @@ -// RUN: %clang -target i386-apple-darwin9 -miphoneos-version-min=3.0 -arch armv7 -stdlib=platform -flto -S -o - %s | FileCheck %s +// RUN: %clang -target i386-apple-darwin9 -miphoneos-version-min=3.0 -arch armv7 -stdlib=platform -flto -S -emit-llvm -o - %s | FileCheck %s // CHECK: @f0() [[F0:#[0-9]+]] // CHECK: @__f0_block_invoke Index: test/Driver/darwin-objc-gc.m =================================================================== --- test/Driver/darwin-objc-gc.m +++ test/Driver/darwin-objc-gc.m @@ -1,6 +1,6 @@ // Check that we warn, but accept, -fobjc-gc for iPhone OS. -// RUN: %clang -target i386-apple-darwin9 -miphoneos-version-min=3.0 -stdlib=platform -fobjc-gc -flto -S -o %t %s 2> %t.err +// RUN: %clang -target i386-apple-darwin9 -miphoneos-version-min=3.0 -stdlib=platform -fobjc-gc -flto -S -emit-llvm -o %t %s 2> %t.err // RUN: FileCheck --check-prefix=IPHONE_OBJC_GC_LL %s < %t // RUN: FileCheck --check-prefix=IPHONE_OBJC_GC_STDERR %s < %t.err