diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2011-09-22 18:56:30 +0000 | 
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2011-09-22 18:56:30 +0000 | 
| commit | f9b785f1851ae7ee0d39b597637daaf966d356dc (patch) | |
| tree | 2ac85bd6f3942de20fc869eb81c810a227b2e3f2 /llvm/lib/Transforms | |
| parent | e643b854a5c767b565b32bac500b6dc2d0f8a37c (diff) | |
| download | bcm5719-llvm-f9b785f1851ae7ee0d39b597637daaf966d356dc.tar.gz bcm5719-llvm-f9b785f1851ae7ee0d39b597637daaf966d356dc.zip | |
PR10987: add a missed safety check to isSafePHIToSpeculate in scalarrepl.
llvm-svn: 140327
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp | 18 | 
1 files changed, 11 insertions, 7 deletions
| diff --git a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 37218079338..82364c36e42 100644 --- a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -1286,17 +1286,21 @@ static bool isSafePHIToSpeculate(PHINode *PN, const TargetData *TD) {    // trapping load in the predecessor if it is a critical edge.    for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {      BasicBlock *Pred = PN->getIncomingBlock(i); +    Value *InVal = PN->getIncomingValue(i); + +    // If the terminator of the predecessor has side-effects (an invoke), +    // there is no safe place to put a load in the predecessor. +    if (Pred->getTerminator()->mayHaveSideEffects()) +      return false; + +    // If the value is produced by the terminator of the predecessor +    // (an invoke), there is no valid place to put a load in the predecessor. +    if (Pred->getTerminator() == InVal) +      return false;      // If the predecessor has a single successor, then the edge isn't critical.      if (Pred->getTerminator()->getNumSuccessors() == 1)        continue; -     -    Value *InVal = PN->getIncomingValue(i); -     -    // If the InVal is an invoke in the pred, we can't put a load on the edge. -    if (InvokeInst *II = dyn_cast<InvokeInst>(InVal)) -      if (II->getParent() == Pred) -        return false;      // If this pointer is always safe to load, or if we can prove that there is      // already a load in the block, then we can move the load to the pred block. | 

