Skip to content

AMDGPU: Fix assertion on load of vector of pointers #110436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Sep 29, 2024

Fix InferAddressSpaces asserting on a load of a vector of flat
pointers.

Fixes #110433

Copy link
Contributor Author

arsenm commented Sep 29, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @arsenm and the rest of your teammates on Graphite Graphite

@llvmbot
Copy link
Member

llvmbot commented Sep 29, 2024

@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-backend-amdgpu

Author: Matt Arsenault (arsenm)

Changes

Fix InferAddressSpaces asserting on a load of a vector of flat
pointers.

Fixes #110433


Full diff: https://github.com/llvm/llvm-project/pull/110436.diff

1 Files Affected:

  • (modified) llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp (+2-3)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
index abd50748f2cc05..ce3d70332d0a67 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -799,12 +799,11 @@ bool AMDGPUTargetMachine::isNoopAddrSpaceCast(unsigned SrcAS,
 
 unsigned AMDGPUTargetMachine::getAssumedAddrSpace(const Value *V) const {
   const auto *LD = dyn_cast<LoadInst>(V);
-  if (!LD)
+  if (!LD) // TODO: Handle invariant load like constant.
     return AMDGPUAS::UNKNOWN_ADDRESS_SPACE;
 
   // It must be a generic pointer loaded.
-  assert(V->getType()->isPointerTy() &&
-         V->getType()->getPointerAddressSpace() == AMDGPUAS::FLAT_ADDRESS);
+  assert(V->getType()->getPointerAddressSpace() == AMDGPUAS::FLAT_ADDRESS);
 
   const auto *Ptr = LD->getPointerOperand();
   if (Ptr->getType()->getPointerAddressSpace() != AMDGPUAS::CONSTANT_ADDRESS)

@arsenm arsenm marked this pull request as ready for review September 29, 2024 19:52
Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix.

@shiltian
Copy link
Contributor

test?

Fix InferAddressSpaces asserting on a load of a vector of flat
pointers.

Fixes #110433
@arsenm arsenm force-pushed the users/arsenm/amdgpu-fix-assert-vector-of-pointers branch from 77fb625 to 3867866 Compare September 30, 2024 04:56
@arsenm
Copy link
Contributor Author

arsenm commented Sep 30, 2024

test?

forgot to git add

Comment on lines +7 to +10
; CHECK-NEXT: [[LD:%.*]] = load <8 x ptr>, ptr addrspace(4) [[PTR]], align 128
; CHECK-NEXT: [[TMP1:%.*]] = addrspacecast <8 x ptr> [[LD]] to <8 x ptr addrspace(1)>
; CHECK-NEXT: [[TMP2:%.*]] = addrspacecast <8 x ptr addrspace(1)> [[TMP1]] to <8 x ptr>
; CHECK-NEXT: [[CMP:%.*]] = icmp eq <8 x ptr> [[TMP2]], zeroinitializer
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This output isn't great. We should have changed the type of the load and compare

@arsenm arsenm merged commit a87640c into main Sep 30, 2024
9 checks passed
@arsenm arsenm deleted the users/arsenm/amdgpu-fix-assert-vector-of-pointers branch September 30, 2024 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[AMDGPU] Assertion hit in infer-address-spaces on vector of pointers
4 participants