Correlate stubs with functions in JIT: when emitting a stub, the JIT tells the memory manager which function
the stub will resolve.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49814 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/ARM/ARMJITInfo.cpp b/lib/Target/ARM/ARMJITInfo.cpp
index 915963c..bc2bba3 100644
--- a/lib/Target/ARM/ARMJITInfo.cpp
+++ b/lib/Target/ARM/ARMJITInfo.cpp
@@ -15,6 +15,7 @@
 #include "ARMJITInfo.h"
 #include "ARMRelocations.h"
 #include "ARMSubtarget.h"
+#include "llvm/Function.h"
 #include "llvm/CodeGen/MachineCodeEmitter.h"
 #include "llvm/Config/alloca.h"
 #include <cstdlib>
@@ -93,20 +94,21 @@
   return ARMCompilationCallback;
 }
 
-void *ARMJITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) {
+void *ARMJITInfo::emitFunctionStub(const Function* F, void *Fn,
+                                   MachineCodeEmitter &MCE) {
   unsigned addr = (intptr_t)Fn;
   // If this is just a call to an external function, emit a branch instead of a
   // call.  The code is the same except for one bit of the last instruction.
   if (Fn != (void*)(intptr_t)ARMCompilationCallback) {
     // branch to the corresponding function addr
     // the stub is 8-byte size and 4-aligned
-    MCE.startFunctionStub(8, 4);
+    MCE.startFunctionStub(F, 8, 4);
     MCE.emitWordLE(0xE51FF004); // LDR PC, [PC,#-4]
     MCE.emitWordLE(addr);       // addr of function
   } else {
     // branch and link to the corresponding function addr
     // the stub is 20-byte size and 4-aligned
-    MCE.startFunctionStub(20, 4);
+    MCE.startFunctionStub(F, 20, 4);
     MCE.emitWordLE(0xE92D4800); // STMFD SP!, [R11, LR]
     MCE.emitWordLE(0xE28FE004); // ADD LR, PC, #4
     MCE.emitWordLE(0xE51FF004); // LDR PC, [PC,#-4]
@@ -114,7 +116,7 @@
     MCE.emitWordLE(0xE8BD8800); // LDMFD SP!, [R11, PC]
   }
 
-  return MCE.finishFunctionStub(0);
+  return MCE.finishFunctionStub(F);
 }
 
 /// relocate - Before the JIT can run a block of code that has been emitted,