Page MenuHomePhabricator

[MachineCycle][NFC]add a cache for block and top level cycle mapping
ClosedPublic

Authored by shchenz on Sep 16 2022, 12:22 AM.

Details

Summary

This solves the big compile time regression in https://github.com/llvm/llvm-project/issues/57664

The hot function is getTopLevelParentCycle.

Too many redundant computations to get a top level cycle for a block.

This patch improves compile time about X15 on PPC64 Linux.

Diff Detail

Event Timeline

shchenz created this revision.Sep 16 2022, 12:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 16 2022, 12:22 AM
shchenz requested review of this revision.Sep 16 2022, 12:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 16 2022, 12:23 AM
nikic added inline comments.Sep 16 2022, 1:00 AM
llvm/include/llvm/ADT/GenericCycleImpl.h
185

This assumes the new parent is a top level cycle. Is this guaranteed?

sameerds added inline comments.Sep 16 2022, 2:24 AM
llvm/include/llvm/ADT/GenericCycleImpl.h
185

At the only call to this function, it seems to be true that NewParent is a newly discovered top-level cycle, and Child is an existing top-level cycle. This loop then updates the cache to replace Child with NewParent. But that makes the whole thing a bit fragile if this function is ever called from a different place.

Maybe we should make this a private function "moveTopLevelCycleToNewParent", with suitable assertions?

shchenz updated this revision to Diff 460702.Sep 16 2022, 4:50 AM
shchenz retitled this revision from [MachineCycle][NFC]add a cache from block and top level cycle mapping to [MachineCycle][NFC]add a cache for block and top level cycle mapping.

address comments:
1: change moveToNewParent to only apply top level parameters

shchenz marked 2 inline comments as done.Sep 16 2022, 4:50 AM
shchenz added inline comments.
llvm/include/llvm/ADT/GenericCycleImpl.h
185

Thanks. Updated!

Thanks for the quick fix!
I unfortunately don't understand this code here, and can't give you a review, though

sameerds accepted this revision.Sep 18 2022, 9:51 PM
This revision is now accepted and ready to land.Sep 18 2022, 9:51 PM

does it make sense to add a regression test?

shchenz marked an inline comment as done.Sep 20 2022, 10:16 PM

does it make sense to add a regression test?

This is a compile time improvement, no compiler functionality change. AFAIK, we don't have regression test for the compile time changes.