@@ -117,6 +117,27 @@ unsigned StructLayout::getElementContainingOffset(uint64_t FixedOffset) const {
117
117
return SI - MemberOffsets.begin ();
118
118
}
119
119
120
+ namespace {
121
+
122
+ class StructLayoutMap {
123
+ using LayoutInfoTy = DenseMap<StructType *, StructLayout *>;
124
+ LayoutInfoTy LayoutInfo;
125
+
126
+ public:
127
+ ~StructLayoutMap () {
128
+ // Remove any layouts.
129
+ for (const auto &I : LayoutInfo) {
130
+ StructLayout *Value = I.second ;
131
+ Value->~StructLayout ();
132
+ free (Value);
133
+ }
134
+ }
135
+
136
+ StructLayout *&operator [](StructType *STy) { return LayoutInfo[STy]; }
137
+ };
138
+
139
+ } // end anonymous namespace
140
+
120
141
// ===----------------------------------------------------------------------===//
121
142
// LayoutAlignElem, LayoutAlign support
122
143
// ===----------------------------------------------------------------------===//
@@ -191,36 +212,31 @@ static const std::pair<AlignTypeEnum, LayoutAlignElem> DefaultAlignments[] = {
191
212
{VECTOR_ALIGN, {128 , Align (16 ), Align (16 )}}, // v16i8, v8i16, v4i32, ...
192
213
};
193
214
194
- void DataLayout::reset (StringRef Desc) {
195
- clear ();
196
-
197
- LayoutMap = nullptr ;
215
+ DataLayout::DataLayout (StringRef LayoutString) {
198
216
BigEndian = false ;
199
217
AllocaAddrSpace = 0 ;
200
- StackNaturalAlign.reset ();
201
218
ProgramAddrSpace = 0 ;
202
219
DefaultGlobalsAddrSpace = 0 ;
203
- FunctionPtrAlign.reset ();
204
220
TheFunctionPtrAlignType = FunctionPtrAlignType::Independent;
205
221
ManglingMode = MM_None;
206
- NonIntegralAddressSpaces.clear ();
207
222
StructAlignment = LayoutAlignElem::get (Align (1 ), Align (8 ), 0 );
208
223
209
224
// Default alignments
210
225
for (const auto &[Kind, Layout] : DefaultAlignments) {
211
226
if (Error Err = setAlignment (Kind, Layout.ABIAlign , Layout.PrefAlign ,
212
227
Layout.TypeBitWidth ))
213
- return report_fatal_error (std::move (Err));
228
+ report_fatal_error (std::move (Err));
214
229
}
215
230
if (Error Err = setPointerAlignmentInBits (0 , Align (8 ), Align (8 ), 64 , 64 ))
216
- return report_fatal_error (std::move (Err));
231
+ report_fatal_error (std::move (Err));
217
232
218
- if (Error Err = parseSpecifier (Desc ))
219
- return report_fatal_error (std::move (Err));
233
+ if (Error Err = parseSpecifier (LayoutString ))
234
+ report_fatal_error (std::move (Err));
220
235
}
221
236
222
237
DataLayout &DataLayout::operator =(const DataLayout &Other) {
223
- clear ();
238
+ delete static_cast <StructLayoutMap *>(LayoutMap);
239
+ LayoutMap = nullptr ;
224
240
StringRepresentation = Other.StringRepresentation ;
225
241
BigEndian = Other.BigEndian ;
226
242
AllocaAddrSpace = Other.AllocaAddrSpace ;
@@ -693,42 +709,7 @@ Align DataLayout::getIntegerAlignment(uint32_t BitWidth,
693
709
return abi_or_pref ? I->ABIAlign : I->PrefAlign ;
694
710
}
695
711
696
- namespace {
697
-
698
- class StructLayoutMap {
699
- using LayoutInfoTy = DenseMap<StructType*, StructLayout*>;
700
- LayoutInfoTy LayoutInfo;
701
-
702
- public:
703
- ~StructLayoutMap () {
704
- // Remove any layouts.
705
- for (const auto &I : LayoutInfo) {
706
- StructLayout *Value = I.second ;
707
- Value->~StructLayout ();
708
- free (Value);
709
- }
710
- }
711
-
712
- StructLayout *&operator [](StructType *STy) {
713
- return LayoutInfo[STy];
714
- }
715
- };
716
-
717
- } // end anonymous namespace
718
-
719
- void DataLayout::clear () {
720
- LegalIntWidths.clear ();
721
- IntAlignments.clear ();
722
- FloatAlignments.clear ();
723
- VectorAlignments.clear ();
724
- Pointers.clear ();
725
- delete static_cast <StructLayoutMap *>(LayoutMap);
726
- LayoutMap = nullptr ;
727
- }
728
-
729
- DataLayout::~DataLayout () {
730
- clear ();
731
- }
712
+ DataLayout::~DataLayout () { delete static_cast <StructLayoutMap *>(LayoutMap); }
732
713
733
714
const StructLayout *DataLayout::getStructLayout (StructType *Ty) const {
734
715
if (!LayoutMap)
0 commit comments