List.unreachable

This commit is contained in:
Folkert 2022-07-02 19:31:35 +02:00
parent 543615292a
commit 506e374642
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
7 changed files with 36 additions and 0 deletions

View file

@ -6068,6 +6068,20 @@ fn run_low_level<'a, 'ctx, 'env>(
PtrCast | RefCountInc | RefCountDec => {
unreachable!("Not used in LLVM backend: {:?}", op);
}
Unreachable => match RocReturn::from_layout(env, layout) {
RocReturn::Return => {
let basic_type = basic_type_from_layout(env, layout);
basic_type.const_zero()
}
RocReturn::ByPointer => {
let basic_type = basic_type_from_layout(env, layout);
let ptr = env.builder.build_alloca(basic_type, "unreachable_alloca");
env.builder.build_store(ptr, basic_type.const_zero());
ptr.into()
}
},
}
}