[MemCpyOptimizer] hasUndefContents - only look for underlying object if we've found an alloca
Provides an early-out if we fail to find an AllocaInst, and avoids a static analyzer warning about null dereferencing.
This commit is contained in:
parent
8399fa673b
commit
5bbcff6181
@ -1271,12 +1271,14 @@ static bool hasUndefContents(MemorySSA *MSSA, AliasAnalysis *AA, Value *V,
|
||||
// does) and we're querying a pointer based on that alloca, then we know
|
||||
// the memory is definitely undef, regardless of how exactly we alias.
|
||||
// The size also doesn't matter, as an out-of-bounds access would be UB.
|
||||
auto *Alloca = dyn_cast<AllocaInst>(getUnderlyingObject(V));
|
||||
if (getUnderlyingObject(II->getArgOperand(1)) == Alloca) {
|
||||
const DataLayout &DL = Alloca->getModule()->getDataLayout();
|
||||
if (Optional<TypeSize> AllocaSize = Alloca->getAllocationSizeInBits(DL))
|
||||
if (*AllocaSize == LTSize->getValue() * 8)
|
||||
return true;
|
||||
if (auto *Alloca = dyn_cast<AllocaInst>(getUnderlyingObject(V))) {
|
||||
if (getUnderlyingObject(II->getArgOperand(1)) == Alloca) {
|
||||
const DataLayout &DL = Alloca->getModule()->getDataLayout();
|
||||
if (Optional<TypeSize> AllocaSize =
|
||||
Alloca->getAllocationSizeInBits(DL))
|
||||
if (*AllocaSize == LTSize->getValue() * 8)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user