aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-01-15 21:36:08 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-01-15 21:36:08 +0000
commitdbee8a7a7ad891cff3f8938d5992999903fe6764 (patch)
tree4f8ae9cf7920ca3ccafcf4f7fa19316f2341d8d2 /clang/lib/CodeGen/CodeGenModule.cpp
parentc59328e627ca607d14d2c34cca9fefe8c8749fa5 (diff)
downloadllvm-dbee8a7a7ad891cff3f8938d5992999903fe6764.zip
llvm-dbee8a7a7ad891cff3f8938d5992999903fe6764.tar.gz
llvm-dbee8a7a7ad891cff3f8938d5992999903fe6764.tar.bz2
Use a trivial comdat for inline ctor/dtor when not using C5/D5.
When combined with llvm not producing implicit comdats, not doing this would cause code bloat on ELF and link errors on COFF. llvm-svn: 226211
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 8981bfe..7a97aa6 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1953,6 +1953,13 @@ static bool shouldBeInCOMDAT(CodeGenModule &CGM, const Decl &D) {
llvm_unreachable("No such linkage");
}
+void CodeGenModule::maybeSetTrivialComdat(const Decl &D,
+ llvm::GlobalObject &GO) {
+ if (!shouldBeInCOMDAT(*this, D))
+ return;
+ GO.setComdat(TheModule.getOrInsertComdat(GO.getName()));
+}
+
void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
llvm::Constant *Init = nullptr;
QualType ASTTy = D->getType();
@@ -2096,8 +2103,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
setTLSMode(GV, *D);
}
- if (shouldBeInCOMDAT(*this, *D))
- GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
+ maybeSetTrivialComdat(*D, *GV);
// Emit the initializer function if necessary.
if (NeedsGlobalCtor || NeedsGlobalDtor)
@@ -2433,8 +2439,7 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD,
MaybeHandleStaticInExternC(D, Fn);
- if (shouldBeInCOMDAT(*this, *D))
- Fn->setComdat(TheModule.getOrInsertComdat(Fn->getName()));
+ maybeSetTrivialComdat(*D, *Fn);
CodeGenFunction(*this).GenerateCode(D, Fn, FI);