From 460ea29b456185e169a5ef036d22e25dd0afa58e Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 7 Nov 2002 07:06:20 +0000 Subject: [PATCH] Instead of using a bool that constant has to be explained, use a self explanitory enum instead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4600 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/DSGraph.h | 21 ++++++++++++------- include/llvm/Analysis/DataStructure/DSGraph.h | 21 ++++++++++++------- .../DataStructure/BottomUpClosure.cpp | 4 ++-- lib/Analysis/DataStructure/DataStructure.cpp | 11 +++++----- lib/Analysis/DataStructure/TopDownClosure.cpp | 2 +- 5 files changed, 34 insertions(+), 25 deletions(-) diff --git a/include/llvm/Analysis/DSGraph.h b/include/llvm/Analysis/DSGraph.h index 572410d6492..66a4e6835e0 100644 --- a/include/llvm/Analysis/DSGraph.h +++ b/include/llvm/Analysis/DSGraph.h @@ -125,25 +125,30 @@ public: // void removeDeadNodes(bool KeepAllGlobals = false, bool KeepCalls = true); + enum AllocaBit { + StripAllocaBit, + KeepAllocaBit + }; + // cloneInto - Clone the specified DSGraph into the current graph, returning // the Return node of the graph. The translated ScalarMap for the old - // function is filled into the OldValMap member. If StripScalars - // (StripAllocas) is set to true, Scalar (Alloca) markers are removed from the - // graph as the graph is being cloned. + // function is filled into the OldValMap member. If StripAllocas is set to + // 'StripAllocaBit', Alloca markers are removed from the graph as the graph is + // being cloned. // DSNodeHandle cloneInto(const DSGraph &G, std::map &OldValMap, std::map &OldNodeMap, - bool StripAllocas = false); + AllocaBit StripAllocas = KeepAllocaBit); /// mergeInGraph - The method is used for merging graphs together. If the /// argument graph is not *this, it makes a clone of the specified graph, then /// merges the nodes specified in the call site with the formal arguments in - /// the graph. If the StripAlloca's argument is true then Alloca markers are - /// removed from nodes. + /// the graph. If the StripAlloca's argument is 'StripAllocaBit' then Alloca + /// markers are removed from nodes. /// - void mergeInGraph(DSCallSite &CS, const DSGraph &Graph, bool StripAllocas); - + void mergeInGraph(DSCallSite &CS, const DSGraph &Graph, + AllocaBit StripAllocas); #if 0 // cloneGlobalInto - Clone the given global node (or the node for the given diff --git a/include/llvm/Analysis/DataStructure/DSGraph.h b/include/llvm/Analysis/DataStructure/DSGraph.h index 572410d6492..66a4e6835e0 100644 --- a/include/llvm/Analysis/DataStructure/DSGraph.h +++ b/include/llvm/Analysis/DataStructure/DSGraph.h @@ -125,25 +125,30 @@ public: // void removeDeadNodes(bool KeepAllGlobals = false, bool KeepCalls = true); + enum AllocaBit { + StripAllocaBit, + KeepAllocaBit + }; + // cloneInto - Clone the specified DSGraph into the current graph, returning // the Return node of the graph. The translated ScalarMap for the old - // function is filled into the OldValMap member. If StripScalars - // (StripAllocas) is set to true, Scalar (Alloca) markers are removed from the - // graph as the graph is being cloned. + // function is filled into the OldValMap member. If StripAllocas is set to + // 'StripAllocaBit', Alloca markers are removed from the graph as the graph is + // being cloned. // DSNodeHandle cloneInto(const DSGraph &G, std::map &OldValMap, std::map &OldNodeMap, - bool StripAllocas = false); + AllocaBit StripAllocas = KeepAllocaBit); /// mergeInGraph - The method is used for merging graphs together. If the /// argument graph is not *this, it makes a clone of the specified graph, then /// merges the nodes specified in the call site with the formal arguments in - /// the graph. If the StripAlloca's argument is true then Alloca markers are - /// removed from nodes. + /// the graph. If the StripAlloca's argument is 'StripAllocaBit' then Alloca + /// markers are removed from nodes. /// - void mergeInGraph(DSCallSite &CS, const DSGraph &Graph, bool StripAllocas); - + void mergeInGraph(DSCallSite &CS, const DSGraph &Graph, + AllocaBit StripAllocas); #if 0 // cloneGlobalInto - Clone the given global node (or the node for the given diff --git a/lib/Analysis/DataStructure/BottomUpClosure.cpp b/lib/Analysis/DataStructure/BottomUpClosure.cpp index cbe53ce68e2..ed9336d2b73 100644 --- a/lib/Analysis/DataStructure/BottomUpClosure.cpp +++ b/lib/Analysis/DataStructure/BottomUpClosure.cpp @@ -93,7 +93,7 @@ DSGraph &BUDataStructures::calculateGraph(Function &F) { DEBUG(std::cerr << "\t[BU] Self Inlining: " << F.getName() << "\n"); // Handle self recursion by resolving the arguments and return value - Graph->mergeInGraph(Call, *Graph, true); + Graph->mergeInGraph(Call, *Graph, DSGraph::StripAllocaBit); // Erase the entry in the callees vector Callees.erase(Callees.begin()+c--); @@ -120,7 +120,7 @@ DSGraph &BUDataStructures::calculateGraph(Function &F) { CallSitesForFunc.back().setCallee(0); // Handle self recursion by resolving the arguments and return value - Graph->mergeInGraph(Call, GI, true); + Graph->mergeInGraph(Call, GI, DSGraph::StripAllocaBit); // Erase the entry in the Callees vector Callees.erase(Callees.begin()+c--); diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp index 41cd7185ec9..31ff0a91b24 100644 --- a/lib/Analysis/DataStructure/DataStructure.cpp +++ b/lib/Analysis/DataStructure/DataStructure.cpp @@ -526,7 +526,7 @@ void DSNode::remapLinks(std::map &OldNodeMap) { DSNodeHandle DSGraph::cloneInto(const DSGraph &G, std::map &OldValMap, std::map &OldNodeMap, - bool StripAllocas) { + AllocaBit StripAllocas) { assert(OldNodeMap.empty() && "Returned OldNodeMap should be empty!"); unsigned FN = Nodes.size(); // First new node... @@ -544,11 +544,10 @@ DSNodeHandle DSGraph::cloneInto(const DSGraph &G, for (unsigned i = FN, e = Nodes.size(); i != e; ++i) Nodes[i]->remapLinks(OldNodeMap); - // Remove local markers as specified - unsigned char StripBits = StripAllocas ? DSNode::AllocaNode : 0; - if (StripBits) + // Remove alloca markers as specified + if (StripAllocas == StripAllocaBit) for (unsigned i = FN, e = Nodes.size(); i != e; ++i) - Nodes[i]->NodeType &= ~StripBits; + Nodes[i]->NodeType &= ~DSNode::AllocaNode; // Copy the value map... and merge all of the global nodes... for (std::map::const_iterator I = G.ScalarMap.begin(), @@ -580,7 +579,7 @@ DSNodeHandle DSGraph::cloneInto(const DSGraph &G, /// graph. /// void DSGraph::mergeInGraph(DSCallSite &CS, const DSGraph &Graph, - bool StripAllocas) { + AllocaBit StripAllocas) { std::map OldValMap; DSNodeHandle RetVal; std::map *ScalarMap = &OldValMap; diff --git a/lib/Analysis/DataStructure/TopDownClosure.cpp b/lib/Analysis/DataStructure/TopDownClosure.cpp index 817e734a9cc..a37ccd98fab 100644 --- a/lib/Analysis/DataStructure/TopDownClosure.cpp +++ b/lib/Analysis/DataStructure/TopDownClosure.cpp @@ -177,7 +177,7 @@ DSGraph &TDDataStructures::calculateGraph(Function &F) { // Strip scalars but not allocas since they are alive in callee. // DSNodeHandle RetVal = Graph->cloneInto(CG, OldValMap, OldNodeMap, - /*StripAllocas*/ false); + DSGraph::KeepAllocaBit); ResolveCallSite(*Graph, DSCallSite(CallSiteInCG, OldNodeMap)); }