[llvm] [Attributor] Only manifest pointer operand for StoreInst in AAAddressSpace (PR #65708)
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 7 20:37:36 PDT 2023
https://github.com/shiltian created https://github.com/llvm/llvm-project/pull/65708:
None
>From 12038c3cda07e794e85801bf77470794693206f8 Mon Sep 17 00:00:00 2001
From: Shilei Tian <i at tianshilei.me>
Date: Thu, 7 Sep 2023 23:37:17 -0400
Subject: [PATCH] [Attributor] Only manifest pointer operand for StoreInst in
AAAddressSpace
---
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | 7 ++++++-
llvm/test/Transforms/Attributor/address_space_info.ll | 3 +--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 26c560cee2173a8..cebb6a96b150028 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -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;
};
diff --git a/llvm/test/Transforms/Attributor/address_space_info.ll b/llvm/test/Transforms/Attributor/address_space_info.ll
index 076060a2763c2af..d865ae1eae39b4b 100644
--- a/llvm/test/Transforms/Attributor/address_space_info.ll
+++ b/llvm/test/Transforms/Attributor/address_space_info.ll
@@ -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:
More information about the llvm-commits
mailing list