[all-commits] [llvm/llvm-project] 45b3c4: [CIR] Split RecordType into StructType/UnionType
adams381 via All-commits
all-commits at lists.llvm.org
Mon Jun 1 16:46:08 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 45b3c4488fb59468fa5fb3637d5b9ecbd4f0c81e
https://github.com/llvm/llvm-project/commit/45b3c4488fb59468fa5fb3637d5b9ecbd4f0c81e
Author: adams381 <adams at nvidia.com>
Date: 2026-06-01 (Mon, 01 Jun 2026)
Changed paths:
M clang/include/clang/CIR/Dialect/IR/CIROps.td
M clang/include/clang/CIR/Dialect/IR/CIRTypes.h
M clang/include/clang/CIR/Dialect/IR/CIRTypes.td
M clang/include/clang/CIR/Dialect/IR/CIRTypesDetails.h
M clang/lib/CIR/CodeGen/CIRGenBuilder.h
M clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
M clang/lib/CIR/CodeGen/CIRGenExpr.cpp
M clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp
M clang/lib/CIR/Dialect/IR/CIRAttrs.cpp
M clang/lib/CIR/Dialect/IR/CIRDataLayout.cpp
M clang/lib/CIR/Dialect/IR/CIRDialect.cpp
M clang/lib/CIR/Dialect/IR/CIRTypes.cpp
M clang/lib/CIR/Dialect/Transforms/CXXABILowering.cpp
M clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp
M clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerItaniumCXXABI.cpp
M clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
M clang/test/CIR/CodeGen/bitfield-union.c
M clang/test/CIR/CodeGen/bitfields.c
M clang/test/CIR/CodeGen/bitfields.cpp
M clang/test/CIR/CodeGen/bitfields_be.c
M clang/test/CIR/CodeGen/class.cpp
M clang/test/CIR/CodeGen/cleanup.cpp
M clang/test/CIR/CodeGen/constant-inits.cpp
M clang/test/CIR/CodeGen/coro-task.cpp
M clang/test/CIR/CodeGen/ctor.cpp
M clang/test/CIR/CodeGen/cxx-abi-lowering-string-array.cpp
M clang/test/CIR/CodeGen/destructors.cpp
M clang/test/CIR/CodeGen/dumb-record.cpp
M clang/test/CIR/CodeGen/dynamic-cast.cpp
M clang/test/CIR/CodeGen/empty-union.c
M clang/test/CIR/CodeGen/empty-union.cpp
M clang/test/CIR/CodeGen/finegrain-bitfield-access.cpp
M clang/test/CIR/CodeGen/forward-decls.cpp
M clang/test/CIR/CodeGen/global-dtor-union-narrowed.cpp
M clang/test/CIR/CodeGen/inline-cxx-func.cpp
M clang/test/CIR/CodeGen/member-functions.cpp
M clang/test/CIR/CodeGen/mms-bitfields.c
M clang/test/CIR/CodeGen/multi-vtable.cpp
M clang/test/CIR/CodeGen/no-proto-fn-ptr-global-init.c
M clang/test/CIR/CodeGen/no-unique-address.cpp
M clang/test/CIR/CodeGen/nonzeroinit-struct.cpp
M clang/test/CIR/CodeGen/paren-list-agg-init.cpp
M clang/test/CIR/CodeGen/record-type-metadata.cpp
M clang/test/CIR/CodeGen/record-with-padded-union.cpp
M clang/test/CIR/CodeGen/record-zero-init-padding.c
M clang/test/CIR/CodeGen/struct.c
M clang/test/CIR/CodeGen/template-specialization.cpp
M clang/test/CIR/CodeGen/three-way-cmp.cpp
M clang/test/CIR/CodeGen/union.c
M clang/test/CIR/CodeGen/union.cpp
M clang/test/CIR/CodeGen/var_arg.c
M clang/test/CIR/CodeGen/variable-template-specialization.cpp
M clang/test/CIR/CodeGen/vbase.cpp
M clang/test/CIR/CodeGen/virtual-function-calls.cpp
M clang/test/CIR/CodeGen/vtable-emission.cpp
M clang/test/CIR/CodeGen/vtable-nyi-nonconvertible-functype.cpp
M clang/test/CIR/CodeGen/vtt.cpp
M clang/test/CIR/CodeGenBuiltins/X86/avx512vlvp2intersect-builtins.c
M clang/test/CIR/CodeGenBuiltins/X86/avx512vp2intersect-builtins.c
M clang/test/CIR/CodeGenBuiltins/X86/keylocker.c
M clang/test/CIR/CodeGenCXX/zero_init_bases.cpp
M clang/test/CIR/IR/array-ctor.cir
M clang/test/CIR/IR/array-dtor.cir
M clang/test/CIR/IR/bitfield_info.cir
M clang/test/CIR/IR/construct-catch-param.cir
M clang/test/CIR/IR/copy.cir
M clang/test/CIR/IR/dynamic-cast.cir
M clang/test/CIR/IR/func-attrs.cir
M clang/test/CIR/IR/func.cir
M clang/test/CIR/IR/global-init.cir
M clang/test/CIR/IR/invalid-array-structor.cir
M clang/test/CIR/IR/invalid-cast.cir
M clang/test/CIR/IR/invalid-const-record.cir
M clang/test/CIR/IR/invalid-construct-catch-param.cir
M clang/test/CIR/IR/invalid-data-member.cir
M clang/test/CIR/IR/invalid-delete-array.cir
M clang/test/CIR/IR/invalid-dyn-cast.cir
M clang/test/CIR/IR/invalid-struct.cir
M clang/test/CIR/IR/invalid-type-info.cir
M clang/test/CIR/IR/invalid-vtable.cir
M clang/test/CIR/IR/method-attr.cir
M clang/test/CIR/IR/struct.cir
M clang/test/CIR/IR/vtable-addrpt.cir
M clang/test/CIR/IR/vtable-attr.cir
M clang/test/CIR/IR/vtt-addrpoint.cir
M clang/test/CIR/Lowering/struct.cir
M clang/test/CIR/Lowering/vtt-addrpoint.cir
M clang/test/CIR/Transforms/canonicalize-cleanup-scope.cir
M clang/test/CIR/Transforms/cxx-abi-lowering-attrs.cir
M clang/test/CIR/Transforms/eh-abi-lowering-construct-catch-invalid.cir
M clang/test/CIR/Transforms/eh-abi-lowering-construct-catch.cir
M clang/test/CIR/Transforms/eh-abi-lowering-itanium.cir
M clang/test/CIR/Transforms/flatten-cleanup-scope-eh.cir
M clang/test/CIR/Transforms/flatten-cleanup-scope-multi-exit.cir
M clang/test/CIR/Transforms/flatten-cleanup-scope-simple.cir
M clang/test/CIR/Transforms/flatten-preserve-attrs.cir
M clang/test/CIR/Transforms/flatten-throwing-in-cleanup.cir
M clang/test/CIR/Transforms/flatten-try-op.cir
M clang/test/CIR/Transforms/pure-ptr-arithmetic.cir
M clang/unittests/CIR/PointerLikeTest.cpp
M clang/unittests/CIR/RecordTypeMetadataTest.cpp
M clang/unittests/CIR/UnionTypeSizeTest.cpp
Log Message:
-----------
[CIR] Split RecordType into StructType/UnionType
Union tail padding was stored as the last element of the `members` array
with a `padded = true` flag. Every pass touching `RecordType` had to
special-case unions: skip the last member when iterating, call
`getLargestMember()` to find the storage type, check `isUnion()` before
almost every layout query. This spread union-specific logic across
`CIRTypes.cpp`, `LowerToLLVM.cpp`, `CXXABILowering.cpp`,
`CIRGenRecordLayoutBuilder.cpp`, and `CIRGenExpr.cpp`.
This PR moves union tail padding to a dedicated `padding` field on
`RecordTypeStorage` and introduces two C++ view classes: `UnionType` and
`StructType`, both subclassing `RecordType` via `classof`-based
dispatch. `mlir::dyn_cast<UnionType>` and `mlir::isa<StructType>` work
naturally.
`UnionType` owns the union-specific API: `getPadding()` returns the
tail-padding type (null if none), and `getUnionStorageType(DataLayout)`
returns the highest-alignment variant. `RecordType::getLargestMember()`
and the old `RecordType::getPadding()` (which returned the last member)
are removed.
The CIR text syntax for padded unions changes from `union "Name" padded
{members..., padType}` to `union "Name" padded {members...}, padding =
{padType}`, separating padding from the member list.
`CIRGenRecordLayoutBuilder::appendPaddingBytes` now routes union tail
padding to a new `unionPadding` field instead of appending to
`fieldTypes`. `LowerToLLVM` and `CXXABILowering` use the new `UnionType`
API 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