[Mlir-commits] [mlir] [mlir][Tosa] Optimize compliance initialization for size to improve build time (NFC) (PR #222791)

Mehdi Amini llvmlistbot at llvm.org
Thu Sep 10 14:46:52 PDT 2026


https://github.com/joker-eph created https://github.com/llvm/llvm-project/pull/222791

The compliance-map constructor includes a 4,920-line generated initializer. Mark it minsize because it runs only when creating the validation pass and optimizing this single large function at -O3 is expensive.

LLVM pass timing attributes most of the saving to code generation. Greedy register allocation fell from 7.070s to 1.348s as global live-range splitting fell from 6.403s to 0.021s after the constructor became 47.6% smaller.

Across five controlled rebuilds of the affected TU, median instructions fell from 205.087B to 66.157B (-67.742%) and median wall time fell from 19.83s to 7.95s (-59.909%).

Assisted-by: Codex

>From 3525b510b045edf90f5aca4c45cfd3ac3c5a758e Mon Sep 17 00:00:00 2001
From: Mehdi Amini <joker.eph at gmail.com>
Date: Tue, 8 Sep 2026 02:08:42 -0700
Subject: [PATCH] [mlir][Tosa] Optimize compliance initialization for size
 (NFC)

The compliance-map constructor includes a 4,920-line generated initializer.
Mark it minsize because it runs only when creating the validation pass and
optimizing this single large function at -O3 is expensive.

LLVM pass timing attributes most of the saving to code generation. Greedy
register allocation fell from 7.070s to 1.348s as global live-range splitting
fell from 6.403s to 0.021s after the constructor became 47.6% smaller.

Across five controlled rebuilds of the affected TU, median instructions fell
from 205.087B to 66.157B (-67.742%) and median wall time fell from 19.83s to
7.95s (-59.909%).

Assisted-by: Codex
---
 mlir/lib/Dialect/Tosa/Transforms/TosaProfileCompliance.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaProfileCompliance.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaProfileCompliance.cpp
index f0c484b02f414..81b9ed7b8cd90 100644
--- a/mlir/lib/Dialect/Tosa/Transforms/TosaProfileCompliance.cpp
+++ b/mlir/lib/Dialect/Tosa/Transforms/TosaProfileCompliance.cpp
@@ -8,12 +8,13 @@
 
 #include "mlir/Dialect/Tosa/IR/TosaProfileCompliance.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace mlir;
 using namespace mlir::tosa;
 
-TosaProfileCompliance::TosaProfileCompliance() {
+LLVM_ATTRIBUTE_MINSIZE TosaProfileCompliance::TosaProfileCompliance() {
   const TypeInfo boolT = {mlir::IntegerType::getTypeID(), 1};
   const TypeInfo i4T = {mlir::IntegerType::getTypeID(), 4};
   const TypeInfo i8T = {mlir::IntegerType::getTypeID(), 8};



More information about the Mlir-commits mailing list