mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-18 12:29:21 +00:00
Start using retnodes_* for iteration.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20618 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
60cc3e1c4e
commit
a5f47ea23d
@ -228,8 +228,8 @@ unsigned BUDataStructures::calculateGraphs(Function *F,
|
||||
SCCGraph->getReturnNodes(), NodeMap);
|
||||
}
|
||||
// Update the DSInfo map and delete the old graph...
|
||||
for (DSGraph::ReturnNodesTy::iterator I = G.getReturnNodes().begin(),
|
||||
E = G.getReturnNodes().end(); I != E; ++I)
|
||||
for (DSGraph::retnodes_iterator I = G.retnodes_begin(),
|
||||
E = G.retnodes_end(); I != E; ++I)
|
||||
DSInfo[I->first] = SCCGraph;
|
||||
delete &G;
|
||||
}
|
||||
@ -496,7 +496,7 @@ void BUDataStructures::copyValue(Value *From, Value *To) {
|
||||
assert(NG->getReturnNodes().size() == 1 && "Cannot copy SCC's yet!");
|
||||
|
||||
// Change the Function* is the returnnodes map to the ToF.
|
||||
DSNodeHandle Ret = NG->getReturnNodes().begin()->second;
|
||||
DSNodeHandle Ret = NG->retnodes_begin()->second;
|
||||
NG->getReturnNodes().clear();
|
||||
NG->getReturnNodes()[ToF] = Ret;
|
||||
return;
|
||||
|
@ -127,8 +127,8 @@ DSGraph &CompleteBUDataStructures::getOrCreateGraph(Function &F) {
|
||||
|
||||
// Make sure to update the DSInfo map for all of the functions currently in
|
||||
// this graph!
|
||||
for (DSGraph::ReturnNodesTy::iterator I = Graph->getReturnNodes().begin();
|
||||
I != Graph->getReturnNodes().end(); ++I)
|
||||
for (DSGraph::retnodes_iterator I = Graph->retnodes_begin();
|
||||
I != Graph->retnodes_end(); ++I)
|
||||
DSInfo[I->first] = Graph;
|
||||
|
||||
return *Graph;
|
||||
@ -180,8 +180,8 @@ unsigned CompleteBUDataStructures::calculateSCCGraphs(DSGraph &FG,
|
||||
FG.cloneInto(*NG, FG.getScalarMap(), FG.getReturnNodes(), NodeMap);
|
||||
|
||||
// Update the DSInfo map and delete the old graph...
|
||||
for (DSGraph::ReturnNodesTy::iterator I = NG->getReturnNodes().begin();
|
||||
I != NG->getReturnNodes().end(); ++I)
|
||||
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.
|
||||
|
@ -547,8 +547,8 @@ bool DSNode::mergeTypeInfo(const Type *NewTy, unsigned Offset,
|
||||
}
|
||||
|
||||
Module *M = 0;
|
||||
if (getParentGraph()->getReturnNodes().size())
|
||||
M = getParentGraph()->getReturnNodes().begin()->first->getParent();
|
||||
if (getParentGraph()->retnodes_begin() != getParentGraph()->retnodes_end())
|
||||
M = getParentGraph()->retnodes_begin()->first->getParent();
|
||||
DEBUG(std::cerr << "MergeTypeInfo Folding OrigTy: ";
|
||||
WriteTypeSymbolic(std::cerr, Ty, M) << "\n due to:";
|
||||
WriteTypeSymbolic(std::cerr, NewTy, M) << " @ " << Offset << "!\n"
|
||||
@ -1058,11 +1058,11 @@ void DSCallSite::InitNH(DSNodeHandle &NH, const DSNodeHandle &Src,
|
||||
std::string DSGraph::getFunctionNames() const {
|
||||
switch (getReturnNodes().size()) {
|
||||
case 0: return "Globals graph";
|
||||
case 1: return getReturnNodes().begin()->first->getName();
|
||||
case 1: return retnodes_begin()->first->getName();
|
||||
default:
|
||||
std::string Return;
|
||||
for (DSGraph::ReturnNodesTy::const_iterator I = getReturnNodes().begin();
|
||||
I != getReturnNodes().end(); ++I)
|
||||
for (DSGraph::retnodes_iterator I = retnodes_begin();
|
||||
I != retnodes_end(); ++I)
|
||||
Return += I->first->getName() + " ";
|
||||
Return.erase(Return.end()-1, Return.end()); // Remove last space character
|
||||
return Return;
|
||||
@ -1233,8 +1233,8 @@ void DSGraph::cloneInto(const DSGraph &G, DSScalarMap &OldValMap,
|
||||
}
|
||||
|
||||
// Map the return node pointers over...
|
||||
for (ReturnNodesTy::const_iterator I = G.getReturnNodes().begin(),
|
||||
E = G.getReturnNodes().end(); I != E; ++I) {
|
||||
for (retnodes_iterator I = G.retnodes_begin(),
|
||||
E = G.retnodes_end(); I != E; ++I) {
|
||||
const DSNodeHandle &Ret = I->second;
|
||||
DSNodeHandle &MappedRet = OldNodeMap[Ret.getNode()];
|
||||
DSNode *MappedRetN = MappedRet.getNode();
|
||||
|
@ -45,7 +45,7 @@ static void CheckAllGraphs(Module *M, GT &ECGraphs) {
|
||||
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
|
||||
if (!I->isExternal()) {
|
||||
DSGraph &G = ECGraphs.getDSGraph(*I);
|
||||
if (G.getReturnNodes().begin()->first != I)
|
||||
if (G.retnodes_begin()->first != I)
|
||||
continue; // Only check a graph once.
|
||||
|
||||
DSGraph::NodeMapTy GlobalsGraphNodeMapping;
|
||||
@ -181,9 +181,8 @@ void EquivClassGraphs::buildIndirectFunctionSets(Module &M) {
|
||||
// Currently, that is just the functions in the same call-graph-SCC as F.
|
||||
//
|
||||
DSGraph& funcDSGraph = CBU->getDSGraph(*I->second);
|
||||
const DSGraph::ReturnNodesTy &RetNodes = funcDSGraph.getReturnNodes();
|
||||
for (DSGraph::ReturnNodesTy::const_iterator RI=RetNodes.begin(),
|
||||
RE=RetNodes.end(); RI != RE; ++RI)
|
||||
for (DSGraph::retnodes_iterator RI = funcDSGraph.retnodes_begin(),
|
||||
RE = funcDSGraph.retnodes_end(); RI != RE; ++RI)
|
||||
FuncECs.unionSetsWith(FirstFunc, RI->first);
|
||||
}
|
||||
|
||||
@ -235,10 +234,8 @@ void EquivClassGraphs::buildIndirectFunctionSets(Module &M) {
|
||||
continue;
|
||||
|
||||
// Record the "folded" graph for the function.
|
||||
for (DSGraph::ReturnNodesTy::iterator
|
||||
I = CBUGraph.getReturnNodes().begin(),
|
||||
E = CBUGraph.getReturnNodes().end();
|
||||
I != E; ++I) {
|
||||
for (DSGraph::retnodes_iterator I = CBUGraph.retnodes_begin(),
|
||||
E = CBUGraph.retnodes_end(); I != E; ++I) {
|
||||
assert(DSInfo[I->first] == 0 && "Graph already exists for Fn!");
|
||||
DSInfo[I->first] = &MergedG;
|
||||
}
|
||||
@ -284,8 +281,8 @@ DSGraph &EquivClassGraphs::getOrCreateGraph(Function &F) {
|
||||
Graph->setPrintAuxCalls();
|
||||
|
||||
// Make sure to update the DSInfo map for all functions in the graph!
|
||||
for (DSGraph::ReturnNodesTy::iterator I = Graph->getReturnNodes().begin();
|
||||
I != Graph->getReturnNodes().end(); ++I)
|
||||
for (DSGraph::retnodes_iterator I = Graph->retnodes_begin();
|
||||
I != Graph->retnodes_end(); ++I)
|
||||
if (I->first != &F) {
|
||||
DSGraph *&FG = DSInfo[I->first];
|
||||
assert(FG == 0 && "Merging function in SCC twice?");
|
||||
@ -342,8 +339,8 @@ processSCC(DSGraph &FG, std::vector<DSGraph*> &Stack, unsigned &NextID,
|
||||
FG.cloneInto(*NG, FG.getScalarMap(), FG.getReturnNodes(), NodeMap);
|
||||
|
||||
// Update the DSInfo map and delete the old graph...
|
||||
for (DSGraph::ReturnNodesTy::iterator I = NG->getReturnNodes().begin();
|
||||
I != NG->getReturnNodes().end(); ++I)
|
||||
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.
|
||||
|
@ -44,8 +44,8 @@ static std::string getCaption(const DSNode *N, const DSGraph *G) {
|
||||
if (!G) G = N->getParentGraph();
|
||||
|
||||
// Get the module from ONE of the functions in the graph it is available.
|
||||
if (G && !G->getReturnNodes().empty())
|
||||
M = G->getReturnNodes().begin()->first->getParent();
|
||||
if (G && G->retnodes_begin() != G->retnodes_end())
|
||||
M = G->retnodes_begin()->first->getParent();
|
||||
if (M == 0 && G) {
|
||||
// If there is a global in the graph, we can use it to find the module.
|
||||
const DSScalarMap &SM = G->getScalarMap();
|
||||
@ -126,8 +126,8 @@ struct DOTGraphTraits<const DSGraph*> : public DefaultDOTGraphTraits {
|
||||
static void addCustomGraphFeatures(const DSGraph *G,
|
||||
GraphWriter<const DSGraph*> &GW) {
|
||||
Module *CurMod = 0;
|
||||
if (!G->getReturnNodes().empty())
|
||||
CurMod = G->getReturnNodes().begin()->first->getParent();
|
||||
if (G->retnodes_begin() != G->retnodes_end())
|
||||
CurMod = G->retnodes_begin()->first->getParent();
|
||||
else {
|
||||
// If there is a global in the graph, we can use it to find the module.
|
||||
const DSScalarMap &SM = G->getScalarMap();
|
||||
@ -154,12 +154,11 @@ struct DOTGraphTraits<const DSGraph*> : public DefaultDOTGraphTraits {
|
||||
|
||||
|
||||
// Output the returned value pointer...
|
||||
const DSGraph::ReturnNodesTy &RetNodes = G->getReturnNodes();
|
||||
for (DSGraph::ReturnNodesTy::const_iterator I = RetNodes.begin(),
|
||||
E = RetNodes.end(); I != E; ++I)
|
||||
for (DSGraph::retnodes_iterator I = G->retnodes_begin(),
|
||||
E = G->retnodes_end(); I != E; ++I)
|
||||
if (I->second.getNode()) {
|
||||
std::string Label;
|
||||
if (RetNodes.size() == 1)
|
||||
if (G->getReturnNodes().size() == 1)
|
||||
Label = "returning";
|
||||
else
|
||||
Label = I->first->getName() + " ret node";
|
||||
@ -276,7 +275,7 @@ static void printCollection(const Collection &C, std::ostream &O,
|
||||
|
||||
TotalCallNodes += NumCalls;
|
||||
if (I->getName() == "main" || !OnlyPrintMain) {
|
||||
Function *SCCFn = Gr.getReturnNodes().begin()->first;
|
||||
Function *SCCFn = Gr.retnodes_begin()->first;
|
||||
if (&*I == SCCFn)
|
||||
Gr.writeGraphToFile(O, Prefix+I->getName());
|
||||
else
|
||||
|
@ -179,9 +179,8 @@ void TDDataStructures::inlineGraphIntoCallees(DSGraph &Graph) {
|
||||
// If any of the functions has incomplete incoming arguments, don't mark any
|
||||
// of them as complete.
|
||||
bool HasIncompleteArgs = false;
|
||||
const DSGraph::ReturnNodesTy &GraphReturnNodes = Graph.getReturnNodes();
|
||||
for (DSGraph::ReturnNodesTy::const_iterator I = GraphReturnNodes.begin(),
|
||||
E = GraphReturnNodes.end(); I != E; ++I)
|
||||
for (DSGraph::retnodes_iterator I = Graph.retnodes_begin(),
|
||||
E = Graph.retnodes_end(); I != E; ++I)
|
||||
if (ArgsRemainIncomplete.count(I->first)) {
|
||||
HasIncompleteArgs = true;
|
||||
break;
|
||||
@ -330,7 +329,7 @@ void TDDataStructures::copyValue(Value *From, Value *To) {
|
||||
assert(NG->getReturnNodes().size() == 1 && "Cannot copy SCC's yet!");
|
||||
|
||||
// Change the Function* is the returnnodes map to the ToF.
|
||||
DSNodeHandle Ret = NG->getReturnNodes().begin()->second;
|
||||
DSNodeHandle Ret = NG->retnodes_begin()->second;
|
||||
NG->getReturnNodes().clear();
|
||||
NG->getReturnNodes()[ToF] = Ret;
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user