Skip to content

Crash in CIRIfFlatten when if clause #1090

@orbiri

Description

@orbiri

When trying to debug why this reduced snippet from SingleSource fails:

extern void link_error1();

void test4(float x, float y) {
  if ((x == y) || (x != y)) {
  } else
    link_error1();
}

With this crash

Assertion failed: (!NodePtr->isKnownSentinel()), function operator*, file ilist_iterator.h, line 168.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /Users/orbiri/cir/llvm-project/build/Release/bin/cir-opt --mlir-print-ir-after-failure --cir-to-llvm --reconcile-unrealized-casts /tmp/test.cir -o /tmp/test.mlir
 #0 0x0000000107267a28 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Users/orbiri/cir/llvm-project/build/Release/bin/cir-opt+0x101418a28)
 #1 0x0000000107265929 llvm::sys::RunSignalHandlers() (/Users/orbiri/cir/llvm-project/build/Release/bin/cir-opt+0x101416929)
 #2 0x0000000107268096 SignalHandler(int) (/Users/orbiri/cir/llvm-project/build/Release/bin/cir-opt+0x101419096)
 #3 0x00007ff812efce9d (/usr/lib/system/libsystem_platform.dylib+0x7ff80047fe9d)
 #4 0x00007ff7ba0af3f0 
 #5 0x00007ff812de8b19 (/usr/lib/system/libsystem_c.dylib+0x7ff80036bb19)
 #6 0x00007ff812de7ddc (/usr/lib/system/libsystem_c.dylib+0x7ff80036addc)
 #7 0x00000001074d1d93 (anonymous namespace)::CIRIfFlattening::matchAndRewrite(mlir::cir::IfOp, mlir::PatternRewriter&) const (.cold.14) (/Users/orbiri/cir/llvm-project/build/Release/bin/cir-opt+0x101682d93)

I reduced the problem to

#true = #cir.bool<true> : !cir.bool

cir.func @test4() {
    %6 = cir.const #true
    cir.if %6 {
    } else {
    }
    cir.return
  }

While the following snippet do pass

#true = #cir.bool<true> : !cir.bool

cir.func @test4() {
    %6 = cir.const #true
    cir.if %6 {
          %5 = cir.const #true

    } else {
    }
    cir.return
  }

I am now building with debug and will try to understand the cause for this issue :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions