[PATCH] D53870: [clang-cl] Put dllexport attrs on static locals also in template instantiations (PR39496)
Hans Wennborg via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 31 01:50:43 PDT 2018
hans added inline comments.
================
Comment at: test/CodeGenCXX/dllimport.cpp:1010
+int bar() { T<int> t; return t.foo(); }
+// MO1-DAG: @"?x@?{{1|2}}??foo@?$T at H@pr39496@@Q{{[A-Z]*}}HXZ at 4HA" = available_externally dllimport global i32 0, align 4
+}
----------------
rnk wrote:
> I notice that we don't emit `foo` as an available_externally definition right now. With your change, will we do so? Should we?
Ah, good point. It's actually the static local that was previously preventing us from emitting it available_externally. We normally would, but DLLImportFunctionVisitor would discover that the function referenced a non-dllimport "global" variable, and determine that it was not safe to emit the definition.
But now that the static local inherits the dll attribute, this works out automatically.
```
$ bin/clang -cc1 -triple i686-windows-msvc -fms-extensions -emit-llvm -std=c++1y -O1 -disable-llvm-passes -o - ../tools/clang/test/CodeGenCXX/dllimport.cpp -DMSABI -w | grep 'define.*?foo@?$T at H@pr39496'
define available_externally dllimport x86_thiscallcc i32 @"?foo@?$T at H@pr39496@@QAEHXZ"(%"struct.pr39496::T"* %this) #0 align 2 {
```
(Same for S<int>::foo() one.)
Repository:
rC Clang
https://reviews.llvm.org/D53870
More information about the cfe-commits
mailing list