Index: clang/include/clang/Driver/Driver.h =================================================================== --- clang/include/clang/Driver/Driver.h +++ clang/include/clang/Driver/Driver.h @@ -304,13 +304,8 @@ bool isSaveTempsObj() const { return SaveTemps == SaveTempsObj; } bool embedBitcodeEnabled() const { return BitcodeEmbed != EmbedNone; } - bool embedBitcodeInObject() const { - // LTO has no object file output so ignore embed bitcode option in LTO. - return (BitcodeEmbed == EmbedBitcode) && !isUsingLTO(); - } - bool embedBitcodeMarkerOnly() const { - return (BitcodeEmbed == EmbedMarker) && !isUsingLTO(); - } + bool embedBitcodeInObject() const { return (BitcodeEmbed == EmbedBitcode); } + bool embedBitcodeMarkerOnly() const { return (BitcodeEmbed == EmbedMarker); } /// Compute the desired OpenMP runtime from the flags provided. OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList &Args) const; Index: clang/lib/Driver/Driver.cpp =================================================================== --- clang/lib/Driver/Driver.cpp +++ clang/lib/Driver/Driver.cpp @@ -3180,7 +3180,8 @@ const JobAction *JA = cast(A); ActionList CollapsedOffloadActions; - ToolSelector TS(JA, *TC, C, isSaveTempsEnabled(), embedBitcodeInObject()); + ToolSelector TS(JA, *TC, C, isSaveTempsEnabled(), + embedBitcodeInObject() && !isUsingLTO()); const Tool *T = TS.getTool(Inputs, CollapsedOffloadActions); if (!T) Index: clang/lib/Driver/Tools.cpp =================================================================== --- clang/lib/Driver/Tools.cpp +++ clang/lib/Driver/Tools.cpp @@ -4258,14 +4258,14 @@ } // Embed-bitcode option. - if (C.getDriver().embedBitcodeInObject() && + if (C.getDriver().embedBitcodeInObject() && !C.getDriver().isUsingLTO() && (isa(JA) || isa(JA))) { // Add flags implied by -fembed-bitcode. Args.AddLastArg(CmdArgs, options::OPT_fembed_bitcode_EQ); // Disable all llvm IR level optimizations. CmdArgs.push_back("-disable-llvm-passes"); } - if (C.getDriver().embedBitcodeMarkerOnly()) + if (C.getDriver().embedBitcodeMarkerOnly() && !C.getDriver().isUsingLTO()) CmdArgs.push_back("-fembed-bitcode=marker"); // We normally speed up the clang process a bit by skipping destructors at @@ -6461,7 +6461,8 @@ // pristine IR generated by the frontend. Ideally, a new compile action should // be added so both IR can be captured. if (C.getDriver().isSaveTempsEnabled() && - !C.getDriver().embedBitcodeInObject() && isa(JA)) + !C.getDriver().embedBitcodeInObject() && !C.getDriver().isUsingLTO() && + isa(JA)) CmdArgs.push_back("-disable-llvm-passes"); if (Output.getType() == types::TY_Dependencies) {