Skip to content

[TIR] Ignore None-valued pragma annotations - #20265

Merged
tlopex merged 4 commits into
apache:mainfrom
StrongbodyStrongmind:fix-18393-latest
Sep 9, 2026
Merged

[TIR] Ignore None-valued pragma annotations#20265
tlopex merged 4 commits into
apache:mainfrom
StrongbodyStrongmind:fix-18393-latest

Conversation

@StrongbodyStrongmind

Copy link
Copy Markdown
Contributor

Fixes #18393.

None-valued pragma annotations represent an unspecified pragma and should not be lowered into AttrStmt nodes with undefined PrimExpr values.

Previously, pragma_unroll_explicit=None was lowered into an AttrStmt with an undefined value. During FlattenBuffer, StmtExprMutator attempted to visit that value and triggered a segmentation fault.

This patch skips None-valued pragma annotations during opaque lowering while preserving the existing behavior for valid pragma values.

For pragma_unroll, the existing upstream behavior is preserved: non-null values remain attached to the loop, while null values are ignored.

Tests:

  • tests/python/tirx-transform/test_tir_transform_flatten_buffer.py: 11 passed
  • tests/python/s_tir/transform/test_s_tir_transform_lower_opaque_block.py: 13 passed
  • git diff --check upstream/main..HEAD: passed

@tlopex tlopex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks good. Could you add a direct LowerTIRxOpaque regression without s_tir=True? Both new tests exercise the S-TIR path, leaving the TIRx changes uncovered. Please check that None is dropped for both pragma_unroll and pragma_unroll_explicit, while False and 0 are preserved.

@tlopex
tlopex merged commit 40c2f54 into apache:main Sep 9, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Segfault in TVM when building TIR module with pragma_unroll_explicit annotations

2 participants