[all-commits] [llvm/llvm-project] 9d4d0b: [CIR] Mark record members as data, pad, or empty i...

Adam Smith via All-commits all-commits at lists.llvm.org
Sun Aug 9 21:06:57 PDT 2026


  Branch: refs/heads/users/adams381/cir-record-member-kind-cirgen
  Home:   https://github.com/llvm/llvm-project
  Commit: 9d4d0bdd9345c55f676085121dff2062df610736
      https://github.com/llvm/llvm-project/commit/9d4d0bdd9345c55f676085121dff2062df610736
  Author: Adam Smith <adams at nvidia.com>
  Date:   2026-08-09 (Sun, 09 Aug 2026)

  Changed paths:
    M clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
    M clang/include/clang/CIR/Dialect/IR/CIROps.td
    M clang/lib/CIR/CodeGen/CIRGenBuilder.cpp
    M clang/lib/CIR/CodeGen/CIRGenBuilder.h
    M clang/lib/CIR/CodeGen/CIRGenRecordLayout.h
    M clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp
    M clang/lib/CIR/CodeGen/TargetInfo.cpp
    M clang/lib/CIR/CodeGen/TargetInfo.h
    M clang/lib/CIR/Dialect/Transforms/CXXABILowering.cpp
    M clang/test/CIR/CodeGen/bitfields.c
    M clang/test/CIR/CodeGen/cleanup.cpp
    M clang/test/CIR/CodeGen/dumb-record.cpp
    M clang/test/CIR/CodeGen/empty-union.cpp
    M clang/test/CIR/CodeGen/finegrain-bitfield-access.cpp
    M clang/test/CIR/CodeGen/member-functions.cpp
    M clang/test/CIR/CodeGen/no-unique-address.cpp
    M clang/test/CIR/CodeGen/paren-list-agg-init.cpp
    M clang/test/CIR/CodeGen/pointer-to-empty-data-member.cpp
    A clang/test/CIR/CodeGen/record-member-kinds-nyi.cpp
    A clang/test/CIR/CodeGen/record-member-kinds.c
    A clang/test/CIR/CodeGen/record-member-kinds.cpp
    M clang/test/CIR/CodeGen/record-type-metadata.cpp
    M clang/test/CIR/CodeGen/struct.c
    M clang/test/CIR/CodeGen/template-specialization.cpp
    M clang/test/CIR/CodeGen/vtt.cpp
    M clang/test/CIR/CodeGenCXX/zero_init_bases.cpp
    M clang/test/CIR/CodeGenCoroutines/coro-task.cpp

  Log Message:
  -----------
  [CIR] Mark record members as data, pad, or empty in CIRGen

The per-member marks landed with no producer, so every record still reads as
though all of its members held data.  A record type still can't say whether it
carries anything for argument passing.  The x86_64 classifier has to know that
before it can drop an empty class from a signature.

CIRGen fills the marks in now.  Every member goes through one `addField` that
takes its kind, so a new push site can't quietly inherit a default.

A field's mark comes from `isEmptyFieldForABI`, ported from `isEmptyField` in
`ABIInfoImpl.cpp`.  Taking the ABI predicate rather than the layout one is
what gets C right.  Given `struct E {}`, a struct holding one `E` is empty for
the ABI in C but not in C++.

An assert on every record checks the marks against `isEmptyRecordForABI`, so
the existing `-fclangir` tests exercise them.

One case is now NYI.  A `[[no_unique_address]]` field that
`isEmptyFieldForLayout` drops from the layout can still hold ABI data.  With
the field gone there is no member left to mark, so CIRGen says so rather than
emit a record that understates what it holds.

This is the second of three PRs.  Nothing reads the marks yet.  The `padded`
bool stays, and `computeStructDataSize` still uses it.  The next PR will
properly use the marks and remove `padded`.

Assisted-by: Cursor / claude-opus-5



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