Skip to content

[Attributor] Indicate optimistic fixed point if an instruction already has non-zero address space #101589

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
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12491,6 +12491,9 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
void initialize(Attributor &A) override {
assert(getAssociatedType()->isPtrOrPtrVectorTy() &&
"Associated value is not a pointer");
auto *PtrTy = cast<PointerType>(getAssociatedType());
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you need this cast.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well, it is needed as getAddressSpace is a method of PointerType instead of Type.

if (PtrTy->getAddressSpace())
indicateOptimisticFixpoint();
}

ChangeStatus updateImpl(Attributor &A) override {
Expand Down
6 changes: 4 additions & 2 deletions llvm/test/Transforms/Attributor/memory_locations_gpu.ll
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ define i32 @test_const_as_call2() {
; CHECK-LABEL: define {{[^@]+}}@test_const_as_call2
; CHECK-SAME: () #[[ATTR3:[0-9]+]] {
; CHECK-NEXT: [[P2:%.*]] = call ptr @ptr() #[[ATTR4]]
; CHECK-NEXT: [[L2:%.*]] = load i32, ptr [[P2]], align 4
; CHECK-NEXT: [[C2:%.*]] = addrspacecast ptr [[P2]] to ptr addrspace(4)
; CHECK-NEXT: [[L2:%.*]] = load i32, ptr addrspace(4) [[C2]], align 4
; CHECK-NEXT: ret i32 [[L2]]
;
%p2 = call ptr @ptr()
Expand Down Expand Up @@ -84,7 +85,8 @@ define i32 @test_shared_as_call2() {
; CHECK-LABEL: define {{[^@]+}}@test_shared_as_call2
; CHECK-SAME: () #[[ATTR2]] {
; CHECK-NEXT: [[P2:%.*]] = call ptr @ptr() #[[ATTR4]]
; CHECK-NEXT: [[L2:%.*]] = load i32, ptr [[P2]], align 4
; CHECK-NEXT: [[C2:%.*]] = addrspacecast ptr [[P2]] to ptr addrspace(3)
; CHECK-NEXT: [[L2:%.*]] = load i32, ptr addrspace(3) [[C2]], align 4
; CHECK-NEXT: ret i32 [[L2]]
;
%p2 = call ptr @ptr()
Expand Down
Loading