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 {...@@ -2365,7 +2365,7 @@ pub const DeclGen = struct {
2365 }2365 }
2366 dg.addFnAttr(llvm_fn, "nounwind");2366 dg.addFnAttr(llvm_fn, "nounwind");
2367 if (comp.unwind_tables) {2367 if (comp.unwind_tables) {
2368 dg.addFnAttr(llvm_fn, "uwtable");2368 dg.addFnAttrString(llvm_fn, "uwtable", "sync");
2369 }2369 }
2370 if (comp.bin_file.options.skip_linker_dependencies or2370 if (comp.bin_file.options.skip_linker_dependencies or
2371 comp.bin_file.options.no_builtin)2371 comp.bin_file.options.no_builtin)
...@@ -4996,8 +4996,8 @@ pub const FuncGen = struct {...@@ -4996,8 +4996,8 @@ pub const FuncGen = struct {
4996 const indices: [2]*const llvm.Value = .{4996 const indices: [2]*const llvm.Value = .{
4997 llvm_usize.constNull(), llvm_usize.constNull(),4997 llvm_usize.constNull(), llvm_usize.constNull(),
4998 };4998 };
4999 const elem_llvm_ty = try self.dg.lowerType(array_ty.childType());4999 const array_llvm_ty = try self.dg.lowerType(array_ty);
5000 const ptr = self.builder.buildInBoundsGEP(elem_llvm_ty, operand, &indices, indices.len, "");5000 const ptr = self.builder.buildInBoundsGEP(array_llvm_ty, operand, &indices, indices.len, "");
5001 const partial = self.builder.buildInsertValue(slice_llvm_ty.getUndef(), ptr, 0, "");5001 const partial = self.builder.buildInsertValue(slice_llvm_ty.getUndef(), ptr, 0, "");
5002 return self.builder.buildInsertValue(partial, len, 1, "");5002 return self.builder.buildInsertValue(partial, len, 1, "");
5003 }5003 }
...@@ -5174,13 +5174,14 @@ pub const FuncGen = struct {...@@ -5174,13 +5174,14 @@ pub const FuncGen = struct {
5174 const array_llvm_val = try self.resolveInst(bin_op.lhs);5174 const array_llvm_val = try self.resolveInst(bin_op.lhs);
5175 const rhs = try self.resolveInst(bin_op.rhs);5175 const rhs = try self.resolveInst(bin_op.rhs);
5176 if (isByRef(array_ty)) {5176 if (isByRef(array_ty)) {
5177 const elem_ty = array_ty.childType();5177 const array_llvm_ty = try self.dg.lowerType(array_ty);
5178 const elem_llvm_ty = try self.dg.lowerType(elem_ty);
5179 const indices: [2]*const llvm.Value = .{ self.context.intType(32).constNull(), rhs };5178 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();
5181 if (isByRef(elem_ty)) {5181 if (isByRef(elem_ty)) {
5182 return elem_ptr;5182 return elem_ptr;
5183 } else {5183 } else {
5184 const elem_llvm_ty = try self.dg.lowerType(elem_ty);
5184 return self.builder.buildLoad(elem_llvm_ty, elem_ptr, "");5185 return self.builder.buildLoad(elem_llvm_ty, elem_ptr, "");
5185 }5186 }
5186 }5187 }
...@@ -7306,6 +7307,7 @@ pub const FuncGen = struct {...@@ -7306,6 +7307,7 @@ pub const FuncGen = struct {
7306 } else {7307 } else {
7307 // If the ABI size of the element type is not evenly divisible by size in bits;7308 // If the ABI size of the element type is not evenly divisible by size in bits;
7308 // a simple bitcast will not work, and we fall back to extractelement.7309 // a simple bitcast will not work, and we fall back to extractelement.
7310 const array_llvm_ty = try self.dg.lowerType(operand_ty);
7309 const elem_llvm_ty = try self.dg.lowerType(elem_ty);7311 const elem_llvm_ty = try self.dg.lowerType(elem_ty);
7310 const llvm_usize = try self.dg.lowerType(Type.usize);7312 const llvm_usize = try self.dg.lowerType(Type.usize);
7311 const llvm_u32 = self.context.intType(32);7313 const llvm_u32 = self.context.intType(32);
...@@ -7317,7 +7319,7 @@ pub const FuncGen = struct {...@@ -7317,7 +7319,7 @@ pub const FuncGen = struct {
7317 const index_usize = llvm_usize.constInt(i, .False);7319 const index_usize = llvm_usize.constInt(i, .False);
7318 const index_u32 = llvm_u32.constInt(i, .False);7320 const index_u32 = llvm_u32.constInt(i, .False);
7319 const indexes: [2]*const llvm.Value = .{ zero, index_usize };7321 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, "");
7321 const elem = self.builder.buildLoad(elem_llvm_ty, elem_ptr, "");7323 const elem = self.builder.buildLoad(elem_llvm_ty, elem_ptr, "");
7322 vector = self.builder.buildInsertElement(vector, elem, index_u32, "");7324 vector = self.builder.buildInsertElement(vector, elem, index_u32, "");
7323 }7325 }
src/stage1/codegen.cpp+1-1
...@@ -223,7 +223,7 @@ static ZigLLVM_CallingConv get_llvm_cc(CodeGen *g, CallingConvention cc) {...@@ -223,7 +223,7 @@ static ZigLLVM_CallingConv get_llvm_cc(CodeGen *g, CallingConvention cc) {
223223
224static void add_uwtable_attr(CodeGen *g, LLVMValueRef fn_val) {224static void add_uwtable_attr(CodeGen *g, LLVMValueRef fn_val) {
225 if (g->unwind_tables) {225 if (g->unwind_tables) {
226 addLLVMFnAttr(fn_val, "uwtable");226 addLLVMFnAttrStr(fn_val, "uwtable", "sync");
227 }227 }
228}228}
229229