This is a standalone patch and this would help Propeller do a better job of code layout as it can accurately attribute the profiles to the right internal linkage function. This also helps SampledFDO/AutoFDO correctly associate sampled profiles to the right internal function. Currently, if there is more than one internal symbol foo, their profiles are aggregated by SampledFDO. This patch adds a new clang option, -funique-internal-funcnames, to generate unique names for functions with internal linkage. This patch appends the md5 hash of the module name to the function symbol as a best effort to generate a unique name for symbols with internal linkage. Differential Revision: https://reviews.llvm.org/D73307
62 lines
1.9 KiB
C++
62 lines
1.9 KiB
C++
// This test checks if internal linkage symbols get unique names with
|
|
// -funique-internal-linkage-names option.
|
|
// RUN: %clang_cc1 -triple x86_64 -x c++ -S -emit-llvm -o - < %s | FileCheck %s --check-prefix=PLAIN
|
|
// RUN: %clang_cc1 -triple x86_64 -x c++ -S -emit-llvm -funique-internal-linkage-names -o - < %s | FileCheck %s --check-prefix=UNIQUE
|
|
// RUN: %clang_cc1 -triple x86_64 -x c++ -S -emit-llvm -fexperimental-new-pass-manager -funique-internal-linkage-names -o - < %s | FileCheck %s --check-prefix=UNIQUE
|
|
|
|
static int glob;
|
|
static int foo() {
|
|
return 0;
|
|
}
|
|
|
|
int (*bar())() {
|
|
return foo;
|
|
}
|
|
|
|
int getGlob() {
|
|
return glob;
|
|
}
|
|
|
|
// Function local static variable and anonymous namespace namespace variable.
|
|
namespace {
|
|
int anon_m;
|
|
int getM() {
|
|
return anon_m;
|
|
}
|
|
} // namespace
|
|
|
|
int retAnonM() {
|
|
static int fGlob;
|
|
return getM() + fGlob;
|
|
}
|
|
|
|
// Multiversioning symbols
|
|
__attribute__((target("default"))) static int mver() {
|
|
return 0;
|
|
}
|
|
|
|
__attribute__((target("sse4.2"))) static int mver() {
|
|
return 1;
|
|
}
|
|
|
|
int mver_call() {
|
|
return mver();
|
|
}
|
|
|
|
// PLAIN: @_ZL4glob = internal global
|
|
// PLAIN: @_ZZ8retAnonMvE5fGlob = internal global
|
|
// PLAIN: @_ZN12_GLOBAL__N_16anon_mE = internal global
|
|
// PLAIN: define internal i32 @_ZL3foov()
|
|
// PLAIN: define internal i32 @_ZN12_GLOBAL__N_14getMEv
|
|
// PLAIN: define weak_odr i32 ()* @_ZL4mverv.resolver()
|
|
// PLAIN: define internal i32 @_ZL4mverv()
|
|
// PLAIN: define internal i32 @_ZL4mverv.sse4.2()
|
|
// UNIQUE: @_ZL4glob.{{[0-9a-f]+}} = internal global
|
|
// UNIQUE: @_ZZ8retAnonMvE5fGlob.{{[0-9a-f]+}} = internal global
|
|
// UNIQUE: @_ZN12_GLOBAL__N_16anon_mE.{{[0-9a-f]+}} = internal global
|
|
// UNIQUE: define internal i32 @_ZL3foov.{{[0-9a-f]+}}()
|
|
// UNIQUE: define internal i32 @_ZN12_GLOBAL__N_14getMEv.{{[0-9a-f]+}}
|
|
// UNIQUE: define weak_odr i32 ()* @_ZL4mverv.resolver()
|
|
// UNIQUE: define internal i32 @_ZL4mverv.{{[0-9a-f]+}}()
|
|
// UNIQUE: define internal i32 @_ZL4mverv.sse4.2.{{[0-9a-f]+}}
|