Revert D142708 "[NFC] Transition GlobalObject alignment from MaybeAlign to Align"

This is breaking the build bots. e.g.,
https://lab.llvm.org/buildbot/#/builders/121/builds/27549

This reverts commit 6717efe74da825214cb4d307ad35e5fbda353301.
This commit is contained in:
Guillaume Chatelet 2023-01-31 14:10:25 +00:00
parent 6717efe74d
commit e098ee726e
7 changed files with 7 additions and 22 deletions

View File

@ -82,12 +82,6 @@ public:
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 {

View File

@ -289,7 +289,7 @@ private:
const Config &Conf);
struct CommonResolution {
uint64_t Size = 0;
Align Align;
MaybeAlign Align;
/// Record if at least one instance of the common was marked as prevailing
bool Prevailing = false;
};

View File

@ -150,7 +150,7 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {
// 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);
}
@ -6047,7 +6047,7 @@ bool LLParser::parseFunctionHeader(Function *&Fn, bool IsDefine) {
Fn->setCallingConv(CC);
Fn->setAttributes(PAL);
Fn->setUnnamedAddr(UnnamedAddr);
Fn->setAlignment(Alignment);
Fn->setAlignment(MaybeAlign(Alignment));
Fn->setSection(Section);
Fn->setPartition(Partition);
Fn->setComdat(C);

View File

@ -127,16 +127,6 @@ void GlobalObject::setAlignment(MaybeAlign Align) {
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());

View File

@ -839,7 +839,8 @@ LTO::addRegularLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms,
auto &CommonRes = RegularLTO.Commons[std::string(Sym.getIRName())];
CommonRes.Size = std::max(CommonRes.Size, Sym.getCommonSize());
if (uint32_t SymAlignValue = Sym.getCommonAlignment()) {
CommonRes.Align = std::max(Align(SymAlignValue), CommonRes.Align);
const Align SymAlign(SymAlignValue);
CommonRes.Align = std::max(SymAlign, CommonRes.Align.valueOrOne());
}
CommonRes.Prevailing |= Res.Prevailing;
}

View File

@ -3300,7 +3300,7 @@ struct AAHeapToSharedFunction : public AAHeapToShared {
MaybeAlign Alignment = CB->getRetAlign();
assert(Alignment &&
"HeapToShared on allocation without alignment attribute");
SharedMem->setAlignment(*Alignment);
SharedMem->setAlignment(MaybeAlign(Alignment));
A.changeAfterManifest(IRPosition::callsite_returned(*CB), *NewBuffer);
A.deleteAfterManifest(*CB);

View File

@ -2306,7 +2306,7 @@ bool ModuleAddressSanitizer::InstrumentGlobals(IRBuilder<> &IRB, Module &M,
G->getThreadLocalMode(), G->getAddressSpace());
NewGlobal->copyAttributesFrom(G);
NewGlobal->setComdat(G->getComdat());
NewGlobal->setAlignment(Align(getMinRedzoneSizeForGlobal()));
NewGlobal->setAlignment(MaybeAlign(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.