# llvm: correctly lower c-abi for Wasm target · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/200b2e4ee108d388e0db2120aee38f83d1c7abdb)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 200b2e4ee108d388e0db2120aee38f83d1c7abdb

Requested commit: 200b2e4ee108d388e0db2120aee38f83d1c7abdb

Commit: 200b2e4ee108d388e0db2120aee38f83d1c7abdb

Tree: 49139a306103997d18ed83624b3fec2c3cb13468

Author: Luuk de Gram

Committer: Luuk de Gram

## Message

```
llvm: correctly lower c-abi for Wasm target

When lowering the return type for Wasm if the calling convention is `C`,
it now correctly lower it according to what clang does as specified in:
https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md

This makes use of the same logic as the Wasm backend, ensuring the
generated code does not diverge in function signatures.

When passing arguments accross the C-ABI for the Wasm target,
we want slightly different behavior than x86_64.
For instance: a struct with multiple fields must always be passed
by reference, even if its ABI size fits in a single integer.
However, we do pass larger integers such as 128bit by value,
which LLVM will correctly lower to use double arguments instead.

```

## Parents

- [bf28a47cf23a60539f7cc6cb87309d1a7fa01c18](https://git.cafe/gitcafe/zig/commit/bf28a47cf23a60539f7cc6cb87309d1a7fa01c18?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/200b2e4ee108d388e0db2120aee38f83d1c7abdb?format=markdown)
