[llvm-branch-commits] [clang] [CIR] Derive record padding from the member marks (PR #215176)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sun Aug 9 21:17:09 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-amdgpu
@llvm/pr-subscribers-clangir
Author: Adam Smith (adams381)
<details>
<summary>Changes</summary>
Now that every record member carries a kind, the record-level `padded` bool is redundant: a record is padded exactly when some member is marked pad. Drop the parameter and answer `getPadded()` from the marks.
That also fixes `computeStructDataSize`, which had read the bool as "the last member is tail padding" and so dropped a real member when padding sat between two data members. It now drops the trailing run of pad members instead.
Depends on [#<!-- -->215175](https://github.com/llvm/llvm-project/pull/215175).
Assisted-by: Cursor / claude-opus-5
---
Patch is 92.30 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/215176.diff
60 Files Affected:
- (modified) clang/include/clang/CIR/Dialect/IR/CIRAttrs.td (+2-2)
- (modified) clang/include/clang/CIR/Dialect/IR/CIROps.td (+4-4)
- (modified) clang/include/clang/CIR/Dialect/IR/CIRTypes.h (+3-1)
- (modified) clang/include/clang/CIR/Dialect/IR/CIRTypes.td (+11-13)
- (modified) clang/include/clang/CIR/Dialect/IR/CIRTypesDetails.h (+13-18)
- (modified) clang/lib/CIR/CodeGen/CIRGenAsm.cpp (+1-2)
- (modified) clang/lib/CIR/CodeGen/CIRGenBuilder.cpp (+1-26)
- (modified) clang/lib/CIR/CodeGen/CIRGenBuilder.h (+12-27)
- (modified) clang/lib/CIR/CodeGen/CIRGenBuiltinAMDGPU.cpp (+2-4)
- (modified) clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp (+4-5)
- (modified) clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp (-2)
- (modified) clang/lib/CIR/CodeGen/CIRGenModule.cpp (+1-2)
- (modified) clang/lib/CIR/CodeGen/CIRGenRecordLayout.h (+2-2)
- (modified) clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp (+6-12)
- (modified) clang/lib/CIR/CodeGen/CIRGenTypes.cpp (+1-2)
- (modified) clang/lib/CIR/CodeGen/CIRGenVTables.cpp (+1-1)
- (modified) clang/lib/CIR/Dialect/IR/CIRTypes.cpp (+44-48)
- (modified) clang/lib/CIR/Dialect/Transforms/CXXABILowering.cpp (+4-4)
- (modified) clang/lib/CIR/Dialect/Transforms/CallConvLoweringPass.cpp (+1-1)
- (modified) clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp (+3-3)
- (modified) clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerItaniumCXXABI.cpp (+1-2)
- (modified) clang/test/CIR/CodeGen/bitfields.c (+1-1)
- (modified) clang/test/CIR/CodeGen/cleanup.cpp (+1-1)
- (modified) clang/test/CIR/CodeGen/dumb-record.cpp (+2-2)
- (modified) clang/test/CIR/CodeGen/empty-union.cpp (+1-1)
- (modified) clang/test/CIR/CodeGen/finegrain-bitfield-access.cpp (+1-1)
- (modified) clang/test/CIR/CodeGen/member-functions.cpp (+1-1)
- (modified) clang/test/CIR/CodeGen/no-unique-address.cpp (+1-1)
- (modified) clang/test/CIR/CodeGen/paren-list-agg-init.cpp (+4-4)
- (modified) clang/test/CIR/CodeGen/pointer-to-empty-data-member.cpp (+3-3)
- (modified) clang/test/CIR/CodeGen/record-member-kinds.c (+1-1)
- (modified) clang/test/CIR/CodeGen/record-member-kinds.cpp (+7-7)
- (modified) clang/test/CIR/CodeGen/record-type-metadata.cpp (+2-2)
- (modified) clang/test/CIR/CodeGen/struct.c (+1-1)
- (modified) clang/test/CIR/CodeGen/template-specialization.cpp (+1-1)
- (modified) clang/test/CIR/CodeGen/vtt.cpp (+2-2)
- (modified) clang/test/CIR/CodeGenCXX/zero_init_bases.cpp (+1-1)
- (modified) clang/test/CIR/CodeGenCoroutines/coro-task.cpp (+9-9)
- (modified) clang/test/CIR/IR/array-ctor.cir (+1-1)
- (modified) clang/test/CIR/IR/array-dtor.cir (+1-1)
- (modified) clang/test/CIR/IR/construct-catch-param.cir (+1-1)
- (modified) clang/test/CIR/IR/func-attrs.cir (+1-1)
- (modified) clang/test/CIR/IR/global-init.cir (+3-3)
- (modified) clang/test/CIR/IR/invalid-array-structor.cir (+16-16)
- (modified) clang/test/CIR/IR/invalid-construct-catch-param.cir (+7-7)
- (modified) clang/test/CIR/IR/invalid-delete-array.cir (+1-1)
- (modified) clang/test/CIR/IR/invalid-loop-cleanup.cir (+4-4)
- (modified) clang/test/CIR/IR/loop-cleanup.cir (+1-1)
- (modified) clang/test/CIR/IR/struct.cir (+11-8)
- (added) clang/test/CIR/Lowering/copy-skip-tail-padding.cir (+136)
- (modified) clang/test/CIR/Transforms/abi-lowering/x86_64-aggregate-nyi.cir (+6-6)
- (modified) clang/test/CIR/Transforms/cxx-abi-lowering-attrs.cir (+1-1)
- (modified) clang/test/CIR/Transforms/eh-abi-lowering-construct-catch-invalid.cir (+3-3)
- (modified) clang/test/CIR/Transforms/eh-abi-lowering-construct-catch.cir (+1-1)
- (modified) clang/test/CIR/Transforms/flatten-cleanup-scope-eh.cir (+1-1)
- (modified) clang/test/CIR/Transforms/flatten-loop-cleanup.cir (+1-1)
- (modified) clang/test/CIR/Transforms/mem2reg.cir (+27)
- (modified) clang/unittests/CIR/PointerLikeTest.cpp (+3-3)
- (modified) clang/unittests/CIR/RecordMemberKindTest.cpp (+47-14)
- (modified) clang/unittests/CIR/RecordTypeMetadataTest.cpp (+1-1)
``````````diff
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index 9a726a3619ffc..e1c432fb2d382 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -1563,8 +1563,8 @@ def CIR_BitfieldInfoAttr : CIR_Attr<"BitfieldInfo", "bitfield_info"> {
The CIR representation of the struct `S` might look like:
```
- !rec_S = !cir.record<struct "S" packed padded {!u64i, !u16i,
- pad !cir.array<!u8i x 2>}>
+ !rec_S = !cir.struct<"S" packed {!u64i, !u16i,
+ pad !cir.array<!u8i x 2>}>
```
And the bitfield info attribute for member `a` would be:
```
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 513d765fff23d..9cc32b66fb245 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -3751,8 +3751,8 @@ def CIR_SetBitfieldOp : CIR_Op<"set_bitfield"> {
```
// 'e' is in the storage with the index 1
- !record_type = !cir.record<struct "S" packed padded {!u64i, !u16i,
- pad !cir.array<!u8i x 2>} #cir.record.decl.ast>
+ !record_type = !cir.struct<"S" packed {!u64i, !u16i,
+ pad !cir.array<!u8i x 2>}>
#bfi_e = #cir.bitfield_info<name = "e", storage_type = !u16i, size = 15,
offset = 0, is_signed = true>
@@ -3842,8 +3842,8 @@ def CIR_GetBitfieldOp : CIR_Op<"get_bitfield"> {
```
// 'e' is in the storage with the index 1
- !cir.record<struct "S" packed padded {!u64i, !u16i,
- pad !cir.array<!u8i x 2>}>
+ !cir.struct<"S" packed {!u64i, !u16i,
+ pad !cir.array<!u8i x 2>}>
#bfi_e = #cir.bitfield_info<name = "e", storage_type = !u16i, size = 15,
offset = 0, is_signed = true>
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.h b/clang/include/clang/CIR/Dialect/IR/CIRTypes.h
index f93e9ad24b349..ca2376fff43db 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.h
+++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.h
@@ -133,7 +133,9 @@ class RecordType : public mlir::Type {
std::string getKindAsStr() const;
std::string getPrefixedName() const;
- void complete(llvm::ArrayRef<mlir::Type> members, bool packed, bool padded,
+ /// \p padding is union-only. A struct carries its padding as a member
+ /// marked pad.
+ void complete(llvm::ArrayRef<mlir::Type> members, bool packed,
mlir::Type padding = {},
llvm::ArrayRef<RecordMemberKind> memberKinds = {});
uint64_t getElementOffset(const mlir::DataLayout &dataLayout,
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
index 365b96cd8e86f..412b5e953e6e3 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
@@ -700,7 +700,6 @@ def CIR_StructType : CIR_Type<"Struct", "struct", [
!rec_incomplete = !cir.struct<"incomplete" incomplete>
!anonymous = !cir.struct<{!u8i}>
!rec_packed = !cir.struct<"p1" packed {!u8i, !u8i}>
- !rec_padded = !cir.struct<"p2" padded {!u8i, !u8i}>
!rec_pad = !cir.struct<"p3" {!u8i, pad !cir.array<!u8i x 3>}>
!rec_empty = !cir.struct<"e" {empty !u8i}>
!recursive = !cir.struct<"Node" {!cir.ptr<!cir.struct<"Node">>}>
@@ -712,7 +711,6 @@ def CIR_StructType : CIR_Type<"Struct", "struct", [
OptionalParameter<"mlir::StringAttr">:$name,
"bool":$incomplete,
"bool":$packed,
- "bool":$padded,
OptionalArrayRefParameter<"cir::RecordMemberKind">:$member_kinds,
"bool":$is_class
);
@@ -730,11 +728,10 @@ def CIR_StructType : CIR_Type<"Struct", "struct", [
"llvm::ArrayRef<mlir::Type>":$members,
"mlir::StringAttr":$name,
"bool":$packed,
- "bool":$padded,
"bool":$is_class,
CArg<"llvm::ArrayRef<cir::RecordMemberKind>", "{}">:$member_kinds
), [{
- return $_get($_ctxt, members, name, /*incomplete=*/false, packed, padded,
+ return $_get($_ctxt, members, name, /*incomplete=*/false, packed,
cir::normalizeRecordMemberKinds(member_kinds), is_class);
}]>,
@@ -744,7 +741,7 @@ def CIR_StructType : CIR_Type<"Struct", "struct", [
"bool":$is_class
), [{
return $_get($_ctxt, /*members=*/llvm::ArrayRef<mlir::Type>{}, name,
- /*incomplete=*/true, /*packed=*/false, /*padded=*/false,
+ /*incomplete=*/true, /*packed=*/false,
/*member_kinds=*/llvm::ArrayRef<cir::RecordMemberKind>{},
is_class);
}]>,
@@ -753,13 +750,12 @@ def CIR_StructType : CIR_Type<"Struct", "struct", [
TypeBuilder<(ins
"llvm::ArrayRef<mlir::Type>":$members,
"bool":$packed,
- "bool":$padded,
"bool":$is_class,
CArg<"llvm::ArrayRef<cir::RecordMemberKind>", "{}">:$member_kinds
), [{
return $_get($_ctxt, members, mlir::StringAttr{}, /*incomplete=*/false,
- packed, padded,
- cir::normalizeRecordMemberKinds(member_kinds), is_class);
+ packed, cir::normalizeRecordMemberKinds(member_kinds),
+ is_class);
}]>
];
@@ -783,9 +779,11 @@ def CIR_StructType : CIR_Type<"Struct", "struct", [
}
void complete(llvm::ArrayRef<mlir::Type> members, bool packed,
- bool isPadded,
llvm::ArrayRef<cir::RecordMemberKind> memberKinds = {});
+ /// Whether any member is marked pad.
+ bool getPadded() const;
+
uint64_t getElementOffset(const mlir::DataLayout &dataLayout,
unsigned idx) const;
@@ -809,7 +807,9 @@ def CIR_StructType : CIR_Type<"Struct", "struct", [
bool isSized() const { return isComplete(); }
- /// Returns the data size (excluding tail padding) for this struct type.
+ /// Returns the data size for this struct type. Tail padding is the
+ /// trailing run of pad members, so interior padding and a trailing empty
+ /// member stay inside the data size.
unsigned computeStructDataSize(const mlir::DataLayout &dataLayout) const;
private:
@@ -918,9 +918,7 @@ def CIR_UnionType : CIR_Type<"Union", "union", [
bool isComplete() const { return !isIncomplete(); }
bool isIncomplete() const;
- /// Returns true when this union carries a tail-padding type.
- /// Derived from getPadding(): a union is padded iff it has a non-null
- /// padding type.
+ /// Whether this union carries a tail-padding type.
bool getPadded() const;
size_t getNumElements() const { return getMembers().size(); }
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypesDetails.h b/clang/include/clang/CIR/Dialect/IR/CIRTypesDetails.h
index 123fa059cfeac..6357a4270821c 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRTypesDetails.h
+++ b/clang/include/clang/CIR/Dialect/IR/CIRTypesDetails.h
@@ -32,68 +32,64 @@ struct StructTypeStorage : public mlir::TypeStorage {
mlir::StringAttr name;
bool incomplete;
bool packed;
- bool padded;
llvm::ArrayRef<RecordMemberKind> member_kinds;
bool is_class;
KeyTy(llvm::ArrayRef<mlir::Type> members, mlir::StringAttr name,
- bool incomplete, bool packed, bool padded,
+ bool incomplete, bool packed,
llvm::ArrayRef<RecordMemberKind> member_kinds, bool is_class)
: members(members), name(name), incomplete(incomplete), packed(packed),
- padded(padded), member_kinds(member_kinds), is_class(is_class) {}
+ member_kinds(member_kinds), is_class(is_class) {}
};
llvm::ArrayRef<mlir::Type> members;
mlir::StringAttr name;
bool incomplete;
bool packed;
- bool padded;
llvm::ArrayRef<RecordMemberKind> member_kinds;
bool is_class;
StructTypeStorage(llvm::ArrayRef<mlir::Type> members, mlir::StringAttr name,
- bool incomplete, bool packed, bool padded,
+ bool incomplete, bool packed,
llvm::ArrayRef<RecordMemberKind> member_kinds,
bool is_class)
: members(members), name(name), incomplete(incomplete), packed(packed),
- padded(padded), member_kinds(member_kinds), is_class(is_class) {
+ member_kinds(member_kinds), is_class(is_class) {
assert((name || !incomplete) && "Incomplete records must have a name");
assert((member_kinds.empty() || member_kinds.size() == members.size()) &&
"member kind list must cover every member");
}
KeyTy getAsKey() const {
- return KeyTy(members, name, incomplete, packed, padded, member_kinds,
- is_class);
+ return KeyTy(members, name, incomplete, packed, member_kinds, is_class);
}
bool operator==(const KeyTy &key) const {
if (name)
return (name == key.name) && (is_class == key.is_class);
- return std::tie(members, name, incomplete, packed, padded, member_kinds,
+ return std::tie(members, name, incomplete, packed, member_kinds,
is_class) == std::tie(key.members, key.name, key.incomplete,
- key.packed, key.padded,
- key.member_kinds, key.is_class);
+ key.packed, key.member_kinds,
+ key.is_class);
}
static llvm::hash_code hashKey(const KeyTy &key) {
if (key.name)
return llvm::hash_combine(key.name, key.is_class);
return llvm::hash_combine(key.members, key.incomplete, key.packed,
- key.padded, key.member_kinds, key.is_class);
+ key.member_kinds, key.is_class);
}
static StructTypeStorage *construct(mlir::TypeStorageAllocator &allocator,
const KeyTy &key) {
return new (allocator.allocate<StructTypeStorage>()) StructTypeStorage(
allocator.copyInto(key.members), key.name, key.incomplete, key.packed,
- key.padded, allocator.copyInto(key.member_kinds), key.is_class);
+ allocator.copyInto(key.member_kinds), key.is_class);
}
/// Mutates the members and attributes of an identified struct/class.
llvm::LogicalResult mutate(mlir::TypeStorageAllocator &allocator,
llvm::ArrayRef<mlir::Type> members, bool packed,
- bool padded,
llvm::ArrayRef<RecordMemberKind> memberKinds) {
if (!name)
return llvm::failure();
@@ -102,9 +98,9 @@ struct StructTypeStorage : public mlir::TypeStorage {
// including the marks: otherwise it silently keeps the marks it was given
// the first time.
if (!incomplete)
- return mlir::success(
- (this->members == members) && (this->packed == packed) &&
- (this->padded == padded) && (this->member_kinds == memberKinds));
+ return mlir::success((this->members == members) &&
+ (this->packed == packed) &&
+ (this->member_kinds == memberKinds));
// mutate is the one entrance verify() never sees, so check the length here
// rather than leave it to an assert.
@@ -113,7 +109,6 @@ struct StructTypeStorage : public mlir::TypeStorage {
this->members = allocator.copyInto(members);
this->packed = packed;
- this->padded = padded;
this->member_kinds = allocator.copyInto(memberKinds);
incomplete = false;
return llvm::success();
diff --git a/clang/lib/CIR/CodeGen/CIRGenAsm.cpp b/clang/lib/CIR/CodeGen/CIRGenAsm.cpp
index 26f9f5935c2b4..79deede56e424 100644
--- a/clang/lib/CIR/CodeGen/CIRGenAsm.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenAsm.cpp
@@ -537,8 +537,7 @@ mlir::LogicalResult CIRGenFunction::emitAsmStmt(const AsmStmt &s) {
if (resultRegTypes.size() == 1)
resultType = resultRegTypes[0];
else if (resultRegTypes.size() > 1)
- resultType = builder.getAnonRecordTy(resultRegTypes, /*packed=*/false,
- /*padded=*/false);
+ resultType = builder.getAnonRecordTy(resultRegTypes, /*packed=*/false);
bool hasSideEffect = s.isVolatile() || s.getNumOutputs() == 0;
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp b/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp
index d339c35fbffa0..eac10f47bbbae 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp
@@ -195,33 +195,8 @@ uint64_t CIRGenBuilderTy::computeOffsetFromGlobalViewIndices(
return offset;
}
-cir::RecordType clang::CIRGen::CIRGenBuilderTy::getCompleteRecordType(
- mlir::ArrayAttr fields, bool packed, bool padded, llvm::StringRef name) {
- assert(!cir::MissingFeatures::astRecordDeclAttr());
- llvm::SmallVector<mlir::Type> members;
- members.reserve(fields.size());
- llvm::transform(fields, std::back_inserter(members),
- [](mlir::Attribute attr) {
- return mlir::cast<mlir::TypedAttr>(attr).getType();
- });
-
- if (name.empty())
- return getAnonRecordTy(members, packed, padded);
-
- return getCompleteNamedRecordType(members, packed, padded, name,
- /*memberKinds=*/{});
-}
-
mlir::Attribute clang::CIRGen::CIRGenBuilderTy::getConstRecordOrZeroAttr(
- mlir::ArrayAttr arrayAttr, bool packed, bool padded, mlir::Type type) {
- auto recordTy = mlir::cast_or_null<cir::RecordType>(type);
-
- // Record type not specified: create anon record type from members.
- if (!recordTy) {
- recordTy = getCompleteRecordType(arrayAttr, packed, padded);
- }
-
- // Return zero or anonymous constant record.
+ mlir::ArrayAttr arrayAttr, cir::RecordType recordTy) {
const bool isZero = llvm::all_of(
arrayAttr, [&](mlir::Attribute a) { return isNullValue(a); });
if (isZero)
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.h b/clang/lib/CIR/CodeGen/CIRGenBuilder.h
index f414f67c76fbe..b241b4f029dc6 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuilder.h
+++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.h
@@ -79,25 +79,16 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
}
mlir::Attribute getConstRecordOrZeroAttr(mlir::ArrayAttr arrayAttr,
- bool packed = false,
- bool padded = false,
- mlir::Type type = {});
-
- cir::ConstRecordAttr getAnonConstRecord(mlir::ArrayAttr arrayAttr,
- bool packed = false,
- bool padded = false,
- mlir::Type ty = {}) {
- llvm::SmallVector<mlir::Type, 4> members;
+ cir::RecordType recordTy);
+
+ cir::ConstRecordAttr getAnonConstRecord(mlir::ArrayAttr arrayAttr) {
+ llvm::SmallVector<mlir::Type> members;
for (auto &f : arrayAttr) {
auto ta = mlir::cast<mlir::TypedAttr>(f);
members.push_back(ta.getType());
}
- if (!ty)
- ty = getAnonRecordTy(members, packed, padded);
-
- auto sTy = mlir::cast<cir::RecordType>(ty);
- return cir::ConstRecordAttr::get(sTy, arrayAttr);
+ return cir::ConstRecordAttr::get(getAnonRecordTy(members), arrayAttr);
}
cir::TypeInfoAttr getTypeInfo(mlir::ArrayAttr fieldsAttr) {
@@ -155,26 +146,20 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
/// If a record already exists and is complete, but the client tries to fetch
/// it with a different set of attributes, this method will crash.
cir::RecordType getCompleteNamedRecordType(
- llvm::ArrayRef<mlir::Type> members, bool packed, bool padded,
- llvm::StringRef name, llvm::ArrayRef<cir::RecordMemberKind> memberKinds) {
+ llvm::ArrayRef<mlir::Type> members, bool packed, llvm::StringRef name,
+ llvm::ArrayRef<cir::RecordMemberKind> memberKinds) {
const auto nameAttr = getStringAttr(name);
assert(!cir::MissingFeatures::astRecordDeclAttr());
- // Create or get the struct type (named anonymous struct helper — always
- // struct, never class or union at this call site).
+ // Always a struct at this call site, never a class or a union.
auto type = cir::StructType::get(getContext(), members, nameAttr, packed,
- padded, /*is_class=*/false, memberKinds);
+ /*is_class=*/false, memberKinds);
- type.complete(members, packed, padded, memberKinds);
+ type.complete(members, packed, memberKinds);
return type;
}
- cir::RecordType getCompleteRecordType(mlir::ArrayAttr fields,
- bool packed = false,
- bool padded = false,
- llvm::StringRef name = "");
-
/// Get an incomplete CIR record type. If we have a complete record
/// declaration, we may create an incomplete type and then add the
/// members, so \p rd here may be complete.
@@ -396,9 +381,9 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
/// Get a CIR anonymous struct type.
cir::StructType getAnonRecordTy(llvm::ArrayRef<mlir::Type> members,
- bool packed = false, bool padded = false) {
+ bool packed = false) {
assert(!cir::MissingFeatures::astRecordDeclAttr());
- return cir::StructType::get(getContext(), members, packed, padded,
+ return cir::StructType::get(getContext(), members, packed,
/*is_class=*/false);
}
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinAMDGPU.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinAMDGPU.cpp
index e2a1c2b94dec4..fd38b35bdb726 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltinAMDGPU.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinAMDGPU.cpp
@@ -76,8 +76,7 @@ static mlir::Value emitLogbBuiltin(CIRGenFunction &cgf, const CallExpr *e,
mlir::Type srcTy = src0.getType();
mlir::Type int32Ty = builder.getSInt32Ty();
- cir::RecordType frExpResTy =
- builder.getAnonRecordTy({srcTy, int32Ty}, false, false);
+ cir::RecordType frExpResTy = builder.getAnonRecordTy({srcTy, int32Ty});
mlir::Value frExpResult = builder.emitIntrinsicCallOp(
loc, "frexp", frExpResTy, mlir::ValueRange{src0});
@@ -174,8 +173,7 @@ CIRGenFunction::emitAMDGPUBuiltinExpr(unsigned builtinId,
mlir::Value z = emitScalarExpr(expr->getArg(2));
auto i1Ty = builder.getUIntNTy(1);
- cir::RecordType resTy = builder.getAnonRecordTy(
- {x.getType(), i1Ty}, /*packed=*/false, /*padded=*/false);
+ cir::RecordType resTy = builder.getAnonRecordTy({x.getType(), i1Ty});
mlir::Value structResult =
cir::LLVMIntrinsicCallOp::create(builder, getLoc(expr->getExprLoc()),
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
index 9228367fdd44f..a4b5651878836 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
@@ -209,7 +209,7 @@ emitEncodeKey(mlir::MLIRContext *context, CIRGenBuilderTy &builder,
llvm::append_range(members,
llvm::SmallVector<mlir::Type>(vecOutputCount, resVector));
cir::StructType resRecord = cir::StructType::get(
- context, members, /*packed=*/false, /*padded=*/false, /*is_class=*/false);
+ context, members, /*packed=*/false, /*is_class=*/false);
mlir::Value outputPtr =
builder.createBitcast(outputOperand, cir::PointerType::get(resVector));
@@ -927,7 +927,7 @@ cir::GetGlobalOp CIRGenFunction::createGetCpuModel(mlir::Location loc) {
// unsigned int __cpu_subtype;
// unsigned int __cpu_features[1];
mlir::Type tys[] = {u32, u32, u32, cir::ArrayType::get(u32, 1)};
- mlir::Type modelTy = builder.getAnonRecordTy(tys, /*incomplete=*/false);
+ mlir::Type modelTy = builder.getAnonRecordTy(tys, /*packed=*/false);
cpuModel =
cgm.createGlobalOp(loc, "__cpu_model", modelTy, /*isConstant=*/false);
cpuModel.setDsoLocal(...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/215176
More information about the llvm-branch-commits
mailing list