[PATCH] D123026: [clang][NFC] Extract the EmitAssemblyHelper::shouldEmitLTOSummary method
Pavel Samolysov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 6 06:57:36 PDT 2022
psamolysov-intel updated this revision to Diff 420831.
psamolysov-intel retitled this revision from "[clang][NFC] Extract the EmitAssemblyHelper::emitLTOSummary method" to "[clang][NFC] Extract the EmitAssemblyHelper::shouldEmitLTOSummary method".
psamolysov-intel edited the summary of this revision.
psamolysov-intel added a comment.
@tejohnson Thank you for your opinion. I've renamed the function member into `shouldEmitLTOSummary` and extract the condition only. The code that changes the module flags is still inlined. The patch description was also edited to reflect these changes.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123026/new/
https://reviews.llvm.org/D123026
Files:
clang/lib/CodeGen/BackendUtil.cpp
Index: clang/lib/CodeGen/BackendUtil.cpp
===================================================================
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -164,6 +164,16 @@
std::unique_ptr<raw_pwrite_stream> &OS,
std::unique_ptr<llvm::ToolOutputFile> &DwoOS);
+ /// Check whether we should emit a module summary.
+ /// The module summary should be emitted by default for Regular LTO
+ /// except for ld64 targets.
+ ///
+ /// \return True if the module summary should be emitted.
+ bool shouldEmitLTOSummary() const {
+ return CodeGenOpts.PrepareForLTO && !CodeGenOpts.DisableLLVMPasses &&
+ TargetTriple.getVendor() != llvm::Triple::Apple;
+ }
+
public:
EmitAssemblyHelper(DiagnosticsEngine &_Diags,
const HeaderSearchOptions &HeaderSearchOpts,
@@ -1054,9 +1064,7 @@
} else {
// Emit a module summary by default for Regular LTO except for ld64
// targets
- bool EmitLTOSummary =
- (CodeGenOpts.PrepareForLTO && !CodeGenOpts.DisableLLVMPasses &&
- TargetTriple.getVendor() != llvm::Triple::Apple);
+ bool EmitLTOSummary = shouldEmitLTOSummary();
if (EmitLTOSummary) {
if (!TheModule->getModuleFlag("ThinLTO"))
TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
@@ -1064,7 +1072,6 @@
TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
uint32_t(1));
}
-
PerModulePasses.add(createBitcodeWriterPass(
*OS, CodeGenOpts.EmitLLVMUseLists, EmitLTOSummary));
}
@@ -1470,9 +1477,7 @@
} else {
// Emit a module summary by default for Regular LTO except for ld64
// targets
- bool EmitLTOSummary =
- (CodeGenOpts.PrepareForLTO && !CodeGenOpts.DisableLLVMPasses &&
- TargetTriple.getVendor() != llvm::Triple::Apple);
+ bool EmitLTOSummary = shouldEmitLTOSummary();
if (EmitLTOSummary) {
if (!TheModule->getModuleFlag("ThinLTO"))
TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123026.420831.patch
Type: text/x-patch
Size: 2168 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220406/57a74d0a/attachment.bin>
More information about the cfe-commits
mailing list