[llvm-commits] CVS: llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp

Evan Cheng evan.cheng at apple.com
Tue Jul 25 13:41:14 PDT 2006



Changes in directory llvm/lib/ExecutionEngine/JIT:

JITEmitter.cpp updated: 1.106 -> 1.107
---
Log message:

- Refactor the code that resolve basic block references to a TargetJITInfo
  method.
- Added synchronizeICache() to TargetJITInfo. It is called after each block
  of code is emitted to flush the icache. This ensures correct execution
  on targets that have separate dcache and icache.
- Added PPC / Mac OS X specific code to do icache flushing.



---
Diffs of the changes:  (+16 -1)

 JITEmitter.cpp |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletion(-)


Index: llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp
diff -u llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp:1.106 llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp:1.107
--- llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp:1.106	Fri Jul  7 12:31:41 2006
+++ llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp	Tue Jul 25 15:40:54 2006
@@ -542,6 +542,10 @@
     TheJIT->updateGlobalMapping(F, Stub);
   }
 
+  // Invalidate the icache if necessary.
+  TheJIT->getJITInfo().
+    synchronizeICache(Stub, MCE.getCurrentPCValue()-(intptr_t)Stub);
+
   DEBUG(std::cerr << "JIT: Stub emitted at [" << Stub << "] for function '"
                   << F->getName() << "'\n");
 
@@ -559,6 +563,11 @@
   if (Stub) return Stub;
 
   Stub = TheJIT->getJITInfo().emitFunctionStub(FnAddr, MCE);
+
+  // Invalidate the icache if necessary.
+  TheJIT->getJITInfo().
+    synchronizeICache(Stub, MCE.getCurrentPCValue()-(intptr_t)Stub);
+
   DEBUG(std::cerr << "JIT: Stub emitted at [" << Stub
         << "] for external function at '" << FnAddr << "'\n");
   return Stub;
@@ -747,7 +756,7 @@
   // About to start emitting the machine code for the function.
   emitAlignment(std::max(F.getFunction()->getAlignment(), 8U));
   TheJIT->updateGlobalMapping(F.getFunction(), CurBufferPtr);
-  
+
   MBBLocations.clear();
 }
 
@@ -825,6 +834,12 @@
     }
   }
 
+  // Resolve BasicaBlock references.
+  TheJIT->getJITInfo().resolveBBRefs(*this);
+
+  // Invalidate the icache if necessary.
+  TheJIT->getJITInfo().synchronizeICache(FnStart, FnEnd-FnStart);
+
   DEBUG(std::cerr << "JIT: Finished CodeGen of [" << (void*)FnStart
                   << "] Function: " << F.getFunction()->getName()
                   << ": " << (FnEnd-FnStart) << " bytes of text, "






More information about the llvm-commits mailing list