[all-commits] [llvm/llvm-project] b8d049: [CIR] Accept a union covered only by a bit-field's...

Adam Smith via All-commits all-commits at lists.llvm.org
Tue Sep 8 12:11:14 PDT 2026


  Branch: refs/heads/users/adams381/cir-union-bitfield-declared-extent
  Home:   https://github.com/llvm/llvm-project
  Commit: b8d0491dc437bd4a4d16f0287b8d358e0293cebc
      https://github.com/llvm/llvm-project/commit/b8d0491dc437bd4a4d16f0287b8d358e0293cebc
  Author: Adam Smith <adams at nvidia.com>
  Date:   2026-09-08 (Tue, 08 Sep 2026)

  Changed paths:
    M clang/include/clang/CIR/Dialect/IR/CIRTypes.td
    M clang/lib/CIR/Dialect/IR/CIRTypes.cpp
    M clang/lib/CIR/Dialect/Transforms/CallConvLoweringPass.cpp
    A clang/test/CIR/CodeGen/call-conv-lowering-x86_64-union-bitfield.c
    A clang/test/CIR/CodeGen/call-conv-lowering-x86_64-union-bitfield.cpp
    M clang/test/CIR/Transforms/abi-lowering/x86_64-aggregate-nyi.cir
    M clang/test/CIR/Transforms/abi-lowering/x86_64-union.cir

  Log Message:
  -----------
  [CIR] Accept a union covered only by a bit-field's declared type

The size of a union is calculated by its largest member.  When that
member is a bit-field, the unit storing it can be narrower than the type
it was declared with, and it is the declared type that accounts for the
union's bytes.  BitFieldType gains a query for that declared type, and
the x86_64 union rule reads it rather than the stored size, so
`union { int x : 3; }` and `union { int x : 3; char c; }` now both pass
as i32.

A union larger than one eightbyte still needs a member covering it
outright, since the coerce basis skips the entry carrying the
declaration.

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