authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-08-08 21:32:55-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-08-08 22:09:44-04:00
log53bea0f7e44591e741c357297a1f25310d36ca78
treee5fa468528a67c551c268691d58380a82f1fce3b
parent35cd56a3693d55eedb80e8bd1538420597b05ff5

llvm: remove dependence on llvm data layout alignment

by just using the zig alignment and letting llvm promote it as desired

1 files changed, 6 insertions(+), 15 deletions(-)

src/codegen/llvm.zig+6-15
......@@ -1408,11 +1408,7 @@ pub const Object = struct {
14081408 llvm_arg_i += 1;
14091409
14101410 const param_llvm_ty = try o.lowerType(param_ty);
1411 const int_llvm_ty = try o.builder.intType(@intCast(param_ty.abiSize(mod) * 8));
1412 const alignment = Builder.Alignment.fromByteUnits(@max(
1413 param_ty.abiAlignment(mod),
1414 o.target_data.abiAlignmentOfType(int_llvm_ty.toLlvm(&o.builder)),
1415 ));
1411 const alignment = Builder.Alignment.fromByteUnits(param_ty.abiAlignment(mod));
14161412 const arg_ptr = try buildAllocaInner(&wip, false, param_llvm_ty, alignment, target);
14171413 _ = try wip.store(.normal, param, arg_ptr, alignment);
14181414
......@@ -4938,10 +4934,7 @@ pub const FuncGen = struct {
49384934 } else {
49394935 // LLVM does not allow bitcasting structs so we must allocate
49404936 // a local, store as one type, and then load as another type.
4941 const alignment = Builder.Alignment.fromByteUnits(@max(
4942 param_ty.abiAlignment(mod),
4943 o.target_data.abiAlignmentOfType(int_llvm_ty.toLlvm(&o.builder)),
4944 ));
4937 const alignment = Builder.Alignment.fromByteUnits(param_ty.abiAlignment(mod));
49454938 const int_ptr = try self.buildAlloca(int_llvm_ty, alignment);
49464939 _ = try self.wip.store(.normal, llvm_arg, int_ptr, alignment);
49474940 const loaded = try self.wip.load(.normal, int_llvm_ty, int_ptr, alignment, "");
......@@ -5117,12 +5110,10 @@ pub const FuncGen = struct {
51175110 // In this case the function return type is honoring the calling convention by having
51185111 // a different LLVM type than the usual one. We solve this here at the callsite
51195112 // by using our canonical type, then loading it if necessary.
5120 const alignment = Builder.Alignment.fromByteUnits(@max(
5121 o.target_data.abiAlignmentOfType(abi_ret_ty.toLlvm(&o.builder)),
5122 return_type.abiAlignment(mod),
5123 ));
5124 assert(o.target_data.abiSizeOfType(abi_ret_ty.toLlvm(&o.builder)) >=
5125 o.target_data.abiSizeOfType(llvm_ret_ty.toLlvm(&o.builder)));
5113 const alignment = Builder.Alignment.fromByteUnits(return_type.abiAlignment(mod));
5114 if (o.builder.useLibLlvm())
5115 assert(o.target_data.abiSizeOfType(abi_ret_ty.toLlvm(&o.builder)) >=
5116 o.target_data.abiSizeOfType(llvm_ret_ty.toLlvm(&o.builder)));
51265117 const rp = try self.buildAlloca(abi_ret_ty, alignment);
51275118 _ = try self.wip.store(.normal, call, rp, alignment);
51285119 return if (isByRef(return_type, mod))