When rewriting the original call instruction, make sure to rewrite it to
authorChris Lattner <sabre@nondot.org>
Wed, 24 Nov 2004 18:00:02 +0000 (18:00 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 24 Nov 2004 18:00:02 +0000 (18:00 +0000)
call the right address.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18213 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PowerPC/PPCJITInfo.cpp

index 299dce771f9cf88feeea3c12a81b6146669c12a7..f7abc53a897d3983de37bd91607bd5f52f3aee22 100644 (file)
@@ -81,12 +81,13 @@ static void CompilationCallback() {
   // does not need to go through the stub anymore.
   unsigned CameFromOrigInst = CameFromOrig[-1];
   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?
-      // FIXME: hasn't been tested at all.
-      // Clear the original target out:
+      // Clear the original target out.
       CameFromOrigInst &= (63 << 26) | 3;
-      CameFromOrigInst |= Offset << 2;
+      // Fill in the new target.
+      CameFromOrigInst |= (Offset & ((1 << 24)-1)) << 2;
+      // Replace the call.
       CameFromOrig[-1] = CameFromOrigInst;
     }
   }