Merge pull request #7397 from kalsprite/union_ternary_phi

backend: a union constant in a ternary or  builds an ill-typed phi
This commit is contained in:
Jeroen van Rijn authored and GitHub committed 2026-08-20 03:24:04 +02:00
commit e551ef5f15
3 files changed
+60 -3

No files matched your search

+4
View File
@@ -4613,6 +4613,9 @@ gb_internal lbValue lb_build_expr_internal(lbProcedure *p, Ast *expr) {
if (is_type_internally_pointer_like(type)) {
incoming_values[0] = LLVMBuildBitCast(p->builder, incoming_values[0], llvm_type, "");
}
// A union constant is built as an anonymous packed struct, which a phi cannot accept
// alongside the named type it results in, even though the two are laid out identically
incoming_values[0] = OdinLLVMBuildTransmute(p, incoming_values[0], llvm_type);
lb_emit_jump(p, done);
lb_start_block(p, else_);
@@ -4622,6 +4625,7 @@ gb_internal lbValue lb_build_expr_internal(lbProcedure *p, Ast *expr) {
if (is_type_internally_pointer_like(type)) {
incoming_values[1] = LLVMBuildBitCast(p->builder, incoming_values[1], llvm_type, "");
}
incoming_values[1] = OdinLLVMBuildTransmute(p, incoming_values[1], llvm_type);
lb_emit_jump(p, done);
lb_start_block(p, done);