This is an archive of the discontinued LLVM Phabricator instance.

[NPM][Inliner] Factor ImportedFunctionStats in the InlineAdvisor
ClosedPublic

Authored by mtrofin on Jan 19 2021, 10:20 AM.

Details

Summary

When using 2 InlinePass instances in the same CGSCC - one for other
mandatory inlinings, the other for the heuristic-driven ones - the order
in which the ImportedFunctionStats would be output-ed would depend on
the destruction order of the inline passes, which is not deterministic.

This patch moves the ImportedFunctionStats responsibility to the
InlineAdvisor to address this problem.

Diff Detail

Event Timeline

mtrofin created this revision.Jan 19 2021, 10:20 AM
mtrofin requested review of this revision.Jan 19 2021, 10:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 19 2021, 10:20 AM

Do you have an example showing the non-determinsticness ?

llvm/include/llvm/Analysis/InlineAdvisor.h
15

Should the file be moved to the Analysis directory?

llvm/lib/Analysis/InlineAdvisor.cpp
447

Why is the first check needed?

I don't understand the non-deterministic part, but otherwise this makes sense

llvm/include/llvm/Analysis/InlineAdvisor.h
117

drive by comment, this could be under #ifdef NDEBUG

170

is this used anywhere except the constructor?

llvm/lib/Analysis/InlineAdvisor.cpp
136

if (Advisor->ImportedFunctionsStats)?

Do you have an example showing the non-determinsticness ?

See http://lab.llvm.org:8011/#/builders/74/builds/2135. That reproduced locally, too. I've also linked the related temporary fix (https://github.com/llvm/llvm-project/commit/a61e42efbb73e55c44cbb0eb2686c7b4a25ca812)

mtrofin updated this revision to Diff 317724.Jan 19 2021, 4:30 PM
mtrofin marked 5 inline comments as done.

feedback

llvm/include/llvm/Analysis/InlineAdvisor.h
15

Maybe - I don't have a strong opinion. I'd do it in a separate patch, though - and see what folks think.

117

ack, I'll patch separately, makes sense.

170

MLInlineAdvisor, which had this member as a protected, and now is using this instead.

llvm/lib/Analysis/InlineAdvisor.cpp
136

Ya, that makes more sense (this was copy and paste old code)

447

ha! true. Copy'n'paste which now makes no sense.

aeubanks added inline comments.Jan 19 2021, 4:55 PM
llvm/include/llvm/Analysis/InlineAdvisor.h
170

I tried removing the variable from MLInlineAdvisor and it still compiled.

mtrofin marked an inline comment as done.Jan 19 2021, 5:21 PM
mtrofin added inline comments.
llvm/include/llvm/Analysis/InlineAdvisor.h
170

You need to build with the optional tensorflow dependencies. For uses of M, see: MLinlineAdvisor::onPassEntry, or DevelopmentModeMLInlineAdvisor::getTotalSizeEstimate

aeubanks accepted this revision.Jan 19 2021, 6:35 PM
aeubanks added inline comments.
llvm/include/llvm/Analysis/InlineAdvisor.h
170

Ah sorry I missed that

This revision is now accepted and ready to land.Jan 19 2021, 6:35 PM
This revision was automatically updated to reflect the committed changes.
mtrofin marked an inline comment as done.