AnyDSL / thorin

The Higher-Order Intermediate Representation
https://anydsl.github.io
GNU Lesser General Public License v3.0
150 stars 15 forks source link

Using `undef` in `match`-else branch triggers a `bottom` def #161

Closed PearCoding closed 3 months ago

PearCoding commented 3 months ago

Using the undef[T]() method for complex types in match inside the else/otherwise code produces an error like the following:

Terminator found in the middle of a basic block!
label %match_otherwise
Operand is null
  %cont3 = phi i32 [ %3, %case_body ], [ %4, %case_body1 ], [ %5, %case_body2 ], [ <null operand!>, %match_otherwise ]

The issue can be reproduced with the following code test.zip. Without the main3_err function the code passes. Use artic test.art --emit-llvm to compile.

The issue was detected on Linux Ubuntu first.

Used libraries:

Hugobros3 commented 3 months ago

I got a different error in my reproduction:

artic: /home/gob/git/anydsl/thorin/src/thorin/be/llvm/llvm.cpp:618: void thorin::llvm::CodeGen::emit_epilogue(thorin::Continuation*): Assertion `call_instr && "returning calls always involve one of those"' failed.`

A few questions/remarks:

PearCoding commented 3 months ago

We could use a adapted variant of the zip I send to test this in artic.

PearCoding commented 3 months ago

Oh, also I do get the same error when I have thorin with checks and debug. Forgot to mention that.

PearCoding commented 3 months ago

@Hugobros3 fixed it with https://github.com/AnyDSL/thorin/commit/2400342888fe9e04111ed6c74003c7901717e221