summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2006-12-20 01:03:20 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2006-12-20 01:03:20 +0000
commit15fccf1d9395ccf3f60404e71dc9db029d04f910 (patch)
tree47beb794aa75a98ea0ee726a6d87922879b616b9 /lib
parent0a3615246fe194f64e5d4afea5943542545819fc (diff)
downloadllvm-15fccf1d9395ccf3f60404e71dc9db029d04f910.tar.gz
llvm-15fccf1d9395ccf3f60404e71dc9db029d04f910.tar.bz2
llvm-15fccf1d9395ccf3f60404e71dc9db029d04f910.tar.xz
Fixed dllimported symbols support during JIT'ing. JIT on mingw32
platform should be more or less workable. At least, sim is running fine under lli :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32711 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/X86/X86Subtarget.cpp25
-rw-r--r--lib/Target/X86/X86Subtarget.h7
-rw-r--r--lib/Target/X86/X86TargetMachine.cpp3
3 files changed, 28 insertions, 7 deletions
diff --git a/lib/Target/X86/X86Subtarget.cpp b/lib/Target/X86/X86Subtarget.cpp
index ff88fdbca2..5281dcda7a 100644
--- a/lib/Target/X86/X86Subtarget.cpp
+++ b/lib/Target/X86/X86Subtarget.cpp
@@ -32,13 +32,14 @@ AsmWriterFlavor("x86-asm-syntax", cl::init(X86Subtarget::unset),
/// or index register of the address, not the GV offset field.
bool X86Subtarget::GVRequiresExtraLoad(const GlobalValue* GV, bool isDirectCall) const
{
- if (isTargetDarwin()) {
- return (!isDirectCall &&
- (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
- (GV->isExternal() && !GV->hasNotBeenReadFromBytecode())));
- } else if (isTargetCygwin() || isTargetWindows()) {
- return (GV->hasDLLImportLinkage());
- }
+ if (GenerateExtraLoadsForGVs)
+ if (isTargetDarwin()) {
+ return (!isDirectCall &&
+ (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
+ (GV->isExternal() && !GV->hasNotBeenReadFromBytecode())));
+ } else if (isTargetCygwin() || isTargetWindows()) {
+ return (GV->hasDLLImportLinkage());
+ }
return false;
}
@@ -206,6 +207,15 @@ static const char *GetCurrentX86CPU() {
}
}
+/// SetJITMode - This is called to inform the subtarget info that we are
+/// producing code for the JIT.
+void X86Subtarget::SetJITMode() {
+ // JIT mode doesn't want extra loads for dllimported symbols, it knows exactly
+ // where everything is.
+ if (isTargetCygwin())
+ GenerateExtraLoadsForGVs = false;
+}
+
X86Subtarget::X86Subtarget(const Module &M, const std::string &FS, bool is64Bit)
: AsmFlavor(AsmWriterFlavor)
, X86SSELevel(NoMMXSSE)
@@ -214,6 +224,7 @@ X86Subtarget::X86Subtarget(const Module &M, const std::string &FS, bool is64Bit)
// FIXME: this is a known good value for Yonah. How about others?
, MinRepStrSizeThreshold(128)
, Is64Bit(is64Bit)
+ , GenerateExtraLoadsForGVs(true)
, TargetType(isELF) { // Default to ELF unless otherwise specified.
// Determine default and user specified characteristics
diff --git a/lib/Target/X86/X86Subtarget.h b/lib/Target/X86/X86Subtarget.h
index 70e70e9011..4a3bc342ee 100644
--- a/lib/Target/X86/X86Subtarget.h
+++ b/lib/Target/X86/X86Subtarget.h
@@ -61,6 +61,9 @@ private:
/// pointer size is 64 bit.
bool Is64Bit;
+ /// GenerateExtraLoadsForGVs - True if we should generate extra loads for
+ /// indirect symbols (e.g. dllimported symbols on windows).
+ bool GenerateExtraLoadsForGVs;
public:
enum {
isELF, isCygwin, isDarwin, isWindows
@@ -112,6 +115,10 @@ public:
/// value of GV itself. This means that the GlobalAddress must be in the base
/// or index register of the address, not the GV offset field.
bool GVRequiresExtraLoad(const GlobalValue* GV, bool isDirectCall) const;
+
+ /// SetJITMode - This is called to inform the subtarget info that we are
+ /// producing code for the JIT.
+ void SetJITMode();
};
namespace X86 {
diff --git a/lib/Target/X86/X86TargetMachine.cpp b/lib/Target/X86/X86TargetMachine.cpp
index 2d48056caa..ad0bf5510c 100644
--- a/lib/Target/X86/X86TargetMachine.cpp
+++ b/lib/Target/X86/X86TargetMachine.cpp
@@ -166,6 +166,9 @@ bool X86TargetMachine::addCodeEmitter(FunctionPassManager &PM, bool Fast,
// JIT cannot ensure globals are placed in the lower 4G of address.
if (Subtarget.is64Bit())
setCodeModel(CodeModel::Large);
+
+ // Inform the subtarget that we are in JIT mode.
+ Subtarget.SetJITMode();
PM.add(createX86CodeEmitterPass(*this, MCE));
return false;