fix regression of storing optional with 0-bit payload
parent
5c55a9b4e8
commit
e0000c47bd
|
@ -4731,6 +4731,10 @@ static LLVMValueRef ir_render_optional_unwrap_ptr(CodeGen *g, IrExecutableGen *e
|
||||||
LLVMPositionBuilderAtEnd(g->builder, ok_block);
|
LLVMPositionBuilderAtEnd(g->builder, ok_block);
|
||||||
}
|
}
|
||||||
if (!type_has_bits(child_type)) {
|
if (!type_has_bits(child_type)) {
|
||||||
|
if (instruction->initializing) {
|
||||||
|
LLVMValueRef non_null_bit = LLVMConstInt(LLVMInt1Type(), 1, false);
|
||||||
|
gen_store_untyped(g, non_null_bit, base_ptr, 0, false);
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
} else {
|
} else {
|
||||||
bool is_scalar = !handle_is_ptr(maybe_type);
|
bool is_scalar = !handle_is_ptr(maybe_type);
|
||||||
|
|
|
@ -10402,6 +10402,7 @@ static Error ir_exec_scan_for_side_effects(CodeGen *codegen, IrExecutableGen *ex
|
||||||
if (instr_is_comptime(instruction)) {
|
if (instr_is_comptime(instruction)) {
|
||||||
switch (instruction->id) {
|
switch (instruction->id) {
|
||||||
case IrInstGenIdUnwrapErrPayload:
|
case IrInstGenIdUnwrapErrPayload:
|
||||||
|
case IrInstGenIdOptionalUnwrapPtr:
|
||||||
case IrInstGenIdUnionFieldPtr:
|
case IrInstGenIdUnionFieldPtr:
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
|
@ -18671,7 +18672,7 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr
|
||||||
{
|
{
|
||||||
bool same_comptime_repr = types_have_same_zig_comptime_repr(ira->codegen, actual_elem_type, value_type);
|
bool same_comptime_repr = types_have_same_zig_comptime_repr(ira->codegen, actual_elem_type, value_type);
|
||||||
if (!same_comptime_repr) {
|
if (!same_comptime_repr) {
|
||||||
result_loc_pass1->written = false;
|
result_loc_pass1->written = was_written;
|
||||||
return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, result_loc, false, true);
|
return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, result_loc, false, true);
|
||||||
}
|
}
|
||||||
} else if (actual_elem_type->id == ZigTypeIdErrorUnion && value_type->id != ZigTypeIdErrorUnion) {
|
} else if (actual_elem_type->id == ZigTypeIdErrorUnion && value_type->id != ZigTypeIdErrorUnion) {
|
||||||
|
@ -29971,7 +29972,6 @@ bool ir_inst_gen_has_side_effects(IrInstGen *instruction) {
|
||||||
case IrInstGenIdReturnPtr:
|
case IrInstGenIdReturnPtr:
|
||||||
case IrInstGenIdStructFieldPtr:
|
case IrInstGenIdStructFieldPtr:
|
||||||
case IrInstGenIdTestNonNull:
|
case IrInstGenIdTestNonNull:
|
||||||
case IrInstGenIdOptionalUnwrapPtr:
|
|
||||||
case IrInstGenIdClz:
|
case IrInstGenIdClz:
|
||||||
case IrInstGenIdCtz:
|
case IrInstGenIdCtz:
|
||||||
case IrInstGenIdPopCount:
|
case IrInstGenIdPopCount:
|
||||||
|
@ -30028,6 +30028,8 @@ bool ir_inst_gen_has_side_effects(IrInstGen *instruction) {
|
||||||
return reinterpret_cast<IrInstGenUnwrapErrCode *>(instruction)->initializing;
|
return reinterpret_cast<IrInstGenUnwrapErrCode *>(instruction)->initializing;
|
||||||
case IrInstGenIdUnionFieldPtr:
|
case IrInstGenIdUnionFieldPtr:
|
||||||
return reinterpret_cast<IrInstGenUnionFieldPtr *>(instruction)->initializing;
|
return reinterpret_cast<IrInstGenUnionFieldPtr *>(instruction)->initializing;
|
||||||
|
case IrInstGenIdOptionalUnwrapPtr:
|
||||||
|
return reinterpret_cast<IrInstGenOptionalUnwrapPtr *>(instruction)->initializing;
|
||||||
case IrInstGenIdErrWrapPayload:
|
case IrInstGenIdErrWrapPayload:
|
||||||
return reinterpret_cast<IrInstGenErrWrapPayload *>(instruction)->result_loc != nullptr;
|
return reinterpret_cast<IrInstGenErrWrapPayload *>(instruction)->result_loc != nullptr;
|
||||||
case IrInstGenIdErrWrapCode:
|
case IrInstGenIdErrWrapCode:
|
||||||
|
|
Loading…
Reference in New Issue