Improve JIT debugging outputs format consistency.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58807 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evan Cheng
2008-11-06 17:46:04 +00:00
parent 274c6a6145
commit eb5d95a22d
2 changed files with 18 additions and 16 deletions

View File

@@ -94,7 +94,7 @@ Function *ExecutionEngine::FindFunctionNamed(const char *FnName) {
void ExecutionEngine::addGlobalMapping(const GlobalValue *GV, void *Addr) { void ExecutionEngine::addGlobalMapping(const GlobalValue *GV, void *Addr) {
MutexGuard locked(lock); MutexGuard locked(lock);
DOUT << "Map \'" << GV->getNameStart() << "\' to " << Addr << "\n"; DOUT << "JIT: Map \'" << GV->getNameStart() << "\' to " << Addr << "\n";
void *&CurVal = state.getGlobalAddressMap(locked)[GV]; void *&CurVal = state.getGlobalAddressMap(locked)[GV];
assert((CurVal == 0 || Addr == 0) && "GlobalMapping already established!"); assert((CurVal == 0 || Addr == 0) && "GlobalMapping already established!");
CurVal = Addr; CurVal = Addr;
@@ -211,13 +211,13 @@ static void *CreateArgv(ExecutionEngine *EE,
unsigned PtrSize = EE->getTargetData()->getPointerSize(); unsigned PtrSize = EE->getTargetData()->getPointerSize();
char *Result = new char[(InputArgv.size()+1)*PtrSize]; char *Result = new char[(InputArgv.size()+1)*PtrSize];
DOUT << "ARGV = " << (void*)Result << "\n"; DOUT << "JIT: ARGV = " << (void*)Result << "\n";
const Type *SBytePtr = PointerType::getUnqual(Type::Int8Ty); const Type *SBytePtr = PointerType::getUnqual(Type::Int8Ty);
for (unsigned i = 0; i != InputArgv.size(); ++i) { for (unsigned i = 0; i != InputArgv.size(); ++i) {
unsigned Size = InputArgv[i].size()+1; unsigned Size = InputArgv[i].size()+1;
char *Dest = new char[Size]; char *Dest = new char[Size];
DOUT << "ARGV[" << i << "] = " << (void*)Dest << "\n"; DOUT << "JIT: ARGV[" << i << "] = " << (void*)Dest << "\n";
std::copy(InputArgv[i].begin(), InputArgv[i].end(), Dest); std::copy(InputArgv[i].begin(), InputArgv[i].end(), Dest);
Dest[Size-1] = 0; Dest[Size-1] = 0;
@@ -839,7 +839,7 @@ void ExecutionEngine::LoadValueFromMemory(GenericValue &Result,
// specified memory location... // specified memory location...
// //
void ExecutionEngine::InitializeMemory(const Constant *Init, void *Addr) { void ExecutionEngine::InitializeMemory(const Constant *Init, void *Addr) {
DOUT << "Initializing " << Addr << " "; DOUT << "JIT: Initializing " << Addr << " ";
DEBUG(Init->dump()); DEBUG(Init->dump());
if (isa<UndefValue>(Init)) { if (isa<UndefValue>(Init)) {
return; return;
@@ -989,7 +989,6 @@ void ExecutionEngine::emitGlobals() {
// already in the map. // already in the map.
void ExecutionEngine::EmitGlobalVariable(const GlobalVariable *GV) { void ExecutionEngine::EmitGlobalVariable(const GlobalVariable *GV) {
void *GA = getPointerToGlobalIfAvailable(GV); void *GA = getPointerToGlobalIfAvailable(GV);
DOUT << "Global '" << GV->getName() << "' -> " << GA << "\n";
if (GA == 0) { if (GA == 0) {
// If it's not already specified, allocate memory for the global. // If it's not already specified, allocate memory for the global.

View File

@@ -226,7 +226,7 @@ unsigned JITResolver::getGOTIndexForAddr(void* addr) {
if (!idx) { if (!idx) {
idx = ++nextGOTIndex; idx = ++nextGOTIndex;
revGOTMap[addr] = idx; revGOTMap[addr] = idx;
DOUT << "Adding GOT entry " << idx << " for addr " << addr << "\n"; DOUT << "JIT: Adding GOT entry " << idx << " for addr " << addr << "\n";
} }
return idx; return idx;
} }
@@ -664,7 +664,7 @@ unsigned JITEmitter::addSizeOfGlobal(const GlobalVariable *GV, unsigned Size) {
size_t GVSize = (size_t)TheJIT->getTargetData()->getABITypeSize(ElTy); size_t GVSize = (size_t)TheJIT->getTargetData()->getABITypeSize(ElTy);
size_t GVAlign = size_t GVAlign =
(size_t)TheJIT->getTargetData()->getPreferredAlignment(GV); (size_t)TheJIT->getTargetData()->getPreferredAlignment(GV);
DOUT << "Adding in size " << GVSize << " alignment " << GVAlign; DOUT << "JIT: Adding in size " << GVSize << " alignment " << GVAlign;
DEBUG(GV->dump()); DEBUG(GV->dump());
// Assume code section ends with worst possible alignment, so first // Assume code section ends with worst possible alignment, so first
// variable needs maximal padding. // variable needs maximal padding.
@@ -787,7 +787,7 @@ unsigned JITEmitter::GetSizeOfGlobalsInBytes(MachineFunction &MF) {
} }
} }
} }
DOUT << "About to look through initializers\n"; DOUT << "JIT: About to look through initializers\n";
// Look for more globals that are referenced only from initializers. // Look for more globals that are referenced only from initializers.
// GVSet.end is computed each time because the set can grow as we go. // GVSet.end is computed each time because the set can grow as we go.
for (std::set<const GlobalVariable *>::iterator I = GVSet.begin(); for (std::set<const GlobalVariable *>::iterator I = GVSet.begin();
@@ -801,11 +801,14 @@ unsigned JITEmitter::GetSizeOfGlobalsInBytes(MachineFunction &MF) {
} }
void JITEmitter::startFunction(MachineFunction &F) { void JITEmitter::startFunction(MachineFunction &F) {
DOUT << "JIT: Starting CodeGen of Function "
<< F.getFunction()->getName() << "\n";
uintptr_t ActualSize = 0; uintptr_t ActualSize = 0;
// Set the memory writable, if it's not already // Set the memory writable, if it's not already
MemMgr->setMemoryWritable(); MemMgr->setMemoryWritable();
if (MemMgr->NeedsExactSize()) { if (MemMgr->NeedsExactSize()) {
DOUT << "ExactSize\n"; DOUT << "JIT: ExactSize\n";
const TargetInstrInfo* TII = F.getTarget().getInstrInfo(); const TargetInstrInfo* TII = F.getTarget().getInstrInfo();
MachineJumpTableInfo *MJTI = F.getJumpTableInfo(); MachineJumpTableInfo *MJTI = F.getJumpTableInfo();
MachineConstantPool *MCP = F.getConstantPool(); MachineConstantPool *MCP = F.getConstantPool();
@@ -833,12 +836,12 @@ void JITEmitter::startFunction(MachineFunction &F) {
// Add the function size // Add the function size
ActualSize += TII->GetFunctionSizeInBytes(F); ActualSize += TII->GetFunctionSizeInBytes(F);
DOUT << "ActualSize before globals " << ActualSize << "\n"; DOUT << "JIT: ActualSize before globals " << ActualSize << "\n";
// Add the size of the globals that will be allocated after this function. // Add the size of the globals that will be allocated after this function.
// These are all the ones referenced from this function that were not // These are all the ones referenced from this function that were not
// previously allocated. // previously allocated.
ActualSize += GetSizeOfGlobalsInBytes(F); ActualSize += GetSizeOfGlobalsInBytes(F);
DOUT << "ActualSize after globals " << ActualSize << "\n"; DOUT << "JIT: ActualSize after globals " << ActualSize << "\n";
} }
BufferBegin = CurBufferPtr = MemMgr->startFunctionBody(F.getFunction(), BufferBegin = CurBufferPtr = MemMgr->startFunctionBody(F.getFunction(),
@@ -912,7 +915,7 @@ bool JITEmitter::finishFunction(MachineFunction &F) {
unsigned idx = Resolver.getGOTIndexForAddr(ResultPtr); unsigned idx = Resolver.getGOTIndexForAddr(ResultPtr);
MR.setGOTIndex(idx); MR.setGOTIndex(idx);
if (((void**)MemMgr->getGOTBase())[idx] != ResultPtr) { if (((void**)MemMgr->getGOTBase())[idx] != ResultPtr) {
DOUT << "GOT was out of date for " << ResultPtr DOUT << "JIT: GOT was out of date for " << ResultPtr
<< " pointing at " << ((void**)MemMgr->getGOTBase())[idx] << " pointing at " << ((void**)MemMgr->getGOTBase())[idx]
<< "\n"; << "\n";
((void**)MemMgr->getGOTBase())[idx] = ResultPtr; ((void**)MemMgr->getGOTBase())[idx] = ResultPtr;
@@ -928,7 +931,7 @@ bool JITEmitter::finishFunction(MachineFunction &F) {
if (MemMgr->isManagingGOT()) { if (MemMgr->isManagingGOT()) {
unsigned idx = Resolver.getGOTIndexForAddr((void*)BufferBegin); unsigned idx = Resolver.getGOTIndexForAddr((void*)BufferBegin);
if (((void**)MemMgr->getGOTBase())[idx] != (void*)BufferBegin) { if (((void**)MemMgr->getGOTBase())[idx] != (void*)BufferBegin) {
DOUT << "GOT was out of date for " << (void*)BufferBegin DOUT << "JIT: GOT was out of date for " << (void*)BufferBegin
<< " pointing at " << ((void**)MemMgr->getGOTBase())[idx] << "\n"; << " pointing at " << ((void**)MemMgr->getGOTBase())[idx] << "\n";
((void**)MemMgr->getGOTBase())[idx] = (void*)BufferBegin; ((void**)MemMgr->getGOTBase())[idx] = (void*)BufferBegin;
} }
@@ -958,16 +961,16 @@ bool JITEmitter::finishFunction(MachineFunction &F) {
#ifndef NDEBUG #ifndef NDEBUG
{ {
DOUT << "JIT: Disassembled code:\n";
if (sys::hasDisassembler()) if (sys::hasDisassembler())
DOUT << "Disassembled code:\n" DOUT << sys::disassembleBuffer(FnStart, FnEnd-FnStart, (uintptr_t)FnStart);
<< sys::disassembleBuffer(FnStart, FnEnd-FnStart, (uintptr_t)FnStart);
else { else {
DOUT << std::hex; DOUT << std::hex;
int i; int i;
unsigned char* q = FnStart; unsigned char* q = FnStart;
for (i=1; q!=FnEnd; q++, i++) { for (i=1; q!=FnEnd; q++, i++) {
if (i%8==1) if (i%8==1)
DOUT << "0x" << (long)q << ": "; DOUT << "JIT: 0x" << (long)q << ": ";
DOUT<< std::setw(2) << std::setfill('0') << (unsigned short)*q << " "; DOUT<< std::setw(2) << std::setfill('0') << (unsigned short)*q << " ";
if (i%8==0) if (i%8==0)
DOUT << '\n'; DOUT << '\n';