diff options
| author | JF Bastien <jfb@google.com> | 2015-07-15 21:51:33 +0000 |
|---|---|---|
| committer | JF Bastien <jfb@google.com> | 2015-07-15 21:51:33 +0000 |
| commit | 7289f73b8d6886bc04d19d0d518c2536d4b5f149 (patch) | |
| tree | 0e349dbd0c0032c6aaf3d371719583148567d0c2 /llvm/lib/Transforms/IPO | |
| parent | f662e00a688305fa72fbbb7fb840eac173ed3c0f (diff) | |
| download | bcm5719-llvm-7289f73b8d6886bc04d19d0d518c2536d4b5f149.tar.gz bcm5719-llvm-7289f73b8d6886bc04d19d0d518c2536d4b5f149.zip | |
Fix mergefunc infinite loop
Self-referential constants containing references to a merged function
no longer cause the MergeFunctions pass to infinite loop. Also adds a
reproduction IR which would otherwise fail, which was isolated from a similar
issue in Chromium.
Author: jrkoenig
Reviewers: nlewycky, jfb
Subscribers: llvm-commits, nlewycky, jfb
Differential Revision: http://reviews.llvm.org/D11208
llvm-svn: 242337
Diffstat (limited to 'llvm/lib/Transforms/IPO')
| -rw-r--r-- | llvm/lib/Transforms/IPO/MergeFunctions.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp index 2e3519eac6a..109cac7fece 100644 --- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp +++ b/llvm/lib/Transforms/IPO/MergeFunctions.cpp @@ -1516,6 +1516,8 @@ void MergeFunctions::remove(Function *F) { void MergeFunctions::removeUsers(Value *V) { std::vector<Value *> Worklist; Worklist.push_back(V); + SmallSet<Value*, 8> Visited; + Visited.insert(V); while (!Worklist.empty()) { Value *V = Worklist.back(); Worklist.pop_back(); @@ -1526,8 +1528,10 @@ void MergeFunctions::removeUsers(Value *V) { } else if (isa<GlobalValue>(U)) { // do nothing } else if (Constant *C = dyn_cast<Constant>(U)) { - for (User *UU : C->users()) - Worklist.push_back(UU); + for (User *UU : C->users()) { + if (!Visited.insert(UU).second) + Worklist.push_back(UU); + } } } } |

