[PATCH] D42455: Don't create hidden dllimport global values

Rafael Avila de Espindola via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 23 17:41:49 PST 2018


espindola created this revision.
espindola added a reviewer: rnk.

hidden visibility is almost the opposite of dllimport. We were producing them before (dllimport wins in the existing llvm implementation), but now the llvm verifier produces an error.


https://reviews.llvm.org/D42455

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGenCXX/hidden-dllimport.cpp


Index: test/CodeGenCXX/hidden-dllimport.cpp
===================================================================
--- /dev/null
+++ test/CodeGenCXX/hidden-dllimport.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -emit-llvm -fvisibility-inlines-hidden -o - %s | FileCheck %s
+
+// We used to declare this hidden dllimport, which is contradictory.
+
+// CHECK: declare dllimport void @"\01?bar at foo@@QEAAXXZ"(%struct.foo*)
+
+struct __attribute__((dllimport)) foo {
+  void bar() {}
+};
+void zed(foo *p) { p->bar(); }
Index: lib/CodeGen/CodeGenModule.cpp
===================================================================
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -694,6 +694,8 @@
 void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
                                         const NamedDecl *D,
                                         ForDefinition_t IsForDefinition) const {
+  if (GV->hasDLLImportStorageClass())
+    return;
   // Internal definitions always have default visibility.
   if (GV->hasLocalLinkage()) {
     GV->setVisibility(llvm::GlobalValue::DefaultVisibility);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42455.131179.patch
Type: text/x-patch
Size: 1144 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180124/ee7e9b91/attachment.bin>


More information about the llvm-commits mailing list