diff options
author | Misha Brukman <brukman+llvm@gmail.com> | 2005-04-21 21:13:18 +0000 |
---|---|---|
committer | Misha Brukman <brukman+llvm@gmail.com> | 2005-04-21 21:13:18 +0000 |
commit | 2b37d7cf28b1382420b5e4007042feeb66d21ac8 (patch) | |
tree | edf1e11bc9d3208c7e04392a840f8812b506a751 /lib/Analysis/DataStructure | |
parent | 019b63931b946a7dbf55282f4dce7d94d617c5fb (diff) | |
download | external_llvm-2b37d7cf28b1382420b5e4007042feeb66d21ac8.zip external_llvm-2b37d7cf28b1382420b5e4007042feeb66d21ac8.tar.gz external_llvm-2b37d7cf28b1382420b5e4007042feeb66d21ac8.tar.bz2 |
Remove trailing whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21416 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure')
-rw-r--r-- | lib/Analysis/DataStructure/BottomUpClosure.cpp | 36 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/CompleteBottomUp.cpp | 22 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/DataStructure.cpp | 116 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/DataStructureAA.cpp | 18 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/DataStructureOpt.cpp | 6 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/DataStructureStats.cpp | 10 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/EquivClassGraphs.cpp | 52 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/GraphChecker.cpp | 14 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/Local.cpp | 44 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/Printer.cpp | 16 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/Steensgaard.cpp | 16 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/TopDownClosure.cpp | 16 |
12 files changed, 183 insertions, 183 deletions
diff --git a/lib/Analysis/DataStructure/BottomUpClosure.cpp b/lib/Analysis/DataStructure/BottomUpClosure.cpp index 4f244b3..aa51444 100644 --- a/lib/Analysis/DataStructure/BottomUpClosure.cpp +++ b/lib/Analysis/DataStructure/BottomUpClosure.cpp @@ -1,10 +1,10 @@ //===- BottomUpClosure.cpp - Compute bottom-up interprocedural closure ----===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the BUDataStructures class, which represents the @@ -26,7 +26,7 @@ namespace { Statistic<> MaxSCC("budatastructure", "Maximum SCC Size in Call Graph"); Statistic<> NumBUInlines("budatastructures", "Number of graphs inlined"); Statistic<> NumCallEdges("budatastructures", "Number of 'actual' call edges"); - + RegisterAnalysis<BUDataStructures> X("budatastructure", "Bottom-up Data Structure Analysis"); } @@ -48,23 +48,23 @@ static void BuildGlobalECs(DSGraph &GG, std::set<GlobalValue*> &ECGlobals) { GlobalValue *First = GVs[0]; for (unsigned i = 1, e = GVs.size(); i != e; ++i) GlobalECs.unionSets(First, GVs[i]); - + // Next, get the leader element. assert(First == GlobalECs.getLeaderValue(First) && "First did not end up being the leader?"); - + // Next, remove all globals from the scalar map that are not the leader. assert(GVs[0] == First && "First had to be at the front!"); for (unsigned i = 1, e = GVs.size(); i != e; ++i) { ECGlobals.insert(GVs[i]); SM.erase(SM.find(GVs[i])); } - + // Finally, change the global node to only contain the leader. I->clearGlobals(); I->addGlobal(First); } - + DEBUG(GG.AssertGraphOK()); } @@ -161,7 +161,7 @@ bool BUDataStructures::runOnModule(Module &M) { // nothing! In particular, externally visible globals and unresolvable call // nodes at the end of the BU phase should make things that they point to // incomplete in the globals graph. - // + // GlobalsGraph->removeTriviallyDeadNodes(); GlobalsGraph->maskIncompleteMarkers(); @@ -186,7 +186,7 @@ bool BUDataStructures::runOnModule(Module &M) { if (MainFunc && !MainFunc->isExternal()) { DSGraph &MainGraph = getOrCreateGraph(MainFunc); const DSGraph &GG = *MainGraph.getGlobalsGraph(); - ReachabilityCloner RC(MainGraph, GG, + ReachabilityCloner RC(MainGraph, GG, DSGraph::DontCloneCallNodes | DSGraph::DontCloneAuxCallNodes); @@ -197,7 +197,7 @@ bool BUDataStructures::runOnModule(Module &M) { RC.getClonedNH(GG.getNodeForValue(*I)); MainGraph.maskIncompleteMarkers(); - MainGraph.markIncompleteNodes(DSGraph::MarkFormalArgs | + MainGraph.markIncompleteNodes(DSGraph::MarkFormalArgs | DSGraph::IgnoreGlobals); } @@ -210,7 +210,7 @@ DSGraph &BUDataStructures::getOrCreateGraph(Function *F) { if (Graph) return *Graph; DSGraph &LocGraph = getAnalysis<LocalDataStructures>().getDSGraph(*F); - + // Steal the local graph. Graph = new DSGraph(GlobalECs, LocGraph.getTargetData()); Graph->spliceFrom(LocGraph); @@ -235,7 +235,7 @@ static bool isResolvableFunc(const Function* callee) { return !callee->isExternal() || isVAHackFn(callee); } -static void GetAllCallees(const DSCallSite &CS, +static void GetAllCallees(const DSCallSite &CS, std::vector<Function*> &Callees) { if (CS.isDirectCall()) { if (isResolvableFunc(CS.getCalleeFunc())) @@ -244,7 +244,7 @@ static void GetAllCallees(const DSCallSite &CS, // Get all callees. unsigned OldSize = Callees.size(); CS.getCalleeNode()->addFullFunctionList(Callees); - + // If any of the callees are unresolvable, remove the whole batch! for (unsigned i = OldSize, e = Callees.size(); i != e; ++i) if (!isResolvableFunc(Callees[i])) { @@ -265,7 +265,7 @@ static void GetAllAuxCallees(DSGraph &G, std::vector<Function*> &Callees) { unsigned BUDataStructures::calculateGraphs(Function *F, std::vector<Function*> &Stack, - unsigned &NextID, + unsigned &NextID, hash_map<Function*, unsigned> &ValMap) { assert(!ValMap.count(F) && "Shouldn't revisit functions!"); unsigned Min = NextID++, MyID = Min; @@ -488,7 +488,7 @@ void BUDataStructures::calculateGraph(DSGraph &Graph) { if (!Printed) std::cerr << "In Fns: " << Graph.getFunctionNames() << "\n"; std::cerr << " calls " << CalledFuncs.size() - << " fns from site: " << CS.getCallSite().getInstruction() + << " fns from site: " << CS.getCallSite().getInstruction() << " " << *CS.getCallSite().getInstruction(); std::cerr << " Fns ="; unsigned NumPrinted = 0; @@ -510,7 +510,7 @@ void BUDataStructures::calculateGraph(DSGraph &Graph) { if (IndCallGraph.first == 0) { std::vector<Function*>::iterator I = CalledFuncs.begin(), E = CalledFuncs.end(); - + // Start with a copy of the first graph. GI = IndCallGraph.first = new DSGraph(getDSGraph(**I), GlobalECs); GI->setGlobalsGraph(Graph.getGlobalsGraph()); @@ -539,7 +539,7 @@ void BUDataStructures::calculateGraph(DSGraph &Graph) { for (e = NextArgs.size(); i != e; ++i) Args.push_back(NextArgs[i]); } - + // Clean up the final graph! GI->removeDeadNodes(DSGraph::KeepUnreachableGlobals); } else { @@ -580,7 +580,7 @@ void BUDataStructures::calculateGraph(DSGraph &Graph) { // Clone everything reachable from globals in the function graph into the // globals graph. for (DSScalarMap::global_iterator I = MainSM.global_begin(), - E = MainSM.global_end(); I != E; ++I) + E = MainSM.global_end(); I != E; ++I) RC.getClonedNH(MainSM[*I]); //Graph.writeGraphToFile(std::cerr, "bu_" + F.getName()); diff --git a/lib/Analysis/DataStructure/CompleteBottomUp.cpp b/lib/Analysis/DataStructure/CompleteBottomUp.cpp index 9eb5938..5cf4bcf 100644 --- a/lib/Analysis/DataStructure/CompleteBottomUp.cpp +++ b/lib/Analysis/DataStructure/CompleteBottomUp.cpp @@ -1,10 +1,10 @@ //===- CompleteBottomUp.cpp - Complete Bottom-Up Data Structure Graphs ----===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This is the exact same as the bottom-up graphs, but we use take a completed @@ -52,7 +52,7 @@ bool CompleteBUDataStructures::runOnModule(Module &M) { } else { std::cerr << "CBU-DSA: No 'main' function found!\n"; } - + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (!I->isExternal() && !DSInfo.count(I)) calculateSCCGraphs(getOrCreateGraph(*I), Stack, NextID, ValMap); @@ -66,7 +66,7 @@ bool CompleteBUDataStructures::runOnModule(Module &M) { if (MainFunc && !MainFunc->isExternal()) { DSGraph &MainGraph = getOrCreateGraph(*MainFunc); const DSGraph &GG = *MainGraph.getGlobalsGraph(); - ReachabilityCloner RC(MainGraph, GG, + ReachabilityCloner RC(MainGraph, GG, DSGraph::DontCloneCallNodes | DSGraph::DontCloneAuxCallNodes); @@ -77,7 +77,7 @@ bool CompleteBUDataStructures::runOnModule(Module &M) { RC.getClonedNH(GG.getNodeForValue(*I)); MainGraph.maskIncompleteMarkers(); - MainGraph.markIncompleteNodes(DSGraph::MarkFormalArgs | + MainGraph.markIncompleteNodes(DSGraph::MarkFormalArgs | DSGraph::IgnoreGlobals); } @@ -107,7 +107,7 @@ DSGraph &CompleteBUDataStructures::getOrCreateGraph(Function &F) { unsigned CompleteBUDataStructures::calculateSCCGraphs(DSGraph &FG, std::vector<DSGraph*> &Stack, - unsigned &NextID, + unsigned &NextID, hash_map<DSGraph*, unsigned> &ValMap) { assert(!ValMap.count(&FG) && "Shouldn't revisit functions!"); unsigned Min = NextID++, MyID = Min; @@ -157,7 +157,7 @@ unsigned CompleteBUDataStructures::calculateSCCGraphs(DSGraph &FG, // Remove NG from the ValMap since the pointer may get recycled. ValMap.erase(NG); delete NG; - + Stack.pop_back(); IsMultiNodeSCC = true; } @@ -165,7 +165,7 @@ unsigned CompleteBUDataStructures::calculateSCCGraphs(DSGraph &FG, // Clean up the graph before we start inlining a bunch again... if (IsMultiNodeSCC) FG.removeTriviallyDeadNodes(); - + Stack.pop_back(); processGraph(FG); ValMap[&FG] = ~0U; @@ -187,7 +187,7 @@ void CompleteBUDataStructures::processGraph(DSGraph &G) { assert(calls.insert(TheCall).second && "Call instruction occurs multiple times in graph??"); - + // Fast path for noop calls. Note that we don't care about merging globals // in the callee with nodes in the caller here. if (CS.getRetVal().isNull() && CS.getNumPtrArgs() == 0) @@ -196,7 +196,7 @@ void CompleteBUDataStructures::processGraph(DSGraph &G) { // Loop over all of the potentially called functions... // Inline direct calls as well as indirect calls because the direct // callee may have indirect callees and so may have changed. - // + // callee_iterator I = callee_begin(TheCall),E = callee_end(TheCall); unsigned TNum = 0, Num = 0; DEBUG(Num = std::distance(I, E)); @@ -208,7 +208,7 @@ void CompleteBUDataStructures::processGraph(DSGraph &G) { // calls or for self recursion within an SCC. DSGraph &GI = getOrCreateGraph(*CalleeFunc); ++NumCBUInlines; - G.mergeInGraph(CS, *CalleeFunc, GI, + G.mergeInGraph(CS, *CalleeFunc, GI, DSGraph::StripAllocaBit | DSGraph::DontCloneCallNodes | DSGraph::DontCloneAuxCallNodes); DEBUG(std::cerr << " Inlining graph [" << i << "/" diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp index c3d1705..a95d252 100644 --- a/lib/Analysis/DataStructure/DataStructure.cpp +++ b/lib/Analysis/DataStructure/DataStructure.cpp @@ -1,10 +1,10 @@ //===- DataStructure.cpp - Implement the core data structure analysis -----===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the core data structure functionality. @@ -95,7 +95,7 @@ DSNodeHandle &DSScalarMap::AddGlobal(GlobalValue *GV) { return I->second; } } - + // Okay, this is either not an equivalenced global or it is the leader, it // will be inserted into the scalar map now. GlobalSet.insert(GV); @@ -163,7 +163,7 @@ void DSNode::forwardNode(DSNode *To, unsigned Offset) { Ty = Type::VoidTy; // Remove this node from the parent graph's Nodes list. - ParentGraph->unlinkNode(this); + ParentGraph->unlinkNode(this); ParentGraph = 0; } @@ -221,16 +221,16 @@ void DSNode::foldNodeCompletely() { DestNode->Ty = Type::VoidTy; DestNode->Size = 1; DestNode->Globals.swap(Globals); - + // Start forwarding to the destination node... forwardNode(DestNode, 0); - + if (!Links.empty()) { DestNode->Links.reserve(1); - + DSNodeHandle NH(DestNode); DestNode->Links.push_back(Links[0]); - + // If we have links, merge all of our outgoing links together... for (unsigned i = Links.size()-1; i != 0; --i) NH.getNode()->Links[0].mergeWith(Links[i]); @@ -328,7 +328,7 @@ namespace { ++SS.Idx; if (SS.Idx != ST->getNumElements()) { const StructLayout *SL = TD.getStructLayout(ST); - SS.Offset += + SS.Offset += unsigned(SL->MemberOffsets[SS.Idx]-SL->MemberOffsets[SS.Idx-1]); return; } @@ -388,7 +388,7 @@ namespace { static bool ElementTypesAreCompatible(const Type *T1, const Type *T2, bool AllowLargerT1, const TargetData &TD){ TypeElementWalker T1W(T1, TD), T2W(T2, TD); - + while (!T1W.isDone() && !T2W.isDone()) { if (T1W.getCurrentOffset() != T2W.getCurrentOffset()) return false; @@ -397,11 +397,11 @@ static bool ElementTypesAreCompatible(const Type *T1, const Type *T2, const Type *T2 = T2W.getCurrentType(); if (T1 != T2 && !T1->isLosslesslyConvertibleTo(T2)) return false; - + T1W.StepToNextType(); T2W.StepToNextType(); } - + return AllowLargerT1 || T1W.isDone(); } @@ -573,13 +573,13 @@ bool DSNode::mergeTypeInfo(const Type *NewTy, unsigned Offset, if (isa<FunctionType>(SubType) && isa<FunctionType>(NewTy)) return false; - unsigned SubTypeSize = SubType->isSized() ? + unsigned SubTypeSize = SubType->isSized() ? (unsigned)TD.getTypeSize(SubType) : 0; // Ok, we are getting desperate now. Check for physical subtyping, where we // just require each element in the node to be compatible. if (NewTySize <= SubTypeSize && NewTySize && NewTySize < 256 && - SubTypeSize && SubTypeSize < 256 && + SubTypeSize && SubTypeSize < 256 && ElementTypesAreCompatible(NewTy, SubType, !isArray(), TD)) return false; @@ -611,7 +611,7 @@ bool DSNode::mergeTypeInfo(const Type *NewTy, unsigned Offset, NextPadSize = NextSubTypeSize; break; default: ; - // fall out + // fall out } if (NextSubType == 0) @@ -707,14 +707,14 @@ static void MergeSortedVectors(std::vector<GlobalValue*> &Dest, } else { // Make a copy to the side of Dest... std::vector<GlobalValue*> Old(Dest); - + // Make space for all of the type entries now... Dest.resize(Dest.size()+Src.size()); - + // Merge the two sorted ranges together... into Dest. std::merge(Old.begin(), Old.end(), Src.begin(), Src.end(), Dest.begin()); - - // Now erase any duplicate entries that may have accumulated into the + + // Now erase any duplicate entries that may have accumulated into the // vectors (because they were in both of the input sets) Dest.erase(std::unique(Dest.begin(), Dest.end()), Dest.end()); } @@ -728,7 +728,7 @@ void DSNode::mergeGlobals(const std::vector<GlobalValue*> &RHS) { // This function does the hard work of merging two nodes, CurNodeH // and NH after filtering out trivial cases and making sure that // CurNodeH.offset >= NH.offset. -// +// // ***WARNING*** // Since merging may cause either node to go away, we must always // use the node-handles to refer to the nodes. These node handles are @@ -761,7 +761,7 @@ void DSNode::MergeNodes(DSNodeHandle& CurNodeH, DSNodeHandle& NH) { #endif } - // Merge the type entries of the two nodes together... + // Merge the type entries of the two nodes together... if (NH.getNode()->Ty != Type::VoidTy) CurNodeH.getNode()->mergeTypeInfo(NH.getNode()->Ty, NOffset); assert(!CurNodeH.getNode()->isDeadNode()); @@ -916,7 +916,7 @@ DSNodeHandle ReachabilityCloner::getClonedNH(const DSNodeHandle &SrcNH) { DSNode *DN = new DSNode(*SN, &Dest, true /* Null out all links */); DN->maskNodeTypes(BitsToKeep); NH = DN; - + // Next, recursively clone all outgoing links as necessary. Note that // adding these links can cause the node to collapse itself at any time, and // the current node may be merged with arbitrary other nodes. For this @@ -939,7 +939,7 @@ DSNodeHandle ReachabilityCloner::getClonedNH(const DSNodeHandle &SrcNH) { CN->addEdgeTo(MergeOffset, DestEdge); } } - + // If this node contains any globals, make sure they end up in the scalar // map with the correct offset. for (DSNode::globals_iterator I = SN->globals_begin(), E = SN->globals_end(); @@ -977,7 +977,7 @@ void ReachabilityCloner::merge(const DSNodeHandle &NH, SCNH.getOffset()+SrcNH.getOffset())); return; // Nothing to do! } - + // Okay, so the source node has not already been cloned. Instead of creating // a new DSNode, only to merge it into the one we already have, try to perform // the merge in-place. The only case we cannot handle here is when the offset @@ -1006,8 +1006,8 @@ void ReachabilityCloner::merge(const DSNodeHandle &NH, } #endif } - - // Merge the type entries of the two nodes together... + + // Merge the type entries of the two nodes together... if (SN->getType() != Type::VoidTy && !DN->isNodeCompletelyFolded()) { DN->mergeTypeInfo(SN->getType(), NH.getOffset()-SrcNH.getOffset()); DN = NH.getNode(); @@ -1015,7 +1015,7 @@ void ReachabilityCloner::merge(const DSNodeHandle &NH, } assert(!DN->isDeadNode()); - + // Merge the NodeType information. DN->mergeNodeFlags(SN->getNodeFlags() & BitsToKeep); @@ -1060,7 +1060,7 @@ void ReachabilityCloner::merge(const DSNodeHandle &NH, // sure it is known that this is the representative node for the src node. SCNH = DSNodeHandle(NH.getNode(), NH.getOffset()-SrcNH.getOffset()); - // If the source node contained any globals, make sure to create entries + // If the source node contained any globals, make sure to create entries // in the scalar map for them! for (DSNode::globals_iterator I = SN->globals_begin(), E = SN->globals_end(); I != E; ++I) { @@ -1092,7 +1092,7 @@ void ReachabilityCloner::merge(const DSNodeHandle &NH, DSNode *CN = SCNH.getNode(); unsigned MergeOffset = ((i << DS::PointerShift)+SCNH.getOffset()) % CN->getSize(); - + DSNodeHandle Tmp = CN->getLink(MergeOffset); if (!Tmp.isNull()) { // Perform the recursive merging. Make sure to create a temporary NH, @@ -1120,7 +1120,7 @@ void ReachabilityCloner::mergeCallSite(DSCallSite &DestCS, merge(DestCS.getRetVal(), SrcCS.getRetVal()); unsigned MinArgs = DestCS.getNumPtrArgs(); if (SrcCS.getNumPtrArgs() < MinArgs) MinArgs = SrcCS.getNumPtrArgs(); - + for (unsigned a = 0; a != MinArgs; ++a) merge(DestCS.getPtrArg(a), SrcCS.getPtrArg(a)); @@ -1253,11 +1253,11 @@ void DSGraph::cloneInto(const DSGraph &G, unsigned CloneFlags) { New->maskNodeTypes(~BitsToClear); OldNodeMap[I] = New; } - + #ifndef NDEBUG Timer::addPeakMemoryMeasurement(); #endif - + // Rewrite the links in the new nodes to point into the current graph now. // Note that we don't loop over the node's list to do this. The problem is // that remaping links can cause recursive merging to happen, which means @@ -1314,7 +1314,7 @@ void DSGraph::spliceFrom(DSGraph &RHS) { I->setParentGraph(this); // Take all of the nodes. Nodes.splice(Nodes.end(), RHS.Nodes); - + // Take all of the calls. FunctionCalls.splice(FunctionCalls.end(), RHS.FunctionCalls); AuxFunctionCalls.splice(AuxFunctionCalls.end(), RHS.AuxFunctionCalls); @@ -1376,7 +1376,7 @@ namespace { unsigned CurNodeId; std::vector<const DSNode*> SCCStack; std::map<const DSNode*, std::pair<unsigned, bool> > NodeInfo; - + HackedGraphSCCFinder(ReachabilityCloner &rc) : RC(rc), CurNodeId(1) { // Remove null pointer as a special case. NodeInfo[0] = std::make_pair(0, false); @@ -1473,7 +1473,7 @@ OutOfLoop: /// call site (in this graph) with the bindings specified by the vector in G2. /// The two DSGraphs must be different. /// -void DSGraph::mergeInGraph(const DSCallSite &CS, +void DSGraph::mergeInGraph(const DSCallSite &CS, std::vector<DSNodeHandle> &Args, const DSGraph &Graph, unsigned CloneFlags) { TIME_REGION(X, "mergeInGraph"); @@ -1485,12 +1485,12 @@ void DSGraph::mergeInGraph(const DSCallSite &CS, if (&Graph == this) { // Merge the return value with the return value of the context. Args[0].mergeWith(CS.getRetVal()); - + // Resolve all of the function arguments. for (unsigned i = 0, e = CS.getNumPtrArgs(); i != e; ++i) { if (i == Args.size()-1) break; - + // Add the link from the argument scalar to the provided value. Args[i+1].mergeWith(CS.getPtrArg(i)); } @@ -1501,7 +1501,7 @@ void DSGraph::mergeInGraph(const DSCallSite &CS, // scalars in the old graph _used_ to point, and of the new nodes matching // nodes of the old graph. ReachabilityCloner RC(*this, Graph, CloneFlags); - + // Map the return node pointer over. if (!CS.getRetVal().isNull()) RC.merge(CS.getRetVal(), Args[0]); @@ -1510,11 +1510,11 @@ void DSGraph::mergeInGraph(const DSCallSite &CS, for (unsigned i = 0, e = CS.getNumPtrArgs(); i != e; ++i) { if (i == Args.size()-1) break; - + // Add the link from the argument scalar to the provided value. RC.merge(CS.getPtrArg(i), Args[i+1]); } - + // We generally don't want to copy global nodes or aux calls from the callee // graph to the caller graph. However, we have to copy them if there is a // path from the node to a node we have already copied which does not go @@ -1548,7 +1548,7 @@ void DSGraph::mergeInGraph(const DSCallSite &CS, // Copy aux calls that are needed. for (unsigned i = 0, e = AuxCallToCopy.size(); i != e; ++i) AuxFunctionCalls.push_back(DSCallSite(*AuxCallToCopy[i], RC)); - + // Copy globals that are needed. for (unsigned i = 0, e = GlobalsToCopy.size(); i != e; ++i) RC.getClonedNH(Graph.getNodeForValue(GlobalsToCopy[i])); @@ -1759,7 +1759,7 @@ static void removeIdenticalCalls(std::list<DSCallSite> &Calls) { killIfUselessEdge(CS.getRetVal()); for (unsigned a = 0, e = CS.getNumPtrArgs(); a != e; ++a) killIfUselessEdge(CS.getPtrArg(a)); - + #if 0 // If this call site calls the same function as the last call site, and if // the function pointer contains an external function, this node will @@ -1776,7 +1776,7 @@ static void removeIdenticalCalls(std::list<DSCallSite> &Calls) { else LastCalleeContainsExternalFunction = LastCalleeFunc->isExternal(); } - + // It is not clear why, but enabling this code makes DSA really // sensitive to node forwarding. Basically, with this enabled, DSA // performs different number of inlinings based on which nodes are @@ -1791,11 +1791,11 @@ static void removeIdenticalCalls(std::list<DSCallSite> &Calls) { NumDuplicateCalls > 20 #endif ) { - + std::list<DSCallSite>::iterator PrevIt = OldIt; --PrevIt; PrevIt->mergeWith(CS); - + // No need to keep this call anymore. Calls.erase(OldIt); ++NumDeleted; @@ -1957,7 +1957,7 @@ void DSNode::markReachableNodes(hash_set<const DSNode*> &ReachableNodes) const { void DSCallSite::markReachableNodes(hash_set<const DSNode*> &Nodes) const { getRetVal().getNode()->markReachableNodes(Nodes); if (isIndirectCall()) getCalleeNode()->markReachableNodes(Nodes); - + for (unsigned i = 0, e = getNumPtrArgs(); i != e; ++i) getPtrArg(i).getNode()->markReachableNodes(Nodes); } @@ -2055,7 +2055,7 @@ void DSGraph::removeDeadNodes(unsigned Flags) { // Make sure that all globals are cloned over as roots. if (!(Flags & DSGraph::RemoveUnreachableGlobals) && GlobalsGraph) { - DSGraph::ScalarMapTy::iterator SMI = + DSGraph::ScalarMapTy::iterator SMI = GlobalsGraph->getScalarMap().find(I->first); if (SMI != GlobalsGraph->getScalarMap().end()) GGCloner.merge(SMI->second, I->second); @@ -2079,7 +2079,7 @@ void DSGraph::removeDeadNodes(unsigned Flags) { // Now find globals and aux call nodes that are already live or reach a live // value (which makes them live in turn), and continue till no more are found. - // + // bool Iterate; hash_set<const DSNode*> Visited; hash_set<const DSCallSite*> AuxFCallsAlive; @@ -2092,7 +2092,7 @@ void DSGraph::removeDeadNodes(unsigned Flags) { Iterate = false; if (!(Flags & DSGraph::RemoveUnreachableGlobals)) for (unsigned i = 0; i != GlobalNodes.size(); ++i) - if (CanReachAliveNodes(GlobalNodes[i].second, Alive, Visited, + if (CanReachAliveNodes(GlobalNodes[i].second, Alive, Visited, Flags & DSGraph::RemoveUnreachableGlobals)) { std::swap(GlobalNodes[i--], GlobalNodes.back()); // Move to end to... GlobalNodes.pop_back(); // erase efficiently @@ -2124,7 +2124,7 @@ void DSGraph::removeDeadNodes(unsigned Flags) { // Copy and merge global nodes and dead aux call nodes into the // GlobalsGraph, and all nodes reachable from those nodes. Update their // target pointers using the GGCloner. - // + // if (!(Flags & DSGraph::RemoveUnreachableGlobals)) GlobalsGraph->AuxFunctionCalls.push_back(DSCallSite(*CI, GGCloner)); @@ -2180,7 +2180,7 @@ void DSGraph::AssertCallSiteInGraph(const DSCallSite &CS) const { #if 0 if (CS.getNumPtrArgs() && CS.getCalleeNode() == CS.getPtrArg(0).getNode() && CS.getCalleeNode() && CS.getCalleeNode()->getGlobals().empty()) - std::cerr << "WARNING: WEIRD CALL SITE FOUND!\n"; + std::cerr << "WARNING: WEIRD CALL SITE FOUND!\n"; #endif } AssertNodeInGraph(CS.getRetVal().getNode()); @@ -2250,7 +2250,7 @@ void DSGraph::computeNodeMapping(const DSNodeHandle &NH1, } return; } - + Entry.setTo(N2, NH2.getOffset()-NH1.getOffset()); // Loop over all of the fields that N1 and N2 have in common, recursively @@ -2284,7 +2284,7 @@ void DSGraph::computeGToGGMapping(NodeMapTy &NodeMap) { E = SM.global_end(); I != E; ++I) DSGraph::computeNodeMapping(SM[*I], GG.getNodeForValue(*I), NodeMap); } - + /// computeGGToGMapping - Compute the mapping of nodes in the global graph to /// nodes in this graph. Note that any uses of this method are probably bugs, /// unless it is known that the globals graph has been merged into this graph! @@ -2298,7 +2298,7 @@ void DSGraph::computeGGToGMapping(InvNodeMapTy &InvNodeMap) { NodeMap.erase(NodeMap.begin()); } } - + /// computeCalleeCallerMapping - Given a call from a function in the current /// graph to the 'Callee' function (which lives in 'CalleeGraph'), compute the @@ -2309,7 +2309,7 @@ void DSGraph::computeCalleeCallerMapping(DSCallSite CS, const Function &Callee, DSCallSite CalleeArgs = CalleeGraph.getCallSiteForArguments(const_cast<Function&>(Callee)); - + computeNodeMapping(CalleeArgs.getRetVal(), CS.getRetVal(), NodeMap); unsigned NumArgs = CS.getNumPtrArgs(); @@ -2318,18 +2318,18 @@ void DSGraph::computeCalleeCallerMapping(DSCallSite CS, const Function &Callee, for (unsigned i = 0; i != NumArgs; ++i) computeNodeMapping(CalleeArgs.getPtrArg(i), CS.getPtrArg(i), NodeMap); - + // Map the nodes that are pointed to by globals. DSScalarMap &CalleeSM = CalleeGraph.getScalarMap(); DSScalarMap &CallerSM = getScalarMap(); if (CalleeSM.global_size() >= CallerSM.global_size()) { - for (DSScalarMap::global_iterator GI = CallerSM.global_begin(), + for (DSScalarMap::global_iterator GI = CallerSM.global_begin(), E = CallerSM.global_end(); GI != E; ++GI) if (CalleeSM.global_count(*GI)) computeNodeMapping(CalleeSM[*GI], CallerSM[*GI], NodeMap); } else { - for (DSScalarMap::global_iterator GI = CalleeSM.global_begin(), + for (DSScalarMap::global_iterator GI = CalleeSM.global_begin(), E = CalleeSM.global_end(); GI != E; ++GI) if (CallerSM.global_count(*GI)) computeNodeMapping(CalleeSM[*GI], CallerSM[*GI], NodeMap); diff --git a/lib/Analysis/DataStructure/DataStructureAA.cpp b/lib/Analysis/DataStructure/DataStructureAA.cpp index 65b9b12..1ea1d88 100644 --- a/lib/Analysis/DataStructure/DataStructureAA.cpp +++ b/lib/Analysis/DataStructure/DataStructureAA.cpp @@ -1,10 +1,10 @@ //===- DataStructureAA.cpp - Data Structure Based Alias Analysis ----------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This pass uses the top-down data structure graphs to implement a simple @@ -68,7 +68,7 @@ namespace { //------------------------------------------------ // Implement the AliasAnalysis API - // + // AliasResult alias(const Value *V1, unsigned V1Size, const Value *V2, unsigned V2Size); @@ -124,14 +124,14 @@ AliasAnalysis::AliasResult DSAA::alias(const Value *V1, unsigned V1Size, DSGraph *G1 = getGraphForValue(V1); DSGraph *G2 = getGraphForValue(V2); assert((!G1 || !G2 || G1 == G2) && "Alias query for 2 different functions?"); - + // Get the graph to use... DSGraph &G = *(G1 ? G1 : (G2 ? G2 : &TD->getGlobalsGraph())); const DSGraph::ScalarMapTy &GSM = G.getScalarMap(); DSGraph::ScalarMapTy::const_iterator I = GSM.find((Value*)V1); if (I == GSM.end()) return NoAlias; - + DSGraph::ScalarMapTy::const_iterator J = GSM.find((Value*)V2); if (J == GSM.end()) return NoAlias; @@ -188,10 +188,10 @@ DSAA::getModRefInfo(CallSite CS, Value *P, unsigned Size) { HaveMappingInfo: assert(N && "Null pointer in scalar map??"); - + typedef std::multimap<DSNode*, const DSNode*>::iterator NodeMapIt; std::pair<NodeMapIt, NodeMapIt> Range = CallerCalleeMap.equal_range(N); - + // Loop over all of the nodes in the callee that correspond to "N", keeping // track of aggregate mod/ref info. bool NeverReads = true, NeverWrites = true; @@ -203,13 +203,13 @@ DSAA::getModRefInfo(CallSite CS, Value *P, unsigned Size) { if (NeverReads == false && NeverWrites == false) return AliasAnalysis::getModRefInfo(CS, P, Size); } - + ModRefResult Result = ModRef; if (NeverWrites) // We proved it was not modified. Result = ModRefResult(Result & ~Mod); if (NeverReads) // We proved it was not read. Result = ModRefResult(Result & ~Ref); - + return ModRefResult(Result & AliasAnalysis::getModRefInfo(CS, P, Size)); } diff --git a/lib/Analysis/DataStructure/DataStructureOpt.cpp b/lib/Analysis/DataStructure/DataStructureOpt.cpp index 6315041..c464aee 100644 --- a/lib/Analysis/DataStructure/DataStructureOpt.cpp +++ b/lib/Analysis/DataStructure/DataStructureOpt.cpp @@ -1,10 +1,10 @@ //===- DataStructureOpt.cpp - Data Structure Analysis Based Optimizations -===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This pass uses DSA to a series of simple optimizations, like marking @@ -66,7 +66,7 @@ bool DSOpt::OptimizeGlobals(Module &M) { DSNode *GNode = 0; DSGraph::ScalarMapTy::const_iterator SMI = SM.find(I); if (SMI != SM.end()) GNode = SMI->second.getNode(); - + if (GNode == 0 && I->hasInternalLinkage()) { // If there is no entry in the scalar map for this global, it was never // referenced in the program. If it has internal linkage, that means we diff --git a/lib/Analysis/DataStructure/DataStructureStats.cpp b/lib/Analysis/DataStructure/DataStructureStats.cpp index afb69b8..d86c2a2 100644 --- a/lib/Analysis/DataStructure/DataStructureStats.cpp +++ b/lib/Analysis/DataStructure/DataStructureStats.cpp @@ -1,10 +1,10 @@ //===- DataStructureStats.cpp - Various statistics for DS Graphs ----------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file defines a little pass that prints out statistics for DS Graphs. @@ -76,7 +76,7 @@ void DSGraphStats::countCallees(const Function& F) { unsigned numIndirectCalls = 0, totalNumCallees = 0; for (DSGraph::fc_iterator I = TDGraph->fc_begin(), E = TDGraph->fc_end(); - I != E; ++I) + I != E; ++I) if (isIndirectCallee(I->getCallSite().getCalledValue())) { // This is an indirect function call std::vector<Function*> Callees; @@ -90,10 +90,10 @@ void DSGraphStats::countCallees(const Function& F) { << "' at call: \n" << *I->getCallSite().getInstruction(); } - + TotalNumCallees += totalNumCallees; NumIndirectCalls += numIndirectCalls; - + if (numIndirectCalls) std::cout << " In function " << F.getName() << ": " << (totalNumCallees / (double) numIndirectCalls) diff --git a/lib/Analysis/DataStructure/EquivClassGraphs.cpp b/lib/Analysis/DataStructure/EquivClassGraphs.cpp index a8e0f35..e9b324a 100644 --- a/lib/Analysis/DataStructure/EquivClassGraphs.cpp +++ b/lib/Analysis/DataStructure/EquivClassGraphs.cpp @@ -1,10 +1,10 @@ //===- EquivClassGraphs.cpp - Merge equiv-class graphs & inline bottom-up -===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This pass is the same as the complete bottom-up graphs, but @@ -50,12 +50,12 @@ static void CheckAllGraphs(Module *M, GT &ECGraphs) { DSGraph::NodeMapTy GlobalsGraphNodeMapping; G.computeGToGGMapping(GlobalsGraphNodeMapping); - } + } } #endif // getSomeCalleeForCallSite - Return any one callee function at a call site. -// +// Function *EquivClassGraphs::getSomeCalleeForCallSite(const CallSite &CS) const{ Function *thisFunc = CS.getCaller(); assert(thisFunc && "getSomeCalleeForCallSite(): Not a valid call site?"); @@ -94,7 +94,7 @@ bool EquivClassGraphs::runOnModule(Module &M) { } else { std::cerr << "Fold Graphs: No 'main' function found!\n"; } - + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (!I->isExternal()) processSCC(getOrCreateGraph(*I), Stack, NextID, ValMap); @@ -110,7 +110,7 @@ bool EquivClassGraphs::runOnModule(Module &M) { if (MainFunc && !MainFunc->isExternal()) { DSGraph &MainGraph = getOrCreateGraph(*MainFunc); const DSGraph &GG = *MainGraph.getGlobalsGraph(); - ReachabilityCloner RC(MainGraph, GG, + ReachabilityCloner RC(MainGraph, GG, DSGraph::DontCloneCallNodes | DSGraph::DontCloneAuxCallNodes); @@ -121,7 +121,7 @@ bool EquivClassGraphs::runOnModule(Module &M) { RC.getClonedNH(GG.getNodeForValue(*I)); MainGraph.maskIncompleteMarkers(); - MainGraph.markIncompleteNodes(DSGraph::MarkFormalArgs | + MainGraph.markIncompleteNodes(DSGraph::MarkFormalArgs | DSGraph::IgnoreGlobals); } @@ -158,7 +158,7 @@ bool EquivClassGraphs::runOnModule(Module &M) { // void EquivClassGraphs::buildIndirectFunctionSets(Module &M) { const ActualCalleesTy& AC = CBU->getActualCallees(); - + // Loop over all of the indirect calls in the program. If a call site can // call multiple different functions, we need to unify all of the callees into // the same equivalence class. @@ -204,7 +204,7 @@ void EquivClassGraphs::buildIndirectFunctionSets(Module &M) { // equivalence class. More precisely, if F is in the class, and G(F) is // its graph, then we include all other functions that are also in G(F). // Currently, that is just the functions in the same call-graph-SCC as F. - // + // DSGraph& funcDSGraph = CBU->getDSGraph(*I->second); for (DSGraph::retnodes_iterator RI = funcDSGraph.retnodes_begin(), RE = funcDSGraph.retnodes_end(); RI != RE; ++RI) @@ -242,24 +242,24 @@ void EquivClassGraphs::buildIndirectFunctionSets(Module &M) { DSGraph &MergedG = getOrCreateGraph(*LF); // Record the argument nodes for use in merging later below. - std::vector<DSNodeHandle> ArgNodes; + std::vector<DSNodeHandle> ArgNodes; for (Function::arg_iterator AI = LF->arg_begin(), E = LF->arg_end(); AI != E; ++AI) if (DS::isPointerType(AI->getType())) ArgNodes.push_back(MergedG.getNodeForValue(AI)); - + // Merge in the graphs of all other functions in this equiv. class. Note // that two or more functions may have the same graph, and it only needs // to be merged in once. std::set<DSGraph*> GraphsMerged; GraphsMerged.insert(&CBU->getDSGraph(*LF)); - + for (++SI; SI != FuncECs.member_end(); ++SI) { Function *F = *SI; DSGraph *&FG = DSInfo[F]; - - DSGraph &CBUGraph = CBU->getDSGraph(*F); + + DSGraph &CBUGraph = CBU->getDSGraph(*F); if (GraphsMerged.insert(&CBUGraph).second) { // Record the "folded" graph for the function. for (DSGraph::retnodes_iterator I = CBUGraph.retnodes_begin(), @@ -267,14 +267,14 @@ void EquivClassGraphs::buildIndirectFunctionSets(Module &M) { assert(DSInfo[I->first] == 0 && "Graph already exists for Fn!"); DSInfo[I->first] = &MergedG; } - + // Clone this member of the equivalence class into MergedG. MergedG.cloneInto(CBUGraph); } - + // Merge the return nodes of all functions together. MergedG.getReturnNodes()[LF].mergeWith(MergedG.getReturnNodes()[F]); - + // Merge the function arguments with all argument nodes found so far. // If there are extra function args, add them to the vector of argNodes Function::arg_iterator AI2 = F->arg_begin(), AI2end = F->arg_end(); @@ -282,7 +282,7 @@ void EquivClassGraphs::buildIndirectFunctionSets(Module &M) { arg != numArgs && AI2 != AI2end; ++AI2, ++arg) if (DS::isPointerType(AI2->getType())) ArgNodes[arg].mergeWith(MergedG.getNodeForValue(AI2)); - + for ( ; AI2 != AI2end; ++AI2) if (DS::isPointerType(AI2->getType())) ArgNodes.push_back(MergedG.getNodeForValue(AI2)); @@ -319,7 +319,7 @@ DSGraph &EquivClassGraphs::getOrCreateGraph(Function &F) { unsigned EquivClassGraphs:: -processSCC(DSGraph &FG, std::vector<DSGraph*> &Stack, unsigned &NextID, +processSCC(DSGraph &FG, std::vector<DSGraph*> &Stack, unsigned &NextID, std::map<DSGraph*, unsigned> &ValMap) { std::map<DSGraph*, unsigned>::iterator It = ValMap.lower_bound(&FG); if (It != ValMap.end() && It->first == &FG) @@ -366,7 +366,7 @@ processSCC(DSGraph &FG, std::vector<DSGraph*> &Stack, unsigned &NextID, for (DSGraph::retnodes_iterator I = NG->retnodes_begin(); I != NG->retnodes_end(); ++I) DSInfo[I->first] = &FG; - + // Remove NG from the ValMap since the pointer may get recycled. ValMap.erase(NG); delete NG; @@ -404,14 +404,14 @@ void EquivClassGraphs::processGraph(DSGraph &G) { assert(calls.insert(TheCall).second && "Call instruction occurs multiple times in graph??"); - + if (CS.getRetVal().isNull() && CS.getNumPtrArgs() == 0) continue; // Inline the common callee graph into the current graph, if the callee // graph has not changed. Note that all callees should have the same // graph so we only need to do this once. - // + // DSGraph* CalleeGraph = NULL; callee_iterator I = callee_begin(TheCall), E = callee_end(TheCall); unsigned TNum, Num; @@ -424,12 +424,12 @@ void EquivClassGraphs::processGraph(DSGraph &G) { // Now check if the graph has changed and if so, clone and inline it. if (I != E) { Function *CalleeFunc = I->second; - + // Merge the callee's graph into this graph, if not already the same. // Callees in the same equivalence class (which subsumes those // in the same SCCs) have the same graph. Note that all recursion // including self-recursion have been folded in the equiv classes. - // + // CalleeGraph = &getOrCreateGraph(*CalleeFunc); if (CalleeGraph != &G) { ++NumFoldGraphInlines; @@ -463,7 +463,7 @@ void EquivClassGraphs::processGraph(DSGraph &G) { // Recompute the Incomplete markers. G.maskIncompleteMarkers(); G.markIncompleteNodes(DSGraph::MarkFormalArgs); - + // Delete dead nodes. Treat globals that are unreachable but that can // reach live nodes as live. G.removeDeadNodes(DSGraph::KeepUnreachableGlobals); @@ -476,7 +476,7 @@ void EquivClassGraphs::processGraph(DSGraph &G) { // globals graph. DSScalarMap &MainSM = G.getScalarMap(); for (DSScalarMap::global_iterator I = MainSM.global_begin(), - E = MainSM.global_end(); I != E; ++I) + E = MainSM.global_end(); I != E; ++I) RC.getClonedNH(MainSM[*I]); DEBUG(std::cerr << " -- DONE ProcessGraph for function " diff --git a/lib/Analysis/DataStructure/GraphChecker.cpp b/lib/Analysis/DataStructure/GraphChecker.cpp index ba3315b..fa083d9 100644 --- a/lib/Analysis/DataStructure/GraphChecker.cpp +++ b/lib/Analysis/DataStructure/GraphChecker.cpp @@ -1,10 +1,10 @@ //===- GraphChecker.cpp - Assert that various graph properties hold -------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This pass is used to test DSA with regression tests. It can be used to check @@ -39,7 +39,7 @@ namespace { cl::desc("Specify which DSA pass the -datastructure-gc pass should use"), cl::values(clEnumVal(local, "Local pass"), clEnumVal(bu, "Bottom-up pass"), - clEnumVal(td, "Top-down pass"), + clEnumVal(td, "Top-down pass"), clEnumValEnd), cl::init(local)); cl::opt<bool> @@ -133,7 +133,7 @@ void DSGC::verify(const DSGraph &G) { std::set<std::string> AbortIfMergedS(AbortIfMerged.begin(), AbortIfMerged.end()); std::map<std::string, unsigned> CheckFlagsM; - + for (cl::list<std::string>::iterator I = CheckFlags.begin(), E = CheckFlags.end(); I != E; ++I) { std::string::size_type ColonPos = I->rfind(':'); @@ -158,18 +158,18 @@ void DSGC::verify(const DSGraph &G) { } CheckFlagsM[std::string(I->begin(), I->begin()+ColonPos)] = Flags; } - + // Now we loop over all of the scalars, checking to see if any are collapsed // that are not supposed to be, or if any are merged together. const DSGraph::ScalarMapTy &SM = G.getScalarMap(); std::map<DSNode*, std::string> AbortIfMergedNodes; - + for (DSGraph::ScalarMapTy::const_iterator I = SM.begin(), E = SM.end(); I != E; ++I) if (I->first->hasName() && I->second.getNode()) { const std::string &Name = I->first->getName(); DSNode *N = I->second.getNode(); - + // Verify it is not collapsed if it is not supposed to be... if (N->isNodeCompletelyFolded() && AbortIfCollapsedS.count(Name)) { std::cerr << "Node for value '%" << Name << "' is collapsed: "; diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp index cf8f8f4..106f3a1 100644 --- a/lib/Analysis/DataStructure/Local.cpp +++ b/lib/Analysis/DataStructure/Local.cpp @@ -1,10 +1,10 @@ //===- Local.cpp - Compute a local data structure graph for a function ----===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // Compute the local version of the data structure graph for a function. The @@ -76,7 +76,7 @@ namespace { std::list<DSCallSite> *FunctionCalls; public: - GraphBuilder(Function &f, DSGraph &g, DSNodeHandle &retNode, + GraphBuilder(Function &f, DSGraph &g, DSNodeHandle &retNode, std::list<DSCallSite> &fc) : G(g), RetNode(&retNode), ScalarMap(G.getScalarMap()), FunctionCalls(&fc) { @@ -148,7 +148,7 @@ namespace { /// void setDestTo(Value &V, const DSNodeHandle &NH); - /// getValueDest - Return the DSNode that the actual value points to. + /// getValueDest - Return the DSNode that the actual value points to. /// DSNodeHandle getValueDest(Value &V); @@ -182,7 +182,7 @@ DSGraph::DSGraph(EquivalenceClasses<GlobalValue*> &ECs, const TargetData &td, // initializers into the local graph from the globals graph. if (ScalarMap.global_begin() != ScalarMap.global_end()) { ReachabilityCloner RC(*this, *GG, 0); - + for (DSScalarMap::global_iterator I = ScalarMap.global_begin(); I != ScalarMap.global_end(); ++I) if (GlobalVariable *GV = dyn_cast<GlobalVariable>(*I)) @@ -313,7 +313,7 @@ void GraphBuilder::visitPHINode(PHINode &PN) { void GraphBuilder::visitSelectInst(SelectInst &SI) { if (!isPointerType(SI.getType())) return; // Only pointer Selects - + DSNodeHandle &Dest = ScalarMap[&SI]; Dest.mergeWith(getValueDest(*SI.getOperand(1))); Dest.mergeWith(getValueDest(*SI.getOperand(2))); @@ -573,7 +573,7 @@ void GraphBuilder::visitCallSite(CallSite CS) { AI != E; ++AI) { if (isPointerType((*AI)->getType())) if (DSNode *N = getValueDest(**AI).getNode()) - N->setReadMarker(); + N->setReadMarker(); } return; } else if (F->getName() == "read" || F->getName() == "pipe" || @@ -583,7 +583,7 @@ void GraphBuilder::visitCallSite(CallSite CS) { AI != E; ++AI) { if (isPointerType((*AI)->getType())) if (DSNode *N = getValueDest(**AI).getNode()) - N->setModifiedMarker(); + N->setModifiedMarker(); } return; } else if (F->getName() == "stat" || F->getName() == "fstat" || @@ -630,7 +630,7 @@ void GraphBuilder::visitCallSite(CallSite CS) { if (isPointerType((*AI)->getType())) if (DSNode *N = getValueDest(**AI).getNode()) N->setReadMarker(); - + // fopen allocates in an unknown way and writes to the file // descriptor. Also, merge the allocated type into the node. DSNodeHandle Result = getValueDest(*CS.getInstruction()); @@ -661,7 +661,7 @@ void GraphBuilder::visitCallSite(CallSite CS) { N->mergeTypeInfo(PTy->getElementType(), H.getOffset()); } return; - } else if (CS.arg_end()-CS.arg_begin() == 1 && + } else if (CS.arg_end()-CS.arg_begin() == 1 && (F->getName() == "fflush" || F->getName() == "feof" || F->getName() == "fileno" || F->getName() == "clearerr" || F->getName() == "rewind" || F->getName() == "ftell" || @@ -672,13 +672,13 @@ void GraphBuilder::visitCallSite(CallSite CS) { DSNodeHandle H = getValueDest(**CS.arg_begin()); if (DSNode *N = H.getNode()) { N->setReadMarker()->setModifiedMarker(); - + const Type *ArgTy = F->getFunctionType()->getParamType(0); if (const PointerType *PTy = dyn_cast<PointerType>(ArgTy)) N->mergeTypeInfo(PTy->getElementType(), H.getOffset()); } return; - } else if (CS.arg_end()-CS.arg_begin() == 4 && + } else if (CS.arg_end()-CS.arg_begin() == 4 && (F->getName() == "fwrite" || F->getName() == "fread")) { // fread writes the first operand, fwrite reads it. They both // read/write the FILE descriptor, and merges the FILE type. @@ -739,7 +739,7 @@ void GraphBuilder::visitCallSite(CallSite CS) { AI != E; ++AI) if (isPointerType((*AI)->getType())) if (DSNode *N = getValueDest(**AI).getNode()) - N->setReadMarker(); + N->setReadMarker(); return; } else if (F->getName() == "fseek" || F->getName() == "fgetpos" || F->getName() == "fsetpos") { @@ -789,7 +789,7 @@ void GraphBuilder::visitCallSite(CallSite CS) { // printf reads all pointer arguments. if (isPointerType((*AI)->getType())) if (DSNode *N = getValueDest(**AI).getNode()) - N->setReadMarker(); + N->setReadMarker(); } return; } else if (F->getName() == "vprintf" || F->getName() == "vfprintf" || @@ -825,7 +825,7 @@ void GraphBuilder::visitCallSite(CallSite CS) { N->setReadMarker(); ++AI; } - + // Read the valist, and the pointed-to objects. if (AI != E && isPointerType((*AI)->getType())) { const DSNodeHandle &VAList = getValueDest(**AI); @@ -869,7 +869,7 @@ void GraphBuilder::visitCallSite(CallSite CS) { // scanf writes all pointer arguments. if (isPointerType((*AI)->getType())) if (DSNode *N = getValueDest(**AI).getNode()) - N->setModifiedMarker(); + N->setModifiedMarker(); } return; } else if (F->getName() == "strtok") { @@ -905,7 +905,7 @@ void GraphBuilder::visitCallSite(CallSite CS) { if (isPointerType((*AI)->getType())) if (DSNode *N = getValueDest(**AI).getNode()) N->setReadMarker(); - + if (DSNode *N = H.getNode()) N->setReadMarker(); return; @@ -1079,23 +1079,23 @@ static void BuildGlobalECs(DSGraph &GG, std::set<GlobalValue*> &ECGlobals) { GlobalValue *First = GVs[0]; for (unsigned i = 1, e = GVs.size(); i != e; ++i) GlobalECs.unionSets(First, GVs[i]); - + // Next, get the leader element. assert(First == GlobalECs.getLeaderValue(First) && "First did not end up being the leader?"); - + // Next, remove all globals from the scalar map that are not the leader. assert(GVs[0] == First && "First had to be at the front!"); for (unsigned i = 1, e = GVs.size(); i != e; ++i) { ECGlobals.insert(GVs[i]); SM.erase(SM.find(GVs[i])); } - + // Finally, change the global node to only contain the leader. I->clearGlobals(); I->addGlobal(First); } - + DEBUG(GG.AssertGraphOK()); } @@ -1151,7 +1151,7 @@ bool LocalDataStructures::runOnModule(Module &M) { GlobalsGraph = new DSGraph(GlobalECs, TD); { GraphBuilder GGB(*GlobalsGraph); - + // Add initializers for all of the globals to the globals graph. for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) diff --git a/lib/Analysis/DataStructure/Printer.cpp b/lib/Analysis/DataStructure/Printer.cpp index b5fd689..2cd044e 100644 --- a/lib/Analysis/DataStructure/Printer.cpp +++ b/lib/Analysis/DataStructure/Printer.cpp @@ -1,10 +1,10 @@ //===- Printer.cpp - Code for printing data structure graphs nicely -------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the 'dot' graph printer. @@ -76,7 +76,7 @@ static std::string getCaption(const DSNode *N, const DSGraph *G) { EquivalenceClasses<GlobalValue*> *GlobalECs = 0; if (G) GlobalECs = &G->getGlobalECs(); - + for (unsigned i = 0, e = N->getGlobalsList().size(); i != e; ++i) { WriteAsOperand(OS, N->getGlobalsList()[i], false, true, M); @@ -85,7 +85,7 @@ static std::string getCaption(const DSNode *N, const DSGraph *G) { EquivalenceClasses<GlobalValue*>::iterator I = GlobalECs->findValue(N->getGlobalsList()[i]); if (I != GlobalECs->end()) { - unsigned NumMembers = + unsigned NumMembers = std::distance(GlobalECs->member_begin(I), GlobalECs->member_end()); if (NumMembers != 1) OS << " + " << (NumMembers-1) << " EC"; } @@ -132,7 +132,7 @@ struct DOTGraphTraits<const DSGraph*> : public DefaultDOTGraphTraits { return R; } - + /// addCustomGraphFeatures - Use this graph writing hook to emit call nodes /// and the return node. /// @@ -156,7 +156,7 @@ struct DOTGraphTraits<const DSGraph*> : public DefaultDOTGraphTraits { std::stringstream OS; WriteAsOperand(OS, I->first, false, true, CurMod); GW.emitSimpleNode(I->first, "", OS.str()); - + // Add edge from return node to real destination DSNode *DestNode = I->second.getNode(); int EdgeDest = I->second.getOffset() >> DS::PointerShift; @@ -241,7 +241,7 @@ void DSGraph::writeGraphToFile(std::ostream &O, std::string Filename = GraphName + ".dot"; O << "Writing '" << Filename << "'..."; std::ofstream F(Filename.c_str()); - + if (F.good()) { print(F); unsigned NumCalls = shouldPrintAuxCalls() ? @@ -329,7 +329,7 @@ static void printCollection(const Collection &C, std::ostream &O, << GG.getGraphSize() << "+" << GG.getFunctionCalls().size() << "]\n"; } - O << "\nGraphs contain [" << TotalNumNodes << "+" << TotalCallNodes + O << "\nGraphs contain [" << TotalNumNodes << "+" << TotalCallNodes << "] nodes total" << std::endl; } diff --git a/lib/Analysis/DataStructure/Steensgaard.cpp b/lib/Analysis/DataStructure/Steensgaard.cpp index 9f0574d..ec0bc1f 100644 --- a/lib/Analysis/DataStructure/Steensgaard.cpp +++ b/lib/Analysis/DataStructure/Steensgaard.cpp @@ -1,10 +1,10 @@ //===- Steensgaard.cpp - Context Insensitive Alias Analysis ---------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This pass uses the data structure graphs to implement a simple context @@ -59,7 +59,7 @@ namespace { //------------------------------------------------ // Implement the AliasAnalysis API - // + // AliasResult alias(const Value *V1, unsigned V1Size, const Value *V2, unsigned V2Size); @@ -140,12 +140,12 @@ bool Steens::runOnModule(Module &M) { for (std::list<DSCallSite>::iterator CI = Calls.begin(), E = Calls.end(); CI != E;) { DSCallSite &CurCall = *CI++; - + // Loop over the called functions, eliminating as many as possible... std::vector<Function*> CallTargets; if (CurCall.isDirectCall()) CallTargets.push_back(CurCall.getCalleeFunc()); - else + else CurCall.getCalleeNode()->addFullFunctionList(CallTargets); for (unsigned c = 0; c != CallTargets.size(); ) { @@ -239,11 +239,11 @@ AliasAnalysis::AliasResult Steens::alias(const Value *V1, unsigned V1Size, AliasAnalysis::ModRefResult Steens::getModRefInfo(CallSite CS, Value *P, unsigned Size) { AliasAnalysis::ModRefResult Result = ModRef; - + // Find the node in question. DSGraph::ScalarMapTy &GSM = ResultGraph->getScalarMap(); DSGraph::ScalarMapTy::iterator I = GSM.find(P); - + if (I != GSM.end() && !I->second.isNull()) { DSNode *N = I->second.getNode(); if (N->isComplete()) { @@ -253,7 +253,7 @@ Steens::getModRefInfo(CallSite CS, Value *P, unsigned Size) { if (Function *F = CS.getCalledFunction()) if (F->isExternal()) return NoModRef; - + // Otherwise, if the node is complete, but it is only M or R, return this. // This can be useful for globals that should be marked const but are not. if (!N->isModified()) diff --git a/lib/Analysis/DataStructure/TopDownClosure.cpp b/lib/Analysis/DataStructure/TopDownClosure.cpp index 9ce6cde..c1a6cb8 100644 --- a/lib/Analysis/DataStructure/TopDownClosure.cpp +++ b/lib/Analysis/DataStructure/TopDownClosure.cpp @@ -1,10 +1,10 @@ //===- TopDownClosure.cpp - Compute the top-down interprocedure closure ---===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the TDDataStructures class, which represents the @@ -135,7 +135,7 @@ bool TDDataStructures::runOnModule(Module &M) { delete IndCallMap.begin()->second; IndCallMap.erase(IndCallMap.begin()); } - + ArgsRemainIncomplete.clear(); GlobalsGraph->removeTriviallyDeadNodes(); @@ -170,7 +170,7 @@ void TDDataStructures::ComputePostOrder(Function &F,hash_set<DSGraph*> &Visited, DSGraph &G = getOrCreateDSGraph(F); if (Visited.count(&G)) return; Visited.insert(&G); - + // Recursively traverse all of the callee graphs. for (DSGraph::fc_iterator CI = G.fc_begin(), CE = G.fc_end(); CI != CE; ++CI){ Instruction *CallI = CI->getCallSite().getInstruction(); @@ -214,12 +214,12 @@ void TDDataStructures::InlineCallersIntoGraph(DSGraph &DSG) { // sites that call into this graph. std::vector<CallerCallEdge> EdgesFromCaller; std::map<DSGraph*, std::vector<CallerCallEdge> >::iterator - CEI = CallerEdges.find(&DSG); + CEI = CallerEdges.find(&DSG); if (CEI != CallerEdges.end()) { std::swap(CEI->second, EdgesFromCaller); CallerEdges.erase(CEI); } - + // Sort the caller sites to provide a by-caller-graph ordering. std::sort(EdgesFromCaller.begin(), EdgesFromCaller.end()); @@ -267,7 +267,7 @@ void TDDataStructures::InlineCallersIntoGraph(DSGraph &DSG) { getParent()->getParent()->getName() << "'"); DEBUG(std::cerr << ": " << CF.getFunctionType()->getNumParams() << " args\n"); - + // Get the formal argument and return nodes for the called function and // merge them with the cloned subgraph. DSCallSite T1 = DSG.getCallSiteForArguments(CF); @@ -356,7 +356,7 @@ void TDDataStructures::InlineCallersIntoGraph(DSGraph &DSG) { // so we build up a new, private, graph that represents the calls of all // calls to this set of functions. std::vector<Function*> Callees; - for (BUDataStructures::ActualCalleesTy::const_iterator I = + for (BUDataStructures::ActualCalleesTy::const_iterator I = BUInfo->callee_begin(CallI), E = BUInfo->callee_end(CallI); I != E; ++I) if (!I->second->isExternal()) |