aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2023-08-08 21:32:55 -0400
committerJacob Young <jacobly0@users.noreply.github.com>2023-08-08 22:09:44 -0400
commit53bea0f7e44591e741c357297a1f25310d36ca78 (patch)
treee5fa468528a67c551c268691d58380a82f1fce3b /src/codegen
parent35cd56a3693d55eedb80e8bd1538420597b05ff5 (diff)
downloadzig-53bea0f7e44591e741c357297a1f25310d36ca78.tar.gz
zig-53bea0f7e44591e741c357297a1f25310d36ca78.zip
llvm: remove dependence on llvm data layout alignment
by just using the zig alignment and letting llvm promote it as desired
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/llvm.zig21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index d5856bcb52..3a2846ef8c 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -1408,11 +1408,7 @@ pub const Object = struct {
llvm_arg_i += 1;
const param_llvm_ty = try o.lowerType(param_ty);
- const int_llvm_ty = try o.builder.intType(@intCast(param_ty.abiSize(mod) * 8));
- const alignment = Builder.Alignment.fromByteUnits(@max(
- param_ty.abiAlignment(mod),
- o.target_data.abiAlignmentOfType(int_llvm_ty.toLlvm(&o.builder)),
- ));
+ const alignment = Builder.Alignment.fromByteUnits(param_ty.abiAlignment(mod));
const arg_ptr = try buildAllocaInner(&wip, false, param_llvm_ty, alignment, target);
_ = try wip.store(.normal, param, arg_ptr, alignment);
@@ -4938,10 +4934,7 @@ pub const FuncGen = struct {
} else {
// LLVM does not allow bitcasting structs so we must allocate
// a local, store as one type, and then load as another type.
- const alignment = Builder.Alignment.fromByteUnits(@max(
- param_ty.abiAlignment(mod),
- o.target_data.abiAlignmentOfType(int_llvm_ty.toLlvm(&o.builder)),
- ));
+ const alignment = Builder.Alignment.fromByteUnits(param_ty.abiAlignment(mod));
const int_ptr = try self.buildAlloca(int_llvm_ty, alignment);
_ = try self.wip.store(.normal, llvm_arg, int_ptr, alignment);
const loaded = try self.wip.load(.normal, int_llvm_ty, int_ptr, alignment, "");
@@ -5117,12 +5110,10 @@ pub const FuncGen = struct {
// In this case the function return type is honoring the calling convention by having
// a different LLVM type than the usual one. We solve this here at the callsite
// by using our canonical type, then loading it if necessary.
- const alignment = Builder.Alignment.fromByteUnits(@max(
- o.target_data.abiAlignmentOfType(abi_ret_ty.toLlvm(&o.builder)),
- return_type.abiAlignment(mod),
- ));
- assert(o.target_data.abiSizeOfType(abi_ret_ty.toLlvm(&o.builder)) >=
- o.target_data.abiSizeOfType(llvm_ret_ty.toLlvm(&o.builder)));
+ const alignment = Builder.Alignment.fromByteUnits(return_type.abiAlignment(mod));
+ if (o.builder.useLibLlvm())
+ assert(o.target_data.abiSizeOfType(abi_ret_ty.toLlvm(&o.builder)) >=
+ o.target_data.abiSizeOfType(llvm_ret_ty.toLlvm(&o.builder)));
const rp = try self.buildAlloca(abi_ret_ty, alignment);
_ = try self.wip.store(.normal, call, rp, alignment);
return if (isByRef(return_type, mod))