[all-commits] [llvm/llvm-project] 383733: [CIR] Always set base subobject type for C++ recor...

Bruno Cardoso Lopes via All-commits all-commits at lists.llvm.org
Tue Apr 28 17:55:57 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 383733ea8d15524517b0f1f15c8380c24f17407d
      https://github.com/llvm/llvm-project/commit/383733ea8d15524517b0f1f15c8380c24f17407d
  Author: Bruno Cardoso Lopes <bruno.cardoso at gmail.com>
  Date:   2026-04-28 (Tue, 28 Apr 2026)

  Changed paths:
    M clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp
    M clang/test/CIR/CodeGen/no-unique-address.cpp

  Log Message:
  -----------
  [CIR] Always set base subobject type for C++ records (#194504)

For unions and final C++ classes, computeRecordLayout previously left
the base-subobject type as a default-constructed (null) cir::RecordType.
The non-virtual size always equals the size for those kinds of records,
so no separate ".base" variant is needed, but `BaseSubobjectType` itself
was never set to the complete type either.

That null leaked through
getCIRGenRecordLayout(RD).getBaseSubobjectCIRType(), which is called by
getStorageType(const CXXRecordDecl *) when laying out a
[[no_unique_address]] / potentially-overlapping field. The null
mlir::Type was then stored as MemberInfo::data and tripped a
SmallVector::back() !empty() assertion in
CIRRecordLowering::fillOutputFields, because a member with null data is
interpreted as a bitfield placeholder and reads fieldTypes.back() that
was never pushed.

Match classic CodeGen (CGRecordLayoutBuilder.cpp) and unconditionally
set baseTy = *ty for any CXXRecordDecl, only constructing a separate
".base" record when nv-size != size (which excludes unions and final
classes by construction).

Reproducer:
```
  union U { int a; long b; };
  struct S {
    [[no_unique_address]] U u;
    int x;
  } s;
```

This comes from a crash on the libc++ test-suite (~1,500 tests affected,
all crashing inside CIRRecordLowering::lower while laying out
__compressed_pair_padding-style structs in <string>).



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