[clang] 633ca3f - [UniqueLinkageName] Use exsiting GlobalDecl object instead of reconstructing one.
Hongtao Yu via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 28 14:51:00 PDT 2021
Author: Hongtao Yu
Date: 2021-06-28T14:50:41-07:00
New Revision: 633ca3ff2f8fc2e2b69001d17abc43f302578fc1
URL: https://github.com/llvm/llvm-project/commit/633ca3ff2f8fc2e2b69001d17abc43f302578fc1
DIFF: https://github.com/llvm/llvm-project/commit/633ca3ff2f8fc2e2b69001d17abc43f302578fc1.diff
LOG: [UniqueLinkageName] Use exsiting GlobalDecl object instead of reconstructing one.
C++ constructors/destructors need to go through a different constructor to construct a GlobalDecl object in order to retrieve their linkage type. This causes an assert failure in the default constructor of GlobalDecl. I'm chaning it to using the exsiting GlobalDecl object.
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D102356
Added:
Modified:
clang/lib/CodeGen/CGCall.cpp
clang/test/CodeGen/unique-internal-linkage-names.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 1cd972f32f3ff..35b34179cc231 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2174,7 +2174,8 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
// functions with -funique-internal-linkage-names.
if (TargetDecl && CodeGenOpts.UniqueInternalLinkageNames) {
if (auto *Fn = dyn_cast<FunctionDecl>(TargetDecl)) {
- if (this->getFunctionLinkage(Fn) == llvm::GlobalValue::InternalLinkage)
+ if (this->getFunctionLinkage(CalleeInfo.getCalleeDecl()) ==
+ llvm::GlobalValue::InternalLinkage)
FuncAttrs.addAttribute("sample-profile-suffix-elision-policy",
"selected");
}
diff --git a/clang/test/CodeGen/unique-internal-linkage-names.cpp b/clang/test/CodeGen/unique-internal-linkage-names.cpp
index c567bcde45a84..95591de308d37 100644
--- a/clang/test/CodeGen/unique-internal-linkage-names.cpp
+++ b/clang/test/CodeGen/unique-internal-linkage-names.cpp
@@ -42,12 +42,26 @@ int mver_call() {
return mver();
}
+namespace {
+class A {
+public:
+ A() {}
+ ~A() {}
+};
+}
+
+void test() {
+ A a;
+}
+
// 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 void @_ZN12_GLOBAL__N_11AC1Ev
+// PLAIN: define internal void @_ZN12_GLOBAL__N_11AD1Ev
// PLAIN: define internal i32 @_ZL4mverv()
// PLAIN: define internal i32 @_ZL4mverv.sse4.2()
// PLAIN-NOT: "sample-profile-suffix-elision-policy"
@@ -57,6 +71,8 @@ int mver_call() {
// UNIQUE: define internal i32 @_ZL3foov.[[MODHASH:__uniq.[0-9]+]]() #[[#ATTR:]] {
// UNIQUE: define internal i32 @_ZN12_GLOBAL__N_14getMEv.[[MODHASH]]
// UNIQUE: define weak_odr i32 ()* @_ZL4mverv.[[MODHASH]].resolver()
+// UNIQUE: define internal void @_ZN12_GLOBAL__N_11AC1Ev.__uniq.68358509610070717889884130747296293671
+// UNIQUE: define internal void @_ZN12_GLOBAL__N_11AD1Ev.__uniq.68358509610070717889884130747296293671
// UNIQUE: define internal i32 @_ZL4mverv.[[MODHASH]]()
// UNIQUE: define internal i32 @_ZL4mverv.[[MODHASH]].sse4.2
// UNIQUE: attributes #[[#ATTR]] = { {{.*}}"sample-profile-suffix-elision-policy"{{.*}} }
More information about the cfe-commits
mailing list