X86 PIC JIT support fixes: encoding bugs, add lazy pointer stubs support.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45575 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/X86/X86JITInfo.cpp b/lib/Target/X86/X86JITInfo.cpp
index af1a8b8..d5d3cda 100644
--- a/lib/Target/X86/X86JITInfo.cpp
+++ b/lib/Target/X86/X86JITInfo.cpp
@@ -380,6 +380,18 @@
return X86CompilationCallback;
}
+void *X86JITInfo::emitGlobalValueLazyPtr(void *GV, MachineCodeEmitter &MCE) {
+#ifdef __x86_64__
+ MCE.startFunctionStub(8, 8);
+ MCE.emitWordLE(((unsigned *)&GV)[0]);
+ MCE.emitWordLE(((unsigned *)&GV)[1]);
+#else
+ MCE.startFunctionStub(4, 4);
+ MCE.emitWordLE((unsigned)GV);
+#endif
+ return MCE.finishFunctionStub(0);
+}
+
void *X86JITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) {
// Note, we cast to intptr_t here to silence a -pedantic warning that
// complains about casting a function pointer to a normal pointer.