Skip to content

Commit

Permalink
IR: Make getRetAlign check callee function attributes
Browse files Browse the repository at this point in the history
The attribute queries semi-consistently check the attribute set, and
then fallback to checking the callee's attributes.
  • Loading branch information
arsenm committed Jan 12, 2022
1 parent 07ddfa9 commit 3d2d208
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion llvm/include/llvm/IR/InstrTypes.h
Expand Up @@ -1723,7 +1723,13 @@ class CallBase : public Instruction {
}

/// 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 {
Expand Down
Expand Up @@ -159,7 +159,8 @@ define void @declaration_result_align_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()
Expand Down

0 comments on commit 3d2d208

Please sign in to comment.