[all-commits] [llvm/llvm-project] 77eaa6: [CIR] Implement ArgKind::Expand in CallConvLowering

adams381 via All-commits all-commits at lists.llvm.org
Thu Jun 25 12:07:34 PDT 2026


  Branch: refs/heads/users/adams381/cir-callconv-lowering-expand
  Home:   https://github.com/llvm/llvm-project
  Commit: 77eaa68d3b4d2d53789699a363487a3b980b3afc
      https://github.com/llvm/llvm-project/commit/77eaa68d3b4d2d53789699a363487a3b980b3afc
  Author: Adam Smith <adams at nvidia.com>
  Date:   2026-06-25 (Thu, 25 Jun 2026)

  Changed paths:
    M clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRABIRewriteContext.cpp
    M clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRABIRewriteContext.h
    A clang/test/CIR/Transforms/abi-lowering/expand-struct-arg.cir

  Log Message:
  -----------
  [CIR] Implement ArgKind::Expand in CallConvLowering

Struct arguments classified Expand were rejected with an errorNYI in
CallConvLowering; the System V x86-64 ABI passes small structs by
flattening them into one scalar register argument per field, so the
classifier produced Expand but the rewriter could not honor it.

Lower Expand on both sides of the call.  buildNewArgTypes flattens the
struct wire type into one argument per member, and updateArgAttrs emits a
matching empty attribute dict per field.  In the callee, insertArgCoercion
splits the single struct block argument into N scalar field block
arguments and stores each field straight into the parameter's own alloca
(the CIRGen spill slot), erasing the original whole-struct store so no
scratch alloca or reload is introduced; a parameter whose spill slot was
already removed by DCE is only reshaped, with no field stores.  At the call
site,
rewriteCallSite decomposes the struct operand into its fields, reading each
member directly from the source alloca (get_member + load) when the operand
is a load of an alloca, and falling back to cir.extract_member on the value
otherwise; the now-dead whole-struct loads are erased once the original
call is gone.

Because an Expand argument occupies N block-argument slots rather than one,
insertArgCoercion and the Ignore-drop loop in rewriteFunctionDefinition now
walk a running block-argument index instead of computing the index from the
classification position directly.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list