This is an archive of the discontinued LLVM Phabricator instance.

CodeGen: Make MachineOptimizationRemarkEmitterPass a CFG analysis
ClosedPublic

Authored by arsenm on May 10 2021, 6:24 PM.

Details

Reviewers
aeubanks
ychen
Summary

This avoids rerunning it a few times.

Diff Detail

Event Timeline

arsenm created this revision.May 10 2021, 6:24 PM
arsenm requested review of this revision.May 10 2021, 6:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 10 2021, 6:24 PM
Herald added a subscriber: wdng. · View Herald Transcript
/// The analysis pass
///
/// Note that this pass shouldn't generally be marked as preserved by other
/// passes.  It's holding onto BFI, so if the pass does not preserve BFI, BFI
/// could be freed.
class MachineOptimizationRemarkEmitterPass : public MachineFunctionPass {

are you sure this is correct?

/// The analysis pass
///
/// Note that this pass shouldn't generally be marked as preserved by other
/// passes.  It's holding onto BFI, so if the pass does not preserve BFI, BFI
/// could be freed.
class MachineOptimizationRemarkEmitterPass : public MachineFunctionPass {

are you sure this is correct?

I found a bug in some null checks for the BFI, but once that's fixed no tests fail (e.g. MachineBlockFrequencyInfo::getBlockProfileCount checks for null after deref)

/// The analysis pass
///
/// Note that this pass shouldn't generally be marked as preserved by other
/// passes.  It's holding onto BFI, so if the pass does not preserve BFI, BFI
/// could be freed.
class MachineOptimizationRemarkEmitterPass : public MachineFunctionPass {

are you sure this is correct?

I found a bug in some null checks for the BFI, but once that's fixed no tests fail (e.g. MachineBlockFrequencyInfo::getBlockProfileCount checks for null after deref)

But if there is a BFI and a pass doesn't update it, then MachineOptimizationRemarkEmitterPass shouldn't be preserved since its BFI will be out of date.

maybe it should be marked as a CFG analysis? since BFI is a CFG analysis

maybe it should be marked as a CFG analysis? since BFI is a CFG analysis

Do you mean have MachineOptimizationRemarkEmitter setPreservesCFG? It already uses setPreservesAll

I mean change
INITIALIZE_PASS_END(MachineOptimizationRemarkEmitterPass, ORE_NAME, ore_name, false, true)
to
INITIALIZE_PASS_END(MachineOptimizationRemarkEmitterPass, ORE_NAME, ore_name, true, true)

That should make it so passes that don't modify the CFG don't invalidate the analysis

arsenm updated this revision to Diff 344968.May 12 2021, 2:51 PM
arsenm retitled this revision from CodeGen: Make all passes preserve MachineOptimizationRemarkEmitterPass to CodeGen: Make MachineOptimizationRemarkEmitterPass a CFG analysis.
arsenm edited the summary of this revision. (Show Details)
aeubanks accepted this revision.May 12 2021, 4:29 PM

lgtm

I think with the new PM we could make it easier to invalidate this less often

This revision is now accepted and ready to land.May 12 2021, 4:29 PM