diff options
| author | 2017-01-24 08:32:59 +0000 | |
|---|---|---|
| committer | 2017-01-24 08:32:59 +0000 | |
| commit | 53d771aafdbe5b919f264f53cba3788e2c4cffd2 (patch) | |
| tree | 7eca39498be0ff1e3a6daf583cd9ca5886bb2636 /gnu/llvm/lib/Analysis/Loads.cpp | |
| parent | In preparation of compiling our kernels with -ffreestanding, explicitly map (diff) | |
| download | wireguard-openbsd-53d771aafdbe5b919f264f53cba3788e2c4cffd2.tar.xz wireguard-openbsd-53d771aafdbe5b919f264f53cba3788e2c4cffd2.zip | |
Import LLVM 4.0.0 rc1 including clang and lld to help the current
development effort on OpenBSD/arm64.
Diffstat (limited to 'gnu/llvm/lib/Analysis/Loads.cpp')
| -rw-r--r-- | gnu/llvm/lib/Analysis/Loads.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/gnu/llvm/lib/Analysis/Loads.cpp b/gnu/llvm/lib/Analysis/Loads.cpp index 75426b54195..e46541e6538 100644 --- a/gnu/llvm/lib/Analysis/Loads.cpp +++ b/gnu/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); } |
