authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-03 16:42:27-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-03 16:42:27-07:00
loga3045b8abbba896da34a02266f2be89dd6c90ecc
tree9974fe4e4564e10be88289ad19cee0b96f949de6
parent7e43904508a5cce3a4774de7f68983fe4d4bf5ab

LLVM backends: more LLVM 15 fixes

uwtable now needs a "sync" or "async" parameter. more opaque pointer fixes

2 files changed, 10 insertions(+), 8 deletions(-)

src/codegen/llvm.zig+9-7
......@@ -2365,7 +2365,7 @@ pub const DeclGen = struct {
23652365 }
23662366 dg.addFnAttr(llvm_fn, "nounwind");
23672367 if (comp.unwind_tables) {
2368 dg.addFnAttr(llvm_fn, "uwtable");
2368 dg.addFnAttrString(llvm_fn, "uwtable", "sync");
23692369 }
23702370 if (comp.bin_file.options.skip_linker_dependencies or
23712371 comp.bin_file.options.no_builtin)
......@@ -4996,8 +4996,8 @@ pub const FuncGen = struct {
49964996 const indices: [2]*const llvm.Value = .{
49974997 llvm_usize.constNull(), llvm_usize.constNull(),
49984998 };
4999 const elem_llvm_ty = try self.dg.lowerType(array_ty.childType());
5000 const ptr = self.builder.buildInBoundsGEP(elem_llvm_ty, operand, &indices, indices.len, "");
4999 const array_llvm_ty = try self.dg.lowerType(array_ty);
5000 const ptr = self.builder.buildInBoundsGEP(array_llvm_ty, operand, &indices, indices.len, "");
50015001 const partial = self.builder.buildInsertValue(slice_llvm_ty.getUndef(), ptr, 0, "");
50025002 return self.builder.buildInsertValue(partial, len, 1, "");
50035003 }
......@@ -5174,13 +5174,14 @@ pub const FuncGen = struct {
51745174 const array_llvm_val = try self.resolveInst(bin_op.lhs);
51755175 const rhs = try self.resolveInst(bin_op.rhs);
51765176 if (isByRef(array_ty)) {
5177 const elem_ty = array_ty.childType();
5178 const elem_llvm_ty = try self.dg.lowerType(elem_ty);
5177 const array_llvm_ty = try self.dg.lowerType(array_ty);
51795178 const indices: [2]*const llvm.Value = .{ self.context.intType(32).constNull(), rhs };
5180 const elem_ptr = self.builder.buildInBoundsGEP(elem_llvm_ty, array_llvm_val, &indices, indices.len, "");
5179 const elem_ptr = self.builder.buildInBoundsGEP(array_llvm_ty, array_llvm_val, &indices, indices.len, "");
5180 const elem_ty = array_ty.childType();
51815181 if (isByRef(elem_ty)) {
51825182 return elem_ptr;
51835183 } else {
5184 const elem_llvm_ty = try self.dg.lowerType(elem_ty);
51845185 return self.builder.buildLoad(elem_llvm_ty, elem_ptr, "");
51855186 }
51865187 }
......@@ -7306,6 +7307,7 @@ pub const FuncGen = struct {
73067307 } else {
73077308 // If the ABI size of the element type is not evenly divisible by size in bits;
73087309 // a simple bitcast will not work, and we fall back to extractelement.
7310 const array_llvm_ty = try self.dg.lowerType(operand_ty);
73097311 const elem_llvm_ty = try self.dg.lowerType(elem_ty);
73107312 const llvm_usize = try self.dg.lowerType(Type.usize);
73117313 const llvm_u32 = self.context.intType(32);
......@@ -7317,7 +7319,7 @@ pub const FuncGen = struct {
73177319 const index_usize = llvm_usize.constInt(i, .False);
73187320 const index_u32 = llvm_u32.constInt(i, .False);
73197321 const indexes: [2]*const llvm.Value = .{ zero, index_usize };
7320 const elem_ptr = self.builder.buildInBoundsGEP(elem_llvm_ty, operand, &indexes, indexes.len, "");
7322 const elem_ptr = self.builder.buildInBoundsGEP(array_llvm_ty, operand, &indexes, indexes.len, "");
73217323 const elem = self.builder.buildLoad(elem_llvm_ty, elem_ptr, "");
73227324 vector = self.builder.buildInsertElement(vector, elem, index_u32, "");
73237325 }
src/stage1/codegen.cpp+1-1
......@@ -223,7 +223,7 @@ static ZigLLVM_CallingConv get_llvm_cc(CodeGen *g, CallingConvention cc) {
223223
224224static void add_uwtable_attr(CodeGen *g, LLVMValueRef fn_val) {
225225 if (g->unwind_tables) {
226 addLLVMFnAttr(fn_val, "uwtable");
226 addLLVMFnAttrStr(fn_val, "uwtable", "sync");
227227 }
228228}
229229