diff options
author | Mircea Trofin <mtrofin@google.com> | 2020-10-28 20:16:51 -0700 |
---|---|---|
committer | Mircea Trofin <mtrofin@google.com> | 2020-10-29 09:57:42 -0700 |
commit | 13aee94bc710bfa6277c1f07146c714ee65bf2de (patch) | |
tree | f352f8c4fbd7721388fd9e6cf52755ae536d863f /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | ec7780ebdab480139596c3cb08ee77d7035457b3 (diff) | |
download | llvm-13aee94bc710bfa6277c1f07146c714ee65bf2de.zip llvm-13aee94bc710bfa6277c1f07146c714ee65bf2de.tar.gz llvm-13aee94bc710bfa6277c1f07146c714ee65bf2de.tar.bz2 |
[ThinLTO] Fix empty .llvmcmd sections
When passing -lto-embed-bitcode=post-merge-pre-opt, we were getting
empty .llvmcmd sections. It turns out that is because the
CodeGenOptions::CmdArgs field was only populated when clang saw
-fembed-bitcode={all|marker}.
This patch always populates the CodeGenOptions::CmdArgs. The overhead
of carrying through in memory in all cases is likely negligible in
the grand schema of things, and it keeps the using code simple.
Differential Revision: https://reviews.llvm.org/D90366
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 5175063..2257916 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1095,23 +1095,21 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, // FIXME: For backend options that are not yet recorded as function // attributes in the IR, keep track of them so we can embed them in a // separate data section and use them when building the bitcode. - if (Opts.getEmbedBitcode() == CodeGenOptions::Embed_All) { - for (const auto &A : Args) { - // Do not encode output and input. - if (A->getOption().getID() == options::OPT_o || - A->getOption().getID() == options::OPT_INPUT || - A->getOption().getID() == options::OPT_x || - A->getOption().getID() == options::OPT_fembed_bitcode || - A->getOption().matches(options::OPT_W_Group)) - continue; - ArgStringList ASL; - A->render(Args, ASL); - for (const auto &arg : ASL) { - StringRef ArgStr(arg); - Opts.CmdArgs.insert(Opts.CmdArgs.end(), ArgStr.begin(), ArgStr.end()); - // using \00 to separate each commandline options. - Opts.CmdArgs.push_back('\0'); - } + for (const auto &A : Args) { + // Do not encode output and input. + if (A->getOption().getID() == options::OPT_o || + A->getOption().getID() == options::OPT_INPUT || + A->getOption().getID() == options::OPT_x || + A->getOption().getID() == options::OPT_fembed_bitcode || + A->getOption().matches(options::OPT_W_Group)) + continue; + ArgStringList ASL; + A->render(Args, ASL); + for (const auto &arg : ASL) { + StringRef ArgStr(arg); + Opts.CmdArgs.insert(Opts.CmdArgs.end(), ArgStr.begin(), ArgStr.end()); + // using \00 to separate each commandline options. + Opts.CmdArgs.push_back('\0'); } } |