[PATCH] D51382: [MinGW] Don't mark external variables as DSO local

Martin Storsjö via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 29 02:48:05 PDT 2018


mstorsjo added inline comments.


================
Comment at: lib/CodeGen/CodeGenModule.cpp:737
+    // potentially could come from another DLL as DSO local.
+    if (GV->hasExternalLinkage() && GV->isDeclaration() &&
+        isa<llvm::GlobalVariable>(GV) && !GV->isThreadLocal())
----------------
rnk wrote:
> I think this linkage and declaration check should be `GV->isDeclarationForLinker()`, since that will catch `available_externally` globals as well. Those would come from a static data member of a class template that has an explicit instantiation declaration:
> ```
> template <typename T>
> struct Foo {
>   static const int x = 42;
> };
> extern template struct Foo<int>;
> const int *bar() {
>   return &Foo<int>::x;
> }
> ```
> Yep, that does it on x86_64-windows-gnu. We probably want a stub for `Foo<int>::x`.
> 
> Can you add a test at clang/test/CodeGenCXX/dso-local.cpp for this?
Sure, will do.


Repository:
  rC Clang

https://reviews.llvm.org/D51382





More information about the cfe-commits mailing list