diff options
author | Steven Wu <stevenwu@apple.com> | 2016-05-11 16:26:03 +0000 |
---|---|---|
committer | Steven Wu <stevenwu@apple.com> | 2016-05-11 16:26:03 +0000 |
commit | 27fb5227ec1191df23903f15115539796fb17192 (patch) | |
tree | f08d909b31ffa5ce3eb45a940c29e84c2309aaac /clang/lib/Driver/Driver.cpp | |
parent | 330fb175d457e345c7eb55ce4b3ef89041c6c12e (diff) | |
download | bcm5719-llvm-27fb5227ec1191df23903f15115539796fb17192.tar.gz bcm5719-llvm-27fb5227ec1191df23903f15115539796fb17192.zip |
Embed bitcode in object file (clang cc1 part)
Summary:
Teach clang to embed bitcode inside bitcode. When -fembed-bitcode cc1
option is used, clang will embed both the input bitcode and cc1
commandline into the bitcode in special sections before compiling to
the object file. Using -fembed-bitcode-marker will only introduce a
marker in both sections.
Depends on D17390
Reviewers: rsmith
Subscribers: yaron.keren, vsk, cfe-commits
Differential Revision: http://reviews.llvm.org/D17392
llvm-svn: 269202
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r-- | clang/lib/Driver/Driver.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 111614f3a53..1f2c64eaf73 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -507,14 +507,23 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) { // 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 (Args.hasArg(options::OPT_fembed_bitcode)) - BitcodeEmbed = EmbedBitcode; - else if (Args.hasArg(options::OPT_fembed_bitcode_marker)) - BitcodeEmbed = EmbedMarker; + if (Arg *A = Args.getLastArg(options::OPT_fembed_bitcode_EQ)) { + StringRef Name = A->getValue(); + unsigned Model = llvm::StringSwitch<unsigned>(Name) + .Case("off", EmbedNone) + .Case("all", EmbedBitcode) + .Case("bitcode", EmbedBitcode) + .Case("marker", EmbedMarker) + .Default(~0U); + if (Model == ~0U) { + Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) + << Name; + } else + BitcodeEmbed = static_cast<BitcodeEmbedMode>(Model); + } } else { // claim the bitcode option under LTO so no warning is issued. - Args.ClaimAllArgs(options::OPT_fembed_bitcode); - Args.ClaimAllArgs(options::OPT_fembed_bitcode_marker); + Args.ClaimAllArgs(options::OPT_fembed_bitcode_EQ); } setLTOMode(Args); |