-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[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
Conversation
…y has non-zero address space
This stack of pull requests is managed by Graphite. Learn more about stacking. |
@llvm/pr-subscribers-llvm-transforms Author: Shilei Tian (shiltian) ChangesFull diff: https://github.com/llvm/llvm-project/pull/101589.diff 2 Files Affected:
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 2816a85743faa..f69054334c739 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -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());
+ if (PtrTy->getAddressSpace())
+ indicateOptimisticFixpoint();
}
ChangeStatus updateImpl(Attributor &A) override {
diff --git a/llvm/test/Transforms/Attributor/memory_locations_gpu.ll b/llvm/test/Transforms/Attributor/memory_locations_gpu.ll
index 2c7a98a41f86f..c10883b54ad59 100644
--- a/llvm/test/Transforms/Attributor/memory_locations_gpu.ll
+++ b/llvm/test/Transforms/Attributor/memory_locations_gpu.ll
@@ -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()
@@ -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()
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG, see comment.
@@ -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()); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
No description provided.