1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00

When rewriting the original call instruction, make sure to rewrite it to

call the right address.

llvm-svn: 18213
This commit is contained in:
Chris Lattner 2004-11-24 18:00:02 +00:00
parent 8cd0215f14
commit 961fae4d82

View File

@ -81,12 +81,13 @@ static void CompilationCallback() {
// does not need to go through the stub anymore. // does not need to go through the stub anymore.
unsigned CameFromOrigInst = CameFromOrig[-1]; unsigned CameFromOrigInst = CameFromOrig[-1];
if ((CameFromOrigInst >> 26) == 18) { // Direct call. if ((CameFromOrigInst >> 26) == 18) { // Direct call.
intptr_t Offset = ((intptr_t)Target-(intptr_t)CameFromOrig) >> 2; intptr_t Offset = ((intptr_t)Target-(intptr_t)CameFromOrig+4) >> 2;
if (Offset >= -(1 << 23) && Offset < (1 << 23)) { // In range? if (Offset >= -(1 << 23) && Offset < (1 << 23)) { // In range?
// FIXME: hasn't been tested at all. // Clear the original target out.
// Clear the original target out:
CameFromOrigInst &= (63 << 26) | 3; CameFromOrigInst &= (63 << 26) | 3;
CameFromOrigInst |= Offset << 2; // Fill in the new target.
CameFromOrigInst |= (Offset & ((1 << 24)-1)) << 2;
// Replace the call.
CameFromOrig[-1] = CameFromOrigInst; CameFromOrig[-1] = CameFromOrigInst;
} }
} }