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
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 @@
   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 @@
     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 @@
 
   MaybeHandleStaticInExternC(D, Fn);
 
-  if (shouldBeInCOMDAT(*this, *D))
-    Fn->setComdat(TheModule.getOrInsertComdat(Fn->getName()));
+  maybeSetTrivialComdat(*D, *Fn);
 
   CodeGenFunction(*this).GenerateCode(D, Fn, FI);