# LLVM: rework calling convention lowering · gitcafe/zig

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

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

Visibility: public

Requested revision: 1697a6f0443ca8896081f98bd8648bc7bdb2cc58

Requested commit: 1697a6f0443ca8896081f98bd8648bc7bdb2cc58

Commit: 1697a6f0443ca8896081f98bd8648bc7bdb2cc58

Tree: f0704b505b18292c2603271e256189a5075422dd

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
LLVM: rework calling convention lowering

The previous implementation of calling conventions was hacky and broken.
This commit reworks lowerFnParamTy into iterateParamTypes which returns
enum tags indicating how to handle each parameter. This is then used in
the three places that matter:
 * lowering a function type to llvm type
 * converting function parameters to the canonical type representation
   (with respect to isByRef).
 * converting canonical type representation to function arguments at
   callsites (again with respect to isByRef).

As a result, we are one step closer to the C ABI tests passing. Before
this commit, attempting to build them crashed the compiler. I isolated
the broken function and verified that it now is lowered correctly. I
will keep working on this one piece at a time until all the C ABI tests
pass, and then I will enable all of them in the CI.

```

## Parents

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

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