Skip to content

[MLIR] Assertion !NodePtr->isKnownSentinel() in DeadCodeAnalysis::visitRegionBranchEdges when processing acc.serial with empty region #187972

@YuanchengJiang

Description

@YuanchengJiang

Related: #132160

Description

mlir-opt --sccp crashes with an assertion failure in llvm::ilist_iterator::operator*() when processing a function containing an acc.serial op with an empty region body. The DeadCodeAnalysis pass, invoked by SCCP, calls getProgramPointBefore(Block*) on a block pointer obtained by iterating over the regions of acc.serial. When a region has no blocks, the iterator is a sentinel, and dereferencing it triggers the assertion.

Reproducer

module {
  func.func @f() {
    acc.serial {
    }
    return
  }
}

Command

mlir-opt --sccp reproduce.mlir

Expected behavior

--sccp either processes the file successfully or emits a diagnostic. It should not crash when encountering an acc.serial op whose region has no blocks.

Actual behavior

mlir-opt: llvm/include/llvm/ADT/ilist_iterator.h:168:
  reference llvm::ilist_iterator<...>::operator*() const:
  Assertion `!NodePtr->isKnownSentinel()' failed.

Call chain:

SCCP::runOnOperation
  → DataFlowSolver::initializeAndRun
    → DeadCodeAnalysis::initialize
      → DeadCodeAnalysis::initializeRecursively
        → DeadCodeAnalysis::visitRegionBranchOperation
          → DeadCodeAnalysis::visitRegionBranchEdges
            → DataFlowAnalysis::getProgramPointBefore(Block*)
              → ilist_iterator::operator*()  ← assertion: sentinel dereference

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashPrefer [crash-on-valid] or [crash-on-invalid]mlir:dataflow

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions