authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-12-18 15:48:26-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-12-18 15:48:26-05:00
loge077a446566b0aa77a121f9554f3cb355899653a
tree1fce8c2ab0559b96f8e262f06eaf6c2ab827e199
parentf75262b79f0656ebfac7fb5bd2d6d8e8cce01258
signature Commit is signed but in an unrecognized format.

ir: delete dead code


3 files changed, 1 insertions(+), 29 deletions(-)

src/all_types.hpp-1
......@@ -605,7 +605,6 @@ enum CastOp {
605605 CastOpFloatToInt,
606606 CastOpBoolToInt,
607607 CastOpResizeSlice,
608 CastOpBytesToSlice,
609608 CastOpNumLitToConcrete,
610609 CastOpErrSet,
611610 CastOpBitCast,
src/codegen.cpp-26
......@@ -2882,32 +2882,6 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
28822882 gen_store_untyped(g, new_len, dest_len_ptr, 0, false);
28832883
28842884
2885 return cast_instruction->tmp_ptr;
2886 }
2887 case CastOpBytesToSlice:
2888 {
2889 assert(cast_instruction->tmp_ptr);
2890 assert(wanted_type->id == ZigTypeIdStruct);
2891 assert(wanted_type->data.structure.is_slice);
2892 assert(actual_type->id == ZigTypeIdArray);
2893
2894 ZigType *wanted_pointer_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
2895 ZigType *wanted_child_type = wanted_pointer_type->data.pointer.child_type;
2896
2897
2898 size_t wanted_ptr_index = wanted_type->data.structure.fields[0].gen_index;
2899 LLVMValueRef dest_ptr_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr,
2900 (unsigned)wanted_ptr_index, "");
2901 LLVMValueRef src_ptr_casted = LLVMBuildBitCast(g->builder, expr_val, wanted_pointer_type->type_ref, "");
2902 gen_store_untyped(g, src_ptr_casted, dest_ptr_ptr, 0, false);
2903
2904 size_t wanted_len_index = wanted_type->data.structure.fields[1].gen_index;
2905 LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr,
2906 (unsigned)wanted_len_index, "");
2907 LLVMValueRef len_val = LLVMConstInt(g->builtin_types.entry_usize->type_ref,
2908 actual_type->data.array.len / type_size(g, wanted_child_type), false);
2909 gen_store_untyped(g, len_val, len_ptr, 0, false);
2910
29112885 return cast_instruction->tmp_ptr;
29122886 }
29132887 case CastOpIntToFloat:
src/ir.cpp+1-2
......@@ -9339,7 +9339,6 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_
93399339 const_val->type = new_type;
93409340 break;
93419341 case CastOpResizeSlice:
9342 case CastOpBytesToSlice:
93439342 // can't do it
93449343 zig_unreachable();
93459344 case CastOpIntToFloat:
......@@ -9396,7 +9395,7 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst
93969395 ZigType *wanted_type, CastOp cast_op, bool need_alloca)
93979396{
93989397 if ((instr_is_comptime(value) || !type_has_bits(wanted_type)) &&
9399 cast_op != CastOpResizeSlice && cast_op != CastOpBytesToSlice)
9398 cast_op != CastOpResizeSlice)
94009399 {
94019400 IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,
94029401 source_instr->source_node, wanted_type);