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.
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.