This is an archive of the discontinued LLVM Phabricator instance.

[IRSim] Reduce IROutliner Compile time by reducing the number of time the CodeExtractorCache is rebuilt.
Needs ReviewPublic

Authored by AndrewLitteken on Dec 5 2022, 8:40 AM.

Details

Reviewers
paquette
Summary

Currently, in the IROutliner, we rebuild the CodeExtractorCache for every function when it needs to be analyzed for cost, or when it is outlined. For large pieces of code, this takes a long time.

We can instead build the caches at the beginning of the run and then adapt the cache as necessary. This required making the ache accessible from the CodeExtractor, and then adapting the IROutliner to build everything at once, and then reference it when necessary, removing instructions that were no longer in the original functions once they are outlined.

This reduces compile time significantly.

Diff Detail

Event Timeline

AndrewLitteken created this revision.Dec 5 2022, 8:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 5 2022, 8:40 AM
AndrewLitteken requested review of this revision.Dec 5 2022, 8:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 5 2022, 8:40 AM
AndrewLitteken retitled this revision from Reduce IROutliner Compile time by reducing the number of time the CodeExtractorCache is rebuilt. to [IRSim] Reduce IROutliner Compile time by reducing the number of time the CodeExtractorCache is rebuilt..

Fix diff order

paquette added inline comments.Dec 6 2022, 10:28 AM
llvm/lib/Transforms/IPO/IROutliner.cpp
357

comment?

368

we probably want comments for all calls to this explaining why we're doing this

2849

For a follow-up patch: maybe Candidates should have a getFunction function?

llvm/lib/Transforms/Utils/CodeExtractor.cpp
322

comments in this function?

335

comments here too?

AndrewLitteken added inline comments.Dec 7 2022, 8:03 AM
llvm/lib/Transforms/IPO/IROutliner.cpp
2849

It turns out that they do, and I just forgot to use it.