@@ -241,16 +241,16 @@ bool Attribute::hasAttribute(StringRef Kind) const {
241
241
return pImpl && pImpl->hasAttribute (Kind);
242
242
}
243
243
244
- unsigned Attribute::getAlignment () const {
244
+ MaybeAlign Attribute::getAlignment () const {
245
245
assert (hasAttribute (Attribute::Alignment) &&
246
246
" Trying to get alignment from non-alignment attribute!" );
247
- return pImpl->getValueAsInt ();
247
+ return MaybeAlign ( pImpl->getValueAsInt () );
248
248
}
249
249
250
- unsigned Attribute::getStackAlignment () const {
250
+ MaybeAlign Attribute::getStackAlignment () const {
251
251
assert (hasAttribute (Attribute::StackAlignment) &&
252
252
" Trying to get alignment from non-alignment attribute!" );
253
- return pImpl->getValueAsInt ();
253
+ return MaybeAlign ( pImpl->getValueAsInt () );
254
254
}
255
255
256
256
uint64_t Attribute::getDereferenceableBytes () const {
@@ -667,12 +667,12 @@ Attribute AttributeSet::getAttribute(StringRef Kind) const {
667
667
return SetNode ? SetNode->getAttribute (Kind) : Attribute ();
668
668
}
669
669
670
- unsigned AttributeSet::getAlignment () const {
671
- return SetNode ? SetNode->getAlignment () : 0 ;
670
+ MaybeAlign AttributeSet::getAlignment () const {
671
+ return SetNode ? SetNode->getAlignment () : None ;
672
672
}
673
673
674
- unsigned AttributeSet::getStackAlignment () const {
675
- return SetNode ? SetNode->getStackAlignment () : 0 ;
674
+ MaybeAlign AttributeSet::getStackAlignment () const {
675
+ return SetNode ? SetNode->getStackAlignment () : None ;
676
676
}
677
677
678
678
uint64_t AttributeSet::getDereferenceableBytes () const {
@@ -833,18 +833,18 @@ Attribute AttributeSetNode::getAttribute(StringRef Kind) const {
833
833
return {};
834
834
}
835
835
836
- unsigned AttributeSetNode::getAlignment () const {
836
+ MaybeAlign AttributeSetNode::getAlignment () const {
837
837
for (const auto I : *this )
838
838
if (I.hasAttribute (Attribute::Alignment))
839
839
return I.getAlignment ();
840
- return 0 ;
840
+ return None ;
841
841
}
842
842
843
- unsigned AttributeSetNode::getStackAlignment () const {
843
+ MaybeAlign AttributeSetNode::getStackAlignment () const {
844
844
for (const auto I : *this )
845
845
if (I.hasAttribute (Attribute::StackAlignment))
846
846
return I.getStackAlignment ();
847
- return 0 ;
847
+ return None ;
848
848
}
849
849
850
850
Type *AttributeSetNode::getByValType () const {
@@ -1161,7 +1161,7 @@ AttributeList AttributeList::addAttributes(LLVMContext &C, unsigned Index,
1161
1161
#ifndef NDEBUG
1162
1162
// FIXME it is not obvious how this should work for alignment. For now, say
1163
1163
// we can't change a known alignment.
1164
- unsigned OldAlign = getAttributes (Index).getAlignment ();
1164
+ const MaybeAlign OldAlign = getAttributes (Index).getAlignment ();
1165
1165
unsigned NewAlign = B.getAlignment ();
1166
1166
assert ((!OldAlign || !NewAlign || OldAlign == NewAlign) &&
1167
1167
" Attempt to change alignment!" );
@@ -1346,20 +1346,19 @@ Attribute AttributeList::getAttribute(unsigned Index, StringRef Kind) const {
1346
1346
return getAttributes (Index).getAttribute (Kind);
1347
1347
}
1348
1348
1349
- unsigned AttributeList::getRetAlignment () const {
1349
+ MaybeAlign AttributeList::getRetAlignment () const {
1350
1350
return getAttributes (ReturnIndex).getAlignment ();
1351
1351
}
1352
1352
1353
- unsigned AttributeList::getParamAlignment (unsigned ArgNo) const {
1353
+ MaybeAlign AttributeList::getParamAlignment (unsigned ArgNo) const {
1354
1354
return getAttributes (ArgNo + FirstArgIndex).getAlignment ();
1355
1355
}
1356
1356
1357
1357
Type *AttributeList::getParamByValType (unsigned Index) const {
1358
1358
return getAttributes (Index+FirstArgIndex).getByValType ();
1359
1359
}
1360
1360
1361
-
1362
- unsigned AttributeList::getStackAlignment (unsigned Index) const {
1361
+ MaybeAlign AttributeList::getStackAlignment (unsigned Index) const {
1363
1362
return getAttributes (Index).getStackAlignment ();
1364
1363
}
1365
1364
@@ -1516,8 +1515,7 @@ std::pair<unsigned, Optional<unsigned>> AttrBuilder::getAllocSizeArgs() const {
1516
1515
return unpackAllocSizeArgs (AllocSizeArgs);
1517
1516
}
1518
1517
1519
- AttrBuilder &AttrBuilder::addAlignmentAttr (unsigned A) {
1520
- MaybeAlign Align (A);
1518
+ AttrBuilder &AttrBuilder::addAlignmentAttr (MaybeAlign Align) {
1521
1519
if (!Align)
1522
1520
return *this ;
1523
1521
@@ -1528,8 +1526,7 @@ AttrBuilder &AttrBuilder::addAlignmentAttr(unsigned A) {
1528
1526
return *this ;
1529
1527
}
1530
1528
1531
- AttrBuilder &AttrBuilder::addStackAlignmentAttr (unsigned A) {
1532
- MaybeAlign Align (A);
1529
+ AttrBuilder &AttrBuilder::addStackAlignmentAttr (MaybeAlign Align) {
1533
1530
// Default alignment, allow the target to define how to align it.
1534
1531
if (!Align)
1535
1532
return *this ;
0 commit comments