| ... | @@ -3893,15 +3893,30 @@ static LLVMValueRef ir_render_vector_store_elem(CodeGen *g, IrExecutableGen *exe | ... | @@ -3893,15 +3893,30 @@ static LLVMValueRef ir_render_vector_store_elem(CodeGen *g, IrExecutableGen *exe |
| 3893 | } | 3893 | } |
| 3894 | | 3894 | |
| 3895 | static LLVMValueRef ir_render_var_ptr(CodeGen *g, IrExecutableGen *executable, IrInstGenVarPtr *instruction) { | 3895 | static LLVMValueRef ir_render_var_ptr(CodeGen *g, IrExecutableGen *executable, IrInstGenVarPtr *instruction) { |
| 3896 | if (instruction->base.value->special != ConstValSpecialRuntime) | 3896 | Error err; |
| 3897 | return ir_llvm_value(g, &instruction->base); | 3897 | |
| 3898 | ZigVar *var = instruction->var; | 3898 | ZigType *ptr_type = instruction->base.value->type; |
| 3899 | if (type_has_bits(g, var->var_type)) { | 3899 | assert(ptr_type->id == ZigTypeIdPointer); |
| 3900 | assert(var->value_ref); | 3900 | bool ptr_type_has_bits; |
| 3901 | return var->value_ref; | 3901 | if ((err = type_has_bits2(g, ptr_type, &ptr_type_has_bits))) |
| 3902 | } else { | 3902 | codegen_report_errors_and_exit(g); |
| | 3903 | |
| | 3904 | if (!ptr_type_has_bits) { |
| 3903 | return nullptr; | 3905 | return nullptr; |
| 3904 | } | 3906 | } |
| | 3907 | |
| | 3908 | // The extra bitcasts are needed in case the LLVM value is an unnamed |
| | 3909 | // struct, as it happens when rendering container types with extra alignment |
| | 3910 | // fields. |
| | 3911 | if (instruction->base.value->special != ConstValSpecialRuntime) { |
| | 3912 | return LLVMBuildBitCast(g->builder, ir_llvm_value(g, &instruction->base), |
| | 3913 | get_llvm_type(g, ptr_type), ""); |
| | 3914 | } |
| | 3915 | |
| | 3916 | ZigVar *var = instruction->var; |
| | 3917 | assert(var->value_ref); |
| | 3918 | return LLVMBuildBitCast(g->builder, var->value_ref, |
| | 3919 | get_llvm_type(g, ptr_type), ""); |
| 3905 | } | 3920 | } |
| 3906 | | 3921 | |
| 3907 | static LLVMValueRef ir_render_return_ptr(CodeGen *g, IrExecutableGen *executable, | 3922 | static LLVMValueRef ir_render_return_ptr(CodeGen *g, IrExecutableGen *executable, |