Skip to content

[SCEV] Another SEGV/stack overflow in LoopGuards #122913

@danilaml

Description

@danilaml

Similar to #120615. Looks like the fix wasn't a complete one. Here is an example:

target triple = "x86_64-unknown-linux-gnu"

define ptr @f(i32 %0) {
  switch i32 0, label %bb4 [
    i32 1, label %bb4
    i32 2, label %bb4
    i32 3, label %bb4
    i32 4, label %bb1
    i32 5, label %bb4
    i32 6, label %bb4
  ]

bb:                                               ; No predecessors!
  switch i32 0, label %bb4 [
    i32 0, label %bb4
    i32 1, label %bb1
  ]

bb1:                                              ; preds = %bb2, %bb, %1
  %2 = phi i32 [ %3, %bb2 ], [ 0, %bb ], [ 0, %1 ]
  switch i32 %0, label %bb3 [
    i32 0, label %bb2
    i32 1, label %bb2
    i32 2, label %bb2
  ]

bb2:                                              ; preds = %bb1, %bb1, %bb1
  %3 = add i32 %2, 1
  %4 = icmp ult i32 %0, 0
  br i1 %4, label %bb1, label %bb4

bb3:                                              ; preds = %bb1
  unreachable

bb4:                                              ; preds = %bb2, %bb, %bb, %1, %1, %1, %1, %1, %1
  ret ptr null
}

Crashes with the same command line opt -passes=nary-reassociate --scalar-evolution-use-expensive-range-sharpening
godbolt: https://godbolt.org/z/4d3jo8jTz

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions