diff options
author | Eli Friedman <efriedma@codeaurora.org> | 2019-01-24 21:31:13 +0000 |
---|---|---|
committer | Eli Friedman <efriedma@codeaurora.org> | 2019-01-24 21:31:13 +0000 |
commit | 525ef0159d663f62755552258dfef2ee38d19005 (patch) | |
tree | b0929c9cd9a17542549c1e26d83503563bddd897 /llvm/lib/Analysis/Loads.cpp | |
parent | b0eabefd7b415d8580cafa4e36ea7e4f61772142 (diff) | |
download | bcm5719-llvm-525ef0159d663f62755552258dfef2ee38d19005.tar.gz bcm5719-llvm-525ef0159d663f62755552258dfef2ee38d19005.zip |
[Analysis] Fix isSafeToLoadUnconditionally handling of volatile.
A volatile operation cannot be used to prove an address points to normal
memory. (LangRef was recently updated to state it explicitly.)
Differential Revision: https://reviews.llvm.org/D57040
llvm-svn: 352109
Diffstat (limited to 'llvm/lib/Analysis/Loads.cpp')
-rw-r--r-- | llvm/lib/Analysis/Loads.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp index ba4f759a17b..7da9bd718a5 100644 --- a/llvm/lib/Analysis/Loads.cpp +++ b/llvm/lib/Analysis/Loads.cpp @@ -280,9 +280,17 @@ bool llvm::isSafeToLoadUnconditionally(Value *V, unsigned Align, Value *AccessedPtr; unsigned AccessedAlign; if (LoadInst *LI = dyn_cast<LoadInst>(BBI)) { + // Ignore volatile loads. The execution of a volatile load cannot + // be used to prove an address is backed by regular memory; it can, + // for example, point to an MMIO register. + if (LI->isVolatile()) + continue; AccessedPtr = LI->getPointerOperand(); AccessedAlign = LI->getAlignment(); } else if (StoreInst *SI = dyn_cast<StoreInst>(BBI)) { + // Ignore volatile stores (see comment for loads). + if (SI->isVolatile()) + continue; AccessedPtr = SI->getPointerOperand(); AccessedAlign = SI->getAlignment(); } else |