Index: mlir/lib/Dialect/ArmSME/Transforms/LegalizeForLLVMExport.cpp =================================================================== --- mlir/lib/Dialect/ArmSME/Transforms/LegalizeForLLVMExport.cpp +++ mlir/lib/Dialect/ArmSME/Transforms/LegalizeForLLVMExport.cpp @@ -59,6 +59,8 @@ // 2. the 'arm_za' function attribute is present and the first op in the // function is an 'arm_sme::aarch64_sme_za_enable' intrinsic. target.addDynamicallyLegalOp([&](func::FuncOp funcOp) { + if (funcOp.isDeclaration()) + return true; auto firstOp = funcOp.getBody().front().begin(); return !funcOp->hasAttr("arm_za") || isa(firstOp); Index: mlir/test/Dialect/ArmSME/enable-arm-za.mlir =================================================================== --- mlir/test/Dialect/ArmSME/enable-arm-za.mlir +++ mlir/test/Dialect/ArmSME/enable-arm-za.mlir @@ -2,6 +2,9 @@ // RUN: mlir-opt %s -enable-arm-streaming -convert-vector-to-llvm="enable-arm-sme" | FileCheck %s -check-prefix=DISABLE-ZA // RUN: mlir-opt %s -convert-vector-to-llvm="enable-arm-sme" | FileCheck %s -check-prefix=NO-ARM-STREAMING +// CHECK-LABEL: @declaration +func.func private @declaration() + // CHECK-LABEL: @arm_za func.func @arm_za() { // ENABLE-ZA: arm_sme.intr.za.enable