summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/lib/Analysis/Loads.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/lib/Analysis/Loads.cpp')
-rw-r--r--contrib/llvm/lib/Analysis/Loads.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/contrib/llvm/lib/Analysis/Loads.cpp b/contrib/llvm/lib/Analysis/Loads.cpp
index 75426b5..e46541e 100644
--- a/contrib/llvm/lib/Analysis/Loads.cpp
+++ b/contrib/llvm/lib/Analysis/Loads.cpp
@@ -55,6 +55,10 @@ static bool isDereferenceableAndAlignedPointer(
const Value *V, unsigned Align, const APInt &Size, const DataLayout &DL,
const Instruction *CtxI, const DominatorTree *DT,
SmallPtrSetImpl<const Value *> &Visited) {
+ // Already visited? Bail out, we've likely hit unreachable code.
+ if (!Visited.insert(V).second)
+ return false;
+
// Note that it is not safe to speculate into a malloc'd region because
// malloc may return null.
@@ -87,9 +91,11 @@ static bool isDereferenceableAndAlignedPointer(
// then the GEP (== Base + Offset == k_0 * Align + k_1 * Align) is also
// aligned to Align bytes.
- return Visited.insert(Base).second &&
- isDereferenceableAndAlignedPointer(Base, Align, Offset + Size, DL,
- CtxI, DT, Visited);
+ // Offset and Size may have different bit widths if we have visited an
+ // addrspacecast, so we can't do arithmetic directly on the APInt values.
+ return isDereferenceableAndAlignedPointer(
+ Base, Align, Offset + Size.sextOrTrunc(Offset.getBitWidth()),
+ DL, CtxI, DT, Visited);
}
// For gc.relocate, look through relocations
@@ -302,11 +308,11 @@ llvm::DefMaxInstsToScan("available-load-scan-limit", cl::init(6), cl::Hidden,
"to scan backward from a given instruction, when searching for "
"available loaded value"));
-Value *llvm::FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB,
+Value *llvm::FindAvailableLoadedValue(LoadInst *Load,
+ BasicBlock *ScanBB,
BasicBlock::iterator &ScanFrom,
unsigned MaxInstsToScan,
- AliasAnalysis *AA, AAMDNodes *AATags,
- bool *IsLoadCSE) {
+ AliasAnalysis *AA, bool *IsLoadCSE) {
if (MaxInstsToScan == 0)
MaxInstsToScan = ~0U;
@@ -356,8 +362,6 @@ Value *llvm::FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB,
if (LI->isAtomic() < Load->isAtomic())
return nullptr;
- if (AATags)
- LI->getAAMetadata(*AATags);
if (IsLoadCSE)
*IsLoadCSE = true;
return LI;
@@ -377,8 +381,8 @@ Value *llvm::FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB,
if (SI->isAtomic() < Load->isAtomic())
return nullptr;
- if (AATags)
- SI->getAAMetadata(*AATags);
+ if (IsLoadCSE)
+ *IsLoadCSE = false;
return SI->getOperand(0);
}
OpenPOWER on IntegriCloud