[PATCH] D21006: [Driver] Make -flto -S emit assembly
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 5 15:17:55 PDT 2016
davide created this revision.
davide added reviewers: rafael, rsmith, echristo.
davide added a subscriber: llvm-commits.
Herald added a subscriber: mehdi_amini.
Currently clang emits LLVM IR if -flto -S is specified.
This confuses build systems, which generally want assembly to emitted if -S is specified (as it happens with non-LTO).
I propose to change the driver so that -flto -S emits assembly. If somebody wants to override the behavior can specify -S -flto -emit-llvm
http://reviews.llvm.org/D21006
Files:
lib/Driver/Driver.cpp
test/CodeGen/2009-10-20-GlobalDebug.c
test/CodeGenCXX/cxx-apple-kext.cpp
test/Driver/darwin-iphone-defaults.m
test/Driver/darwin-objc-gc.m
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
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/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/CodeGen/2009-10-20-GlobalDebug.c
===================================================================
--- test/CodeGen/2009-10-20-GlobalDebug.c
+++ test/CodeGen/2009-10-20-GlobalDebug.c
@@ -1,16 +1,17 @@
// 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;
return 0;
}
// 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: 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 :
+ type::TY_PP_Asm;
+ else
+ Output = types::TY_LTO_BC;
return C.MakeAction<BackendJobAction>(Input, Output);
}
if (Args.hasArg(options::OPT_emit_llvm)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21006.59677.patch
Type: text/x-patch
Size: 3731 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160605/2e947f4a/attachment.bin>
More information about the llvm-commits
mailing list