Index: lib/IR/Mangler.cpp =================================================================== --- lib/IR/Mangler.cpp +++ lib/IR/Mangler.cpp @@ -112,6 +112,10 @@ return; } + // dllimported symbols have a __imp_ prefix. + if (GV->hasDLLImportStorageClass()) + OS << "__imp_"; + StringRef Name = GV->getName(); char Prefix = DL->getGlobalPrefix(); Index: lib/Target/ARM/ARMAsmPrinter.cpp =================================================================== --- lib/Target/ARM/ARMAsmPrinter.cpp +++ lib/Target/ARM/ARMAsmPrinter.cpp @@ -851,16 +851,7 @@ } else if (Subtarget->isTargetCOFF()) { assert(Subtarget->isTargetWindows() && "Windows is the only supported COFF target"); - - bool IsIndirect = (TargetFlags & ARMII::MO_DLLIMPORT); - if (!IsIndirect) - return getSymbol(GV); - - SmallString<128> Name; - Name = "__imp_"; - getNameWithPrefix(Name, GV); - - return OutContext.getOrCreateSymbol(Name); + return getSymbol(GV); } else if (Subtarget->isTargetELF()) { return getSymbol(GV); } Index: lib/Target/ARM/ARMISelLowering.cpp =================================================================== --- lib/Target/ARM/ARMISelLowering.cpp +++ lib/Target/ARM/ARMISelLowering.cpp @@ -1750,11 +1750,8 @@ } else if (Subtarget->isTargetCOFF()) { assert(Subtarget->isTargetWindows() && "Windows is the only supported COFF target"); - unsigned TargetFlags = GV->hasDLLImportStorageClass() - ? ARMII::MO_DLLIMPORT - : ARMII::MO_NO_FLAG; Callee = DAG.getTargetGlobalAddress(GV, dl, getPointerTy(), /*Offset=*/0, - TargetFlags); + ARMII::MO_NO_FLAG); if (GV->hasDLLImportStorageClass()) Callee = DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(), DAG.getNode(ARMISD::Wrapper, dl, getPointerTy(), @@ -2643,8 +2640,6 @@ "Windows on ARM expects to use movw/movt"); const GlobalValue *GV = cast(Op)->getGlobal(); - const ARMII::TOF TargetFlags = - (GV->hasDLLImportStorageClass() ? ARMII::MO_DLLIMPORT : ARMII::MO_NO_FLAG); EVT PtrVT = getPointerTy(); SDValue Result; SDLoc DL(Op); @@ -2655,7 +2650,7 @@ // operands, expand this into two nodes. Result = DAG.getNode(ARMISD::Wrapper, DL, PtrVT, DAG.getTargetGlobalAddress(GV, DL, PtrVT, /*Offset=*/0, - TargetFlags)); + ARMII::MO_NO_FLAG)); if (GV->hasDLLImportStorageClass()) Result = DAG.getLoad(PtrVT, DL, DAG.getEntryNode(), Result, MachinePointerInfo::getGOT(), false, false, false, 0); Index: lib/Target/X86/X86AsmPrinter.cpp =================================================================== --- lib/Target/X86/X86AsmPrinter.cpp +++ lib/Target/X86/X86AsmPrinter.cpp @@ -94,11 +94,6 @@ else GVSym = P.getSymbol(GV); - // Handle dllimport linkage. - if (MO.getTargetFlags() == X86II::MO_DLLIMPORT) - GVSym = - P.OutContext.getOrCreateSymbol(Twine("__imp_") + GVSym->getName()); - if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY || MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) { MCSymbol *Sym = P.getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr"); Index: lib/Target/X86/X86MCInstLower.cpp =================================================================== --- lib/Target/X86/X86MCInstLower.cpp +++ lib/Target/X86/X86MCInstLower.cpp @@ -133,10 +133,6 @@ StringRef Suffix; switch (MO.getTargetFlags()) { - case X86II::MO_DLLIMPORT: - // Handle dllimport linkage. - Name += "__imp_"; - break; case X86II::MO_DARWIN_STUB: Suffix = "$stub"; break; Index: test/Object/dllimport.ll =================================================================== --- /dev/null +++ test/Object/dllimport.ll @@ -0,0 +1,17 @@ +; RUN: llvm-as %s -o - | llvm-nm - | FileCheck %s + +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc" + +; CHECK: U __imp_f +; CHECK: U __imp_v +; CHECK: T g + +declare dllimport void @f() +@v = external dllimport global i32 + +define void @g() { + call void @f() + store i32 42, i32* @v + ret void +}