[Mlir-commits] [mlir] [mlir][spirv] Ensure function declarations precede definitions (PR #164956)
Jakub Kuderski
llvmlistbot at llvm.org
Fri Oct 24 07:56:55 PDT 2025
================
@@ -89,6 +89,22 @@ static bool isZeroValue(Attribute attr) {
return false;
}
+/// Move all functions declaration before functions definitions. In SPIR-V
+/// "declarations" are functions without a body and "definitions" functions
+/// with a body. This is stronger than necessary. It should be sufficient to
+/// ensure any declarations precede their uses and not all definitions, however
+/// this allows to avoid analysing every function in the module this way.
+static void moveFuncDeclarationsToTop(spirv::ModuleOp moduleOp) {
+ Block::OpListType &ops = moduleOp.getBody()->getOperations();
+ if (!ops.empty()) {
----------------
kuhar wrote:
nit: flip this condition and return early instead
https://github.com/llvm/llvm-project/pull/164956
More information about the Mlir-commits
mailing list