diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -1518,8 +1518,8 @@ Value *BPtr = B.getPointer(); bool AIsWrite = A.getInt(); bool BIsWrite = B.getInt(); - Type *ATy = APtr->getType()->getPointerElementType(); - Type *BTy = BPtr->getType()->getPointerElementType(); + Type *ATy = getLoadStoreType(InstMap[AIdx]); + Type *BTy = getLoadStoreType(InstMap[BIdx]); // Two reads are independent. if (!AIsWrite && !BIsWrite) diff --git a/llvm/test/Analysis/LoopAccessAnalysis/opaque-ptr.ll b/llvm/test/Analysis/LoopAccessAnalysis/opaque-ptr.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Analysis/LoopAccessAnalysis/opaque-ptr.ll @@ -0,0 +1,15 @@ +; RUN: opt -passes=print-access-info --opaque-pointers --disable-output %s 2>&1 | FileCheck %s + +; CHECK: Loop access info in function 'f' + +define void @f(ptr %p) { + br label %loop + +loop: + store ptr null, ptr %p + %l = load i8, ptr %p + br i1 true, label %exit, label %loop + +exit: + ret void +}