authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-07 11:50:15-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-07 23:36:36-04:00
logab483281d31c852e77fe0afc6a623fedd1574546
tree0bd35f022784035d8ca3574d4d06b113e528bc5a
parent2fc18b52788f789ceba7b4f60e850de3ce67495c

stage1: elide `@intToPtr` alignment safety check for 1-byte alignment


1 files changed, 2 insertions(+), 2 deletions(-)

src/codegen.cpp+2-2
...@@ -3480,8 +3480,9 @@ static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, IrExecutableGen *exec...@@ -3480,8 +3480,9 @@ static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, IrExecutableGen *exec
3480static LLVMValueRef ir_render_int_to_ptr(CodeGen *g, IrExecutableGen *executable, IrInstGenIntToPtr *instruction) {3480static LLVMValueRef ir_render_int_to_ptr(CodeGen *g, IrExecutableGen *executable, IrInstGenIntToPtr *instruction) {
3481 ZigType *wanted_type = instruction->base.value->type;3481 ZigType *wanted_type = instruction->base.value->type;
3482 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);3482 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
3483 const uint32_t align_bytes = get_ptr_align(g, wanted_type);
34833484
3484 if (ir_want_runtime_safety(g, &instruction->base)) {3485 if (ir_want_runtime_safety(g, &instruction->base) && align_bytes > 1) {
3485 ZigType *usize = g->builtin_types.entry_usize;3486 ZigType *usize = g->builtin_types.entry_usize;
3486 LLVMValueRef zero = LLVMConstNull(usize->llvm_type);3487 LLVMValueRef zero = LLVMConstNull(usize->llvm_type);
34873488
...@@ -3498,7 +3499,6 @@ static LLVMValueRef ir_render_int_to_ptr(CodeGen *g, IrExecutableGen *executable...@@ -3498,7 +3499,6 @@ static LLVMValueRef ir_render_int_to_ptr(CodeGen *g, IrExecutableGen *executable
3498 }3499 }
34993500
3500 {3501 {
3501 const uint32_t align_bytes = get_ptr_align(g, wanted_type);
3502 LLVMValueRef alignment_minus_1 = LLVMConstInt(usize->llvm_type, align_bytes - 1, false);3502 LLVMValueRef alignment_minus_1 = LLVMConstInt(usize->llvm_type, align_bytes - 1, false);
3503 LLVMValueRef anded_val = LLVMBuildAnd(g->builder, target_val, alignment_minus_1, "");3503 LLVMValueRef anded_val = LLVMBuildAnd(g->builder, target_val, alignment_minus_1, "");
3504 LLVMValueRef is_ok_bit = LLVMBuildICmp(g->builder, LLVMIntEQ, anded_val, zero, "");3504 LLVMValueRef is_ok_bit = LLVMBuildICmp(g->builder, LLVMIntEQ, anded_val, zero, "");