[llvm-commits] CVS: llvm/lib/Target/X86/X86Subtarget.cpp X86Subtarget.h X86TargetMachine.cpp

Anton Korobeynikov asl at math.spbu.ru
Tue Dec 19 17:03:35 PST 2006



Changes in directory llvm/lib/Target/X86:

X86Subtarget.cpp updated: 1.43 -> 1.44
X86Subtarget.h updated: 1.22 -> 1.23
X86TargetMachine.cpp updated: 1.131 -> 1.132
---
Log message:

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 :)


---
Diffs of the changes:  (+28 -7)

 X86Subtarget.cpp     |   25 ++++++++++++++++++-------
 X86Subtarget.h       |    7 +++++++
 X86TargetMachine.cpp |    3 +++
 3 files changed, 28 insertions(+), 7 deletions(-)


Index: llvm/lib/Target/X86/X86Subtarget.cpp
diff -u llvm/lib/Target/X86/X86Subtarget.cpp:1.43 llvm/lib/Target/X86/X86Subtarget.cpp:1.44
--- llvm/lib/Target/X86/X86Subtarget.cpp:1.43	Thu Dec  7 16:21:48 2006
+++ llvm/lib/Target/X86/X86Subtarget.cpp	Tue Dec 19 19:03:20 2006
@@ -32,13 +32,14 @@
 /// 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 @@
   }
 }
 
+/// 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 @@
   // 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


Index: llvm/lib/Target/X86/X86Subtarget.h
diff -u llvm/lib/Target/X86/X86Subtarget.h:1.22 llvm/lib/Target/X86/X86Subtarget.h:1.23
--- llvm/lib/Target/X86/X86Subtarget.h:1.22	Thu Nov 30 16:42:55 2006
+++ llvm/lib/Target/X86/X86Subtarget.h	Tue Dec 19 19:03:20 2006
@@ -61,6 +61,9 @@
   /// 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 @@
   /// 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 {


Index: llvm/lib/Target/X86/X86TargetMachine.cpp
diff -u llvm/lib/Target/X86/X86TargetMachine.cpp:1.131 llvm/lib/Target/X86/X86TargetMachine.cpp:1.132
--- llvm/lib/Target/X86/X86TargetMachine.cpp:1.131	Tue Dec 19 13:40:09 2006
+++ llvm/lib/Target/X86/X86TargetMachine.cpp	Tue Dec 19 19:03:20 2006
@@ -166,6 +166,9 @@
   // 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;






More information about the llvm-commits mailing list