[llvm] r209600 - Emit data or code export directives based on the type.

Rafael Espindola rafael.espindola at gmail.com
Sun May 25 05:49:07 PDT 2014


Author: rafael
Date: Sun May 25 07:49:07 2014
New Revision: 209600

URL: http://llvm.org/viewvc/llvm-project?rev=209600&view=rev
Log:
Emit data or code export directives based on the type.

Currently we look at the Aliasee to decide what type of export
directive to use. It seems better to use the type of the alias
directly. This is similar to how we handle the alias having the
same address but other attributes (linkage, visibility) from the
aliasee.

With this patch it is now possible to do things like

target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"
@foo = global [6 x i8] c"\B8*\00\00\00\C3", section ".text", align 16
@f = dllexport alias i32 (), [6 x i8]* @foo
!llvm.module.flags = !{!0}
!0 = metadata !{i32 6, metadata !"Linker Options", metadata !1}
!1 = metadata !{metadata !2, metadata !3}
!2 = metadata !{metadata !"/DEFAULTLIB:libcmt.lib"}
!3 = metadata !{metadata !"/DEFAULTLIB:oldnames.lib"}

Modified:
    llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
    llvm/trunk/test/CodeGen/X86/dllexport-x86_64.ll

Modified: llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp?rev=209600&r1=209599&r2=209600&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp Sun May 25 07:49:07 2014
@@ -670,16 +670,12 @@ void X86AsmPrinter::EmitEndOfAsmFile(Mod
         DLLExportedGlobals.push_back(getSymbol(&Global));
 
     for (const auto &Alias : M.aliases()) {
-      const GlobalValue *GV = &Alias;
-      if (!GV->hasDLLExportStorageClass())
+      if (!Alias.hasDLLExportStorageClass())
         continue;
 
-      while (const GlobalAlias *A = dyn_cast<GlobalAlias>(GV))
-        GV = A->getAliasee();
-
-      if (isa<Function>(GV))
+      if (Alias.getType()->getElementType()->isFunctionTy())
         DLLExportedFns.push_back(getSymbol(&Alias));
-      else if (isa<GlobalVariable>(GV))
+      else
         DLLExportedGlobals.push_back(getSymbol(&Alias));
     }
 

Modified: llvm/trunk/test/CodeGen/X86/dllexport-x86_64.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/dllexport-x86_64.ll?rev=209600&r1=209599&r2=209600&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/dllexport-x86_64.ll (original)
+++ llvm/trunk/test/CodeGen/X86/dllexport-x86_64.ll Sun May 25 07:49:07 2014
@@ -72,6 +72,8 @@ define weak_odr dllexport void @weak1()
 ; CHECK: weak_alias = f1
 @weak_alias = dllexport alias weak_odr void()* @f1
 
+ at blob = global [6 x i8] c"\B8*\00\00\00\C3", section ".text", align 16
+ at blob_alias = dllexport alias i32 (), [6 x i8]* @blob
 
 ; CHECK: .section .drectve
 ; WIN32: /EXPORT:Var1,DATA"
@@ -88,6 +90,7 @@ define weak_odr dllexport void @weak1()
 ; WIN32: /EXPORT:alias2"
 ; WIN32: /EXPORT:alias3"
 ; WIN32: /EXPORT:weak_alias"
+; WIN32: /EXPORT:blob_alias"
 ; MINGW: -export:Var1,data"
 ; MINGW: -export:Var2,data"
 ; MINGW: -export:Var3,data"
@@ -102,3 +105,4 @@ define weak_odr dllexport void @weak1()
 ; MINGW: -export:alias2"
 ; MINGW: -export:alias3"
 ; MINGW: -export:weak_alias"
+; MINGW: -export:blob_alias"





More information about the llvm-commits mailing list