commit 47f7ed1c4cb8acf7fed99a057fb84202962e4b1b (tree)
parent 6926e6e705b7d1c0a69ec20b6b0e1ea280f036d1
Author: Andrew Kelley <andrew@ziglang.org>
Date: Thu, 19 Aug 2021 17:09:55 -0700
Revert "Add mask before truncating dereferenced bit pointers (#9584)"
This was a workaround for an LLVM 12 bug which has been fixed in LLVM
13.
This reverts commit 5cd1d42a351aa77d2a030e59cbd2b9abf7c44444 but keeps
the test case.
Diffstat:
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/stage1/codegen.cpp b/src/stage1/codegen.cpp
@@ -3831,14 +3831,10 @@ static LLVMValueRef ir_render_load_ptr(CodeGen *g, Stage1Air *executable,
LLVMValueRef shift_amt_val = LLVMConstInt(LLVMTypeOf(containing_int), shift_amt, false);
LLVMValueRef shifted_value = LLVMBuildLShr(g->builder, containing_int, shift_amt_val, "");
- LLVMTypeRef same_size_int = LLVMIntType(size_in_bits);
- LLVMValueRef mask = LLVMConstAllOnes(LLVMIntType(size_in_bits));
- mask = LLVMConstZExt(mask, LLVMTypeOf(containing_int));
- LLVMValueRef masked_value = LLVMBuildAnd(g->builder, shifted_value, mask, "");
-
if (handle_is_ptr(g, child_type)) {
LLVMValueRef result_loc = ir_llvm_value(g, instruction->result_loc);
- LLVMValueRef truncated_int = LLVMBuildTrunc(g->builder, masked_value, same_size_int, "");
+ LLVMTypeRef same_size_int = LLVMIntType(size_in_bits);
+ LLVMValueRef truncated_int = LLVMBuildTrunc(g->builder, shifted_value, same_size_int, "");
LLVMValueRef bitcasted_ptr = LLVMBuildBitCast(g->builder, result_loc,
LLVMPointerType(same_size_int, 0), "");
LLVMBuildStore(g->builder, truncated_int, bitcasted_ptr);
@@ -3846,11 +3842,12 @@ static LLVMValueRef ir_render_load_ptr(CodeGen *g, Stage1Air *executable,
}
if (child_type->id == ZigTypeIdFloat) {
- LLVMValueRef truncated_int = LLVMBuildTrunc(g->builder, masked_value, same_size_int, "");
+ LLVMTypeRef same_size_int = LLVMIntType(size_in_bits);
+ LLVMValueRef truncated_int = LLVMBuildTrunc(g->builder, shifted_value, same_size_int, "");
return LLVMBuildBitCast(g->builder, truncated_int, get_llvm_type(g, child_type), "");
}
- return LLVMBuildTrunc(g->builder, masked_value, get_llvm_type(g, child_type), "");
+ return LLVMBuildTrunc(g->builder, shifted_value, get_llvm_type(g, child_type), "");
}
static bool value_is_all_undef_array(CodeGen *g, ZigValue *const_val, size_t len) {