From: Chris Lattner Date: Mon, 8 Sep 2003 18:13:58 +0000 (+0000) Subject: Fix bug: RLE-Preserve-Volatile.ll X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=bd70a31c51267a3ef4840877bdc0b98f590e94a6;p=oota-llvm.git Fix bug: RLE-Preserve-Volatile.ll Volatile loads and stores must not be value numbered git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8398 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/LoadValueNumbering.cpp b/lib/Analysis/LoadValueNumbering.cpp index c47010c3831..b433de3d53f 100644 --- a/lib/Analysis/LoadValueNumbering.cpp +++ b/lib/Analysis/LoadValueNumbering.cpp @@ -90,6 +90,10 @@ void LoadVN::getEqualNumberNodes(Value *V, getAnalysis().getMustAliases(V, RetVals); if (LoadInst *LI = dyn_cast(V)) { + // Volatile loads cannot be replaced with the value of other loads. + if (LI->isVolatile()) + return getAnalysis().getEqualNumberNodes(V, RetVals); + // If we have a load instruction, find all of the load and store // instructions that use the same source operand. We implement this // recursively, because there could be a load of a load of a load that are @@ -119,10 +123,10 @@ void LoadVN::getEqualNumberNodes(Value *V, UI != UE; ++UI) if (LoadInst *Cand = dyn_cast(*UI)) {// Is a load of source? if (Cand->getParent()->getParent() == F && // In the same function? - Cand != LI) // Not LI itself? + Cand != LI && !Cand->isVolatile()) // Not LI itself? CandidateLoads.push_back(Cand); // Got one... } else if (StoreInst *Cand = dyn_cast(*UI)) { - if (Cand->getParent()->getParent() == F && + if (Cand->getParent()->getParent() == F && !Cand->isVolatile() && Cand->getOperand(1) == Source) // It's a store THROUGH the ptr... CandidateStores.push_back(Cand); }