Skip to content

[GVN] hits assertion "Cannot split critical edge from IndirectBrInst" in llvm::SplitKnownCriticalEdge #150229

@tetzank

Description

@tetzank

The gvn pass cannot handle the indirectbr instruction with more than one destination. It hits an assertion in llvm::SplitKnownCriticalEdge trying to add a "dead" block after the indirectbr.
The newgvn pass works fine.

Reproducer:

define void @foo(i1 %cmp) {
first:
  br i1 %cmp, label %exit, label %second

second:
  br i1 %cmp, label %ibr, label %exit ; cmp must be false to reach this, branch to ibr never taken

ibr: ; this block is dead
  indirectbr ptr blockaddress(@foo, %exit), [label %exit, label %exit] ; double label required, works with just one

exit:
  ret void
}

opt --passes=gvn -S minimal.ll

Related Bug: #49237

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashPrefer [crash-on-valid] or [crash-on-invalid]llvm:GVNGVN and NewGVN stages (Global value numbering)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions