From de0e59b188ea9fce68a7587fa3c4e8e8742e48c3 Mon Sep 17 00:00:00 2001 From: Lauri Vasama Date: Fri, 27 Mar 2026 15:55:08 +0200 Subject: [PATCH] Move FunctionOp arg attr verify to model verify --- lib/Clift/Clift.cpp | 23 ----------------------- lib/CliftImportModel/ModelVerify.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/lib/Clift/Clift.cpp b/lib/Clift/Clift.cpp index b6a5973a0..2dd7feff5 100644 --- a/lib/Clift/Clift.cpp +++ b/lib/Clift/Clift.cpp @@ -462,29 +462,6 @@ mlir::LogicalResult FunctionOp::verify() { return mlir::success(); }); - for (uint64_t Index = 0; Index < getArgCount(); ++Index) { - uint64_t RegAttributeCount = 0; - uint64_t StackAttributeCount = 0; - - mlir::clift::AttrDictView View = getArgAttrs(Index); - if (auto CAs = View.getOfType("clift.c_attributes")) { - for (mlir::Attribute CAttribute : CAs) { - auto AttrName = mlir::cast(CAttribute) - .getName() - .getName(); - if (AttrName == "_REG") - ++RegAttributeCount; - else if (AttrName == "_STACK") - ++StackAttributeCount; - } - } - - revng_assert(RegAttributeCount <= 1 and StackAttributeCount <= 1); - if (RegAttributeCount + StackAttributeCount > 1) - return emitOpError() << "An argument is not allowed to specify *both* " - " `_REG` and `_STACK` attributes."; - } - return mlir::failure(Result.wasInterrupted()); } diff --git a/lib/CliftImportModel/ModelVerify.cpp b/lib/CliftImportModel/ModelVerify.cpp index c47eb2954..cd29fe599 100644 --- a/lib/CliftImportModel/ModelVerify.cpp +++ b/lib/CliftImportModel/ModelVerify.cpp @@ -205,6 +205,33 @@ private: "definition: '" << Op.getHandle() << "'"; + for (unsigned Index = 0; Index < Op.getArgCount(); ++Index) { + bool IsStack = false; + bool IsRegister = false; + + mlir::clift::AttrDictView View = Op.getArgAttrs(Index); + if (auto CAs = View.getOfType("clift.c_attributes")) { + for (mlir::Attribute CAttribute : CAs) { + auto AttrName = mlir::cast(CAttribute) + .getName() + .getName(); + + if (AttrName == "_STACK" and std::exchange(IsStack, true)) + return getCurrentOp()->emitError() << "Function argument contains " + "duplicate _STACK attribute."; + + if (AttrName == "_REG" and std::exchange(IsRegister, true)) + return getCurrentOp()->emitError() << "Function argument contains " + "duplicate _REG attribute."; + + if (IsStack and IsRegister) + return getCurrentOp()->emitError() << "Function argument contains " + "both _STACK and _REG " + "attributes."; + } + } + } + return mlir::success(); }