This is an archive of the discontinued LLVM Phabricator instance.

[ThinLTO] Import static functions from the same module as caller
ClosedPublic

Authored by tejohnson on Jan 6 2017, 9:34 PM.

Details

Summary

We can sometimes end up with multiple copies of a local function that
have the same GUID in the index. This happens when there are local
functions with the same name that are in different source files with the
same name (but in different directories), and they were compiled in
their own directory so had the same path at compile time.

In this case make sure we import the copy in the caller's module. While
it isn't a correctness problem (the renamed reference which is based on the
module IR hash will be unique since the module must have had an
externally visible function that was imported), importing the wrong copy
will result in lost performance opportunity since it won't be referenced
and inlined.

Diff Detail

Repository
rL LLVM

Event Timeline

tejohnson updated this revision to Diff 83506.Jan 6 2017, 9:34 PM
tejohnson retitled this revision from to [ThinLTO] Import static functions from the same module as caller.
tejohnson updated this object.
tejohnson added a reviewer: mehdi_amini.
tejohnson added a subscriber: llvm-commits.
mehdi_amini accepted this revision.Jan 6 2017, 9:36 PM
mehdi_amini edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Jan 6 2017, 9:36 PM
tejohnson updated this revision to Diff 84177.Jan 12 2017, 2:15 PM
tejohnson edited edge metadata.

Slight update to enable importing a local from another module when
there is a single summary for that GUID - in that case this must be
due to indirect call profile metadata. This was flagged by
test/Transforms/PGOProfile/thinlto_indirect_call_promotion.ll.

Note if there are multiple matching locals and there is indirect call
profile data pointing to them, we wouldn't know which to import
anyway (the profile data uses the same GUID).

This revision was automatically updated to reflect the committed changes.