chore(mlirlite): too-many-elements 处打印 n/g/src 前缀 - 定位哪个全局数组被放大

This commit is contained in:
TermiNexus committed 2026-10-16 12:53:31 +08:00
1 parent e9e1933a62
commit c816f53af4
1 file changed
+10
+10
View File
@@ -929,6 +929,16 @@ def _MlirArrayDenseAt(buf: str, size: sizet, src: str,
# 上限只用于防"解析不收敛"的死循环,不是数组容量限制:位图字体表
# `[256] x [16]uint8` 本身就 4352 个元素(外层 256 + 内层 4096),旧值 4096 会误报。
if g > 1048576:
# [DIAG] 元素数冲到上限 ⇒ 直接暴露"是哪个数组、什么形态"(错误诊断增强:正常路径不打印)。
# 有了这段才能判断是"文本里真的百万元素"还是"解析重复吃同一段"。
db: str = pool.alloc(200)
if db is not None:
i2: int = 0
while i2 < 180 and src[i2] != '\0':
db[i2] = src[i2]
i2 += 1
db[i2] = '\0'
stdio.printf("[MLIR-DIAG] too-many-elements n=%d g=%d src_head=%s\n", n, g, db)
MlirFail("MLIR render: too many global array elements")
p = _mlir_ws(p)
if p[0] == ']':