Eliminate using declarations, adjust for new DSGraph API

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6992 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2003-06-30 03:14:44 +00:00
parent 17fefa3ac3
commit 8bc95a176a

View File

@@ -17,9 +17,6 @@
#include "llvm/Support/InstVisitor.h" #include "llvm/Support/InstVisitor.h"
#include "Support/Statistic.h" #include "Support/Statistic.h"
#include "Support/VectorExtras.h" #include "Support/VectorExtras.h"
using std::vector;
using std::map;
using std::multimap;
using namespace PA; using namespace PA;
namespace { namespace {
@@ -32,7 +29,7 @@ namespace {
// poolfree?) // poolfree?)
const Type *PoolDescType = const Type *PoolDescType =
StructType::get(make_vector<const Type*>(VoidPtrTy, Type::UIntTy, StructType::get(make_vector<const Type*>(VoidPtrTy, Type::UIntTy,
Type::UIntTy, 0)); Type::UIntTy, 0));
const PointerType *PoolDescPtr = PointerType::get(PoolDescType); const PointerType *PoolDescPtr = PointerType::get(PoolDescType);
@@ -49,9 +46,9 @@ void PoolAllocate::getAnalysisUsage(AnalysisUsage &AU) const {
// Prints out the functions mapped to the leader of the equivalence class they // Prints out the functions mapped to the leader of the equivalence class they
// belong to. // belong to.
void PoolAllocate::printFuncECs() { void PoolAllocate::printFuncECs() {
map<Function*, Function*> &leaderMap = FuncECs.getLeaderMap(); std::map<Function*, Function*> &leaderMap = FuncECs.getLeaderMap();
std::cerr << "Indirect Function Map \n"; std::cerr << "Indirect Function Map \n";
for (map<Function*, Function*>::iterator LI = leaderMap.begin(), for (std::map<Function*, Function*>::iterator LI = leaderMap.begin(),
LE = leaderMap.end(); LI != LE; ++LI) { LE = leaderMap.end(); LI != LE; ++LI) {
std::cerr << LI->first->getName() << ": leader is " std::cerr << LI->first->getName() << ": leader is "
<< LI->second->getName() << "\n"; << LI->second->getName() << "\n";
@@ -78,7 +75,7 @@ void PoolAllocate::buildIndirectFunctionSets(Module &M) {
// For each call site in the function // For each call site in the function
// All the functions that can be called at the call site are put in the // All the functions that can be called at the call site are put in the
// same equivalence class. // same equivalence class.
for (vector<DSCallSite>::iterator CSI = callSites.begin(), for (std::vector<DSCallSite>::iterator CSI = callSites.begin(),
CSE = callSites.end(); CSI != CSE ; ++CSI) { CSE = callSites.end(); CSI != CSE ; ++CSI) {
if (CSI->isIndirectCall()) { if (CSI->isIndirectCall()) {
DSNode *DSN = CSI->getCalleeNode(); DSNode *DSN = CSI->getCalleeNode();
@@ -234,7 +231,7 @@ void PoolAllocate::FindFunctionPoolArgs(Function &F) {
Nodes[i]->markReachableNodes(MarkedNodes); Nodes[i]->markReachableNodes(MarkedNodes);
// Marked the returned node as alive... // Marked the returned node as alive...
if (DSNode *RetNode = G.getRetNode().getNode()) if (DSNode *RetNode = G.getReturnNodeFor(F).getNode())
if (RetNode->isHeapNode()) if (RetNode->isHeapNode())
RetNode->markReachableNodes(MarkedNodes); RetNode->markReachableNodes(MarkedNodes);
@@ -423,7 +420,7 @@ void PoolAllocate::ProcessFunctionBody(Function &F, Function &NewF) {
} }
// Transform the body of the function now... // Transform the body of the function now...
TransformFunctionBody(NewF, G, FI); TransformFunctionBody(NewF, F, G, FI);
} }
@@ -540,9 +537,9 @@ namespace {
}; };
} }
void PoolAllocate::TransformFunctionBody(Function &F, DSGraph &G, FuncInfo &FI){ void PoolAllocate::TransformFunctionBody(Function &F, Function &OldF,
DSGraph &TDG = TDDS->getDSGraph(G.getFunction()); DSGraph &G, FuncInfo &FI) {
FuncTransform(*this, G, TDG, FI).visit(F); FuncTransform(*this, G, TDDS->getDSGraph(OldF), FI).visit(F);
} }
// Returns true if V is a function pointer // Returns true if V is a function pointer
@@ -672,8 +669,8 @@ void FuncTransform::visitMallocInst(MallocInst &MI) {
// Remove old malloc instruction // Remove old malloc instruction
MI.getParent()->getInstList().erase(&MI); MI.getParent()->getInstList().erase(&MI);
hash_map<Value*, DSNodeHandle> &SM = G.getScalarMap(); DSGraph::ScalarMapTy &SM = G.getScalarMap();
hash_map<Value*, DSNodeHandle>::iterator MII = SM.find(&MI); DSGraph::ScalarMapTy::iterator MII = SM.find(&MI);
// If we are modifying the original function, update the DSGraph... // If we are modifying the original function, update the DSGraph...
if (MII != SM.end()) { if (MII != SM.end()) {
@@ -754,16 +751,16 @@ void FuncTransform::visitCallInst(CallInst &CI) {
} }
std::vector<Value*> Args; std::vector<Value*> Args;
if (!CF) { if (!CF) { // Indirect call
// Indirect call
DEBUG(std::cerr << " Handling call: " << CI); DEBUG(std::cerr << " Handling call: " << CI);
std::map<unsigned, Value*> PoolArgs; std::map<unsigned, Value*> PoolArgs;
Function *FuncClass; Function *FuncClass;
std::pair<multimap<CallInst*, Function*>::iterator, multimap<CallInst*, Function*>::iterator> Targets = PAInfo.CallInstTargets.equal_range(&CI); std::pair<std::multimap<CallInst*, Function*>::iterator,
for (multimap<CallInst*, Function*>::iterator TFI = Targets.first, std::multimap<CallInst*, Function*>::iterator> Targets =
PAInfo.CallInstTargets.equal_range(&CI);
for (std::multimap<CallInst*, Function*>::iterator TFI = Targets.first,
TFE = Targets.second; TFI != TFE; ++TFI) { TFE = Targets.second; TFI != TFE; ++TFI) {
if (TFI == Targets.first) { if (TFI == Targets.first) {
FuncClass = PAInfo.FuncECs.findClass(TFI->second); FuncClass = PAInfo.FuncECs.findClass(TFI->second);
@@ -791,7 +788,8 @@ void FuncTransform::visitCallInst(CallInst &CI) {
assert(OpNum == CI.getNumOperands() && "Varargs calls not handled yet!"); assert(OpNum == CI.getNumOperands() && "Varargs calls not handled yet!");
if (CI.getType() != Type::VoidTy) if (CI.getType() != Type::VoidTy)
CalcNodeMapping(getDSNodeFor(&CI), CG.getRetNode().getNode(), CalcNodeMapping(getDSNodeFor(&CI),
CG.getReturnNodeFor(*TFI->second).getNode(),
NodeMapping); NodeMapping);
unsigned idx = CFI->PoolArgFirst; unsigned idx = CFI->PoolArgFirst;
@@ -881,7 +879,7 @@ void FuncTransform::visitCallInst(CallInst &CI) {
// Map the return value as well... // Map the return value as well...
if (CI.getType() != Type::VoidTy) if (CI.getType() != Type::VoidTy)
CalcNodeMapping(getDSNodeFor(&CI), CG.getRetNode().getNode(), CalcNodeMapping(getDSNodeFor(&CI), CG.getReturnNodeFor(*CF).getNode(),
NodeMapping); NodeMapping);
// Okay, now that we have established our mapping, we can figure out which // Okay, now that we have established our mapping, we can figure out which