Skip to content

[Attributor] Only manifest pointer operand for StoreInst in AAAddressSpace #65708

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 8, 2023
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
7 changes: 6 additions & 1 deletion llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12544,8 +12544,13 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
// CGSCC if the AA is run on CGSCC instead of the entire module.
if (!A.isRunOn(Inst->getFunction()))
return true;
if (isa<LoadInst>(Inst) || isa<StoreInst>(Inst))
if (isa<LoadInst>(Inst))
MakeChange(Inst, const_cast<Use &>(U));
if (auto *SI = dyn_cast<StoreInst>(Inst)) {
// We only make changes if the use is the pointer operand.
if (U.getOperandNo() == 1)
MakeChange(Inst, const_cast<Use &>(U));
}
return true;
};

Expand Down
3 changes: 1 addition & 2 deletions llvm/test/Transforms/Attributor/address_space_info.ll
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ define internal void @_Z12global_writePi(ptr noundef %p) #0 {
; CHECK-SAME: (ptr nofree noundef nonnull writeonly align 4 dereferenceable(8) [[P:%.*]]) #[[ATTR0:[0-9]+]] {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP0:%.*]] = addrspacecast ptr [[P]] to ptr addrspace(1)
; CHECK-NEXT: [[TMP1:%.*]] = addrspacecast ptr [[P]] to ptr addrspace(1)
; CHECK-NEXT: store ptr addrspace(1) [[TMP0]], ptr addrspace(1) [[TMP1]], align 4
; CHECK-NEXT: store ptr [[P]], ptr addrspace(1) [[TMP0]], align 4
; CHECK-NEXT: ret void
;
entry:
Expand Down