[llvm-commits] [llvm] r96956 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Chris Lattner
clattner at apple.com
Tue Feb 23 09:41:28 PST 2010
On Feb 23, 2010, at 9:37 AM, David Greene wrote:
> Author: greened
> Date: Tue Feb 23 11:37:50 2010
> New Revision: 96956
>
> URL: http://llvm.org/viewvc/llvm-project?rev=96956&view=rev
> Log:
>
> Speed up cycle checking significantly by caching results.
Please use a SmallPtrSet instead of std::set, it is much faster for pointers.
-Chris
>
> Modified:
> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=96956&r1=96955&r2=96956&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Feb 23 11:37:50 2010
> @@ -6315,7 +6315,11 @@
> }
>
> static void checkForCyclesHelper(const SDNode *N,
> - std::set<const SDNode *> &visited) {
> + std::set<const SDNode *> &visited,
> + std::set<const SDNode *> &checked) {
> + if (checked.find(N) != checked.end())
> + return;
> +
> if (visited.find(N) != visited.end()) {
> dbgs() << "Offending node:\n";
> N->dumprFull();
> @@ -6329,16 +6333,18 @@
> assert(inserted && "Missed cycle");
>
> for(unsigned i = 0; i < N->getNumOperands(); ++i) {
> - checkForCyclesHelper(N->getOperand(i).getNode(), visited);
> + checkForCyclesHelper(N->getOperand(i).getNode(), visited, checked);
> }
> visited.erase(i);
> + checked.insert(N);
> }
>
> void llvm::checkForCycles(const llvm::SDNode *N) {
> #ifdef XDEBUG
> assert(N && "Checking nonexistant SDNode");
> std::set<const SDNode *> visited;
> - checkForCyclesHelper(N, visited);
> + std::set<const SDNode *> checked;
> + checkForCyclesHelper(N, visited, checked);
> #endif
> }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list