diff options
author | Reid Kleckner <rnk@google.com> | 2016-08-03 20:01:01 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2016-08-03 20:01:01 +0000 |
commit | a6be60871f3ea2ff7778d8289a0bb867fcceac76 (patch) | |
tree | 85350165e717c9089bc78de43f57ba37f797d1f1 /llvm/lib/Transforms/Utils/CloneFunction.cpp | |
parent | f7672854f0910d032dd791ba063694b61ae3eaf2 (diff) | |
download | bcm5719-llvm-a6be60871f3ea2ff7778d8289a0bb867fcceac76.tar.gz bcm5719-llvm-a6be60871f3ea2ff7778d8289a0bb867fcceac76.zip |
Revert "[CloneFunction] Don't remove side effecting calls"
This reverts commit r277611 and the followup r277614.
Bootstrap builds and chromium builds are crashing during inlining after
this change.
llvm-svn: 277642
Diffstat (limited to 'llvm/lib/Transforms/Utils/CloneFunction.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/CloneFunction.cpp | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp index 4f0088246ea..c5ca56360fc 100644 --- a/llvm/lib/Transforms/Utils/CloneFunction.cpp +++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp @@ -14,7 +14,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/Utils/Cloning.h" -#include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Analysis/ConstantFolding.h" #include "llvm/Analysis/InstructionSimplify.h" @@ -553,39 +552,9 @@ void llvm::CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc, // two PHINodes, the iteration over the old PHIs remains valid, and the // mapping will just map us to the new node (which may not even be a PHI // node). - const DataLayout &DL = NewFunc->getParent()->getDataLayout(); - SmallSetVector<const Value *, 8> Worklist; for (unsigned Idx = 0, Size = PHIToResolve.size(); Idx != Size; ++Idx) - if (isa<PHINode>(VMap[PHIToResolve[Idx]])) - Worklist.insert(PHIToResolve[Idx]); - - // Note that we must test the size on each iteration, the worklist can grow. - for (unsigned Idx = 0; Idx != Worklist.size(); ++Idx) { - const Value *OrigV = Worklist[Idx]; - auto *I = cast_or_null<Instruction>(VMap.lookup(OrigV)); - if (!I) - continue; - - // See if this instruction simplifies. - Value *SimpleV = SimplifyInstruction(I, DL); - if (!SimpleV) - continue; - - // Stash away all the uses of the old instruction so we can check them for - // recursive simplifications after a RAUW. This is cheaper than checking all - // uses of To on the recursive step in most cases. - for (const User *U : OrigV->users()) - Worklist.insert(cast<Instruction>(U)); - - // Replace the instruction with its simplified value. - I->replaceAllUsesWith(SimpleV); - - // If the original instruction had no side effects, remove it. - if (isInstructionTriviallyDead(I)) - I->eraseFromParent(); - else - VMap[OrigV] = I; - } + if (PHINode *PN = dyn_cast<PHINode>(VMap[PHIToResolve[Idx]])) + recursivelySimplifyInstruction(PN); // Now that the inlined function body has been fully constructed, go through // and zap unconditional fall-through branches. This happens all the time when |