[PATCH] D116746: IR: Make getRetAlign check callee function attributes
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 6 07:47:48 PST 2022
arsenm created this revision.
arsenm added reviewers: jdoerfert, lebedev.ri.
Herald added subscribers: dexonsmith, kerbowa, nhaehnle, jvesely.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.
The attribute queries semi-consistently check the attribute set, and
then fallback to checking the callee's attributes.
https://reviews.llvm.org/D116746
Files:
llvm/include/llvm/IR/InstrTypes.h
llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-assert-align.ll
Index: llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-assert-align.ll
===================================================================
--- llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-assert-align.ll
+++ llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-assert-align.ll
@@ -159,7 +159,8 @@
; CHECK-NEXT: [[COPY19:%[0-9]+]]:_(s32) = COPY $vgpr1
; CHECK-NEXT: [[MV:%[0-9]+]]:_(p1) = G_MERGE_VALUES [[COPY18]](s32), [[COPY19]](s32)
; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $scc
- ; CHECK-NEXT: G_STORE [[C]](s8), [[MV]](p1) :: (store (s8) into %ir.ptr, align 8, addrspace 1)
+ ; CHECK-NEXT: [[ASSERT_ALIGN:%[0-9]+]]:_(p1) = G_ASSERT_ALIGN [[MV]], 8
+ ; CHECK-NEXT: G_STORE [[C]](s8), [[ASSERT_ALIGN]](p1) :: (store (s8) into %ir.ptr, align 8, addrspace 1)
; CHECK-NEXT: [[COPY20:%[0-9]+]]:ccr_sgpr_64 = COPY [[COPY8]]
; CHECK-NEXT: S_SETPC_B64_return [[COPY20]]
%ptr = call i8 addrspace(1)* @returns_ptr_align8()
Index: llvm/include/llvm/IR/InstrTypes.h
===================================================================
--- llvm/include/llvm/IR/InstrTypes.h
+++ llvm/include/llvm/IR/InstrTypes.h
@@ -1723,7 +1723,13 @@
}
/// Extract the alignment of the return value.
- MaybeAlign getRetAlign() const { return Attrs.getRetAlignment(); }
+ MaybeAlign getRetAlign() const {
+ if (auto Align = Attrs.getRetAlignment())
+ return Align;
+ if (const Function *F = getCalledFunction())
+ return F->getAttributes().getRetAlignment();
+ return None;
+ }
/// Extract the alignment for a call or parameter (0=unknown).
MaybeAlign getParamAlign(unsigned ArgNo) const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116746.397889.patch
Type: text/x-patch
Size: 1648 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220106/77749988/attachment.bin>
More information about the llvm-commits
mailing list