mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
llvm: use alignment of ABI return type when it differs from raw return type
This would previously cause miscompilations when the ABI type had bigger alignment than the raw type.
This commit is contained in:
parent
835a1f7f0c
commit
08a00f0d1c
@ -4876,7 +4876,7 @@ pub const FuncGen = struct {
|
|||||||
// In this case the function return type is honoring the calling convention by having
|
// 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
|
// a different LLVM type than the usual one. We solve this here at the callsite
|
||||||
// by bitcasting a pointer to our canonical type, then loading it if necessary.
|
// by bitcasting a pointer to our canonical type, then loading it if necessary.
|
||||||
const alignment = return_type.abiAlignment(target);
|
const alignment = self.dg.object.target_data.abiAlignmentOfType(abi_ret_ty);
|
||||||
const rp = self.buildAlloca(llvm_ret_ty, alignment);
|
const rp = self.buildAlloca(llvm_ret_ty, alignment);
|
||||||
const ptr_abi_ty = abi_ret_ty.pointerType(0);
|
const ptr_abi_ty = abi_ret_ty.pointerType(0);
|
||||||
const casted_ptr = self.builder.buildBitCast(rp, ptr_abi_ty, "");
|
const casted_ptr = self.builder.buildBitCast(rp, ptr_abi_ty, "");
|
||||||
|
|||||||
@ -917,8 +917,6 @@ test "CFF: C passes to Zig" {
|
|||||||
try expectOk(c_send_CFF());
|
try expectOk(c_send_CFF());
|
||||||
}
|
}
|
||||||
test "CFF: C returns to Zig" {
|
test "CFF: C returns to Zig" {
|
||||||
// segfault on aarch64 and mips
|
|
||||||
if (builtin.target.cpu.arch == .aarch64) return error.SkipZigTest;
|
|
||||||
if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
|
if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
|
||||||
if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
|
if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
|
||||||
if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
|
if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user