-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CGData] Refactor Global Merge Functions #115750
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This refactoring makes much more sense to me than the previous implementation.
// Parameter locations based on the unique hash sequences | ||
// across the candidates. | ||
// Collect stable functions related to the current module. | ||
DenseMap<stable_hash, SmallVector<Function *>> HashToFuncs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DenseMap<stable_hash, SmallVector<Function *>> HashToFuncs; | |
DenseMap<stable_hash, SmallVector<std::pair<Function *, FunctionHashInfo>>> HashToFuncs; |
To save the cost of FuncToFI
. Or maybe we could put Function *
in FunctionHashInfo
?
} | ||
// Iterate functions with the same hash. | ||
for (auto &F : Funcs) { | ||
auto &SFS = Maps.at(Hash); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully this will be hoisted out of the for
loop by the compiler.
// Check if the function is compatible with any stable function | ||
// in terms of the number of instructions and ignored operands. | ||
assert(!SFS.empty()); | ||
auto &RFS = SFS[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I seem to understand the potential size increase introduced by the refactoring: is it possible that stable function entries with the same hash could have different numbers of / incompatible operands? If that is the case, I believe we can assume that the probability of hash collisions should be very low, otherwise we might actually need to improve the hashing algorithm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe we can move the "lightweight" checks back into the nested loop below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the codegen data is not stale —meaning there has been no source change in the first or second pass— the size regression is less of a concern. My main worry was about the stability of optimization when the codegen data becomes outdated.
e09f9c0
to
b45eee4
Compare
Hit an assertion in
|
Thank you for testing and identifying this bug! |
Do we know why |
The |
@nocchijiang The new approach seems to be functioning well and is similar in size to the previous method. |
I can confirm that the performance have been improved significantly from my testing on no-LTO projects that the slowdown is acceptable now. Before applying the PR it was about 50% slowdown, now it is ~5%.
Besides only consuming the matched stable entries like what this PR does, this is exactly what I planned to do to reduce the memory footprint of the deserialized CGData. I would like to discuss the detail in the RFC thread with you to make sure that we are on the same page before coding it. |
That's great to hear! |
1d0a934
to
5edbc30
Compare
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/162/builds/10436 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/78/builds/9621 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/12/builds/9550 Here is the relevant piece of the build log for the reference
|
This reverts commit d3da788.
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/16/builds/8834 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/60/builds/12664 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/56/builds/12175 Here is the relevant piece of the build log for the reference
|
This is a follow-up PR to refactor the initial global merge function pass implemented in llvm#112671. It first collects stable functions relevant to the current module and iterates over those only, instead of iterating through all stable functions in the stable function map. This is a patch for https://discourse.llvm.org/t/rfc-global-function-merging/82608.
This is a follow-up PR to refactor the initial global merge function pass implemented in llvm#112671. It first collects stable functions relevant to the current module and iterates over those only, instead of iterating through all stable functions in the stable function map. This is a patch for https://discourse.llvm.org/t/rfc-global-function-merging/82608.
This is a follow-up PR to refactor the initial global merge function pass implemented in #112671. It first collects stable functions relevant to the current module and iterates over those only, instead of iterating through all stable functions in the stable function map. This is a patch for https://discourse.llvm.org/t/rfc-global-function-merging/82608.
This is a follow-up PR to refactor the initial global merge function pass implemented in #112671.
It first collects stable functions relevant to the current module and iterates over those only, instead of iterating through all stable functions in the stable function map.
This is a patch for https://discourse.llvm.org/t/rfc-global-function-merging/82608.