mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-01 15:17:25 +00:00
Change LowerAllocations pass to 'require' TargetData instead of it being
passed in. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3929 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -20,40 +20,39 @@ using std::vector;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// LowerAllocations - Turn malloc and free instructions into %malloc and %free
|
/// LowerAllocations - Turn malloc and free instructions into %malloc and
|
||||||
// calls.
|
/// %free calls.
|
||||||
//
|
///
|
||||||
class LowerAllocations : public BasicBlockPass {
|
class LowerAllocations : public BasicBlockPass {
|
||||||
Function *MallocFunc; // Functions in the module we are processing
|
Function *MallocFunc; // Functions in the module we are processing
|
||||||
Function *FreeFunc; // Initialized by doInitialization
|
Function *FreeFunc; // Initialized by doInitialization
|
||||||
|
public:
|
||||||
|
LowerAllocations() : MallocFunc(0), FreeFunc(0) {}
|
||||||
|
|
||||||
const TargetData &DataLayout;
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
public:
|
AU.addRequired<TargetData>();
|
||||||
LowerAllocations(const TargetData &TD) : DataLayout(TD) {
|
}
|
||||||
MallocFunc = FreeFunc = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// doPassInitialization - For the lower allocations pass, this ensures that a
|
/// doPassInitialization - For the lower allocations pass, this ensures that
|
||||||
// module contains a declaration for a malloc and a free function.
|
/// a module contains a declaration for a malloc and a free function.
|
||||||
//
|
///
|
||||||
bool doInitialization(Module &M);
|
bool doInitialization(Module &M);
|
||||||
|
|
||||||
|
/// runOnBasicBlock - This method does the actual work of converting
|
||||||
|
/// instructions over, assuming that the pass has already been initialized.
|
||||||
|
///
|
||||||
|
bool runOnBasicBlock(BasicBlock &BB);
|
||||||
|
};
|
||||||
|
|
||||||
// runOnBasicBlock - This method does the actual work of converting
|
RegisterOpt<LowerAllocations>
|
||||||
// instructions over, assuming that the pass has already been initialized.
|
X("lowerallocs", "Lower allocations from instructions to calls");
|
||||||
//
|
|
||||||
bool runOnBasicBlock(BasicBlock &BB);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// createLowerAllocationsPass - Interface to this file...
|
// createLowerAllocationsPass - Interface to this file...
|
||||||
Pass *createLowerAllocationsPass(const TargetData &TD) {
|
Pass *createLowerAllocationsPass() {
|
||||||
return new LowerAllocations(TD);
|
return new LowerAllocations();
|
||||||
}
|
}
|
||||||
|
|
||||||
static RegisterOpt<LowerAllocations>
|
|
||||||
X("lowerallocs", "Lower allocations from instructions to calls (TD)",
|
|
||||||
createLowerAllocationsPass);
|
|
||||||
|
|
||||||
|
|
||||||
// doInitialization - For the lower allocations pass, this ensures that a
|
// doInitialization - For the lower allocations pass, this ensures that a
|
||||||
// module contains a declaration for a malloc and a free function.
|
// module contains a declaration for a malloc and a free function.
|
||||||
@@ -83,6 +82,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
|
|||||||
assert(MallocFunc && FreeFunc && "Pass not initialized!");
|
assert(MallocFunc && FreeFunc && "Pass not initialized!");
|
||||||
|
|
||||||
BasicBlock::InstListType &BBIL = BB.getInstList();
|
BasicBlock::InstListType &BBIL = BB.getInstList();
|
||||||
|
TargetData &DataLayout = getAnalysis<TargetData>();
|
||||||
|
|
||||||
// Loop over all of the instructions, looking for malloc or free instructions
|
// Loop over all of the instructions, looking for malloc or free instructions
|
||||||
for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I) {
|
for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I) {
|
||||||
|
|||||||
Reference in New Issue
Block a user