diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-11-18 22:24:41 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-11-18 22:24:41 -0500 |
| commit | d94cb0566be6463594f0904aa759de9e52585842 (patch) | |
| tree | 470044a3b58fbeee7e270617da76fca54b3a6f0f /src/ir.cpp | |
| parent | bf7cde62c52b370f953db2cd6167a156771d8343 (diff) | |
| download | zig-d94cb0566be6463594f0904aa759de9e52585842.tar.gz zig-d94cb0566be6463594f0904aa759de9e52585842.zip | |
IR: correctly codegening memset and memcpy
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 40377958cf..147b14d19a 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -36,6 +36,7 @@ static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, BlockCont static TypeTableEntry *ir_analyze_instruction(IrAnalyze *ira, IrInstruction *instruction); ConstExprValue *const_ptr_pointee(ConstExprValue *const_val) { + assert(const_val->special == ConstValSpecialStatic); ConstExprValue *base_ptr = const_val->data.x_ptr.base_ptr; size_t index = const_val->data.x_ptr.index; @@ -3620,7 +3621,6 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc assert(ptr_type->id == TypeTableEntryIdPointer); TypeTableEntry *array_type = ptr_type->data.pointer.child_type; - ConstExprValue *array_ptr_val = const_ptr_pointee(&array_ptr->static_value); TypeTableEntry *return_type; if (array_type->id == TypeTableEntryIdInvalid) { @@ -3659,7 +3659,11 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc } } - if (array_ptr_val->special != ConstValSpecialRuntime) { + ConstExprValue *array_ptr_val; + if (array_ptr->static_value.special != ConstValSpecialRuntime && + (array_ptr_val = const_ptr_pointee(&array_ptr->static_value)) && + array_ptr_val->special != ConstValSpecialRuntime) + { bool depends_on_compile_var = array_ptr_val->depends_on_compile_var || casted_elem_index->static_value.depends_on_compile_var; ConstExprValue *out_val = ir_build_const_from(ira, &elem_ptr_instruction->base, depends_on_compile_var); |
