This is an archive of the discontinued LLVM Phabricator instance.

Avoid duplicating uniqueness in ThinLTO when unique internal linkage names are used
Needs ReviewPublic

Authored by tmsriram on Dec 20 2021, 12:57 PM.

Details

Reviewers
tejohnson
wmi
Summary

Option -funique-internal-linkage-names already creates unique names for internal functions.

With ThinLTO, importing internal linkage functions uniqueifies their names to avoid two such functions from different modules colliding. However, -funique-internal-linkage-names already does that independently. This simple patch checks if unique names are already present before adding a unique suffix.

The benefits are that this reduces .strtab size.

Diff Detail

Unit TestsFailed

Event Timeline

tmsriram created this revision.Dec 20 2021, 12:57 PM
tmsriram requested review of this revision.Dec 20 2021, 12:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 20 2021, 12:57 PM
tejohnson added inline comments.Dec 20 2021, 2:28 PM
llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
266

Better to do this in ModuleSummaryIndex::getGlobalNameForLocal (called by getPromotedName) so that it automatically handles all cases. E.g. without that fix cross-module WPD to a local function (requiring promotion) will be broken (we will promote on the devirt side but no longer on the def side).

E.g. see llvm/test/ThinLTO/X86/devirt_promote.ll. Although unfortunately this test case will not catch the breakage since we have hardcoded IR names in the test, i.e. it isn't being generated by -funique-internal-linkage-names.