aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2018-12-18 15:48:26 -0500
committerAndrew Kelley <andrew@ziglang.org>2018-12-18 15:48:26 -0500
commite077a446566b0aa77a121f9554f3cb355899653a (patch)
tree1fce8c2ab0559b96f8e262f06eaf6c2ab827e199 /src
parentf75262b79f0656ebfac7fb5bd2d6d8e8cce01258 (diff)
downloadzig-e077a446566b0aa77a121f9554f3cb355899653a.tar.gz
zig-e077a446566b0aa77a121f9554f3cb355899653a.zip
ir: delete dead code
Diffstat (limited to 'src')
-rw-r--r--src/all_types.hpp1
-rw-r--r--src/codegen.cpp26
-rw-r--r--src/ir.cpp3
3 files changed, 1 insertions, 29 deletions
diff --git a/src/all_types.hpp b/src/all_types.hpp
index 83b7e8495f..11304e536d 100644
--- a/src/all_types.hpp
+++ b/src/all_types.hpp
@@ -605,7 +605,6 @@ enum CastOp {
CastOpFloatToInt,
CastOpBoolToInt,
CastOpResizeSlice,
- CastOpBytesToSlice,
CastOpNumLitToConcrete,
CastOpErrSet,
CastOpBitCast,
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 08dd11800a..e37703d5f0 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -2884,32 +2884,6 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
return cast_instruction->tmp_ptr;
}
- case CastOpBytesToSlice:
- {
- assert(cast_instruction->tmp_ptr);
- assert(wanted_type->id == ZigTypeIdStruct);
- assert(wanted_type->data.structure.is_slice);
- assert(actual_type->id == ZigTypeIdArray);
-
- ZigType *wanted_pointer_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
- ZigType *wanted_child_type = wanted_pointer_type->data.pointer.child_type;
-
-
- size_t wanted_ptr_index = wanted_type->data.structure.fields[0].gen_index;
- LLVMValueRef dest_ptr_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr,
- (unsigned)wanted_ptr_index, "");
- LLVMValueRef src_ptr_casted = LLVMBuildBitCast(g->builder, expr_val, wanted_pointer_type->type_ref, "");
- gen_store_untyped(g, src_ptr_casted, dest_ptr_ptr, 0, false);
-
- size_t wanted_len_index = wanted_type->data.structure.fields[1].gen_index;
- LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr,
- (unsigned)wanted_len_index, "");
- LLVMValueRef len_val = LLVMConstInt(g->builtin_types.entry_usize->type_ref,
- actual_type->data.array.len / type_size(g, wanted_child_type), false);
- gen_store_untyped(g, len_val, len_ptr, 0, false);
-
- return cast_instruction->tmp_ptr;
- }
case CastOpIntToFloat:
assert(actual_type->id == ZigTypeIdInt);
if (actual_type->data.integral.is_signed) {
diff --git a/src/ir.cpp b/src/ir.cpp
index 09a9fceabe..76dd6c6391 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -9339,7 +9339,6 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_
const_val->type = new_type;
break;
case CastOpResizeSlice:
- case CastOpBytesToSlice:
// can't do it
zig_unreachable();
case CastOpIntToFloat:
@@ -9396,7 +9395,7 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst
ZigType *wanted_type, CastOp cast_op, bool need_alloca)
{
if ((instr_is_comptime(value) || !type_has_bits(wanted_type)) &&
- cast_op != CastOpResizeSlice && cast_op != CastOpBytesToSlice)
+ cast_op != CastOpResizeSlice)
{
IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,
source_instr->source_node, wanted_type);