#include "llvm/ModuleProvider.h"
#include "llvm/CodeGen/MachineCodeEmitter.h"
#include "llvm/ExecutionEngine/GenericValue.h"
+#include "llvm/CodeGen/MachineCodeInfo.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetJITInfo.h"
/// just-in-time compilation passes on F, hopefully filling in
/// GlobalAddress[F] with the address of F's machine code.
///
-void JIT::runJITOnFunction(Function *F) {
+void JIT::runJITOnFunction(Function *F, MachineCodeInfo *MCI) {
MutexGuard locked(lock);
+
+ registerMachineCodeInfo(MCI);
+
runJITOnFunctionUnlocked(F, locked);
+
+ registerMachineCodeInfo(0);
}
void JIT::runJITOnFunctionUnlocked(Function *F, const MutexGuard &locked) {
class TargetMachine;
class TargetJITInfo;
class MachineCodeEmitter;
+class MachineCodeInfo;
class JITState {
private:
static ExecutionEngine *createJIT(ModuleProvider *MP, std::string *Err,
JITMemoryManager *JMM,
CodeGenOpt::Level OptLevel);
-
+
+
+ // Run the JIT on F and return information about the generated code
+ void runJITOnFunction(Function *F, MachineCodeInfo *MCI = 0);
+
private:
static MachineCodeEmitter *createEmitter(JIT &J, JITMemoryManager *JMM);
- void runJITOnFunction(Function *F);
+ void registerMachineCodeInfo(MachineCodeInfo *MCI);
void runJITOnFunctionUnlocked(Function *F, const MutexGuard &locked);
void updateFunctionStub(Function *F);
void updateDlsymStubTable();
-
+
protected:
/// getMemoryforGV - Allocate memory for a global variable.
#include "llvm/CodeGen/MachineRelocation.h"
#include "llvm/ExecutionEngine/JITMemoryManager.h"
#include "llvm/ExecutionEngine/GenericValue.h"
+#include "llvm/CodeGen/MachineCodeInfo.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetJITInfo.h"
#include "llvm/Target/TargetMachine.h"
// ExtFnStubs - A map of external function names to stubs which have entries
// in the JITResolver's ExternalFnToStubMap.
StringMap<void *> ExtFnStubs;
-
+
+ // MCI - A pointer to a MachineCodeInfo object to update with information.
+ MachineCodeInfo *MCI;
+
public:
- JITEmitter(JIT &jit, JITMemoryManager *JMM) : Resolver(jit), CurFn(0) {
+ JITEmitter(JIT &jit, JITMemoryManager *JMM) : Resolver(jit), CurFn(0), MCI(0) {
MemMgr = JMM ? JMM : JITMemoryManager::CreateDefaultMemManager();
if (jit.getJITInfo().needsGOT()) {
MemMgr->AllocateGOT();
JITMemoryManager *getMemMgr(void) const { return MemMgr; }
+ void setMachineCodeInfo(MachineCodeInfo *mci) {
+ MCI = mci;
+ }
+
private:
void *getPointerToGlobal(GlobalValue *GV, void *Reference, bool NoNeedStub);
void *getPointerToGVIndirectSym(GlobalValue *V, void *Reference,
<< "] Function: " << F.getFunction()->getName()
<< ": " << (FnEnd-FnStart) << " bytes of text, "
<< Relocations.size() << " relocations\n";
+
+ if (MCI) {
+ MCI->setAddress(FnStart);
+ MCI->setSize(FnEnd-FnStart);
+ }
+
Relocations.clear();
ConstPoolAddresses.clear();
return JE->getJITResolver().getFunctionStub(F);
}
+void JIT::registerMachineCodeInfo(MachineCodeInfo *mc) {
+ assert(isa<JITEmitter>(MCE) && "Unexpected MCE?");
+ JITEmitter *JE = cast<JITEmitter>(getCodeEmitter());
+
+ JE->setMachineCodeInfo(mc);
+}
+
void JIT::updateFunctionStub(Function *F) {
// Get the empty stub we generated earlier.
assert(isa<JITEmitter>(MCE) && "Unexpected MCE?");