Skip to content

Commit e0cb32e

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:98119718603c6e623b34e3d2160b65b26d9bfcdc into amd-gfx:a22f3eb12095
Local branch amd-gfx a22f3eb Merged main:6de04e6fe8b1520ef3e4073ff222e623b7dc9cb9 into amd-gfx:697d8fbeaade Remote branch main 9811971 [GitHub] Run format job on stacked PRs (llvm#102957)
2 parents a22f3eb + 9811971 commit e0cb32e

File tree

8 files changed

+57
-61
lines changed

8 files changed

+57
-61
lines changed

.github/workflows/pr-code-format.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
pull_request:
88
branches:
99
- main
10+
- 'users/**'
1011

1112
jobs:
1213
code_formatter:

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 508409
19+
#define LLVM_MAIN_REVISION 508411
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/include/llvm/IR/DataLayout.h

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ enum AlignTypeEnum {
6565
/// Layout alignment element.
6666
///
6767
/// Stores the alignment data associated with a given type bit width.
68-
///
69-
/// \note The unusual order of elements in the structure attempts to reduce
70-
/// padding and make the structure slightly more cache friendly.
7168
struct LayoutAlignElem {
7269
uint32_t TypeBitWidth;
7370
Align ABIAlign;
@@ -82,14 +79,11 @@ struct LayoutAlignElem {
8279
/// Layout pointer alignment element.
8380
///
8481
/// Stores the alignment data associated with a given pointer and address space.
85-
///
86-
/// \note The unusual order of elements in the structure attempts to reduce
87-
/// padding and make the structure slightly more cache friendly.
8882
struct PointerAlignElem {
83+
uint32_t AddressSpace;
84+
uint32_t TypeBitWidth;
8985
Align ABIAlign;
9086
Align PrefAlign;
91-
uint32_t TypeBitWidth;
92-
uint32_t AddressSpace;
9387
uint32_t IndexBitWidth;
9488

9589
/// Initializer
@@ -115,16 +109,16 @@ class DataLayout {
115109
MultipleOfFunctionAlign,
116110
};
117111
private:
118-
/// Defaults to false.
119-
bool BigEndian;
112+
bool BigEndian = false;
120113

121-
unsigned AllocaAddrSpace;
122-
unsigned ProgramAddrSpace;
123-
unsigned DefaultGlobalsAddrSpace;
114+
unsigned AllocaAddrSpace = 0;
115+
unsigned ProgramAddrSpace = 0;
116+
unsigned DefaultGlobalsAddrSpace = 0;
124117

125118
MaybeAlign StackNaturalAlign;
126119
MaybeAlign FunctionPtrAlign;
127-
FunctionPtrAlignType TheFunctionPtrAlignType;
120+
FunctionPtrAlignType TheFunctionPtrAlignType =
121+
FunctionPtrAlignType::Independent;
128122

129123
enum ManglingModeT {
130124
MM_None,
@@ -136,24 +130,22 @@ class DataLayout {
136130
MM_Mips,
137131
MM_XCOFF
138132
};
139-
ManglingModeT ManglingMode;
133+
ManglingModeT ManglingMode = MM_None;
140134

141135
// FIXME: `unsigned char` truncates the value parsed by `parseSpecifier`.
142136
SmallVector<unsigned char, 8> LegalIntWidths;
143137

144-
/// Primitive type alignment data. This is sorted by type and bit
145-
/// width during construction.
146-
using AlignmentsTy = SmallVector<LayoutAlignElem, 4>;
147-
AlignmentsTy IntAlignments;
148-
AlignmentsTy FloatAlignments;
149-
AlignmentsTy VectorAlignments;
138+
// Primitive type specifications. Sorted and uniqued by type bit width.
139+
SmallVector<LayoutAlignElem, 6> IntAlignments;
140+
SmallVector<LayoutAlignElem, 4> FloatAlignments;
141+
SmallVector<LayoutAlignElem, 10> VectorAlignments;
142+
143+
// Pointer type specifications. Sorted and uniqued by address space number.
144+
SmallVector<PointerAlignElem, 8> Pointers;
150145

151146
/// The string representation used to create this DataLayout
152147
std::string StringRepresentation;
153148

154-
using PointersTy = SmallVector<PointerAlignElem, 8>;
155-
PointersTy Pointers;
156-
157149
const PointerAlignElem &getPointerAlignElem(uint32_t AddressSpace) const;
158150

159151
// Struct type ABI and preferred alignments. The default spec is "a:8:64".
@@ -189,6 +181,9 @@ class DataLayout {
189181
Error parseSpecifier(StringRef Desc);
190182

191183
public:
184+
/// Constructs a DataLayout with default values.
185+
DataLayout();
186+
192187
/// Constructs a DataLayout from a specification string.
193188
/// WARNING: Aborts execution if the string is malformed. Use parse() instead.
194189
explicit DataLayout(StringRef LayoutString);

llvm/lib/IR/DataLayout.cpp

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -198,37 +198,38 @@ const char *DataLayout::getManglingComponent(const Triple &T) {
198198
return "-m:e";
199199
}
200200

201-
static const std::pair<AlignTypeEnum, LayoutAlignElem> DefaultAlignments[] = {
202-
{INTEGER_ALIGN, {1, Align(1), Align(1)}}, // i1
203-
{INTEGER_ALIGN, {8, Align(1), Align(1)}}, // i8
204-
{INTEGER_ALIGN, {16, Align(2), Align(2)}}, // i16
205-
{INTEGER_ALIGN, {32, Align(4), Align(4)}}, // i32
206-
{INTEGER_ALIGN, {64, Align(4), Align(8)}}, // i64
207-
{FLOAT_ALIGN, {16, Align(2), Align(2)}}, // half, bfloat
208-
{FLOAT_ALIGN, {32, Align(4), Align(4)}}, // float
209-
{FLOAT_ALIGN, {64, Align(8), Align(8)}}, // double
210-
{FLOAT_ALIGN, {128, Align(16), Align(16)}}, // ppcf128, quad, ...
211-
{VECTOR_ALIGN, {64, Align(8), Align(8)}}, // v2i32, v1i64, ...
212-
{VECTOR_ALIGN, {128, Align(16), Align(16)}}, // v16i8, v8i16, v4i32, ...
201+
// Default primitive type specifications.
202+
// NOTE: These arrays must be sorted by type bit width.
203+
constexpr LayoutAlignElem DefaultIntSpecs[] = {
204+
{1, Align::Constant<1>(), Align::Constant<1>()}, // i1:8:8
205+
{8, Align::Constant<1>(), Align::Constant<1>()}, // i8:8:8
206+
{16, Align::Constant<2>(), Align::Constant<2>()}, // i16:16:16
207+
{32, Align::Constant<4>(), Align::Constant<4>()}, // i32:32:32
208+
{64, Align::Constant<4>(), Align::Constant<8>()}, // i64:32:64
209+
};
210+
constexpr LayoutAlignElem DefaultFloatSpecs[] = {
211+
{16, Align::Constant<2>(), Align::Constant<2>()}, // f16:16:16
212+
{32, Align::Constant<4>(), Align::Constant<4>()}, // f32:32:32
213+
{64, Align::Constant<8>(), Align::Constant<8>()}, // f64:64:64
214+
{128, Align::Constant<16>(), Align::Constant<16>()}, // f128:128:128
215+
};
216+
constexpr LayoutAlignElem DefaultVectorSpecs[] = {
217+
{64, Align::Constant<8>(), Align::Constant<8>()}, // v64:64:64
218+
{128, Align::Constant<16>(), Align::Constant<16>()}, // v128:128:128
213219
};
214220

215-
DataLayout::DataLayout(StringRef LayoutString) {
216-
BigEndian = false;
217-
AllocaAddrSpace = 0;
218-
ProgramAddrSpace = 0;
219-
DefaultGlobalsAddrSpace = 0;
220-
TheFunctionPtrAlignType = FunctionPtrAlignType::Independent;
221-
ManglingMode = MM_None;
222-
223-
// Default alignments
224-
for (const auto &[Kind, Layout] : DefaultAlignments) {
225-
if (Error Err = setAlignment(Kind, Layout.ABIAlign, Layout.PrefAlign,
226-
Layout.TypeBitWidth))
227-
report_fatal_error(std::move(Err));
228-
}
229-
if (Error Err = setPointerAlignmentInBits(0, Align(8), Align(8), 64, 64))
230-
report_fatal_error(std::move(Err));
221+
// Default pointer type specifications.
222+
constexpr PointerAlignElem DefaultPointerSpecs[] = {
223+
{0, 64, Align::Constant<8>(), Align::Constant<8>(), 64} // p0:64:64:64:64
224+
};
225+
226+
DataLayout::DataLayout()
227+
: IntAlignments(ArrayRef(DefaultIntSpecs)),
228+
FloatAlignments(ArrayRef(DefaultFloatSpecs)),
229+
VectorAlignments(ArrayRef(DefaultVectorSpecs)),
230+
Pointers(ArrayRef(DefaultPointerSpecs)) {}
231231

232+
DataLayout::DataLayout(StringRef LayoutString) : DataLayout() {
232233
if (Error Err = parseSpecifier(LayoutString))
233234
report_fatal_error(std::move(Err));
234235
}
@@ -277,7 +278,7 @@ bool DataLayout::operator==(const DataLayout &Other) const {
277278
}
278279

279280
Expected<DataLayout> DataLayout::parse(StringRef LayoutDescription) {
280-
DataLayout Layout("");
281+
DataLayout Layout;
281282
if (Error Err = Layout.parseSpecifier(LayoutDescription))
282283
return std::move(Err);
283284
return Layout;

llvm/lib/IR/Module.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ template class llvm::SymbolTableListTraits<GlobalIFunc>;
7373

7474
Module::Module(StringRef MID, LLVMContext &C)
7575
: Context(C), ValSymTab(std::make_unique<ValueSymbolTable>(-1)),
76-
ModuleID(std::string(MID)), SourceFileName(std::string(MID)), DL(""),
76+
ModuleID(std::string(MID)), SourceFileName(std::string(MID)),
7777
IsNewDbgInfoFormat(UseNewDbgInfoFormat) {
7878
Context.addModule(this);
7979
}

llvm/unittests/Analysis/ValueLatticeTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace {
2222
class ValueLatticeTest : public testing::Test {
2323
protected:
2424
LLVMContext Context;
25-
DataLayout DL = DataLayout("");
25+
DataLayout DL;
2626
};
2727

2828
TEST_F(ValueLatticeTest, ValueLatticeGetters) {

llvm/unittests/CodeGen/LowLevelTypeTest.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ namespace {
2020

2121
TEST(LowLevelTypeTest, Token) {
2222
LLVMContext C;
23-
DataLayout DL("");
2423

2524
const LLT TTy = LLT::token();
2625

@@ -38,7 +37,7 @@ TEST(LowLevelTypeTest, Token) {
3837

3938
TEST(LowLevelTypeTest, Scalar) {
4039
LLVMContext C;
41-
DataLayout DL("");
40+
DataLayout DL;
4241

4342
for (unsigned S : {0U, 1U, 17U, 32U, 64U, 0xfffffU}) {
4443
const LLT Ty = LLT::scalar(S);
@@ -70,7 +69,7 @@ TEST(LowLevelTypeTest, Scalar) {
7069

7170
TEST(LowLevelTypeTest, Vector) {
7271
LLVMContext C;
73-
DataLayout DL("");
72+
DataLayout DL;
7473

7574
for (unsigned S : {0U, 1U, 17U, 32U, 64U, 0xfffU}) {
7675
for (auto EC :

llvm/unittests/IR/VectorTypesTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ TEST(VectorTypesTest, BaseVectorType) {
276276

277277
TEST(VectorTypesTest, FixedLenComparisons) {
278278
LLVMContext Ctx;
279-
DataLayout DL("");
279+
DataLayout DL;
280280

281281
Type *Int32Ty = Type::getInt32Ty(Ctx);
282282
Type *Int64Ty = Type::getInt64Ty(Ctx);
@@ -322,7 +322,7 @@ TEST(VectorTypesTest, FixedLenComparisons) {
322322

323323
TEST(VectorTypesTest, ScalableComparisons) {
324324
LLVMContext Ctx;
325-
DataLayout DL("");
325+
DataLayout DL;
326326

327327
Type *Int32Ty = Type::getInt32Ty(Ctx);
328328
Type *Int64Ty = Type::getInt64Ty(Ctx);

0 commit comments

Comments
 (0)