@@ -973,7 +973,7 @@ void ItaniumRecordLayoutBuilder::EnsureVTablePointerAlignment(
973
973
}
974
974
975
975
// Round up the current record size to pointer alignment.
976
- setSize (getSize ().RoundUpToAlignment (BaseAlign));
976
+ setSize (getSize ().alignTo (BaseAlign));
977
977
setDataSize (getSize ());
978
978
979
979
// Update the alignment.
@@ -1194,7 +1194,7 @@ ItaniumRecordLayoutBuilder::LayoutBase(const BaseSubobjectInfo *Base) {
1194
1194
1195
1195
if (!HasExternalLayout) {
1196
1196
// Round up the current record size to the base's alignment boundary.
1197
- Offset = getDataSize ().RoundUpToAlignment (BaseAlign);
1197
+ Offset = getDataSize ().alignTo (BaseAlign);
1198
1198
1199
1199
// Try to place the base.
1200
1200
while (!EmptySubobjects->CanPlaceBaseAtOffset (Base, Offset))
@@ -1204,7 +1204,7 @@ ItaniumRecordLayoutBuilder::LayoutBase(const BaseSubobjectInfo *Base) {
1204
1204
(void )Allowed;
1205
1205
assert (Allowed && " Base subobject externally placed at overlapping offset" );
1206
1206
1207
- if (InferAlignment && Offset < getDataSize ().RoundUpToAlignment (BaseAlign)){
1207
+ if (InferAlignment && Offset < getDataSize ().alignTo (BaseAlign)) {
1208
1208
// The externally-supplied base offset is before the base offset we
1209
1209
// computed. Assume that the structure is packed.
1210
1210
Alignment = CharUnits::One ();
@@ -1292,8 +1292,7 @@ void ItaniumRecordLayoutBuilder::Layout(const CXXRecordDecl *RD) {
1292
1292
LayoutFields (RD);
1293
1293
1294
1294
NonVirtualSize = Context.toCharUnitsFromBits (
1295
- llvm::RoundUpToAlignment (getSizeInBits (),
1296
- Context.getTargetInfo ().getCharAlign ()));
1295
+ llvm::alignTo (getSizeInBits (), Context.getTargetInfo ().getCharAlign ()));
1297
1296
NonVirtualAlignment = Alignment;
1298
1297
1299
1298
// Lay out the virtual bases and add the primary virtual base offsets.
@@ -1364,7 +1363,7 @@ static uint64_t
1364
1363
roundUpSizeToCharAlignment (uint64_t Size ,
1365
1364
const ASTContext &Context) {
1366
1365
uint64_t CharAlignment = Context.getTargetInfo ().getCharAlign ();
1367
- return llvm::RoundUpToAlignment (Size , CharAlignment);
1366
+ return llvm::alignTo (Size , CharAlignment);
1368
1367
}
1369
1368
1370
1369
void ItaniumRecordLayoutBuilder::LayoutWideBitField (uint64_t FieldSize,
@@ -1411,13 +1410,12 @@ void ItaniumRecordLayoutBuilder::LayoutWideBitField(uint64_t FieldSize,
1411
1410
} else {
1412
1411
// The bitfield is allocated starting at the next offset aligned
1413
1412
// appropriately for T', with length n bits.
1414
- FieldOffset = llvm::RoundUpToAlignment (getDataSizeInBits (),
1415
- Context.toBits (TypeAlign));
1413
+ FieldOffset = llvm::alignTo (getDataSizeInBits (), Context.toBits (TypeAlign));
1416
1414
1417
1415
uint64_t NewSizeInBits = FieldOffset + FieldSize;
1418
1416
1419
- setDataSize (llvm::RoundUpToAlignment (NewSizeInBits,
1420
- Context.getTargetInfo ().getCharAlign ()));
1417
+ setDataSize (
1418
+ llvm::alignTo (NewSizeInBits, Context.getTargetInfo ().getCharAlign ()));
1421
1419
UnfilledBitsInLastUnit = getDataSizeInBits () - NewSizeInBits;
1422
1420
}
1423
1421
@@ -1587,9 +1585,9 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
1587
1585
// start a new storage unit), just do so, regardless of any other
1588
1586
// other consideration. Otherwise, round up to the right alignment.
1589
1587
if (FieldSize == 0 || FieldSize > UnfilledBitsInLastUnit) {
1590
- FieldOffset = llvm::RoundUpToAlignment (FieldOffset, FieldAlign);
1591
- UnpackedFieldOffset = llvm::RoundUpToAlignment (UnpackedFieldOffset,
1592
- UnpackedFieldAlign);
1588
+ FieldOffset = llvm::alignTo (FieldOffset, FieldAlign);
1589
+ UnpackedFieldOffset =
1590
+ llvm::alignTo (UnpackedFieldOffset, UnpackedFieldAlign);
1593
1591
UnfilledBitsInLastUnit = 0 ;
1594
1592
}
1595
1593
@@ -1601,22 +1599,22 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
1601
1599
if (FieldSize == 0 ||
1602
1600
(AllowPadding &&
1603
1601
(FieldOffset & (FieldAlign-1 )) + FieldSize > TypeSize)) {
1604
- FieldOffset = llvm::RoundUpToAlignment (FieldOffset, FieldAlign);
1602
+ FieldOffset = llvm::alignTo (FieldOffset, FieldAlign);
1605
1603
} else if (ExplicitFieldAlign) {
1606
1604
// TODO: figure it out what needs to be done on targets that don't honor
1607
1605
// bit-field type alignment like ARM APCS ABI.
1608
- FieldOffset = llvm::RoundUpToAlignment (FieldOffset, ExplicitFieldAlign);
1606
+ FieldOffset = llvm::alignTo (FieldOffset, ExplicitFieldAlign);
1609
1607
}
1610
1608
1611
1609
// Repeat the computation for diagnostic purposes.
1612
1610
if (FieldSize == 0 ||
1613
1611
(AllowPadding &&
1614
1612
(UnpackedFieldOffset & (UnpackedFieldAlign-1 )) + FieldSize > TypeSize))
1615
- UnpackedFieldOffset = llvm::RoundUpToAlignment (UnpackedFieldOffset,
1616
- UnpackedFieldAlign);
1613
+ UnpackedFieldOffset =
1614
+ llvm::alignTo (UnpackedFieldOffset, UnpackedFieldAlign);
1617
1615
else if (ExplicitFieldAlign)
1618
- UnpackedFieldOffset = llvm::RoundUpToAlignment (UnpackedFieldOffset,
1619
- ExplicitFieldAlign);
1616
+ UnpackedFieldOffset =
1617
+ llvm::alignTo (UnpackedFieldOffset, ExplicitFieldAlign);
1620
1618
}
1621
1619
1622
1620
// If we're using external layout, give the external layout a chance
@@ -1677,7 +1675,7 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
1677
1675
} else {
1678
1676
uint64_t NewSizeInBits = FieldOffset + FieldSize;
1679
1677
uint64_t CharAlignment = Context.getTargetInfo ().getCharAlign ();
1680
- setDataSize (llvm::RoundUpToAlignment (NewSizeInBits, CharAlignment));
1678
+ setDataSize (llvm::alignTo (NewSizeInBits, CharAlignment));
1681
1679
UnfilledBitsInLastUnit = getDataSizeInBits () - NewSizeInBits;
1682
1680
1683
1681
// The only time we can get here for an ms_struct is if this is a
@@ -1767,9 +1765,8 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D,
1767
1765
}
1768
1766
1769
1767
// Round up the current record size to the field's alignment boundary.
1770
- FieldOffset = FieldOffset.RoundUpToAlignment (FieldAlign);
1771
- UnpackedFieldOffset =
1772
- UnpackedFieldOffset.RoundUpToAlignment (UnpackedFieldAlign);
1768
+ FieldOffset = FieldOffset.alignTo (FieldAlign);
1769
+ UnpackedFieldOffset = UnpackedFieldOffset.alignTo (UnpackedFieldAlign);
1773
1770
1774
1771
if (UseExternalLayout) {
1775
1772
FieldOffset = Context.toCharUnitsFromBits (
@@ -1840,11 +1837,10 @@ void ItaniumRecordLayoutBuilder::FinishLayout(const NamedDecl *D) {
1840
1837
// record itself.
1841
1838
uint64_t UnpaddedSize = getSizeInBits () - UnfilledBitsInLastUnit;
1842
1839
uint64_t UnpackedSizeInBits =
1843
- llvm::RoundUpToAlignment (getSizeInBits (),
1844
- Context.toBits (UnpackedAlignment));
1840
+ llvm::alignTo (getSizeInBits (), Context.toBits (UnpackedAlignment));
1845
1841
CharUnits UnpackedSize = Context.toCharUnitsFromBits (UnpackedSizeInBits);
1846
- uint64_t RoundedSize
1847
- = llvm::RoundUpToAlignment (getSizeInBits (), Context.toBits (Alignment));
1842
+ uint64_t RoundedSize =
1843
+ llvm::alignTo (getSizeInBits (), Context.toBits (Alignment));
1848
1844
1849
1845
if (UseExternalLayout) {
1850
1846
// If we're inferring alignment, and the external size is smaller than
@@ -2385,7 +2381,7 @@ void MicrosoftRecordLayoutBuilder::layout(const RecordDecl *RD) {
2385
2381
MinEmptyStructSize = CharUnits::fromQuantity (4 );
2386
2382
initializeLayout (RD);
2387
2383
layoutFields (RD);
2388
- DataSize = Size = Size .RoundUpToAlignment (Alignment);
2384
+ DataSize = Size = Size .alignTo (Alignment);
2389
2385
RequiredAlignment = std::max (
2390
2386
RequiredAlignment, Context.toCharUnitsFromBits (RD->getMaxAlignment ()));
2391
2387
finalizeLayout (RD);
@@ -2405,7 +2401,7 @@ void MicrosoftRecordLayoutBuilder::cxxLayout(const CXXRecordDecl *RD) {
2405
2401
auto RoundingAlignment = Alignment;
2406
2402
if (!MaxFieldAlignment.isZero ())
2407
2403
RoundingAlignment = std::min (RoundingAlignment, MaxFieldAlignment);
2408
- NonVirtualSize = Size = Size .RoundUpToAlignment (RoundingAlignment);
2404
+ NonVirtualSize = Size = Size .alignTo (RoundingAlignment);
2409
2405
RequiredAlignment = std::max (
2410
2406
RequiredAlignment, Context.toCharUnitsFromBits (RD->getMaxAlignment ()));
2411
2407
layoutVirtualBases (RD);
@@ -2560,7 +2556,7 @@ void MicrosoftRecordLayoutBuilder::layoutNonVirtualBase(
2560
2556
}
2561
2557
2562
2558
if (!FoundBase)
2563
- BaseOffset = Size .RoundUpToAlignment (Info.Alignment );
2559
+ BaseOffset = Size .alignTo (Info.Alignment );
2564
2560
Bases.insert (std::make_pair (BaseDecl, BaseOffset));
2565
2561
Size = BaseOffset + BaseLayout.getNonVirtualSize ();
2566
2562
PreviousBaseLayout = &BaseLayout;
@@ -2590,7 +2586,7 @@ void MicrosoftRecordLayoutBuilder::layoutField(const FieldDecl *FD) {
2590
2586
Context.toCharUnitsFromBits (External.getExternalFieldOffset (FD));
2591
2587
assert (FieldOffset >= Size && " field offset already allocated" );
2592
2588
} else {
2593
- FieldOffset = Size .RoundUpToAlignment (Info.Alignment );
2589
+ FieldOffset = Size .alignTo (Info.Alignment );
2594
2590
}
2595
2591
placeFieldAtOffset (FieldOffset);
2596
2592
Size = FieldOffset + Info.Size ;
@@ -2625,7 +2621,7 @@ void MicrosoftRecordLayoutBuilder::layoutBitField(const FieldDecl *FD) {
2625
2621
// TODO: Add a Sema warning that MS ignores bitfield alignment in unions.
2626
2622
} else {
2627
2623
// Allocate a new block of memory and place the bitfield in it.
2628
- CharUnits FieldOffset = Size .RoundUpToAlignment (Info.Alignment );
2624
+ CharUnits FieldOffset = Size .alignTo (Info.Alignment );
2629
2625
placeFieldAtOffset (FieldOffset);
2630
2626
Size = FieldOffset + Info.Size ;
2631
2627
Alignment = std::max (Alignment, Info.Alignment );
@@ -2651,7 +2647,7 @@ MicrosoftRecordLayoutBuilder::layoutZeroWidthBitField(const FieldDecl *FD) {
2651
2647
// TODO: Add a Sema warning that MS ignores bitfield alignment in unions.
2652
2648
} else {
2653
2649
// Round up the current record size to the field's alignment boundary.
2654
- CharUnits FieldOffset = Size .RoundUpToAlignment (Info.Alignment );
2650
+ CharUnits FieldOffset = Size .alignTo (Info.Alignment );
2655
2651
placeFieldAtOffset (FieldOffset);
2656
2652
Size = FieldOffset;
2657
2653
Alignment = std::max (Alignment, Info.Alignment );
@@ -2664,7 +2660,7 @@ void MicrosoftRecordLayoutBuilder::injectVBPtr(const CXXRecordDecl *RD) {
2664
2660
// Inject the VBPointer at the injection site.
2665
2661
CharUnits InjectionSite = VBPtrOffset;
2666
2662
// But before we do, make sure it's properly aligned.
2667
- VBPtrOffset = VBPtrOffset.RoundUpToAlignment (PointerInfo.Alignment );
2663
+ VBPtrOffset = VBPtrOffset.alignTo (PointerInfo.Alignment );
2668
2664
// Shift everything after the vbptr down, unless we're using an external
2669
2665
// layout.
2670
2666
if (UseExternalLayout)
@@ -2673,8 +2669,8 @@ void MicrosoftRecordLayoutBuilder::injectVBPtr(const CXXRecordDecl *RD) {
2673
2669
CharUnits FieldStart = VBPtrOffset + PointerInfo.Size ;
2674
2670
// Make sure that the amount we push the fields back by is a multiple of the
2675
2671
// alignment.
2676
- CharUnits Offset = (FieldStart - InjectionSite). RoundUpToAlignment (
2677
- std::max (RequiredAlignment, Alignment));
2672
+ CharUnits Offset = (FieldStart - InjectionSite)
2673
+ . alignTo ( std::max (RequiredAlignment, Alignment));
2678
2674
Size += Offset;
2679
2675
for (uint64_t &FieldOffset : FieldOffsets)
2680
2676
FieldOffset += Context.toBits (Offset);
@@ -2688,8 +2684,8 @@ void MicrosoftRecordLayoutBuilder::injectVFPtr(const CXXRecordDecl *RD) {
2688
2684
return ;
2689
2685
// Make sure that the amount we push the struct back by is a multiple of the
2690
2686
// alignment.
2691
- CharUnits Offset = PointerInfo. Size . RoundUpToAlignment (
2692
- std::max (RequiredAlignment, Alignment));
2687
+ CharUnits Offset =
2688
+ PointerInfo. Size . alignTo ( std::max (RequiredAlignment, Alignment));
2693
2689
// Push back the vbptr, but increase the size of the object and push back
2694
2690
// regular fields by the offset only if not using external record layout.
2695
2691
if (HasVBPtr)
@@ -2743,7 +2739,7 @@ void MicrosoftRecordLayoutBuilder::layoutVirtualBases(const CXXRecordDecl *RD) {
2743
2739
// the required alignment, we don't know why.
2744
2740
if ((PreviousBaseLayout && PreviousBaseLayout->hasZeroSizedSubObject () &&
2745
2741
BaseLayout.leadsWithZeroSizedBase ()) || HasVtordisp) {
2746
- Size = Size .RoundUpToAlignment (VtorDispAlignment) + VtorDispSize;
2742
+ Size = Size .alignTo (VtorDispAlignment) + VtorDispSize;
2747
2743
Alignment = std::max (VtorDispAlignment, Alignment);
2748
2744
}
2749
2745
// Insert the virtual base.
@@ -2758,7 +2754,7 @@ void MicrosoftRecordLayoutBuilder::layoutVirtualBases(const CXXRecordDecl *RD) {
2758
2754
assert (BaseOffset >= Size && " base offset already allocated" );
2759
2755
}
2760
2756
if (!FoundBase)
2761
- BaseOffset = Size .RoundUpToAlignment (Info.Alignment );
2757
+ BaseOffset = Size .alignTo (Info.Alignment );
2762
2758
2763
2759
VBases.insert (std::make_pair (BaseDecl,
2764
2760
ASTRecordLayout::VBaseInfo (BaseOffset, HasVtordisp)));
@@ -2777,7 +2773,7 @@ void MicrosoftRecordLayoutBuilder::finalizeLayout(const RecordDecl *RD) {
2777
2773
if (!MaxFieldAlignment.isZero ())
2778
2774
RoundingAlignment = std::min (RoundingAlignment, MaxFieldAlignment);
2779
2775
RoundingAlignment = std::max (RoundingAlignment, RequiredAlignment);
2780
- Size = Size .RoundUpToAlignment (RoundingAlignment);
2776
+ Size = Size .alignTo (RoundingAlignment);
2781
2777
}
2782
2778
if (Size .isZero ()) {
2783
2779
EndsWithZeroSizedObject = true ;
0 commit comments