Preserving `nosideeffects` on func.func -> util.func import. (#18882)
diff --git a/compiler/src/iree/compiler/InputConversion/Common/IREEImportPublic.cpp b/compiler/src/iree/compiler/InputConversion/Common/IREEImportPublic.cpp
index de1f736..809fe8f 100644
--- a/compiler/src/iree/compiler/InputConversion/Common/IREEImportPublic.cpp
+++ b/compiler/src/iree/compiler/InputConversion/Common/IREEImportPublic.cpp
@@ -347,7 +347,7 @@
// Allowlist of function attributes to retain when importing funcs.
constexpr const char *kRetainedAttributes[] = {
"iree.reflection", "stream.affinity", "vm.fallback",
- "vm.signature", "vm.version",
+ "vm.signature", "vm.version", "nosideeffects",
};
auto retainedAttributes = ArrayRef<const char *>(
kRetainedAttributes,
diff --git a/compiler/src/iree/compiler/InputConversion/Common/test/iree_import_public.mlir b/compiler/src/iree/compiler/InputConversion/Common/test/iree_import_public.mlir
index 0c48dbc..d51c8b6 100644
--- a/compiler/src/iree/compiler/InputConversion/Common/test/iree_import_public.mlir
+++ b/compiler/src/iree/compiler/InputConversion/Common/test/iree_import_public.mlir
@@ -14,6 +14,13 @@
}
// -----
+// CHECK-LABEL: util.func public @nosideeffects_func
+// CHECK: nosideeffects
+func.func @nosideeffects_func() -> () attributes {nosideeffects} {
+ return
+}
+
+// -----
// CHECK-LABEL: util.func public @b_func
// CHECK-SAME: (%arg0: !hal.buffer, %arg1: !hal.buffer) -> (!hal.buffer, !hal.buffer)
// CHECK: util.return %arg0, %arg1 : !hal.buffer, !hal.buffer