[llvm] [AMDGPUAA] Check Type before Taking AddressSpace of a Value (PR #128116)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 20 19:45:00 PST 2025


================
@@ -49,8 +49,12 @@ void AMDGPUAAWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
 AliasResult AMDGPUAAResult::alias(const MemoryLocation &LocA,
                                   const MemoryLocation &LocB, AAQueryInfo &AAQI,
                                   const Instruction *) {
-  unsigned asA = LocA.Ptr->getType()->getPointerAddressSpace();
-  unsigned asB = LocB.Ptr->getType()->getPointerAddressSpace();
+  Type *TypeA = LocA.Ptr->getType();
+  Type *TypeB = LocB.Ptr->getType();
+  if (!TypeA->isPointerTy() || !TypeB->isPointerTy())
+    return AliasResult::MayAlias;
+  unsigned asA = TypeA->getPointerAddressSpace();
+  unsigned asB = TypeB->getPointerAddressSpace();
----------------
arsenm wrote:

use dyn_cast to PointerType

https://github.com/llvm/llvm-project/pull/128116


More information about the llvm-commits mailing list