with Ada.Text_IO; use Ada.Text_IO;
function Mini return Integer is
type Two_Floats is record
a: aliased float;
b: aliased float;
end record
with Convention => C_Pass_By_Copy;
function hello(a: two_floats) return float
with
Import => True,
Convention => C,
External_Name => "hello";
x: Two_Floats;
y: float;
begin
x := (3.0, 4.0);
y := hello(x);
Put_Line(y'Image);
return 0;
end;
gnat-llvm gives incorrect results, while gcc gives the correct one:
Looking at disassembly output I'm seeing that the version built with gnat-llvm passes the struct via RDI register while version built with gcc passes the struct via XMM0 (like the convention used on x86_64 linux assumes):
Minimal example I could come up with:
hello.c:
mini.ada:
gnat-llvm gives incorrect results, while gcc gives the correct one:
Looking at disassembly output I'm seeing that the version built with gnat-llvm passes the struct via RDI register while version built with gcc passes the struct via XMM0 (like the convention used on x86_64 linux assumes):
So I'm wondering whether the issue is reproducible for anyone else, or if it's something wrong with my gnat-llvm setup.