[llvm] 3e1ebd7 - [GlobalISel] Add support for lowering byref attribute
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 26 08:31:55 PDT 2024
Author: darkbuck
Date: 2024-06-26T11:31:52-04:00
New Revision: 3e1ebd77e4e9a772e4f06f12d19c64860fb1f070
URL: https://github.com/llvm/llvm-project/commit/3e1ebd77e4e9a772e4f06f12d19c64860fb1f070
DIFF: https://github.com/llvm/llvm-project/commit/3e1ebd77e4e9a772e4f06f12d19c64860fb1f070.diff
LOG: [GlobalISel] Add support for lowering byref attribute
Reviewers: nikic, spaits, arsenm
Reviewed By: arsenm
Pull Request: https://github.com/llvm/llvm-project/pull/96733
Added:
Modified:
llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
index 2ee035790eff1..5efb3be0e53ae 100644
--- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
@@ -49,6 +49,8 @@ addFlagsUsingAttrFn(ISD::ArgFlagsTy &Flags,
Flags.setNest();
if (AttrFn(Attribute::ByVal))
Flags.setByVal();
+ if (AttrFn(Attribute::ByRef))
+ Flags.setByRef();
if (AttrFn(Attribute::Preallocated))
Flags.setPreallocated();
if (AttrFn(Attribute::InAlloca))
@@ -221,17 +223,26 @@ void CallLowering::setArgFlags(CallLowering::ArgInfo &Arg, unsigned OpIdx,
}
Align MemAlign = DL.getABITypeAlign(Arg.Ty);
- if (Flags.isByVal() || Flags.isInAlloca() || Flags.isPreallocated()) {
+ if (Flags.isByVal() || Flags.isInAlloca() || Flags.isPreallocated() ||
+ Flags.isByRef()) {
assert(OpIdx >= AttributeList::FirstArgIndex);
unsigned ParamIdx = OpIdx - AttributeList::FirstArgIndex;
Type *ElementTy = FuncInfo.getParamByValType(ParamIdx);
+ if (!ElementTy)
+ ElementTy = FuncInfo.getParamByRefType(ParamIdx);
if (!ElementTy)
ElementTy = FuncInfo.getParamInAllocaType(ParamIdx);
if (!ElementTy)
ElementTy = FuncInfo.getParamPreallocatedType(ParamIdx);
+
assert(ElementTy && "Must have byval, inalloca or preallocated type");
- Flags.setByValSize(DL.getTypeAllocSize(ElementTy));
+
+ uint64_t MemSize = DL.getTypeAllocSize(ElementTy);
+ if (Flags.isByRef())
+ Flags.setByRefSize(MemSize);
+ else
+ Flags.setByValSize(MemSize);
// For ByVal, alignment should be passed from FE. BE will guess if
// this info is not there but there are cases it cannot get right.
More information about the llvm-commits
mailing list