This is an archive of the discontinued LLVM Phabricator instance.

[ThinLTO] Handle variable with twice promoted name (Rust)
ClosedPublic

Authored by tejohnson on Jan 14 2020, 8:13 AM.

Details

Summary

Ensure that we can internalize values produced from two rounds of
promotion.

Note that this cannot happen currently via clang, but in other use cases
such as the Rust compiler which does a first round of ThinLTO on library
code, producing bitcode, and a second round on the final binary.

In particular this can happen if a function is exported and promoted,
ending up with a ".llvm.${hash}" suffix, and then goes through a round
of optimization creating an internal switch table expansion variable
that is internal and contains the promoted name of the enclosing
function. This variable will be promoted in the second round of ThinLTO
if @foo is imported again, and therefore ends up with two
".llvm.${hash}" suffixes. Only the final one should be stripped when
consulting the index to locate the summary.

Diff Detail

Event Timeline

tejohnson created this revision.Jan 14 2020, 8:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 14 2020, 8:13 AM
wmi accepted this revision.Jan 14 2020, 8:57 AM

LGTM.

llvm/include/llvm/IR/ModuleSummaryIndex.h
1271–1273

I see that the patch and test descriptions are already very informative about why two rounds of promotion is possible and why rightmost split off is needed for internalizing. Maybe briefly mention two rounds of promotion here to let the reader conveniently know which side chose to split off is not arbitrary.

This revision is now accepted and ready to land.Jan 14 2020, 8:57 AM
tejohnson marked an inline comment as done.Jan 14 2020, 10:53 AM

Address comments

This revision was automatically updated to reflect the committed changes.