return decodeMaybeAlign(AlignmentData);
}
+ /// Sets the alignment attribute of the GlobalObject.
+ void setAlignment(Align Align);
+
+ /// Sets the alignment attribute of the GlobalObject.
+ /// This method will be deprecated as the alignment property should always be
+ /// defined.
void setAlignment(MaybeAlign Align);
unsigned getGlobalObjectSubClassData() const {
const Config &Conf);
struct CommonResolution {
uint64_t Size = 0;
- MaybeAlign Align;
+ Align Align;
/// Record if at least one instance of the common was marked as prevailing
bool Prevailing = false;
};
// If the alignment was parsed as an attribute, move to the alignment
// field.
if (MaybeAlign A = FnAttrs.getAlignment()) {
- Fn->setAlignment(A);
+ Fn->setAlignment(*A);
FnAttrs.removeAttribute(Attribute::Alignment);
}
Fn->setCallingConv(CC);
Fn->setAttributes(PAL);
Fn->setUnnamedAddr(UnnamedAddr);
- Fn->setAlignment(MaybeAlign(Alignment));
+ Fn->setAlignment(Alignment);
Fn->setSection(Section);
Fn->setPartition(Partition);
Fn->setComdat(C);
assert(getAlign() == Align && "Alignment representation error!");
}
+void GlobalObject::setAlignment(Align Align) {
+ assert(Align <= MaximumAlignment &&
+ "Alignment is greater than MaximumAlignment!");
+ unsigned AlignmentData = encode(Align);
+ unsigned OldData = getGlobalValueSubClassData();
+ setGlobalValueSubClassData((OldData & ~AlignmentMask) | AlignmentData);
+ assert(getAlign() && *getAlign() == Align &&
+ "Alignment representation error!");
+}
+
void GlobalObject::copyAttributesFrom(const GlobalObject *Src) {
GlobalValue::copyAttributesFrom(Src);
setAlignment(Src->getAlign());
auto &CommonRes = RegularLTO.Commons[std::string(Sym.getIRName())];
CommonRes.Size = std::max(CommonRes.Size, Sym.getCommonSize());
if (uint32_t SymAlignValue = Sym.getCommonAlignment()) {
- const Align SymAlign(SymAlignValue);
- CommonRes.Align = std::max(SymAlign, CommonRes.Align.valueOrOne());
+ CommonRes.Align = std::max(Align(SymAlignValue), CommonRes.Align);
}
CommonRes.Prevailing |= Res.Prevailing;
}
MaybeAlign Alignment = CB->getRetAlign();
assert(Alignment &&
"HeapToShared on allocation without alignment attribute");
- SharedMem->setAlignment(MaybeAlign(Alignment));
+ SharedMem->setAlignment(*Alignment);
A.changeAfterManifest(IRPosition::callsite_returned(*CB), *NewBuffer);
A.deleteAfterManifest(*CB);
G->getThreadLocalMode(), G->getAddressSpace());
NewGlobal->copyAttributesFrom(G);
NewGlobal->setComdat(G->getComdat());
- NewGlobal->setAlignment(MaybeAlign(getMinRedzoneSizeForGlobal()));
+ NewGlobal->setAlignment(Align(getMinRedzoneSizeForGlobal()));
// Don't fold globals with redzones. ODR violation detector and redzone
// poisoning implicitly creates a dependence on the global's address, so it
// is no longer valid for it to be marked unnamed_addr.