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

Guillaume Chatelet via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 31 06:13:04 PST 2023


Author: Guillaume Chatelet
Date: 2023-01-31T14:12:51Z
New Revision: e098ee726eff11f680149122511d2883cb50e8d2

URL: https://github.com/llvm/llvm-project/commit/e098ee726eff11f680149122511d2883cb50e8d2
DIFF: https://github.com/llvm/llvm-project/commit/e098ee726eff11f680149122511d2883cb50e8d2.diff

LOG: 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.

Added: 
    

Modified: 
    llvm/include/llvm/IR/GlobalObject.h
    llvm/include/llvm/LTO/LTO.h
    llvm/lib/AsmParser/LLParser.cpp
    llvm/lib/IR/Globals.cpp
    llvm/lib/LTO/LTO.cpp
    llvm/lib/Transforms/IPO/OpenMPOpt.cpp
    llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/GlobalObject.h b/llvm/include/llvm/IR/GlobalObject.h
index 889bd3a28e12b..96a2703166867 100644
--- a/llvm/include/llvm/IR/GlobalObject.h
+++ b/llvm/include/llvm/IR/GlobalObject.h
@@ -82,12 +82,6 @@ class GlobalObject : public GlobalValue {
     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 {

diff  --git a/llvm/include/llvm/LTO/LTO.h b/llvm/include/llvm/LTO/LTO.h
index f101734c11fb0..70d5af91e5237 100644
--- a/llvm/include/llvm/LTO/LTO.h
+++ b/llvm/include/llvm/LTO/LTO.h
@@ -289,7 +289,7 @@ class LTO {
                     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;
     };

diff  --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 65b5825f63230..7f451620a08e2 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -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);

diff  --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 275ac2591423c..c208ab0f3d6ba 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -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());

diff  --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index 79204819d9af6..1cd48adac3f0a 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -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;
     }

diff  --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index 0f18d412c41c6..677cd2749fc2d 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -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);

diff  --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 1d013f0061df1..6502e13183408 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -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.


        


More information about the llvm-commits mailing list