forked from OSchip/llvm-project
[ScopBuilder] Avoid pointer element type access
Rather than checking the bitcast pointer element types, compare the element type of the access and the GEP result type. The entire code is dubious due to the inspection of GEP structure, but this at least preserves the spirit of the existing code.
This commit is contained in:
parent
9235e597a4
commit
e1616dc59e
|
@ -1451,23 +1451,12 @@ bool ScopBuilder::buildAccessMultiDimFixed(MemAccInst Inst, ScopStmt *Stmt) {
|
|||
enum MemoryAccess::AccessType AccType =
|
||||
isa<LoadInst>(Inst) ? MemoryAccess::READ : MemoryAccess::MUST_WRITE;
|
||||
|
||||
if (auto *BitCast = dyn_cast<BitCastInst>(Address)) {
|
||||
auto *Src = BitCast->getOperand(0);
|
||||
auto *SrcTy = Src->getType();
|
||||
auto *DstTy = BitCast->getType();
|
||||
// Do not try to delinearize non-sized (opaque) pointers.
|
||||
if ((SrcTy->isPointerTy() && !SrcTy->getPointerElementType()->isSized()) ||
|
||||
(DstTy->isPointerTy() && !DstTy->getPointerElementType()->isSized())) {
|
||||
return false;
|
||||
}
|
||||
if (SrcTy->isPointerTy() && DstTy->isPointerTy() &&
|
||||
DL.getTypeAllocSize(SrcTy->getPointerElementType()) ==
|
||||
DL.getTypeAllocSize(DstTy->getPointerElementType()))
|
||||
Address = Src;
|
||||
}
|
||||
if (auto *BitCast = dyn_cast<BitCastInst>(Address))
|
||||
Address = BitCast->getOperand(0);
|
||||
|
||||
auto *GEP = dyn_cast<GetElementPtrInst>(Address);
|
||||
if (!GEP)
|
||||
if (!GEP || DL.getTypeAllocSize(GEP->getResultElementType()) !=
|
||||
DL.getTypeAllocSize(ElementType))
|
||||
return false;
|
||||
|
||||
SmallVector<const SCEV *, 4> Subscripts;
|
||||
|
|
Loading…
Reference in New Issue