diff options
author | Chris Lattner <sabre@nondot.org> | 2002-04-16 20:39:59 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-04-16 20:39:59 +0000 |
commit | 7650b94c758f55066b43799ecfb50c729c2153af (patch) | |
tree | 29f836dd25a5cd09c714055a0e00ce1e8bb5256b /lib/Analysis/DataStructure/FunctionRepBuilder.cpp | |
parent | 28c238636ea663419f35319bcedc445d08995e57 (diff) |
* Remove the concept of a critical shadow node
* Make the function pointer argument explicit for a call nodes
* Eliminate unreachable global values
* Merge call nodes that are identical
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2266 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure/FunctionRepBuilder.cpp')
-rw-r--r-- | lib/Analysis/DataStructure/FunctionRepBuilder.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/lib/Analysis/DataStructure/FunctionRepBuilder.cpp b/lib/Analysis/DataStructure/FunctionRepBuilder.cpp index 2afede5dfa..6dc2930243 100644 --- a/lib/Analysis/DataStructure/FunctionRepBuilder.cpp +++ b/lib/Analysis/DataStructure/FunctionRepBuilder.cpp @@ -69,7 +69,7 @@ void InitVisitor::visitCallInst(CallInst *CI) { // Create a critical shadow node to represent the memory object that the // return value points to... ShadowDSNode *Shad = new ShadowDSNode(PT->getElementType(), - Func->getParent(), true); + Func->getParent()); Rep->ShadowNodes.push_back(Shad); // The return value of the function is a pointer to the shadow value @@ -88,7 +88,7 @@ void InitVisitor::visitCallInst(CallInst *CI) { // Loop over all of the operands of the call instruction (except the first // one), to look for global variable references... // - for_each(CI->op_begin()+1, CI->op_end(), // Skip first arg + for_each(CI->op_begin(), CI->op_end(), bind_obj(this, &InitVisitor::visitOperand)); } @@ -150,7 +150,7 @@ void FunctionRepBuilder::initializeWorkList(Function *Func) { // Add a shadow value for it to represent what it is pointing to and add // this to the value map... ShadowDSNode *Shad = new ShadowDSNode(PT->getElementType(), - Func->getParent(), true); + Func->getParent()); ShadowNodes.push_back(Shad); ValueMap[Arg].add(PointerVal(Shad), Arg); @@ -296,12 +296,8 @@ void FunctionRepBuilder::visitStoreInst(StoreInst *SI) { void FunctionRepBuilder::visitCallInst(CallInst *CI) { CallDSNode *DSN = CallMap[CI]; - - unsigned PtrNum = 0, i = 0; - if (isa<Function>(CI->getOperand(0))) - ++i; // Not an Indirect function call? Skip the function pointer... - - for (unsigned e = CI->getNumOperands(); i != e; ++i) + unsigned PtrNum = 0; + for (unsigned i = 0, e = CI->getNumOperands(); i != e; ++i) if (isa<PointerType>(CI->getOperand(i)->getType())) DSN->addArgValue(PtrNum++, ValueMap[CI->getOperand(i)]); } @@ -333,6 +329,22 @@ FunctionDSGraph::FunctionDSGraph(Function *F) : Func(F) { RetNode = Builder.getRetNode(); ValueMap = Builder.getValueMap(); + // Remove all entries in the value map that consist of global values pointing + // at things. They can only point to their node, so there is no use keeping + // them. + // + for (map<Value*, PointerValSet>::iterator I = ValueMap.begin(), + E = ValueMap.end(); I != E;) + if (isa<GlobalValue>(I->first)) { +#if MAP_DOESNT_HAVE_BROKEN_ERASE_MEMBER + I = ValueMap.erase(I); +#else + ValueMap.erase(I); // This is really lame. + I = ValueMap.begin(); // GCC's stdc++ lib doesn't return an it! +#endif + } else + ++I; + bool Changed = true; while (Changed) { // Eliminate shadow nodes that are not distinguishable from some other |