diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp @@ -245,16 +245,6 @@ targetAlignment); } -/// Returns true if the given argument or result attribute is supported by the -/// inliner, false otherwise. -static bool isArgOrResAttrSupported(NamedAttribute attr) { - if (attr.getName() == LLVM::LLVMDialect::getInAllocaAttrName()) - return false; - if (attr.getName() == LLVM::LLVMDialect::getNoAliasAttrName()) - return false; - return true; -} - namespace { struct LLVMInlinerInterface : public DialectInlinerInterface { using DialectInlinerInterface::DialectInlinerInterface; @@ -287,27 +277,13 @@ << "Cannot inline: callable is not an LLVM::LLVMFuncOp\n"); return false; } + // TODO: Generate aliasing metadata from noalias argument/result attributes. if (auto attrs = funcOp.getArgAttrs()) { for (DictionaryAttr attrDict : attrs->getAsRange()) { - for (NamedAttribute attr : attrDict) { - if (!isArgOrResAttrSupported(attr)) { - LLVM_DEBUG(llvm::dbgs() << "Cannot inline " << funcOp.getSymName() - << ": unhandled argument attribute " - << attr.getName() << "\n"); - return false; - } - } - } - } - if (auto attrs = funcOp.getResAttrs()) { - for (DictionaryAttr attrDict : attrs->getAsRange()) { - for (NamedAttribute attr : attrDict) { - if (!isArgOrResAttrSupported(attr)) { - LLVM_DEBUG(llvm::dbgs() << "Cannot inline " << funcOp.getSymName() - << ": unhandled return attribute " - << attr.getName() << "\n"); - return false; - } + if (attrDict.contains(LLVM::LLVMDialect::getInAllocaAttrName())) { + LLVM_DEBUG(llvm::dbgs() << "Cannot inline " << funcOp.getSymName() + << ": inalloca arguments not supported\n"); + return false; } } } diff --git a/mlir/test/Dialect/LLVMIR/inlining.mlir b/mlir/test/Dialect/LLVMIR/inlining.mlir --- a/mlir/test/Dialect/LLVMIR/inlining.mlir +++ b/mlir/test/Dialect/LLVMIR/inlining.mlir @@ -564,7 +564,7 @@ // ----- -llvm.func @ignored_attrs(%ptr : !llvm.ptr { llvm.inreg, llvm.nocapture, llvm.nofree, llvm.preallocated = i32, llvm.returned, llvm.alignstack = 32 : i64, llvm.writeonly, llvm.noundef, llvm.nonnull }, %x : i32 { llvm.zeroext }) -> (!llvm.ptr { llvm.noundef, llvm.inreg, llvm.nonnull }) { +llvm.func @ignored_attrs(%ptr : !llvm.ptr { llvm.inreg, llvm.noalias, llvm.nocapture, llvm.nofree, llvm.preallocated = i32, llvm.returned, llvm.alignstack = 32 : i64, llvm.writeonly, llvm.noundef, llvm.nonnull }, %x : i32 { llvm.zeroext }) -> (!llvm.ptr { llvm.noundef, llvm.inreg, llvm.nonnull }) { llvm.return %ptr : !llvm.ptr } @@ -578,7 +578,7 @@ // ----- -llvm.func @disallowed_arg_attr(%ptr : !llvm.ptr { llvm.noalias }) { +llvm.func @disallowed_arg_attr(%ptr : !llvm.ptr { llvm.inalloca = i64 }) { llvm.return } @@ -588,16 +588,3 @@ llvm.call @disallowed_arg_attr(%ptr) : (!llvm.ptr) -> () llvm.return } - -// ----- - -llvm.func @disallowed_res_attr(%ptr : !llvm.ptr) -> (!llvm.ptr { llvm.noalias }) { - llvm.return %ptr : !llvm.ptr -} - -// CHECK-LABEL: @test_disallow_res_attr -// CHECK-NEXT: llvm.call -llvm.func @test_disallow_res_attr(%ptr : !llvm.ptr) { - llvm.call @disallowed_res_attr(%ptr) : (!llvm.ptr) -> (!llvm.ptr) - llvm.return -}