summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2017-10-25 07:25:18 +0000
committerMartin Storsjo <martin@martin.st>2017-10-25 07:25:18 +0000
commit373c8efa1e2e35324878b83027e20b3970876e1a (patch)
treeb5362447e34d361b7278ef947777f14e0aa2a404 /llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
parent8a752b77a2868066237f9ec4c5c9b292f9983afa (diff)
downloadbcm5719-llvm-373c8efa1e2e35324878b83027e20b3970876e1a.tar.gz
bcm5719-llvm-373c8efa1e2e35324878b83027e20b3970876e1a.zip
[AArch64] Add support for dllimport of values and functions
Previously, the dllimport attribute did the right thing in terms of treating it as a pointer to a value, but this makes sure the names get mangled properly, and calls to such functions load the function from the __imp_ pointer. This is based on SVN r212431 and r212430 where the same was implemented for ARM. Differential Revision: https://reviews.llvm.org/D38530 llvm-svn: 316555
Diffstat (limited to 'llvm/lib/Target/AArch64/AArch64MCInstLower.cpp')
-rw-r--r--llvm/lib/Target/AArch64/AArch64MCInstLower.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp b/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
index f82b9dbc2c9..f1281a1b912 100644
--- a/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
+++ b/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
@@ -19,10 +19,12 @@
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/IR/Mangler.h"
+#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetMachine.h"
using namespace llvm;
@@ -33,7 +35,25 @@ AArch64MCInstLower::AArch64MCInstLower(MCContext &ctx, AsmPrinter &printer)
MCSymbol *
AArch64MCInstLower::GetGlobalAddressSymbol(const MachineOperand &MO) const {
- return Printer.getSymbol(MO.getGlobal());
+ const GlobalValue *GV = MO.getGlobal();
+ unsigned TargetFlags = MO.getTargetFlags();
+ const Triple &TheTriple = Printer.TM.getTargetTriple();
+ if (!TheTriple.isOSBinFormatCOFF())
+ return Printer.getSymbol(GV);
+
+ assert(TheTriple.isOSWindows() &&
+ "Windows is the only supported COFF target");
+
+ bool IsIndirect = (TargetFlags & AArch64II::MO_DLLIMPORT);
+ if (!IsIndirect)
+ return Printer.getSymbol(GV);
+
+ SmallString<128> Name;
+ Name = "__imp_";
+ Printer.TM.getNameWithPrefix(Name, GV,
+ Printer.getObjFileLowering().getMangler());
+
+ return Ctx.getOrCreateSymbol(Name);
}
MCSymbol *
OpenPOWER on IntegriCloud