X86 JIT PIC jumptable support.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45616 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp
index aa572a4..049b3bc 100644
--- a/lib/ExecutionEngine/JIT/JITEmitter.cpp
+++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp
@@ -341,7 +341,7 @@
/// JumpTableBase - A pointer to the first entry in the jump table.
///
void *JumpTableBase;
-
+
/// Resolver - This contains info about the currently resolved functions.
JITResolver Resolver;
public:
@@ -380,7 +380,7 @@
virtual intptr_t getConstantPoolEntryAddress(unsigned Entry) const;
virtual intptr_t getJumpTableEntryAddress(unsigned Entry) const;
-
+
virtual intptr_t getMachineBasicBlockAddress(MachineBasicBlock *MBB) const {
assert(MBBLocations.size() > (unsigned)MBB->getNumber() &&
MBBLocations[MBB->getNumber()] && "MBB not emitted!");
@@ -616,8 +616,10 @@
// Store the offset of the basic block for this jump table slot in the
// memory we allocated for the jump table in 'initJumpTableInfo'
intptr_t Base = (intptr_t)SlotPtr;
- for (unsigned mi = 0, me = MBBs.size(); mi != me; ++mi)
- *SlotPtr++ = (intptr_t)getMachineBasicBlockAddress(MBBs[mi]) - Base;
+ for (unsigned mi = 0, me = MBBs.size(); mi != me; ++mi) {
+ intptr_t MBBAddr = getMachineBasicBlockAddress(MBBs[mi]);
+ *SlotPtr++ = TheJIT->getJITInfo().getPICJumpTableEntry(MBBAddr, Base);
+ }
}
} else {
assert(MJTI->getEntrySize() == sizeof(void*) && "Cross JIT'ing?");