This is an archive of the discontinued LLVM Phabricator instance.

[clang][NFC] Extract EmitAssemblyHelper::shouldEmitRegularLTOSummary
ClosedPublic

Authored by psamolysov-intel on Apr 4 2022, 5:56 AM.

Details

Summary

The code to check if the regular LTO summary should be emitted and to
add the corresponding module flags was duplicated in the
'EmitAssemblyHelper::EmitAssemblyWithLegacyPassManager' and
'EmitAssemblyHelper::RunOptimizationPipeline' methods.

In order to eliminate these code duplications, the
'EmitAssemblyHelper::shouldEmitRegularLTOSummary' method has been
extracted. The method returns a bool value, the value is 'true' if the
module summary should be emitted. The patch keeps the setting of the
module flags inline.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptApr 4 2022, 5:56 AM
psamolysov-intel requested review of this revision.Apr 4 2022, 5:56 AM

Colleagues, could you review this small non-functional change. After the TargetTruiple member has been extracted, it becomes clear that there is some code duplication in the BackendUtil.cpp source file. I think this is a good idea to eliminate this code duplication, isn't it?

I'd prefer to keep the setting of the module flags inline here. The main reason is that the EnableSplitLTOUnit module flag is also set inline for the ThinLTO case just above, and it is easier to see what is going on if they are near each other. Suggest making the new emitLTOSummary just about checking the conditions for emitting the summary.

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. (Show Details)

@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.

tejohnson accepted this revision.Apr 6 2022, 7:55 AM

lgtm with a couple of small changes noted below.

clang/lib/CodeGen/BackendUtil.cpp
167

Add "for regular LTO" (this check is not appropriate for ThinLTO). I'd prefer to make the name "shouldEmitRegularLTOSummary" to be explicit about this too.

This revision is now accepted and ready to land.Apr 6 2022, 7:55 AM
psamolysov-intel retitled this revision from [clang][NFC] Extract the EmitAssemblyHelper::shouldEmitLTOSummary method to [clang][NFC] Extract EmitAssemblyHelper::shouldEmitRegularLTOSummary.
psamolysov-intel edited the summary of this revision. (Show Details)

Thank you @tejohnson I've applied the suggested changes.

psamolysov-intel marked an inline comment as done.Apr 7 2022, 8:05 AM

Colleagues, could you help me with landing? @tejohnson has approved the patch (if I applied the suggestion as it was expected, thank you @tejohnson!)

Colleagues, could you help me with landing? @tejohnson has approved the patch (if I applied the suggestion as it was expected, thank you @tejohnson!)

lgtm. I can commit for you today.