forked from OSchip/llvm-project
[mlir] sret and byval now require a type argument when constructed.
Fixes the LLVM code gen bugs and adds the missing tests. Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D95378
This commit is contained in:
parent
302432f75d
commit
1d6df1fcf0
|
@ -1105,7 +1105,8 @@ LogicalResult ModuleTranslation::convertOneFunction(LLVMFuncOp func) {
|
|||
if (!argTy.isa<LLVM::LLVMPointerType>())
|
||||
return func.emitError(
|
||||
"llvm.sret attribute attached to LLVM non-pointer argument");
|
||||
llvmArg.addAttr(llvm::Attribute::AttrKind::StructRet);
|
||||
llvmArg.addAttrs(llvm::AttrBuilder().addStructRetAttr(
|
||||
llvmArg.getType()->getPointerElementType()));
|
||||
}
|
||||
|
||||
if (auto attr = func.getArgAttrOfType<UnitAttr>(argIdx, "llvm.byval")) {
|
||||
|
@ -1113,7 +1114,8 @@ LogicalResult ModuleTranslation::convertOneFunction(LLVMFuncOp func) {
|
|||
if (!argTy.isa<LLVM::LLVMPointerType>())
|
||||
return func.emitError(
|
||||
"llvm.byval attribute attached to LLVM non-pointer argument");
|
||||
llvmArg.addAttr(llvm::Attribute::AttrKind::ByVal);
|
||||
llvmArg.addAttrs(llvm::AttrBuilder().addByValAttr(
|
||||
llvmArg.getType()->getPointerElementType()));
|
||||
}
|
||||
|
||||
valueMapping[mlirArg] = &llvmArg;
|
||||
|
|
|
@ -939,6 +939,16 @@ llvm.func @llvm_noalias(%arg0: !llvm.ptr<f32> {llvm.noalias = true}) {
|
|||
llvm.return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: define void @byvalattr(i32* byval(i32) %
|
||||
llvm.func @byvalattr(%arg0: !llvm.ptr<i32> {llvm.byval}) {
|
||||
llvm.return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: define void @sretattr(i32* sret(i32) %
|
||||
llvm.func @sretattr(%arg0: !llvm.ptr<i32> {llvm.sret}) {
|
||||
llvm.return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: define void @llvm_align(float* align 4 {{%*.}})
|
||||
llvm.func @llvm_align(%arg0: !llvm.ptr<f32> {llvm.align = 4}) {
|
||||
llvm.return
|
||||
|
|
Loading…
Reference in New Issue