authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-28 12:32:39-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-28 12:32:39-05:00
loge0000c47bd22c7b351247b72a85ca26c1c2ada96
treeb90f6afb040e5dbe4d65f7f17ea76d469a36f6c7
parent5c55a9b4e8d6d1f5ee3548cf8033e7e69951b308
signaturelock-open Commit is signed but in an unrecognized format.

fix regression of storing optional with 0-bit payload


2 files changed, 8 insertions(+), 2 deletions(-)

src/codegen.cpp+4
......@@ -4731,6 +4731,10 @@ static LLVMValueRef ir_render_optional_unwrap_ptr(CodeGen *g, IrExecutableGen *e
47314731 LLVMPositionBuilderAtEnd(g->builder, ok_block);
47324732 }
47334733 if (!type_has_bits(child_type)) {
4734 if (instruction->initializing) {
4735 LLVMValueRef non_null_bit = LLVMConstInt(LLVMInt1Type(), 1, false);
4736 gen_store_untyped(g, non_null_bit, base_ptr, 0, false);
4737 }
47344738 return nullptr;
47354739 } else {
47364740 bool is_scalar = !handle_is_ptr(maybe_type);
src/ir.cpp+4-2
......@@ -10402,6 +10402,7 @@ static Error ir_exec_scan_for_side_effects(CodeGen *codegen, IrExecutableGen *ex
1040210402 if (instr_is_comptime(instruction)) {
1040310403 switch (instruction->id) {
1040410404 case IrInstGenIdUnwrapErrPayload:
10405 case IrInstGenIdOptionalUnwrapPtr:
1040510406 case IrInstGenIdUnionFieldPtr:
1040610407 continue;
1040710408 default:
......@@ -18671,7 +18672,7 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr
1867118672 {
1867218673 bool same_comptime_repr = types_have_same_zig_comptime_repr(ira->codegen, actual_elem_type, value_type);
1867318674 if (!same_comptime_repr) {
18674 result_loc_pass1->written = false;
18675 result_loc_pass1->written = was_written;
1867518676 return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, result_loc, false, true);
1867618677 }
1867718678 } else if (actual_elem_type->id == ZigTypeIdErrorUnion && value_type->id != ZigTypeIdErrorUnion) {
......@@ -29971,7 +29972,6 @@ bool ir_inst_gen_has_side_effects(IrInstGen *instruction) {
2997129972 case IrInstGenIdReturnPtr:
2997229973 case IrInstGenIdStructFieldPtr:
2997329974 case IrInstGenIdTestNonNull:
29974 case IrInstGenIdOptionalUnwrapPtr:
2997529975 case IrInstGenIdClz:
2997629976 case IrInstGenIdCtz:
2997729977 case IrInstGenIdPopCount:
......@@ -30028,6 +30028,8 @@ bool ir_inst_gen_has_side_effects(IrInstGen *instruction) {
3002830028 return reinterpret_cast<IrInstGenUnwrapErrCode *>(instruction)->initializing;
3002930029 case IrInstGenIdUnionFieldPtr:
3003030030 return reinterpret_cast<IrInstGenUnionFieldPtr *>(instruction)->initializing;
30031 case IrInstGenIdOptionalUnwrapPtr:
30032 return reinterpret_cast<IrInstGenOptionalUnwrapPtr *>(instruction)->initializing;
3003130033 case IrInstGenIdErrWrapPayload:
3003230034 return reinterpret_cast<IrInstGenErrWrapPayload *>(instruction)->result_loc != nullptr;
3003330035 case IrInstGenIdErrWrapCode: