r224475 - Revert "Put static local variables of inline functions in the function comdat."
Rafael Espindola
rafael.espindola at gmail.com
Wed Dec 17 15:49:22 PST 2014
Author: rafael
Date: Wed Dec 17 17:49:22 2014
New Revision: 224475
URL: http://llvm.org/viewvc/llvm-project?rev=224475&view=rev
Log:
Revert "Put static local variables of inline functions in the function comdat."
This reverts commit r224369.
Thanks to Reid Kleckner for pointing out that we need a bigger gun to fix this
case.
Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/static-init.cpp
Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=224475&r1=224474&r2=224475&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Wed Dec 17 17:49:22 2014
@@ -1711,10 +1711,8 @@ void ItaniumCXXABI::EmitGuardedInit(Code
// The ABI says: It is suggested that it be emitted in the same COMDAT group
// as the associated data object
- if (var->isWeakForLinker() && CGM.supportsCOMDAT()) {
- StringRef ComdatName =
- D.isLocalVarDecl() ? CGF.CurFn->getName() : var->getName();
- llvm::Comdat *C = CGM.getModule().getOrInsertComdat(ComdatName);
+ if (!D.isLocalVarDecl() && var->isWeakForLinker() && CGM.supportsCOMDAT()) {
+ llvm::Comdat *C = CGM.getModule().getOrInsertComdat(var->getName());
guard->setComdat(C);
var->setComdat(C);
CGF.CurFn->setComdat(C);
Modified: cfe/trunk/test/CodeGenCXX/static-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/static-init.cpp?rev=224475&r1=224474&r2=224475&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/static-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/static-init.cpp Wed Dec 17 17:49:22 2014
@@ -7,8 +7,10 @@
// CHECK: @_ZZN5test31BC1EvE1u = internal global { i8, [3 x i8] } { i8 97, [3 x i8] undef }, align 4
// CHECK: @_ZZN5test1L6getvarEiE3var = internal constant [4 x i32] [i32 1, i32 0, i32 2, i32 4], align 16
-// CHECK: @_ZZ2h2vE1i = linkonce_odr global i32 0, comdat $_Z2h2v
-// CHECK: @_ZGVZ2h2vE1i = linkonce_odr global i64 0, comdat $_Z2h2v
+// CHECK: @_ZZ2h2vE1i = linkonce_odr global i32 0
+// CHECK-NOT: comdat
+// CHECK: @_ZGVZ2h2vE1i = linkonce_odr global i64 0
+// CHECK-NOT: comdat
struct A {
A();
@@ -35,7 +37,8 @@ void h() {
static const int i = a();
}
-// CHECK: define linkonce_odr void @_Z2h2v() {{.*}} comdat $_Z2h2v
+// CHECK: define linkonce_odr void @_Z2h2v()
+// CHECK-NOT: comdat
inline void h2() {
static int i = a();
}
More information about the cfe-commits
mailing list