diff options
author | Paul Kirth <paulkirth@google.com> | 2024-01-23 14:04:52 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-23 14:04:52 -0800 |
commit | 9d476e1e1a18af390e3455a6622ee67a69c64103 (patch) | |
tree | f4dfc7844153746db48b935dd4123f1d64cf7bd4 /clang/lib/CodeGen/BackendUtil.cpp | |
parent | a829f109ffd518230df5191c64aa427603cf10d9 (diff) | |
download | llvm-9d476e1e1a18af390e3455a6622ee67a69c64103.zip llvm-9d476e1e1a18af390e3455a6622ee67a69c64103.tar.gz llvm-9d476e1e1a18af390e3455a6622ee67a69c64103.tar.bz2 |
[clang][FatLTO] Avoid UnifiedLTO until it can support WPD/CFI (#79061)
Currently, the UnifiedLTO pipeline seems to have trouble with several
LTO features, like SplitLTO units, which means we cannot use important
optimizations like Whole Program Devirtualization or security hardening
instrumentation like CFI.
This patch reverts FatLTO to using distinct pipelines for Full LTO and
ThinLTO. It still avoids module cloning, since that was error prone.
Diffstat (limited to 'clang/lib/CodeGen/BackendUtil.cpp')
-rw-r--r-- | clang/lib/CodeGen/BackendUtil.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index a6142d9..ec203f6 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -1001,8 +1001,9 @@ void EmitAssemblyHelper::RunOptimizationPipeline( } if (CodeGenOpts.FatLTO) { - assert(CodeGenOpts.UnifiedLTO && "FatLTO requires UnifiedLTO"); - MPM.addPass(PB.buildFatLTODefaultPipeline(Level)); + MPM.addPass(PB.buildFatLTODefaultPipeline( + Level, PrepareForThinLTO, + PrepareForThinLTO || shouldEmitRegularLTOSummary())); } else if (PrepareForThinLTO) { MPM.addPass(PB.buildThinLTOPreLinkDefaultPipeline(Level)); } else if (PrepareForLTO) { @@ -1073,8 +1074,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline( if (!TheModule->getModuleFlag("EnableSplitLTOUnit")) TheModule->addModuleFlag(llvm::Module::Error, "EnableSplitLTOUnit", uint32_t(CodeGenOpts.EnableSplitLTOUnit)); - // FatLTO always means UnifiedLTO - if (!TheModule->getModuleFlag("UnifiedLTO")) + if (CodeGenOpts.UnifiedLTO && !TheModule->getModuleFlag("UnifiedLTO")) TheModule->addModuleFlag(llvm::Module::Error, "UnifiedLTO", uint32_t(1)); } |