diff --git a/llvm/lib/IR/Mangler.cpp b/llvm/lib/IR/Mangler.cpp --- a/llvm/lib/IR/Mangler.cpp +++ b/llvm/lib/IR/Mangler.cpp @@ -241,8 +241,8 @@ else OS << ",data"; } - } - if (GV->hasHiddenVisibility() && !GV->isDeclaration() && TT.isOSCygMing()) { + } else if (GV->hasHiddenVisibility() && !GV->isDeclaration() && + TT.isOSCygMing()) { OS << " -exclude-symbols:"; diff --git a/llvm/test/CodeGen/X86/mingw-hidden.ll b/llvm/test/CodeGen/X86/mingw-hidden.ll --- a/llvm/test/CodeGen/X86/mingw-hidden.ll +++ b/llvm/test/CodeGen/X86/mingw-hidden.ll @@ -17,6 +17,11 @@ ret void } +; CHECK: .globl _exportedHidden +define hidden dllexport void @exportedHidden() { + ret void +} + ; CHECK: .globl _f2 define hidden void @f2() unnamed_addr { ret void @@ -67,9 +72,12 @@ ; NOTEXPORTED-NOT: :notHidden ; NOTEXPORTED-NOT: :notDefined -; CHECK-MSVC-NOT: .section .drectve +; CHECK-MSVC: .section .drectve +; CHECK-MSVC: .ascii " /EXPORT:_exportedHidden" ; CHECK-MINGW: .section .drectve ; CHECK-MINGW: .ascii " -exclude-symbols:f1" +; CHECK-MINGW: .ascii " -export:exportedHidden" +; CHECK-MINGW-NOT: -exclude-symbols:exportedHidden ; CHECK-MINGW: .ascii " -exclude-symbols:f2" ; CHECK-MINGW: .ascii " -exclude-symbols:stdfun@0" ; CHECK-MINGW: .ascii " -exclude-symbols:lnk1"