Prepend "__uniq" to symbol names hash with -funique-internal-linkage-names.
authorSriraman Tallam <tmsriram@google.com>
Mon, 26 Oct 2020 21:20:35 +0000 (14:20 -0700)
committerSriraman Tallam <tmsriram@google.com>
Mon, 26 Oct 2020 21:24:28 +0000 (14:24 -0700)
commitad1b9daa4bf40c1907794fd5de7807aad1f0553c
treee1069e288ca5b5abaa9414e824080f96113040cb
parentdf6d2e8ab1a4212284e4763724a2211df2c7394a
Prepend "__uniq" to symbol names hash with -funique-internal-linkage-names.

Prepend the module name hash with a fixed string ".__uniq." which helps tools
that consume sampled profiles and attribute it to functions to understand
that this symbol belongs to a unique internal linkage type symbol.

Symbols with suffixes can result from various optimizations in the compiler.
Function Multiversioning, function splitting, parameter constant propogation,
unique internal linkage names.

External tools like sampled profile aggregators combine profiles from multiple
runs of a binary. They use various heuristics with symbols that have suffixes
to try and attribute the profile to the right function instance. For instance
multi-versioned symbols like foo.avx, foo.sse4.2, etc even though different
should be attributed to the same source function if a single function is
versioned, using attribute target_clones (supported in GCC but yet to land in
LLVM). Similarly, functions that are split (split part having a .cold suffix)
could have profiles for both the original and split symbols but would be
aggregated and attributed to the original function that was split.

Unique internal linkage functions however have different source instances and
the aggregator must not put them together but attribute it to the appropriate
function instance. To be sure that we are dealing with a symbol of a unique
internal linkage function, we would like to prepend the hash with a known
string ".__uniq." which these tools can check to understand the suffix type.

Differential Revision: https://reviews.llvm.org/D89617
clang/test/CodeGen/unique-internal-linkage-names.cpp
llvm/lib/Transforms/Utils/UniqueInternalLinkageNames.cpp
llvm/test/Transforms/UniqueInternalLinkageNames/unique_symbol_names.ll