This is an archive of the discontinued LLVM Phabricator instance.

[Attributor] Change function internalization to not replace uses in internalized callers
ClosedPublic

Authored by jhuber6 on Jul 27 2021, 7:53 PM.

Details

Summary

The current implementation of function internalization creats a copy of each
function and replaces every use. This has the downside that the external
versions of the functions will call into the internalized versions of the
functions. This prevents them from being fully independent of eachother. This
patch replaces the current internalization scheme with a method that creates
all the copies of the functions intended to be internalized first and then
replaces the uses as long as their caller is not already internalized.

Diff Detail

Event Timeline

jhuber6 created this revision.Jul 27 2021, 7:53 PM
jhuber6 requested review of this revision.Jul 27 2021, 7:53 PM
Herald added a reviewer: baziotis. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
kuter added a comment.EditedJul 28 2021, 1:08 AM

Note: this seems to break some Attributor and AMDGPU Attributor tests. Attributor doesn't internalize by default. Maybe it is breaking that.
But I don't know why.

jhuber6 updated this revision to Diff 362359.Jul 28 2021, 6:29 AM

Fixing test

jdoerfert added inline comments.Jul 28 2021, 9:34 AM
llvm/lib/Transforms/IPO/Attributor.cpp
1946

Rather than doing this lookup can we pass in DenseMap<Function *, Function *> InternalizedFns and use it to lookup the new copy.
More useful in the future too as it allows to lookup all copies.

1959

Move to use to shorten the lifetime.

2001–2003
2006

Why here? Move this to the actual internalization, no?

jhuber6 updated this revision to Diff 362441.Jul 28 2021, 10:17 AM

Addressing comments.

This revision is now accepted and ready to land.Jul 28 2021, 2:56 PM