authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-10-01 17:39:31-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-10-01 17:41:03-04:00
loga8d6954c23d816121471558990c5dd6bf5f82c89
tree3116f932c4abd7fed542647192afd73bbac5e1ad
parentc1a05f058112885adb9ac6f08737e670a3773d4b
signaturelock-open Commit is signed but in an unrecognized format.

fix tripping LLVM assertion in const unions


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

src/codegen.cpp+2-3
......@@ -6764,13 +6764,12 @@ check: switch (const_val->special) {
67646764 assert(LLVMGetTypeKind(field_ty) == LLVMIntegerTypeKind);
67656765 fields[type_struct_field->gen_index] = val;
67666766 } else {
6767 const LLVMValueRef MASK = LLVMConstInt(LLVMInt8Type(), 255, false);
6768 const LLVMValueRef AMT = LLVMConstInt(LLVMInt8Type(), 8, false);
6767 const LLVMValueRef AMT = LLVMConstInt(LLVMTypeOf(val), 8, false);
67696768
67706769 LLVMValueRef *values = allocate<LLVMValueRef>(size_in_bytes);
67716770 for (size_t i = 0; i < size_in_bytes; i++) {
67726771 const size_t idx = is_big_endian ? size_in_bytes - 1 - i : i;
6773 values[idx] = LLVMConstTruncOrBitCast(LLVMConstAnd(val, MASK), LLVMInt8Type());
6772 values[idx] = LLVMConstTruncOrBitCast(val, LLVMInt8Type());
67746773 val = LLVMConstLShr(val, AMT);
67756774 }
67766775