[mlir][ArmSME] Fix crash on func decls in 'arm_za' legality checks
authorCullen Rhodes <cullen.rhodes@arm.com>
Tue, 27 Jun 2023 07:29:11 +0000 (07:29 +0000)
committerCullen Rhodes <cullen.rhodes@arm.com>
Tue, 27 Jun 2023 07:39:35 +0000 (07:39 +0000)
Reviewed By: dcaballe, Dinistro

Differential Revision: https://reviews.llvm.org/D153750

mlir/lib/Dialect/ArmSME/Transforms/LegalizeForLLVMExport.cpp
mlir/test/Dialect/ArmSME/enable-arm-za.mlir

index 3fe9e78..a946126 100644 (file)
@@ -59,6 +59,8 @@ void mlir::configureArmSMELegalizeForExportTarget(
   //   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>([&](func::FuncOp funcOp) {
+    if (funcOp.isDeclaration())
+      return true;
     auto firstOp = funcOp.getBody().front().begin();
     return !funcOp->hasAttr("arm_za") ||
            isa<arm_sme::aarch64_sme_za_enable>(firstOp);
index ae0bbdc..d415b19 100644 (file)
@@ -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