diff --git a/spec/compiler/codegen/c_abi/c_abi_spec.cr b/spec/compiler/codegen/c_abi/c_abi_spec.cr index 1a772b897ae2..2099c597d770 100644 --- a/spec/compiler/codegen/c_abi/c_abi_spec.cr +++ b/spec/compiler/codegen/c_abi/c_abi_spec.cr @@ -84,6 +84,36 @@ describe "Code gen: C ABI" do ), &.to_i.should eq(6)) end + {% if flag?(:x86_64) && !flag?(:win32) %} + pending "passes struct after many other args (for real) (#9519)" + {% else %} + it "passes struct after many other args (for real)" do + test_c( + %( + struct s { + long long x, y; + }; + + long long foo(long long a, long long b, long long c, long long d, long long e, struct s v) { + return a + b + c + d + e + v.x + v.y; + } + ), + %( + lib LibFoo + struct S + x : Int64 + y : Int64 + end + + fun foo(a : Int64, b : Int64, c : Int64, d : Int64, e : Int64, v : S) : Int64 + end + + v = LibFoo::S.new(x: 6, y: 7) + LibFoo.foo(1, 2, 3, 4, 5, v) + ), &.to_string.should eq("28")) + end + {% end %} + it "returns struct less than 64 bits (for real)" do test_c( %( diff --git a/src/llvm/abi/x86_win64.cr b/src/llvm/abi/x86_win64.cr index 5a9a07bdb31e..69e9b0823ba9 100644 --- a/src/llvm/abi/x86_win64.cr +++ b/src/llvm/abi/x86_win64.cr @@ -12,7 +12,7 @@ class LLVM::ABI::X86_Win64 < LLVM::ABI::X86 when 2 then ArgType.direct(t, context.int16) when 4 then ArgType.direct(t, context.int32) when 8 then ArgType.direct(t, context.int64) - else ArgType.indirect(t, LLVM::Attribute::ByVal) + else ArgType.indirect(t, nil) end else non_struct(t, context)