From 13aee94bc710bfa6277c1f07146c714ee65bf2de Mon Sep 17 00:00:00 2001 From: Mircea Trofin Date: Wed, 28 Oct 2020 20:16:51 -0700 Subject: [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 --- clang/lib/Frontend/CompilerInvocation.cpp | 32 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'clang/lib/Frontend/CompilerInvocation.cpp') 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'); } } -- cgit v1.1