Index: llvm/test/CodeGen/X86/dllexport-x86_64.ll =================================================================== --- llvm/test/CodeGen/X86/dllexport-x86_64.ll +++ llvm/test/CodeGen/X86/dllexport-x86_64.ll @@ -1,5 +1,7 @@ -; RUN: llc -mtriple x86_64-pc-win32 < %s | FileCheck -check-prefix=CHECK -check-prefix=WIN32 %s +; RUN: llc -mtriple x86_64-pc-win32 < %s | FileCheck -check-prefix=CHECK -check-prefix=WIN32 %s ; RUN: llc -mtriple x86_64-pc-mingw32 < %s | FileCheck -check-prefix=CHECK -check-prefix=MINGW %s +; RUN: llc -mtriple x86_64-pc-win32 < %s | FileCheck --check-prefix=NOTEXPORTED %s +; RUN: llc -mtriple x86_64-pc-mingw32 < %s | FileCheck --check-prefix=NOTEXPORTED %s ; CHECK: .text @@ -50,11 +52,19 @@ ; CHECK: .globl WeakVar2 @WeakVar2 = weak_odr dllexport unnamed_addr constant i32 1 +; CHECK: .bss +; CHECK: .globl WeakVar3 +@WeakVar3 = weak_odr dllexport global i32 0, align 4 + ; CHECK: .globl alias ; CHECK: alias = notExported @alias = dllexport alias void(), void()* @notExported +; CHECK: .globl aliasNotExported +; CHECK: aliasNotExported = f1 +@aliasNotExported = alias void(), void()* @f1 + ; CHECK: .globl alias2 ; CHECK: alias2 = f1 @alias2 = dllexport alias void(), void()* @f1 @@ -70,6 +80,27 @@ @blob = global [6 x i8] c"\B8*\00\00\00\C3", section ".text", align 16 @blob_alias = dllexport alias i32 (), bitcast ([6 x i8]* @blob to i32 ()*) +; Verify items that should not be exported do not appear in the export table. +; Specifically, an alias of an exported function, where the alias itself was +; not exported, should not be exported. Also, functions and variables that are +; declared as dllexport (and are referenced), but are not defined, should not +; be exported. +@exportedButNotDefinedVariable = external dllexport global i32 +declare dllexport void @exportedButNotDefinedFunction() +define void @foo() { +entry: + store i32 4, i32* @exportedButNotDefinedVariable, align 4 + call void @exportedButNotDefinedFunction() + ret void +} + +; NOTEXPORTED: .section .drectve +; NOTEXPORTED-NOT: notExported +; NOTEXPORTED-NOT: aliasNotExported +; NOTEXPORTED-NOT: exportedButNotDefinedVariable +; NOTEXPORTED-NOT: exportedButNotDefinedFunction + +; Now verify that things we expect to be in the export table are there. ; CHECK: .section .drectve ; WIN32: /EXPORT:f1 ; WIN32-SAME: /EXPORT:f2 @@ -81,6 +112,7 @@ ; WIN32-SAME: /EXPORT:Var3,DATA ; WIN32-SAME: /EXPORT:WeakVar1,DATA ; WIN32-SAME: /EXPORT:WeakVar2,DATA +; WIN32-SAME: /EXPORT:WeakVar3,DATA ; WIN32-SAME: /EXPORT:alias ; WIN32-SAME: /EXPORT:alias2 ; WIN32-SAME: /EXPORT:alias3 @@ -96,6 +128,7 @@ ; MINGW-SAME: -export:Var3,data ; MINGW-SAME: -export:WeakVar1,data ; MINGW-SAME: -export:WeakVar2,data +; MINGW-SAME: -export:WeakVar3,data ; MINGW-SAME: -export:alias ; MINGW-SAME: -export:alias2 ; MINGW-SAME: -export:alias3 Index: llvm/test/CodeGen/X86/dllexport.ll =================================================================== --- llvm/test/CodeGen/X86/dllexport.ll +++ llvm/test/CodeGen/X86/dllexport.ll @@ -5,6 +5,13 @@ ; RUN: llc -mtriple i686-pc-cygwin %s -o - \ ; RUN: | FileCheck -check-prefix CHECK -check-prefix CHECK-GCC %s +; RUN: llc -mtriple i386-pc-win32 < %s \ +; RUN: | FileCheck -check-prefix NOTEXPORTED %s +; RUN: llc -mtriple i386-pc-mingw32 < %s \ +; RUN: | FileCheck -check-prefix NOTEXPORTED %s +; RUN: llc -mtriple i686-pc-cygwin %s -o - \ +; RUN: | FileCheck -check-prefix NOTEXPORTED %s + ; CHECK: .text define void @notExported() { @@ -21,7 +28,7 @@ ret void } -declare dllexport void @not_defined() +declare dllexport void @notDefined() ; CHECK: .globl _stdfun@0 define dllexport x86_stdcallcc void @stdfun() nounwind { @@ -88,8 +95,12 @@ ; CHECK: _weak_alias = _f1 @weak_alias = weak_odr dllexport alias void(), void()* @f1 +; Verify items that should not be exported do not appear in the export table. +; NOTEXPORTED: .section .drectve +; NOTEXPORTED-NOT: notExported +; NOTEXPORTED-NOT: notDefined + ; CHECK: .section .drectve -; CHECK-CL-NOT: not_exported ; CHECK-CL: /EXPORT:_f1 ; CHECK-CL-SAME: /EXPORT:_f2 ; CHECK-CL-SAME: /EXPORT:_stdfun@0 @@ -107,8 +118,6 @@ ; CHECK-CL-SAME: /EXPORT:_alias2 ; CHECK-CL-SAME: /EXPORT:_alias3 ; CHECK-CL-SAME: /EXPORT:_weak_alias" -; CHECK-CL-NOT: not_exported -; CHECK-GCC-NOT: not_exported ; CHECK-GCC: -export:f1 ; CHECK-GCC-SAME: -export:f2 ; CHECK-GCC-SAME: -export:stdfun@0 @@ -126,4 +135,3 @@ ; CHECK-GCC-SAME: -export:alias2 ; CHECK-GCC-SAME: -export:alias3 ; CHECK-GCC-SAME: -export:weak_alias" -; CHECK-GCC-NOT: not_exported