summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/LoadValueNumbering.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-09-08 18:13:58 +0000
committerChris Lattner <sabre@nondot.org>2003-09-08 18:13:58 +0000
commitc4e76944d7cb1db563b7fb56b6544c20e0bb255c (patch)
treebb310afba8e76ca49bbb6c0496cd91347a7b93ec /llvm/lib/Analysis/LoadValueNumbering.cpp
parentff610c47beb1b210626c7e42d9ae63973fa0b6fd (diff)
downloadbcm5719-llvm-c4e76944d7cb1db563b7fb56b6544c20e0bb255c.tar.gz
bcm5719-llvm-c4e76944d7cb1db563b7fb56b6544c20e0bb255c.zip
Fix bug: RLE-Preserve-Volatile.ll
Volatile loads and stores must not be value numbered llvm-svn: 8398
Diffstat (limited to 'llvm/lib/Analysis/LoadValueNumbering.cpp')
-rw-r--r--llvm/lib/Analysis/LoadValueNumbering.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/LoadValueNumbering.cpp b/llvm/lib/Analysis/LoadValueNumbering.cpp
index c47010c3831..b433de3d53f 100644
--- a/llvm/lib/Analysis/LoadValueNumbering.cpp
+++ b/llvm/lib/Analysis/LoadValueNumbering.cpp
@@ -90,6 +90,10 @@ void LoadVN::getEqualNumberNodes(Value *V,
getAnalysis<AliasAnalysis>().getMustAliases(V, RetVals);
if (LoadInst *LI = dyn_cast<LoadInst>(V)) {
+ // Volatile loads cannot be replaced with the value of other loads.
+ if (LI->isVolatile())
+ return getAnalysis<ValueNumbering>().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<LoadInst>(*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<StoreInst>(*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);
}
OpenPOWER on IntegriCloud