aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ExecutionEngine
diff options
context:
space:
mode:
authorMisha Brukman <brukman+llvm@gmail.com>2003-05-30 20:39:37 +0000
committerMisha Brukman <brukman+llvm@gmail.com>2003-05-30 20:39:37 +0000
commit417a7c06e8c0d891820050a8eca4c9b11d7b0377 (patch)
tree8544b3fe82e97d6d0a57d29415cecb6de5c37b5c /lib/ExecutionEngine
parent88ba25444c0542f43dc678392c7fc39fda7488e2 (diff)
downloadexternal_llvm-417a7c06e8c0d891820050a8eca4c9b11d7b0377.zip
external_llvm-417a7c06e8c0d891820050a8eca4c9b11d7b0377.tar.gz
external_llvm-417a7c06e8c0d891820050a8eca4c9b11d7b0377.tar.bz2
Since malloc is no longer used, no need to free() memory.
Fixed BasicBlock patching by supplying correct type for the displacement. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6453 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine')
-rw-r--r--lib/ExecutionEngine/JIT/SparcEmitter.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/lib/ExecutionEngine/JIT/SparcEmitter.cpp b/lib/ExecutionEngine/JIT/SparcEmitter.cpp
index 601be92..f2a62d2 100644
--- a/lib/ExecutionEngine/JIT/SparcEmitter.cpp
+++ b/lib/ExecutionEngine/JIT/SparcEmitter.cpp
@@ -32,16 +32,8 @@ namespace {
std::pair<unsigned*,MachineInstr*> > > BBRefs;
std::map<BasicBlock*, unsigned> BBLocations;
std::vector<void*> ConstantPoolAddresses;
- std::vector<void*> funcMemory;
public:
SparcEmitter(VM &vm) : TheVM(vm) {}
- ~SparcEmitter() {
- while (! funcMemory.empty()) {
- void* addr = funcMemory.back();
- free(addr);
- funcMemory.pop_back();
- }
- }
virtual void startFunction(MachineFunction &F);
virtual void finishFunction(MachineFunction &F);
@@ -76,12 +68,12 @@ MachineCodeEmitter *VM::createSparcEmitter(VM &V) {
// FIXME: This should be rewritten to support a real memory manager for
// executable memory pages!
-void * SparcEmitter::getMemory(unsigned NumPages) {
+void* SparcEmitter::getMemory(unsigned NumPages) {
void *pa;
if (NumPages == 0) return 0;
static const long pageSize = sysconf (_SC_PAGESIZE);
pa = mmap(0, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
- MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
if (pa == MAP_FAILED) {
perror("mmap");
abort();
@@ -91,28 +83,32 @@ void * SparcEmitter::getMemory(unsigned NumPages) {
void SparcEmitter::startFunction(MachineFunction &F) {
- CurBlock = (unsigned char *)getMemory(8);
std::cerr << "Starting function " << F.getFunction()->getName() << "\n";
+ CurBlock = (unsigned char *)getMemory(8);
CurByte = CurBlock; // Start writing at the beginning of the fn.
TheVM.addGlobalMapping(F.getFunction(), CurBlock);
}
void SparcEmitter::finishFunction(MachineFunction &F) {
+ std::cerr << "Finishing function " << F.getFunction()->getName() << "\n";
ConstantPoolAddresses.clear();
// Re-write branches to BasicBlocks for the entire function
for (unsigned i = 0, e = BBRefs.size(); i != e; ++i) {
unsigned Location = BBLocations[BBRefs[i].first];
unsigned *Ref = BBRefs[i].second.first;
MachineInstr *MI = BBRefs[i].second.second;
+ std::cerr << "attempting to resolve BB: " << i << "\n";
for (unsigned i=0, e = MI->getNumOperands(); i != e; ++i) {
MachineOperand &op = MI->getOperand(i);
- if (op.isImmediate()) {
- MI->SetMachineOperandConst(i, op.getType(), Location);
+ if (op.isPCRelativeDisp()) {
+ MI->SetMachineOperandConst(i, MachineOperand::MO_SignExtendedImmed,
+ Location);
+ std::cerr << "Rewrote BB ref: ";
+ unsigned fixedInstr = SparcV9CodeEmitter::getBinaryCodeForInstr(*MI);
+ *Ref = fixedInstr;
break;
}
}
- unsigned fixedInstr = SparcV9CodeEmitter::getBinaryCodeForInstr(*MI);
- *Ref = fixedInstr;
}
BBRefs.clear();
BBLocations.clear();