From 175288a1afef2b6976455aab5ce51c66d28f8bca Mon Sep 17 00:00:00 2001 From: Hongtao Yu Date: Tue, 22 Dec 2020 22:43:22 -0800 Subject: [PATCH] Add sample-profile-suffix-elision-policy attribute with -funique-internal-linkage-names. Adding sample-profile-suffix-elision-policy attribute to functions whose linkage names are uniquefied so that their unique name suffix won't be trimmed when applying AutoFDO profiles. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D94455 --- llvm/lib/Transforms/Utils/UniqueInternalLinkageNames.cpp | 1 + .../UniqueInternalLinkageNames/unique-internal-linkage-names.ll | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/Utils/UniqueInternalLinkageNames.cpp b/llvm/lib/Transforms/Utils/UniqueInternalLinkageNames.cpp index 2909403..c57cec6 100644 --- a/llvm/lib/Transforms/Utils/UniqueInternalLinkageNames.cpp +++ b/llvm/lib/Transforms/Utils/UniqueInternalLinkageNames.cpp @@ -43,6 +43,7 @@ static bool uniqueifyInternalLinkageNames(Module &M) { for (auto &F : M) { if (F.hasInternalLinkage()) { F.setName(F.getName() + ModuleNameHash); + F.addFnAttr("sample-profile-suffix-elision-policy", "selected"); // Replace linkage names in the debug metadata. if (DISubprogram *SP = F.getSubprogram()) { if (SP->getRawLinkageName()) { diff --git a/llvm/test/Transforms/UniqueInternalLinkageNames/unique-internal-linkage-names.ll b/llvm/test/Transforms/UniqueInternalLinkageNames/unique-internal-linkage-names.ll index d07440d..dcb49d9 100644 --- a/llvm/test/Transforms/UniqueInternalLinkageNames/unique-internal-linkage-names.ll +++ b/llvm/test/Transforms/UniqueInternalLinkageNames/unique-internal-linkage-names.ll @@ -42,8 +42,9 @@ entry: ; O2: Running pass: UniqueInternalLinkageNamesPass ; O2: Running pass: SampleProfileProbePass -; UNIQUE: define internal i32 @foo.__uniq.{{[0-9]+}}() +; UNIQUE: define internal i32 @foo.__uniq.{{[0-9]+}}() [[ATTR:#[0-9]+]] ; UNIQUE: ret {{.*}} @foo.__uniq.{{[0-9]+}} {{.*}} +; UNIQUE: attributes [[ATTR]] = {{{.*}} "sample-profile-suffix-elision-policy"="selected" {{.*}}} ; DBG: distinct !DISubprogram(name: "foo", linkageName: "foo.__uniq.{{[0-9]+}}", scope: ![[#]] ; DBG: !DISubprogram(name: "foo", linkageName: "foo.__uniq.{{[0-9]+}}", scope: ![[#]] -- 2.7.4