r269961 - [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:04:53 PDT 2016
Author: steven_wu
Date: Wed May 18 12:04:52 2016
New Revision: 269961
URL: http://llvm.org/viewvc/llvm-project?rev=269961&view=rev
Log:
[Driver] Fix the case when use -fembed-bitcode and -flto= together
Summary:
-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.
Reviewers: joker.eph
Subscribers: joker.eph, cfe-commits
Differential Revision: http://reviews.llvm.org/D20374
Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/embed-bitcode.c
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=269961&r1=269960&r2=269961&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed May 18 12:04:52 2016
@@ -504,9 +504,11 @@ Compilation *Driver::BuildCompilation(Ar
.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 @@ Compilation *Driver::BuildCompilation(Ar
Args.ClaimAllArgs(options::OPT_fembed_bitcode_EQ);
}
- setLTOMode(Args);
-
std::unique_ptr<llvm::opt::InputArgList> UArgs =
llvm::make_unique<InputArgList>(std::move(Args));
Modified: cfe/trunk/test/Driver/embed-bitcode.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/embed-bitcode.c?rev=269961&r1=269960&r2=269961&view=diff
==============================================================================
--- cfe/trunk/test/Driver/embed-bitcode.c (original)
+++ cfe/trunk/test/Driver/embed-bitcode.c Wed May 18 12:04:52 2016
@@ -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'
More information about the cfe-commits
mailing list