aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-06-25 16:13:21 +0000
committerChris Lattner <sabre@nondot.org>2002-06-25 16:13:21 +0000
commit0b12b5f50ec77a8bd01b92d287c52d748619bb4b (patch)
tree5764db59facb124b023f1de96f0e45d37657c82e
parent18961504fc2b299578dba817900a0696cf3ccc4d (diff)
MEGAPATCH checkin.
For details, See: docs/2002-06-25-MegaPatchInfo.txt git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2778 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Bytecode/Reader/Reader.cpp5
-rw-r--r--lib/Bytecode/Writer/InstructionWriter.cpp34
-rw-r--r--lib/Bytecode/Writer/Writer.cpp42
-rw-r--r--lib/Bytecode/Writer/WriterInternals.h4
-rw-r--r--lib/CodeGen/InstrSelection/InstrForest.cpp8
-rw-r--r--lib/CodeGen/InstrSelection/InstrSelection.cpp79
-rw-r--r--lib/CodeGen/MachineFunction.cpp76
-rw-r--r--lib/ExecutionEngine/Interpreter/Execution.cpp227
-rw-r--r--lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp3
-rw-r--r--lib/ExecutionEngine/Interpreter/Interpreter.h8
-rw-r--r--lib/Target/SparcV9/EmitBytecodeToAssembly.cpp4
-rw-r--r--lib/Target/SparcV9/InstrSelection/InstrForest.cpp8
-rw-r--r--lib/Target/SparcV9/InstrSelection/InstrSelection.cpp79
-rw-r--r--lib/Target/SparcV9/SparcV9AsmPrinter.cpp64
-rw-r--r--lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp58
-rw-r--r--lib/Target/SparcV9/SparcV9RegInfo.cpp52
-rw-r--r--lib/Target/SparcV9/SparcV9TargetMachine.cpp29
-rw-r--r--lib/Transforms/IPO/GlobalDCE.cpp19
-rw-r--r--lib/Transforms/IPO/Internalize.cpp14
-rw-r--r--lib/Transforms/IPO/MutateStructTypes.cpp167
-rw-r--r--lib/Transforms/IPO/OldPoolAllocate.cpp264
-rw-r--r--lib/Transforms/IPO/SimpleStructMutation.cpp6
-rw-r--r--lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp65
-rw-r--r--lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp24
-rw-r--r--tools/analyze/analyze.cpp39
-rw-r--r--tools/gccld/gccld.cpp2
26 files changed, 654 insertions, 726 deletions
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index c4ab67f91b..f84ad565ca 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/lib/Bytecode/Reader/Reader.cpp
@@ -18,7 +18,6 @@
#include "llvm/Constants.h"
#include "llvm/iPHINode.h"
#include "llvm/iOther.h"
-#include "llvm/Argument.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
@@ -312,7 +311,7 @@ bool BytecodeParser::ParseMethod(const uchar *&Buf, const uchar *EndBuf,
delete M; return failure(true); // Parse error... :(
}
- M->getBasicBlocks().push_back(BB);
+ M->getBasicBlockList().push_back(BB);
break;
}
@@ -368,7 +367,7 @@ bool BytecodeParser::ParseMethod(const uchar *&Buf, const uchar *EndBuf,
// If the method is empty, we don't need the method argument entries...
if (M->isExternal())
- M->getArgumentList().delete_all();
+ M->getArgumentList().clear();
DeclareNewGlobalValue(M, MethSlot);
diff --git a/lib/Bytecode/Writer/InstructionWriter.cpp b/lib/Bytecode/Writer/InstructionWriter.cpp
index 227980a75e..36414bea94 100644
--- a/lib/Bytecode/Writer/InstructionWriter.cpp
+++ b/lib/Bytecode/Writer/InstructionWriter.cpp
@@ -169,15 +169,15 @@ static void outputInstructionFormat3(const Instruction *I,
output(Bits, Out);
}
-void BytecodeWriter::processInstruction(const Instruction *I) {
- assert(I->getOpcode() < 64 && "Opcode too big???");
+void BytecodeWriter::processInstruction(const Instruction &I) {
+ assert(I.getOpcode() < 64 && "Opcode too big???");
- unsigned NumOperands = I->getNumOperands();
+ unsigned NumOperands = I.getNumOperands();
int MaxOpSlot = 0;
int Slots[3]; Slots[0] = (1 << 12)-1; // Marker to signify 0 operands
for (unsigned i = 0; i < NumOperands; ++i) {
- const Value *Def = I->getOperand(i);
+ const Value *Def = I.getOperand(i);
int slot = Table.getValSlot(Def);
assert(slot != -1 && "Broken bytecode!");
if (slot > MaxOpSlot) MaxOpSlot = slot;
@@ -191,17 +191,17 @@ void BytecodeWriter::processInstruction(const Instruction *I) {
// we take the type of the instruction itself.
//
const Type *Ty;
- switch (I->getOpcode()) {
+ switch (I.getOpcode()) {
case Instruction::Malloc:
case Instruction::Alloca:
- Ty = I->getType(); // Malloc & Alloca ALWAYS want to encode the return type
+ Ty = I.getType(); // Malloc & Alloca ALWAYS want to encode the return type
break;
case Instruction::Store:
- Ty = I->getOperand(1)->getType(); // Encode the pointer type...
+ Ty = I.getOperand(1)->getType(); // Encode the pointer type...
assert(isa<PointerType>(Ty) && "Store to nonpointer type!?!?");
break;
default: // Otherwise use the default behavior...
- Ty = NumOperands ? I->getOperand(0)->getType() : I->getType();
+ Ty = NumOperands ? I.getOperand(0)->getType() : I.getType();
break;
}
@@ -219,20 +219,20 @@ void BytecodeWriter::processInstruction(const Instruction *I) {
if (isa<CastInst>(I)) {
// Cast has to encode the destination type as the second argument in the
// packet, or else we won't know what type to cast to!
- Slots[1] = Table.getValSlot(I->getType());
+ Slots[1] = Table.getValSlot(I.getType());
assert(Slots[1] != -1 && "Cast return type unknown?");
if (Slots[1] > MaxOpSlot) MaxOpSlot = Slots[1];
NumOperands++;
- } else if (const CallInst *CI = dyn_cast<CallInst>(I)) {// Handle VarArg calls
+ } else if (const CallInst *CI = dyn_cast<CallInst>(&I)){// Handle VarArg calls
const PointerType *Ty = cast<PointerType>(CI->getCalledValue()->getType());
if (cast<FunctionType>(Ty->getElementType())->isVarArg()) {
- outputInstrVarArgsCall(I, Table, Type, Out);
+ outputInstrVarArgsCall(CI, Table, Type, Out);
return;
}
- } else if (const InvokeInst *II = dyn_cast<InvokeInst>(I)) { // ... & Invokes
+ } else if (const InvokeInst *II = dyn_cast<InvokeInst>(&I)) {// ... & Invokes
const PointerType *Ty = cast<PointerType>(II->getCalledValue()->getType());
if (cast<FunctionType>(Ty->getElementType())->isVarArg()) {
- outputInstrVarArgsCall(I, Table, Type, Out);
+ outputInstrVarArgsCall(II, Table, Type, Out);
return;
}
}
@@ -246,21 +246,21 @@ void BytecodeWriter::processInstruction(const Instruction *I) {
case 0:
case 1:
if (MaxOpSlot < (1 << 12)-1) { // -1 because we use 4095 to indicate 0 ops
- outputInstructionFormat1(I, Table, Slots, Type, Out);
+ outputInstructionFormat1(&I, Table, Slots, Type, Out);
return;
}
break;
case 2:
if (MaxOpSlot < (1 << 8)) {
- outputInstructionFormat2(I, Table, Slots, Type, Out);
+ outputInstructionFormat2(&I, Table, Slots, Type, Out);
return;
}
break;
case 3:
if (MaxOpSlot < (1 << 6)) {
- outputInstructionFormat3(I, Table, Slots, Type, Out);
+ outputInstructionFormat3(&I, Table, Slots, Type, Out);
return;
}
break;
@@ -268,5 +268,5 @@ void BytecodeWriter::processInstruction(const Instruction *I) {
// If we weren't handled before here, we either have a large number of
// operands or a large operand index that we are refering to.
- outputInstructionFormat0(I, Table, Type, Out);
+ outputInstructionFormat0(&I, Table, Type, Out);
}
diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp
index 145004b716..5545834ff7 100644
--- a/lib/Bytecode/Writer/Writer.cpp
+++ b/lib/Bytecode/Writer/Writer.cpp
@@ -21,9 +21,6 @@
#include "WriterInternals.h"
#include "llvm/Module.h"
-#include "llvm/GlobalVariable.h"
-#include "llvm/Function.h"
-#include "llvm/BasicBlock.h"
#include "llvm/SymbolTable.h"
#include "llvm/DerivedTypes.h"
#include "Support/STLExtras.h"
@@ -49,8 +46,8 @@ BytecodeWriter::BytecodeWriter(std::deque<unsigned char> &o, const Module *M)
outputModuleInfoBlock(M);
// Do the whole module now! Process each function at a time...
- for_each(M->begin(), M->end(),
- bind_obj(this, &BytecodeWriter::processMethod));
+ for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I)
+ processMethod(I);
// If needed, output the symbol table for the module...
if (M->hasSymbolTable())
@@ -112,19 +109,18 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
// Output the types for the global variables in the module...
for (Module::const_giterator I = M->gbegin(), End = M->gend(); I != End;++I) {
- const GlobalVariable *GV = *I;
- int Slot = Table.getValSlot(GV->getType());
+ int Slot = Table.getValSlot(I->getType());
assert(Slot != -1 && "Module global vars is broken!");
// Fields: bit0 = isConstant, bit1 = hasInitializer, bit2=InternalLinkage,
// bit3+ = slot#
- unsigned oSlot = ((unsigned)Slot << 3) | (GV->hasInternalLinkage() << 2) |
- (GV->hasInitializer() << 1) | GV->isConstant();
+ unsigned oSlot = ((unsigned)Slot << 3) | (I->hasInternalLinkage() << 2) |
+ (I->hasInitializer() << 1) | I->isConstant();
output_vbr(oSlot, Out);
// If we have an initializer, output it now.
- if (GV->hasInitializer()) {
- Slot = Table.getValSlot((Value*)GV->getInitializer());
+ if (I->hasInitializer()) {
+ Slot = Table.getValSlot((Value*)I->getInitializer());
assert(Slot != -1 && "No slot for global var initializer!");
output_vbr((unsigned)Slot, Out);
}
@@ -133,7 +129,7 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
// Output the types of the functions in this module...
for (Module::const_iterator I = M->begin(), End = M->end(); I != End; ++I) {
- int Slot = Table.getValSlot((*I)->getType());
+ int Slot = Table.getValSlot(I->getType());
assert(Slot != -1 && "Module const pool is broken!");
assert(Slot >= Type::FirstDerivedTyID && "Derived type not in range!");
output_vbr((unsigned)Slot, Out);
@@ -144,36 +140,36 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
align32(Out);
}
-void BytecodeWriter::processMethod(const Function *M) {
+void BytecodeWriter::processMethod(const Function *F) {
BytecodeBlock FunctionBlock(BytecodeFormat::Function, Out);
- output_vbr((unsigned)M->hasInternalLinkage(), Out);
+ output_vbr((unsigned)F->hasInternalLinkage(), Out);
// Only output the constant pool and other goodies if needed...
- if (!M->isExternal()) {
+ if (!F->isExternal()) {
// Get slot information about the function...
- Table.incorporateFunction(M);
+ Table.incorporateFunction(F);
// Output information about the constants in the function...
outputConstants(true);
// Output basic block nodes...
- for_each(M->begin(), M->end(),
- bind_obj(this, &BytecodeWriter::processBasicBlock));
+ for (Function::const_iterator I = F->begin(), E = F->end(); I != E; ++I)
+ processBasicBlock(*I);
// If needed, output the symbol table for the function...
- if (M->hasSymbolTable())
- outputSymbolTable(*M->getSymbolTable());
+ if (F->hasSymbolTable())
+ outputSymbolTable(*F->getSymbolTable());
Table.purgeFunction();
}
}
-void BytecodeWriter::processBasicBlock(const BasicBlock *BB) {
+void BytecodeWriter::processBasicBlock(const BasicBlock &BB) {
BytecodeBlock FunctionBlock(BytecodeFormat::BasicBlock, Out);
// Process all the instructions in the bb...
- for_each(BB->begin(), BB->end(),
- bind_obj(this, &BytecodeWriter::processInstruction));
+ for(BasicBlock::const_iterator I = BB.begin(), E = BB.end(); I != E; ++I)
+ processInstruction(*I);
}
void BytecodeWriter::outputSymbolTable(const SymbolTable &MST) {
diff --git a/lib/Bytecode/Writer/WriterInternals.h b/lib/Bytecode/Writer/WriterInternals.h
index bd4a328826..7b54a56497 100644
--- a/lib/Bytecode/Writer/WriterInternals.h
+++ b/lib/Bytecode/Writer/WriterInternals.h
@@ -27,8 +27,8 @@ public:
protected:
void outputConstants(bool isMethod);
void processMethod(const Function *F);
- void processBasicBlock(const BasicBlock *BB);
- void processInstruction(const Instruction *I);
+ void processBasicBlock(const BasicBlock &BB);
+ void processInstruction(const Instruction &I);
private :
inline void outputSignature() {
diff --git a/lib/CodeGen/InstrSelection/InstrForest.cpp b/lib/CodeGen/InstrSelection/InstrForest.cpp
index 4a08c24704..a95f1e377a 100644
--- a/lib/CodeGen/InstrSelection/InstrForest.cpp
+++ b/lib/CodeGen/InstrSelection/InstrForest.cpp
@@ -25,7 +25,6 @@
#include "llvm/iTerminators.h"
#include "llvm/iMemory.h"
#include "llvm/Constant.h"
-#include "llvm/BasicBlock.h"
#include "llvm/Type.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "Support/STLExtras.h"
@@ -188,10 +187,9 @@ LabelNode::dumpNode(int indent) const
InstrForest::InstrForest(Function *F)
{
- for (Function::iterator FI = F->begin(), FE = F->end(); FI != FE; ++FI) {
- BasicBlock *BB = *FI;
- for_each(BB->begin(), BB->end(),
- bind_obj(this, &InstrForest::buildTreeForInstruction));
+ for (Function::iterator BB = F->begin(), FE = F->end(); BB != FE; ++BB) {
+ for(BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
+ buildTreeForInstruction(I);
}
}
diff --git a/lib/CodeGen/InstrSelection/InstrSelection.cpp b/lib/CodeGen/InstrSelection/InstrSelection.cpp
index 614c5f6773..b27f9022bb 100644
--- a/lib/CodeGen/InstrSelection/InstrSelection.cpp
+++ b/lib/CodeGen/InstrSelection/InstrSelection.cpp
@@ -123,14 +123,10 @@ SelectInstructionsForMethod(Function *F, TargetMachine &target)
// Record instructions in the vector for each basic block
//
for (Function::iterator BI = F->begin(), BE = F->end(); BI != BE; ++BI)
- {
- MachineCodeForBasicBlock& bbMvec = (*BI)->getMachineInstrVec();
- for (BasicBlock::iterator II = (*BI)->begin(); II != (*BI)->end(); ++II)
- {
- MachineCodeForInstruction &mvec =MachineCodeForInstruction::get(*II);
- for (unsigned i=0; i < mvec.size(); i++)
- bbMvec.push_back(mvec[i]);
- }
+ for (BasicBlock::iterator II = BI->begin(); II != BI->end(); ++II) {
+ MachineCodeForInstruction &mvec =MachineCodeForInstruction::get(II);
+ for (unsigned i=0; i < mvec.size(); i++)
+ BI->getMachineInstrVec().push_back(mvec[i]);
}
// Insert phi elimination code -- added by Ruchira
@@ -191,49 +187,38 @@ InsertCode4AllPhisInMeth(Function *F, TargetMachine &target)
{
// for all basic blocks in function
//
- for (Function::iterator BI = F->begin(); BI != F->end(); ++BI) {
-
- BasicBlock *BB = *BI;
- const BasicBlock::InstListType &InstList = BB->getInstList();
- BasicBlock::InstListType::const_iterator IIt = InstList.begin();
-
- // for all instructions in the basic block
- //
- for( ; IIt != InstList.end(); ++IIt ) {
-
- if (PHINode *PN = dyn_cast<PHINode>(*IIt)) {
- // FIXME: This is probably wrong...
- Value *PhiCpRes = new PHINode(PN->getType(), "PhiCp:");
-
- // for each incoming value of the phi, insert phi elimination
- //
- for (unsigned i = 0; i < PN->getNumIncomingValues(); ++i)
- { // insert the copy instruction to the predecessor BB
- vector<MachineInstr*> mvec, CpVec;
- target.getRegInfo().cpValue2Value(PN->getIncomingValue(i), PhiCpRes,
- mvec);
- for (vector<MachineInstr*>::iterator MI=mvec.begin();
- MI != mvec.end(); ++MI)
- {
- vector<MachineInstr*> CpVec2 =
- FixConstantOperandsForInstr(PN, *MI, target);
- CpVec2.push_back(*MI);
- CpVec.insert(CpVec.end(), CpVec2.begin(), CpVec2.end());
- }
-
- InsertPhiElimInstructions(PN->getIncomingBlock(i), CpVec);
- }
+ for (Function::iterator BB = F->begin(); BB != F->end(); ++BB) {
+ BasicBlock::InstListType &InstList = BB->getInstList();
+ for (BasicBlock::iterator IIt = InstList.begin();
+ PHINode *PN = dyn_cast<PHINode>(&*IIt); ++IIt) {
+ // FIXME: This is probably wrong...
+ Value *PhiCpRes = new PHINode(PN->getType(), "PhiCp:");
- vector<MachineInstr*> mvec;
- target.getRegInfo().cpValue2Value(PhiCpRes, PN, mvec);
+ // for each incoming value of the phi, insert phi elimination
+ //
+ for (unsigned i = 0; i < PN->getNumIncomingValues(); ++i) {
+ // insert the copy instruction to the predecessor BB
+ vector<MachineInstr*> mvec, CpVec;
+ target.getRegInfo().cpValue2Value(PN->getIncomingValue(i), PhiCpRes,
+ mvec);
+ for (vector<MachineInstr*>::iterator MI=mvec.begin();
+ MI != mvec.end(); ++MI) {
+ vector<MachineInstr*> CpVec2 =
+ FixConstantOperandsForInstr(PN, *MI, target);
+ CpVec2.push_back(*MI);
+ CpVec.insert(CpVec.end(), CpVec2.begin(), CpVec2.end());
+ }
- // get an iterator to machine instructions in the BB
- MachineCodeForBasicBlock& bbMvec = BB->getMachineInstrVec();
-
- bbMvec.insert( bbMvec.begin(), mvec.begin(), mvec.end());
+ InsertPhiElimInstructions(PN->getIncomingBlock(i), CpVec);
}
- else break; // since PHI nodes can only be at the top
+ vector<MachineInstr*> mvec;
+ target.getRegInfo().cpValue2Value(PhiCpRes, PN, mvec);
+
+ // get an iterator to machine instructions in the BB
+ MachineCodeForBasicBlock& bbMvec = BB->getMachineInstrVec();
+
+ bbMvec.insert(bbMvec.begin(), mvec.begin(), mvec.end());
} // for each Phi Instr in BB
} // for all BBs in function
}
diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp
index 06e0666ec8..4d50f89729 100644
--- a/lib/CodeGen/MachineFunction.cpp
+++ b/lib/CodeGen/MachineFunction.cpp
@@ -60,43 +60,40 @@ ComputeMaxOptionalArgsSize(const TargetMachine& target, const Function *F,
{
const MachineFrameInfo& frameInfo = target.getFrameInfo();
- unsigned int maxSize = 0;
+ unsigned maxSize = 0;
- for (Function::const_iterator MI = F->begin(), ME = F->end(); MI != ME; ++MI)
- {
- const BasicBlock *BB = *MI;
- for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I)
- if (CallInst *callInst = dyn_cast<CallInst>(*I))
- {
- unsigned int numOperands = callInst->getNumOperands() - 1;
- int numExtra =(int)numOperands-frameInfo.getNumFixedOutgoingArgs();
- if (numExtra <= 0)
- continue;
-
- unsigned int sizeForThisCall;
- if (frameInfo.argsOnStackHaveFixedSize())
- {
- int argSize = frameInfo.getSizeOfEachArgOnStack();
- sizeForThisCall = numExtra * (unsigned) argSize;
- }
- else
- {
- assert(0 && "UNTESTED CODE: Size per stack argument is not "
- "fixed on this architecture: use actual arg sizes to "
- "compute MaxOptionalArgsSize");
- sizeForThisCall = 0;
- for (unsigned i=0; i < numOperands; ++i)
- sizeForThisCall += target.findOptimalStorageSize(callInst->
- getOperand(i)->getType());
- }
-
- if (maxSize < sizeForThisCall)
- maxSize = sizeForThisCall;
-
- if (((int) maxOptionalNumArgs) < numExtra)
- maxOptionalNumArgs = (unsigned) numExtra;
- }
- }
+ for (Function::const_iterator BB = F->begin(), BBE = F->end(); BB !=BBE; ++BB)
+ for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I)
+ if (const CallInst *callInst = dyn_cast<CallInst>(&*I))
+ {
+ unsigned numOperands = callInst->getNumOperands() - 1;
+ int numExtra = (int)numOperands-frameInfo.getNumFixedOutgoingArgs();
+ if (numExtra <= 0)
+ continue;
+
+ unsigned int sizeForThisCall;
+ if (frameInfo.argsOnStackHaveFixedSize())
+ {
+ int argSize = frameInfo.getSizeOfEachArgOnStack();
+ sizeForThisCall = numExtra * (unsigned) argSize;
+ }
+ else
+ {
+ assert(0 && "UNTESTED CODE: Size per stack argument is not "
+ "fixed on this architecture: use actual arg sizes to "
+ "compute MaxOptionalArgsSize");
+ sizeForThisCall = 0;
+ for (unsigned i = 0; i < numOperands; ++i)
+ sizeForThisCall += target.findOptimalStorageSize(callInst->
+ getOperand(i)->getType());
+ }
+
+ if (maxSize < sizeForThisCall)
+ maxSize = sizeForThisCall;
+
+ if ((int)maxOptionalNumArgs < numExtra)
+ maxOptionalNumArgs = (unsigned) numExtra;
+ }
return maxSize;
}
@@ -278,12 +275,11 @@ MachineCodeForMethod::dump() const
std::cerr << "\n" << method->getReturnType()
<< " \"" << method->getName() << "\"\n";
- for (Function::const_iterator BI = method->begin(); BI != method->end(); ++BI)
+ for (Function::const_iterator BB = method->begin(); BB != method->end(); ++BB)
{
- BasicBlock* bb = *BI;
- std::cerr << "\n" << bb->getName() << " (" << bb << ")" << ":\n";
+ std::cerr << "\n" << BB->getName() << " (" << *BB << ")" << ":\n";
- MachineCodeForBasicBlock& mvec = bb->getMachineInstrVec();
+ MachineCodeForBasicBlock& mvec = BB->getMachineInstrVec();
for (unsigned i=0; i < mvec.size(); i++)
std::cerr << "\t" << *mvec[i];
}
diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp
index 8ba41158fe..07ad8003c3 100644
--- a/lib/ExecutionEngine/Interpreter/Execution.cpp
+++ b/lib/ExecutionEngine/Interpreter/Execution.cpp
@@ -168,7 +168,7 @@ void Interpreter::initializeExecutionEngine() {
// InitializeMemory - Recursive function to apply a Constant value into the
// specified memory location...
//
-static void InitializeMemory(Constant *Init, char *Addr) {
+static void InitializeMemory(const Constant *Init, char *Addr) {
#define INITIALIZE_MEMORY(TYID, CLASS, TY) \
case Type::TYID##TyID: { \
TY Tmp = cast<CLASS>(Init)->getValue(); \
@@ -190,7 +190,7 @@ static void InitializeMemory(Constant *Init, char *Addr) {
#undef INITIALIZE_MEMORY
case Type::ArrayTyID: {
- ConstantArray *CPA = cast<ConstantArray>(Init);
+ const ConstantArray *CPA = cast<ConstantArray>(Init);
const vector<Use> &Val = CPA->getValues();
unsigned ElementSize =
TD.getTypeSize(cast<ArrayType>(CPA->getType())->getElementType());
@@ -200,7 +200,7 @@ static void InitializeMemory(Constant *Init, char *Addr) {
}
case Type::StructTyID: {
- ConstantStruct *CPS = cast<ConstantStruct>(Init);
+ const ConstantStruct *CPS = cast<ConstantStruct>(Init);
const StructLayout *SL=TD.getStructLayout(cast<StructType>(CPS->getType()));
const vector<Use> &Val = CPS->getValues();
for (unsigned i = 0; i < Val.size(); ++i)
@@ -212,7 +212,8 @@ static void InitializeMemory(Constant *Init, char *Addr) {
case Type::PointerTyID:
if (isa<ConstantPointerNull>(Init)) {
*(void**)Addr = 0;
- } else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Init)) {
+ } else if (const ConstantPointerRef *CPR =
+ dyn_cast<ConstantPointerRef>(Init)) {
GlobalAddress *Address =
(GlobalAddress*)CPR->getValue()->getOrCreateAnnotation(GlobalAddressAID);
*(void**)Addr = (GenericValue*)Address->Ptr;
@@ -266,9 +267,9 @@ Annotation *GlobalAddress::Create(AnnotationID AID, const Annotable *O, void *){
#define IMPLEMENT_UNARY_OPERATOR(OP, TY) \
case Type::TY##TyID: Dest.TY##Val = OP Src.TY##Val; break
-static void executeNotInst(UnaryOperator *I, ExecutionContext &SF) {
- const Type *Ty = I->getOperand(0)->getType();
- GenericValue Src = getOperandValue(I->getOperand(0), SF);
+static void executeNotInst(UnaryOperator &I, ExecutionContext &SF) {
+ const Type *Ty = I.getOperand(0)->getType();
+ GenericValue Src = getOperandValue(I.getOperand(0), SF);
GenericValue Dest;
switch (Ty->getPrimitiveID()) {
IMPLEMENT_UNARY_OPERATOR(~, UByte);
@@ -283,7 +284,7 @@ static void executeNotInst(UnaryOperator *I, ExecutionContext &SF) {
default:
cout << "Unhandled type for Not instruction: " << Ty << "\n";
}
- SetValue(I, Dest, SF);
+ SetValue(&I, Dest, SF);
}
//===----------------------------------------------------------------------===//
@@ -592,13 +593,13 @@ static GenericValue executeSetGTInst(GenericValue Src1, GenericValue Src2,
return Dest;
}
-static void executeBinaryInst(BinaryOperator *I, ExecutionContext &SF) {
- const Type *Ty = I->getOperand(0)->getType();
- GenericValue Src1 = getOperandValue(I->getOperand(0), SF);
- GenericValue Src2 = getOperandValue(I->getOperand(1), SF);
+static void executeBinaryInst(BinaryOperator &I, ExecutionContext &SF) {
+ const Type *Ty = I.getOperand(0)->getType();
+ GenericValue Src1 = getOperandValue(I.getOperand(0), SF);
+ GenericValue Src2 = getOperandValue(I.getOperand(1), SF);
GenericValue R; // Result
- switch (I->getOpcode()) {
+ switch (I.getOpcode()) {
case Instruction::Add: R = executeAddInst (Src1, Src2, Ty, SF); break;
case Instruction::Sub: R = executeSubInst (Src1, Src2, Ty, SF); break;
case Instruction::Mul: R = executeMulInst (Src1, Src2, Ty, SF); break;
@@ -618,7 +619,7 @@ static void executeBinaryInst(BinaryOperator *I, ExecutionContext &SF) {
R = Src1;
}
- SetValue(I, R, SF);
+ SetValue(&I, R, SF);
}
//===----------------------------------------------------------------------===//
@@ -683,14 +684,14 @@ void Interpreter::exitCalled(GenericValue GV) {
PerformExitStuff();
}
-void Interpreter::executeRetInst(ReturnInst *I, ExecutionContext &SF) {
+void Interpreter::executeRetInst(ReturnInst &I, ExecutionContext &SF) {
const Type *RetTy = 0;
GenericValue Result;
// Save away the return value... (if we are not 'ret void')
- if (I->getNumOperands()) {
- RetTy = I->getReturnValue()->getType();
- Result = getOperandValue(I->getReturnValue(), SF);
+ if (I.getNumOperands()) {
+ RetTy = I.getReturnValue()->getType();
+ Result = getOperandValue(I.getReturnValue(), SF);
}
// Save previously executing meth
@@ -737,16 +738,16 @@ void Interpreter::executeRetInst(ReturnInst *I, ExecutionContext &SF) {
}
}
-void Interpreter::executeBrInst(BranchInst *I, ExecutionContext &SF) {
+void Interpreter::executeBrInst(BranchInst &I, ExecutionContext &SF) {
SF.PrevBB = SF.CurBB; // Update PrevBB so that PHI nodes work...
BasicBlock *Dest;
- Dest = I->getSuccessor(0); // Uncond branches have a fixed dest...
- if (!I->isUnconditional()) {
- Value *Cond = I->getCondition();
+ Dest = I.getSuccessor(0); // Uncond branches have a fixed dest...
+ if (!I.isUnconditional()) {
+ Value *Cond = I.getCondition();
GenericValue CondVal = getOperandValue(Cond, SF);
if (CondVal.BoolVal == 0) // If false cond...
- Dest = I->getSuccessor(1);
+ Dest = I.getSuccessor(1);
}
SF.CurBB = Dest; // Update CurBB to branch destination
SF.CurInst = SF.CurBB->begin(); // Update new instruction ptr...
@@ -756,11 +757,11 @@ void Interpreter::executeBrInst(BranchInst *I, ExecutionContext &SF) {
// Memory Instruction Implementations
//===----------------------------------------------------------------------===//
-void Interpreter::executeAllocInst(AllocationInst *I, ExecutionContext &SF) {
- const Type *Ty = I->getType()->getElementType(); // Type to be allocated
+void Interpreter::executeAllocInst(AllocationInst &I, ExecutionContext &SF) {
+ const Type *Ty = I.getType()->getElementType(); // Type to be allocated
// Get the number of elements being allocated by the array...
- unsigned NumElements = getOperandValue(I->getOperand(0), SF).UIntVal;
+ unsigned NumElements = getOperandValue(I.getOperand(0), SF).UIntVal;
// Allocate enough memory to hold the type...
// FIXME: Don't use CALLOC, use a tainted malloc.
@@ -769,15 +770,15 @@ void Interpreter::executeAllocInst(AllocationInst *I, ExecutionContext &SF) {
GenericValue Result;
Result.PointerVal = (PointerTy)Memory;
assert(Result.PointerVal != 0 && "Null pointer returned by malloc!");
- SetValue(I, Result, SF);
+ SetValue(&I, Result, SF);
- if (I->getOpcode() == Instruction::Alloca)
+ if (I.getOpcode() == Instruction::Alloca)
ECStack.back().Allocas.add(Memory);
}
-static void executeFreeInst(FreeInst *I, ExecutionContext &SF) {
- assert(isa<PointerType>(I->getOperand(0)->getType()) && "Freeing nonptr?");
- GenericValue Value = getOperandValue(I->getOperand(0), SF);
+static void executeFreeInst(FreeInst &I, ExecutionContext &SF) {
+ assert(isa<PointerType>(I.getOperand(0)->getType()) && "Freeing nonptr?");
+ GenericValue Value = getOperandValue(I.getOperand(0), SF);
// TODO: Check to make sure memory is allocated
free((void*)Value.PointerVal); // Free memory
}
@@ -787,20 +788,20 @@ static void executeFreeInst(FreeInst *I, ExecutionContext &SF) {
// function returns the offset that arguments ArgOff+1 -> NumArgs specify for
// the pointer type specified by argument Arg.
//
-static PointerTy getElementOffset(MemAccessInst *I, ExecutionContext &SF) {
- assert(isa<PointerType>(I->getPointerOperand()->getType()) &&
+static PointerTy getElementOffset(MemAccessInst &I, ExecutionContext &SF) {
+ assert(isa<PointerType>(I.getPointerOperand()->getType()) &&
"Cannot getElementOffset of a nonpointer type!");
PointerTy Total = 0;
- const Type *Ty = I->getPointerOperand()->getType();
+ const Type *Ty = I.getPointerOperand()->getType();
- unsigned ArgOff = I->getFirstIndexOperandNumber();
- while (ArgOff < I->getNumOperands()) {
+ unsigned ArgOff = I.getFirstIndexOperandNumber();
+ while (ArgOff < I.getNumOperands()) {
if (const StructType *STy = dyn_cast<StructType>(Ty)) {
const StructLayout *SLO = TD.getStructLayout(STy);
// Indicies must be ubyte constants...
- const ConstantUInt *CPU = cast<ConstantUInt>(I->getOperand(ArgOff++));
+ const ConstantUInt *CPU = cast<ConstantUInt>(I.getOperand(ArgOff++));
assert(CPU->getType() == Type::UByteTy);
unsigned Index = CPU->ge