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