From 9bb5488dbd152de41ffcaedccf94bfc43b069bec Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 26 Aug 2011 02:25:55 +0000 Subject: Address review comments. - Reword comments. - Allow undefined behavior interfering with undefined behavior. - Add address space checks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138619 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/SimplifyCFG.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'lib/Transforms/Utils') diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index dce4e7abab..240f037de7 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/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(Use)) return passingValueIsAlwaysUndefined(V, BC); - // load from null is undefined - if (isa(Use)) - return true; + // Load from null is undefined. + if (LoadInst *LI = dyn_cast(Use)) + return LI->getPointerAddressSpace() == 0; - // store to null is undef - if (isa(Use) && Use->getOperand(1) == I) - return true; + // Store to null is undefined. + if (StoreInst *SI = dyn_cast(Use)) + return SI->getPointerAddressSpace() == 0 && SI->getPointerOperand() == I; } return false; } -- cgit v1.2.3