[PATCH] D20374: [Driver] Fix the case when use -fembed-bitcode and -flto= together
Steven Wu via cfe-commits
cfe-commits at lists.llvm.org
Wed May 18 10:08:11 PDT 2016
steven_wu created this revision.
steven_wu added a reviewer: joker.eph.
steven_wu added a subscriber: cfe-commits.
Herald added a subscriber: joker.eph.
-fembed-bitcode was only checking for old style LTO flag (-flto) but not
considering the new -flto= style option. That makes clang output bitcode
embedded in bitcode object when using -flto= and -fembed-bitcode= together.
Now clang should output normal bitcode file when using LTO and ignores
-fembed-bitcode option.
http://reviews.llvm.org/D20374
Files:
lib/Driver/Driver.cpp
test/Driver/embed-bitcode.c
Index: test/Driver/embed-bitcode.c
===================================================================
--- test/Driver/embed-bitcode.c
+++ test/Driver/embed-bitcode.c
@@ -27,6 +27,8 @@
// CHECK-SAVE-TEMP: -cc1as
// RUN: %clang -c %s -flto -fembed-bitcode 2>&1 -### | FileCheck %s -check-prefix=CHECK-LTO
+// RUN: %clang -c %s -flto=full -fembed-bitcode 2>&1 -### | FileCheck %s -check-prefix=CHECK-LTO
+// RUN: %clang -c %s -flto=thin -fembed-bitcode 2>&1 -### | FileCheck %s -check-prefix=CHECK-LTO
// CHECK-LTO: -cc1
// CHECK-LTO: -emit-llvm-bc
// CHECK-LTO-NOT: warning: argument unused during compilation: '-fembed-bitcode'
Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -504,9 +504,11 @@
.Default(SaveTempsCwd);
}
+ setLTOMode(Args);
+
// Ignore -fembed-bitcode options with LTO
// since the output will be bitcode anyway.
- if (!Args.hasFlag(options::OPT_flto, options::OPT_fno_lto, false)) {
+ if (getLTOMode() == LTOK_None) {
if (Arg *A = Args.getLastArg(options::OPT_fembed_bitcode_EQ)) {
StringRef Name = A->getValue();
unsigned Model = llvm::StringSwitch<unsigned>(Name)
@@ -526,8 +528,6 @@
Args.ClaimAllArgs(options::OPT_fembed_bitcode_EQ);
}
- setLTOMode(Args);
-
std::unique_ptr<llvm::opt::InputArgList> UArgs =
llvm::make_unique<InputArgList>(std::move(Args));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20374.57645.patch
Type: text/x-patch
Size: 1465 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160518/28aaf60f/attachment.bin>
More information about the cfe-commits
mailing list