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 {...@@ -605,7 +605,6 @@ enum CastOp {
605 CastOpFloatToInt,605 CastOpFloatToInt,
606 CastOpBoolToInt,606 CastOpBoolToInt,
607 CastOpResizeSlice,607 CastOpResizeSlice,
608 CastOpBytesToSlice,
609 CastOpNumLitToConcrete,608 CastOpNumLitToConcrete,
610 CastOpErrSet,609 CastOpErrSet,
611 CastOpBitCast,610 CastOpBitCast,
src/codegen.cpp-26
...@@ -2882,32 +2882,6 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,...@@ -2882,32 +2882,6 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
2882 gen_store_untyped(g, new_len, dest_len_ptr, 0, false);2882 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
2911 return cast_instruction->tmp_ptr;2885 return cast_instruction->tmp_ptr;
2912 }2886 }
2913 case CastOpIntToFloat:2887 case CastOpIntToFloat:
src/ir.cpp+1-2
...@@ -9339,7 +9339,6 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_...@@ -9339,7 +9339,6 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_
9339 const_val->type = new_type;9339 const_val->type = new_type;
9340 break;9340 break;
9341 case CastOpResizeSlice:9341 case CastOpResizeSlice:
9342 case CastOpBytesToSlice:
9343 // can't do it9342 // can't do it
9344 zig_unreachable();9343 zig_unreachable();
9345 case CastOpIntToFloat:9344 case CastOpIntToFloat:
...@@ -9396,7 +9395,7 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -9396,7 +9395,7 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst
9396 ZigType *wanted_type, CastOp cast_op, bool need_alloca)9395 ZigType *wanted_type, CastOp cast_op, bool need_alloca)
9397{9396{
9398 if ((instr_is_comptime(value) || !type_has_bits(wanted_type)) &&9397 if ((instr_is_comptime(value) || !type_has_bits(wanted_type)) &&
9399 cast_op != CastOpResizeSlice && cast_op != CastOpBytesToSlice)9398 cast_op != CastOpResizeSlice)
9400 {9399 {
9401 IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,9400 IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,
9402 source_instr->source_node, wanted_type);9401 source_instr->source_node, wanted_type);