diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-08-26 02:25:55 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-08-26 02:25:55 +0000 |
| commit | 0655b78ccca3fb96301674cb62add2ded3af61dc (patch) | |
| tree | c11e696fbc10c008a6cddf2ca645d63fbbd3d394 /llvm/lib/Transforms | |
| parent | fb212a630976fbcee8b34c75c7945ce0ebfff206 (diff) | |
| download | bcm5719-llvm-0655b78ccca3fb96301674cb62add2ded3af61dc.tar.gz bcm5719-llvm-0655b78ccca3fb96301674cb62add2ded3af61dc.zip | |
Address review comments.
- Reword comments.
- Allow undefined behavior interfering with undefined behavior.
- Add address space checks.
llvm-svn: 138619
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index dce4e7abab1..240f037de71 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -2729,7 +2729,7 @@ static bool passingValueIsAlwaysUndefined(Value *V, Instruction *I) { if (!C) return false; - if (!I->hasOneUse()) // FIXME: There is no reason to limit this to one use. + if (!I->hasOneUse()) // Only look at single-use instructions, for compile time return false; if (C->isNullValue()) { @@ -2738,8 +2738,7 @@ static bool passingValueIsAlwaysUndefined(Value *V, Instruction *I) { // Now make sure that there are no instructions in between that can alter // control flow (eg. calls) for (BasicBlock::iterator i = ++BasicBlock::iterator(I); &*i != Use; ++i) - if (i == I->getParent()->end() || - !i->isSafeToSpeculativelyExecute()) + if (i == I->getParent()->end() || i->mayHaveSideEffects()) return false; // Look through GEPs. A load from a GEP derived from NULL is still undefined @@ -2751,13 +2750,13 @@ static bool passingValueIsAlwaysUndefined(Value *V, Instruction *I) { if (BitCastInst *BC = dyn_cast<BitCastInst>(Use)) return passingValueIsAlwaysUndefined(V, BC); - // load from null is undefined - if (isa<LoadInst>(Use)) - return true; + // Load from null is undefined. + if (LoadInst *LI = dyn_cast<LoadInst>(Use)) + return LI->getPointerAddressSpace() == 0; - // store to null is undef - if (isa<StoreInst>(Use) && Use->getOperand(1) == I) - return true; + // Store to null is undefined. + if (StoreInst *SI = dyn_cast<StoreInst>(Use)) + return SI->getPointerAddressSpace() == 0 && SI->getPointerOperand() == I; } return false; } |

