[llvm] r239502 - Revert "Move dllimport name mangling to IR mangler."
Reid Kleckner
reid at kleckner.net
Wed Jun 10 18:31:49 PDT 2015
Author: rnk
Date: Wed Jun 10 20:31:48 2015
New Revision: 239502
URL: http://llvm.org/viewvc/llvm-project?rev=239502&view=rev
Log:
Revert "Move dllimport name mangling to IR mangler."
This reverts commit r239437.
This broke clang-cl self-hosts. We'd end up calling the __imp_ symbol
directly instead of using it to do an indirect function call.
Removed:
llvm/trunk/test/Object/dllimport.ll
Modified:
llvm/trunk/lib/IR/Mangler.cpp
llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp
llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMBaseInfo.h
llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
llvm/trunk/lib/Target/X86/X86MCInstLower.cpp
Modified: llvm/trunk/lib/IR/Mangler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Mangler.cpp?rev=239502&r1=239501&r2=239502&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Mangler.cpp (original)
+++ llvm/trunk/lib/IR/Mangler.cpp Wed Jun 10 20:31:48 2015
@@ -112,10 +112,6 @@ void Mangler::getNameWithPrefix(raw_ostr
return;
}
- // dllimported symbols have a __imp_ prefix.
- if (GV->hasDLLImportStorageClass())
- OS << "__imp_";
-
StringRef Name = GV->getName();
char Prefix = DL->getGlobalPrefix();
Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp?rev=239502&r1=239501&r2=239502&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Wed Jun 10 20:31:48 2015
@@ -851,7 +851,16 @@ MCSymbol *ARMAsmPrinter::GetARMGVSymbol(
} else if (Subtarget->isTargetCOFF()) {
assert(Subtarget->isTargetWindows() &&
"Windows is the only supported COFF target");
- return getSymbol(GV);
+
+ bool IsIndirect = (TargetFlags & ARMII::MO_DLLIMPORT);
+ if (!IsIndirect)
+ return getSymbol(GV);
+
+ SmallString<128> Name;
+ Name = "__imp_";
+ getNameWithPrefix(Name, GV);
+
+ return OutContext.getOrCreateSymbol(Name);
} else if (Subtarget->isTargetELF()) {
return getSymbol(GV);
}
Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=239502&r1=239501&r2=239502&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Wed Jun 10 20:31:48 2015
@@ -1751,8 +1751,11 @@ ARMTargetLowering::LowerCall(TargetLower
} 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,
- ARMII::MO_NO_FLAG);
+ TargetFlags);
if (GV->hasDLLImportStorageClass())
Callee = DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(),
DAG.getNode(ARMISD::Wrapper, dl, getPointerTy(),
@@ -2643,6 +2646,8 @@ SDValue ARMTargetLowering::LowerGlobalAd
"Windows on ARM expects to use movw/movt");
const GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
+ const ARMII::TOF TargetFlags =
+ (GV->hasDLLImportStorageClass() ? ARMII::MO_DLLIMPORT : ARMII::MO_NO_FLAG);
EVT PtrVT = getPointerTy();
SDValue Result;
SDLoc DL(Op);
@@ -2653,7 +2658,7 @@ SDValue ARMTargetLowering::LowerGlobalAd
// operands, expand this into two nodes.
Result = DAG.getNode(ARMISD::Wrapper, DL, PtrVT,
DAG.getTargetGlobalAddress(GV, DL, PtrVT, /*Offset=*/0,
- ARMII::MO_NO_FLAG));
+ TargetFlags));
if (GV->hasDLLImportStorageClass())
Result = DAG.getLoad(PtrVT, DL, DAG.getEntryNode(), Result,
MachinePointerInfo::getGOT(), false, false, false, 0);
Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMBaseInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMBaseInfo.h?rev=239502&r1=239501&r2=239502&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMBaseInfo.h (original)
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMBaseInfo.h Wed Jun 10 20:31:48 2015
@@ -297,12 +297,17 @@ namespace ARMII {
/// just that part of the flag set.
MO_OPTION_MASK = 0x3f,
+ /// MO_DLLIMPORT - On a symbol operand, this represents that the reference
+ /// to the symbol is for an import stub. This is used for DLL import
+ /// storage class indication on Windows.
+ MO_DLLIMPORT = 0x40,
+
/// MO_NONLAZY - This is an independent flag, on a symbol operand "FOO" it
/// represents a symbol which, if indirect, will get special Darwin mangling
/// as a non-lazy-ptr indirect symbol (i.e. "L_FOO$non_lazy_ptr"). Can be
/// combined with MO_LO16, MO_HI16 or MO_NO_FLAG (in a constant-pool, for
/// example).
- MO_NONLAZY = 0x40,
+ MO_NONLAZY = 0x80,
// It's undefined behaviour if an enum overflows the range between its
// smallest and largest values, but since these are |ed together, it can
Modified: llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp?rev=239502&r1=239501&r2=239502&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp Wed Jun 10 20:31:48 2015
@@ -94,6 +94,11 @@ static void printSymbolOperand(X86AsmPri
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");
Modified: llvm/trunk/lib/Target/X86/X86MCInstLower.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCInstLower.cpp?rev=239502&r1=239501&r2=239502&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86MCInstLower.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86MCInstLower.cpp Wed Jun 10 20:31:48 2015
@@ -133,6 +133,10 @@ GetSymbolFromOperand(const MachineOperan
StringRef Suffix;
switch (MO.getTargetFlags()) {
+ case X86II::MO_DLLIMPORT:
+ // Handle dllimport linkage.
+ Name += "__imp_";
+ break;
case X86II::MO_DARWIN_STUB:
Suffix = "$stub";
break;
Removed: llvm/trunk/test/Object/dllimport.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/dllimport.ll?rev=239501&view=auto
==============================================================================
--- llvm/trunk/test/Object/dllimport.ll (original)
+++ llvm/trunk/test/Object/dllimport.ll (removed)
@@ -1,17 +0,0 @@
-; 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()
- at v = external dllimport global i32
-
-define void @g() {
- call void @f()
- store i32 42, i32* @v
- ret void
-}
More information about the llvm-commits
mailing list