[Mlir-commits] [mlir] [mlir][tosa] Use optnone for compliance initialization under MSan (NFC) (PR #223586)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Sep 14 19:47:29 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-tosa

Author: Vitaly Buka (vitalybuka)

<details>
<summary>Changes</summary>

The compliance-map constructor includes a ~5,000-line generated initializer.
Under MemorySanitizer, shadow and origin tracking instrumentation on
this single mega-function causes extreme compilation times (>3.5 minutes),
dominated by InstCombine (~68s) and greedy register allocation (~71s).

Recently, LLVM_ATTRIBUTE_MINSIZE was added to optimize for size, but MSan
instrumentation still inflates the function enough to trigger severe
slowdowns in the backend.

Mark the constructor with optnone under LLVM_MEMORY_SANITIZER_BUILD to skip
expensive optimization and register allocation passes, bringing compilation
time under MSan down from 3m38s to ~30s.

This is done to fix http://lab.llvm.org/buildbot/#/builders/aarch64-linux-msan,
though it is very slow on x86_64 as well.

Assisted-by: Gemini


---
Full diff: https://github.com/llvm/llvm-project/pull/223586.diff


1 Files Affected:

- (modified) mlir/lib/Dialect/Tosa/Transforms/TosaProfileCompliance.cpp (+10-1) 


``````````diff
diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaProfileCompliance.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaProfileCompliance.cpp
index 81b9ed7b8cd90d..3c81be49cbd9a4 100644
--- a/mlir/lib/Dialect/Tosa/Transforms/TosaProfileCompliance.cpp
+++ b/mlir/lib/Dialect/Tosa/Transforms/TosaProfileCompliance.cpp
@@ -14,7 +14,16 @@
 using namespace mlir;
 using namespace mlir::tosa;
 
-LLVM_ATTRIBUTE_MINSIZE TosaProfileCompliance::TosaProfileCompliance() {
+// Building this ~5,000-line generated initializer map under MemorySanitizer
+// leads to extreme compile times (>3.5 minutes) during InstCombine and greedy
+// register allocation due to shadow/origin instrumentation overhead. Disable
+// optimization under MSan to keep build times manageable.
+#if LLVM_MEMORY_SANITIZER_BUILD
+__attribute__((optnone))
+#else
+LLVM_ATTRIBUTE_MINSIZE
+#endif
+TosaProfileCompliance::TosaProfileCompliance() {
   const TypeInfo boolT = {mlir::IntegerType::getTypeID(), 1};
   const TypeInfo i4T = {mlir::IntegerType::getTypeID(), 4};
   const TypeInfo i8T = {mlir::IntegerType::getTypeID(), 8};

``````````

</details>


https://github.com/llvm/llvm-project/pull/223586


More information about the Mlir-commits mailing list