[PATCH] D34972: [CodeGen] Propagate dllexport to thunks

David Majnemer via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 4 08:42:46 PDT 2017


What about the import side?

On Mon, Jul 3, 2017 at 10:37 PM Shoaib Meenai via Phabricator via
cfe-commits <cfe-commits at lists.llvm.org> wrote:

> smeenai created this revision.
>
> Under Windows Itanium, we need to export virtual and non-virtual thunks
> if the functions being thunked are exported. These thunks would
> previously inherit their dllexport attribute from the declaration, but
> r298330 changed declarations to not have dllexport attributes. We
> therefore need to add the dllexport attribute to the definition
> ourselves now. This is consistent with MinGW GCC's behavior.
>
> This redoes r306770 but limits the logic to Itanium. MicrosoftCXXABI's
> setThunkLinkage ensures that thunks aren't exported under that ABI, so
> I'm handling this in ItaniumCXXABI's setThunkLinkage for symmetry.
>
>
> https://reviews.llvm.org/D34972
>
> Files:
>   lib/CodeGen/ItaniumCXXABI.cpp
>   test/CodeGenCXX/dllexport-vtable-thunks.cpp
>
>
> Index: test/CodeGenCXX/dllexport-vtable-thunks.cpp
> ===================================================================
> --- /dev/null
> +++ test/CodeGenCXX/dllexport-vtable-thunks.cpp
> @@ -0,0 +1,23 @@
> +// RUN: %clang_cc1 -triple x86_64-windows-gnu -fdeclspec -emit-llvm -o -
> %s | FileCheck %s
> +// RUN: %clang_cc1 -triple x86_64-windows-itanium -fdeclspec -emit-llvm
> -o - %s | FileCheck %s
> +
> +struct __declspec(dllexport) A {
> +  virtual void m();
> +};
> +struct __declspec(dllexport) B {
> +  virtual void m();
> +};
> +struct __declspec(dllexport) C : A, B {
> +  virtual void m();
> +};
> +void C::m() {}
> +// CHECK: define dllexport void @_ZThn8_N1C1mEv
> +
> +struct Base {
> +  virtual void m();
> +};
> +struct __declspec(dllexport) Derived : virtual Base {
> +  virtual void m();
> +};
> +void Derived::m() {}
> +// CHECK: define dllexport void @_ZTv0_n24_N7Derived1mEv
> Index: lib/CodeGen/ItaniumCXXABI.cpp
> ===================================================================
> --- lib/CodeGen/ItaniumCXXABI.cpp
> +++ lib/CodeGen/ItaniumCXXABI.cpp
> @@ -284,6 +284,11 @@
>      // linkage together with vtables when needed.
>      if (ForVTable && !Thunk->hasLocalLinkage())
>        Thunk->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage);
> +
> +    // Propagate dllexport storage.
> +    const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
> +    if (MD->hasAttr<DLLExportAttr>())
> +      Thunk->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
>    }
>
>    llvm::Value *performThisAdjustment(CodeGenFunction &CGF, Address This,
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170704/80041313/attachment-0001.html>


More information about the cfe-commits mailing list