aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2025-02-03 23:26:22 +1300
committerGitHub <noreply@github.com>2025-02-03 23:26:22 +1300
commit8f025f2a93ee7249336115cff31ae12367f1d0d5 (patch)
treebedc04ef55bdb2e9f5b87c39093c4a7c9a6f81f6 /clang/lib/CodeGen/CodeGenModule.cpp
parent5c065f01cee5dfca28d703983d0ebefa65128e09 (diff)
downloadllvm-8f025f2a93ee7249336115cff31ae12367f1d0d5.zip
llvm-8f025f2a93ee7249336115cff31ae12367f1d0d5.tar.gz
llvm-8f025f2a93ee7249336115cff31ae12367f1d0d5.tar.bz2
[clang] Do not emit template parameter objects as COMDATs when they have internal linkage. (#125448)
Per the ELF spec, section groups may only contain local symbols if those symbols are only referenced from within the section group. [1] In the case of template parameter objects, they can be referenced from outside the group when the type of the object was declared in an anonymous namespace. In that case, we can't place the object in a COMDAT. This matches GCC's linkage behavior on the test input. [1]: https://www.sco.com/developers/gabi/latest/ch4.sheader.html#section_groups
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 05879cd..82002b8d 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -3765,7 +3765,7 @@ ConstantAddress CodeGenModule::GetAddrOfTemplateParamObject(
auto *GV = new llvm::GlobalVariable(getModule(), Init->getType(),
/*isConstant=*/true, Linkage, Init, Name);
setGVProperties(GV, TPO);
- if (supportsCOMDAT())
+ if (supportsCOMDAT() && Linkage == llvm::GlobalValue::LinkOnceODRLinkage)
GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
Emitter.finalize(GV);