r226629 - MS ABI: Let guard variables be present in COMDATs
David Majnemer
david.majnemer at gmail.com
Tue Jan 20 17:04:30 PST 2015
Author: majnemer
Date: Tue Jan 20 19:04:30 2015
New Revision: 226629
URL: http://llvm.org/viewvc/llvm-project?rev=226629&view=rev
Log:
MS ABI: Let guard variables be present in COMDATs
A guard variable in a COMDAT'd function should also be in a COMDAT.
Modified:
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/test/CodeGenCXX/dllexport.cpp
Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=226629&r1=226628&r2=226629&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Tue Jan 20 19:04:30 2015
@@ -1923,6 +1923,9 @@ void MicrosoftCXXABI::EmitGuardedInit(Co
GV->getLinkage(), Zero, GuardName.str());
GI->Guard->setVisibility(GV->getVisibility());
GI->Guard->setDLLStorageClass(GV->getDLLStorageClass());
+ if (GI->Guard->isWeakForLinker())
+ GI->Guard->setComdat(
+ CGM.getModule().getOrInsertComdat(GI->Guard->getName()));
} else {
assert(GI->Guard->getLinkage() == GV->getLinkage() &&
"static local from the same function had different linkage");
Modified: cfe/trunk/test/CodeGenCXX/dllexport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport.cpp?rev=226629&r1=226628&r2=226629&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/dllexport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllexport.cpp Tue Jan 20 19:04:30 2015
@@ -82,8 +82,8 @@ int __declspec(dllexport) nonInlineStati
return x++;
};
-// MSC-DAG: @"\01?x@?1??inlineStaticLocalsFunc@@YAHXZ at 4HA" = weak_odr dllexport global i32 0
-// MSC-DAG: @"\01??_B?1??inlineStaticLocalsFunc@@YAHXZ at 51" = weak_odr dllexport global i32 0
+// MSC-DAG: @"\01?x@?1??inlineStaticLocalsFunc@@YAHXZ at 4HA" = weak_odr dllexport global i32 0, comdat
+// MSC-DAG: @"\01??_B?1??inlineStaticLocalsFunc@@YAHXZ at 51" = weak_odr dllexport global i32 0, comdat
// Note: MinGW doesn't seem to export the static local here.
inline int __declspec(dllexport) inlineStaticLocalsFunc() {
static int x = f();
More information about the cfe-commits
mailing list