llvm / clangir

A new (MLIR based) high-level IR for clang.
https://clangir.org
Other
365 stars 96 forks source link

ABI-aware calling conventions #417

Open bcardosolopes opened 9 months ago

bcardosolopes commented 9 months ago

Right now CIRGen mostly uses direct lowering (1 to 1 correspondence between C/C++ and IR), this is not how things are expected to work, since the LLVM emitted is not ABI compatible with what traditional LLVM codegen does, nor matches what ABI specs expect.

The current plan is to handle all ABI logic before we lower down to LLVM, these are the high level items needed in order to implement this:

  1. Add cir.call support for holding attributes for each param.
  2. In CIRGen, add ABI attributes that represent how these params need to be broken down in a later passes.
  3. Add a new pass or teach LoweringPrepare how to break the params based on each param attributes

(cc: @sitio-couto @sommerlukas)

smeenai commented 6 days ago

Can we close this out now given how much of ABI lowering has landed, or are there still TODO items here? If there's still things to do, it might be better to open specific issues for those instead.