OSDN Git Service

[SimplifyCFG] Change recursive calls to llvm::SimplifyCFG to instead use an outer...
authorCraig Topper <craig.topper@intel.com>
Thu, 4 Oct 2018 21:11:52 +0000 (21:11 +0000)
committerCraig Topper <craig.topper@intel.com>
Thu, 4 Oct 2018 21:11:52 +0000 (21:11 +0000)
commitbb5ea99c11123d254d12d24c8cfabcd3ff387e31
tree53ae19c9ebe65a7e6d1c8da829b725c8ceca3cfa
parent65c237b70d600dc8ac8ffe852553a634d3137a44
[SimplifyCFG] Change recursive calls to llvm::SimplifyCFG to instead use an outer while loop to revisit.

Summary:
The llvm::SimplifyCFG function creates a SimplifyCFGOpt object and calls run on it. There were numerous places reached from this run function that called back out llvm::SimplifyCFG which would create another SimplifyCFGOpt object. This is an inefficient use of stack space at minimum. We are also not passing along the LoopHeaders pointer passed into the outer llvm::SimplifyCFG call. So if its not null we lose it on the first recursion and get nullptr from there on.

This patch adds an outer loop around the main BasicBlock simplifying code and adds a flag to the SimplifyCFGOpt class that can be set by to request another iteration. I don't think we can iterate based just on the change flag alone since some of the simplifications delete a basic block entirely leaving nothing to iterate on.

Reviewers: bogner, eli.friedman, reames

Reviewed By: reames

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D52760

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343816 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/SimplifyCFG.cpp