diff options
author | Fangrui Song <maskray@google.com> | 2019-04-19 07:57:51 +0000 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2019-04-19 07:57:51 +0000 |
commit | 884f557bb216030769d40c00f55977e262b761a4 (patch) | |
tree | b4ef2be41db8ab5bd8bbd9ecf16d6f970b044a96 /llvm/lib/Transforms/IPO/MergeFunctions.cpp | |
parent | 72e2960e525a30bd8a105bd474b5c38267de02fc (diff) | |
download | bcm5719-llvm-884f557bb216030769d40c00f55977e262b761a4.tar.gz bcm5719-llvm-884f557bb216030769d40c00f55977e262b761a4.zip |
[MergeFunc] removeUsers: call remove() only on direct users
removeUsers uses a work list to collect indirect users and call remove()
on those functions. However it has a bug (`if (!Visited.insert(UU).second)`).
Actually, we don't have to collect indirect users.
After the merge of F and G, G's callers will be considered (added to
Deferred). If G's callers can be merged, G's callers' callers will be
considered.
Update the test unnamed-addr-reprocessing.ll to make it clear we can
still merge indirect callers.
llvm-svn: 358741
Diffstat (limited to 'llvm/lib/Transforms/IPO/MergeFunctions.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/MergeFunctions.cpp | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/llvm/lib/Transforms/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp index 8a40f0479f2..9b3bf850528 100644 --- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp +++ b/llvm/lib/Transforms/IPO/MergeFunctions.cpp @@ -948,25 +948,7 @@ void MergeFunctions::remove(Function *F) { // For each instruction used by the value, remove() the function that contains // the instruction. This should happen right before a call to RAUW. void MergeFunctions::removeUsers(Value *V) { - std::vector<Value *> Worklist; - Worklist.push_back(V); - SmallPtrSet<Value*, 8> Visited; - Visited.insert(V); - while (!Worklist.empty()) { - Value *V = Worklist.back(); - Worklist.pop_back(); - - for (User *U : V->users()) { - if (Instruction *I = dyn_cast<Instruction>(U)) { - remove(I->getFunction()); - } else if (isa<GlobalValue>(U)) { - // do nothing - } else if (Constant *C = dyn_cast<Constant>(U)) { - for (User *UU : C->users()) { - if (!Visited.insert(UU).second) - Worklist.push_back(UU); - } - } - } - } + for (User *U : V->users()) + if (auto *I = dyn_cast<Instruction>(U)) + remove(I->getFunction()); } |