[llvm] r284733 - Retire llvm::alignOf in favor of C++11 alignof.

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 20 08:02:18 PDT 2016


Author: d0k
Date: Thu Oct 20 10:02:18 2016
New Revision: 284733

URL: http://llvm.org/viewvc/llvm-project?rev=284733&view=rev
Log:
Retire llvm::alignOf in favor of C++11 alignof.

No functionality change intended.

Modified:
    llvm/trunk/include/llvm/ADT/IntervalMap.h
    llvm/trunk/include/llvm/ADT/StringMap.h
    llvm/trunk/include/llvm/CodeGen/LiveInterval.h
    llvm/trunk/include/llvm/CodeGen/SelectionDAG.h
    llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
    llvm/trunk/include/llvm/IR/DerivedTypes.h
    llvm/trunk/include/llvm/IR/User.h
    llvm/trunk/include/llvm/Object/ELF.h
    llvm/trunk/include/llvm/Support/Allocator.h
    llvm/trunk/include/llvm/Support/ArrayRecycler.h
    llvm/trunk/include/llvm/Support/Endian.h
    llvm/trunk/include/llvm/Support/OnDiskHashTable.h
    llvm/trunk/include/llvm/Support/PointerLikeTypeTraits.h
    llvm/trunk/include/llvm/Support/Recycler.h
    llvm/trunk/include/llvm/Support/RecyclingAllocator.h
    llvm/trunk/include/llvm/Support/TrailingObjects.h
    llvm/trunk/include/llvm/Transforms/Utils/SSAUpdaterImpl.h
    llvm/trunk/lib/Analysis/GlobalsModRef.cpp
    llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp
    llvm/trunk/lib/IR/Metadata.cpp
    llvm/trunk/lib/IR/Type.cpp
    llvm/trunk/lib/IR/User.cpp
    llvm/trunk/lib/MC/MCSymbol.cpp
    llvm/trunk/lib/ProfileData/InstrProfReader.cpp
    llvm/trunk/unittests/Support/TrailingObjectsTest.cpp

Modified: llvm/trunk/include/llvm/ADT/IntervalMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/IntervalMap.h?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/IntervalMap.h (original)
+++ llvm/trunk/include/llvm/ADT/IntervalMap.h Thu Oct 20 10:02:18 2016
@@ -1041,7 +1041,7 @@ private:
 
 public:
   explicit IntervalMap(Allocator &a) : height(0), rootSize(0), allocator(a) {
-    assert((uintptr_t(data.buffer) & (alignOf<RootLeaf>() - 1)) == 0 &&
+    assert((uintptr_t(data.buffer) & (alignof(RootLeaf) - 1)) == 0 &&
            "Insufficient alignment");
     new(&rootLeaf()) RootLeaf();
   }

Modified: llvm/trunk/include/llvm/ADT/StringMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringMap.h?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/StringMap.h (original)
+++ llvm/trunk/include/llvm/ADT/StringMap.h Thu Oct 20 10:02:18 2016
@@ -157,7 +157,7 @@ public:
     // terminator.
     unsigned AllocSize = static_cast<unsigned>(sizeof(StringMapEntry))+
       KeyLength+1;
-    unsigned Alignment = alignOf<StringMapEntry>();
+    unsigned Alignment = alignof(StringMapEntry);
 
     StringMapEntry *NewItem =
       static_cast<StringMapEntry*>(Allocator.Allocate(AllocSize,Alignment));

Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original)
+++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Thu Oct 20 10:02:18 2016
@@ -23,7 +23,6 @@
 
 #include "llvm/ADT/IntEqClasses.h"
 #include "llvm/CodeGen/SlotIndexes.h"
-#include "llvm/Support/AlignOf.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Target/TargetRegisterInfo.h"
 #include <cassert>

Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Thu Oct 20 10:02:18 2016
@@ -183,8 +183,8 @@ class SelectionDAG {
   /// The AllocatorType for allocating SDNodes. We use
   /// pool allocation with recycling.
   typedef RecyclingAllocator<BumpPtrAllocator, SDNode, sizeof(LargestSDNode),
-                             AlignOf<MostAlignedSDNode>::Alignment>
-    NodeAllocatorType;
+                             alignof(MostAlignedSDNode)>
+      NodeAllocatorType;
 
   /// Pool allocation for nodes.
   NodeAllocatorType NodeAllocator;

Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Thu Oct 20 10:02:18 2016
@@ -346,9 +346,8 @@ namespace llvm {
 
     IndexListEntry* createEntry(MachineInstr *mi, unsigned index) {
       IndexListEntry *entry =
-        static_cast<IndexListEntry*>(
-          ileAllocator.Allocate(sizeof(IndexListEntry),
-          alignOf<IndexListEntry>()));
+          static_cast<IndexListEntry *>(ileAllocator.Allocate(
+              sizeof(IndexListEntry), alignof(IndexListEntry)));
 
       new (entry) IndexListEntry(mi, index);
 

Modified: llvm/trunk/include/llvm/IR/DerivedTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DerivedTypes.h?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DerivedTypes.h (original)
+++ llvm/trunk/include/llvm/IR/DerivedTypes.h Thu Oct 20 10:02:18 2016
@@ -138,7 +138,7 @@ public:
     return T->getTypeID() == FunctionTyID;
   }
 };
-static_assert(AlignOf<FunctionType>::Alignment >= AlignOf<Type *>::Alignment,
+static_assert(alignof(FunctionType) >= alignof(Type *),
               "Alignment sufficient for objects appended to FunctionType");
 
 bool Type::isFunctionVarArg() const {

Modified: llvm/trunk/include/llvm/IR/User.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/User.h?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/User.h (original)
+++ llvm/trunk/include/llvm/IR/User.h Thu Oct 20 10:02:18 2016
@@ -22,7 +22,6 @@
 #include "llvm/ADT/iterator.h"
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/IR/Value.h"
-#include "llvm/Support/AlignOf.h"
 #include "llvm/Support/ErrorHandling.h"
 
 namespace llvm {
@@ -250,9 +249,9 @@ public:
   }
 };
 // Either Use objects, or a Use pointer can be prepended to User.
-static_assert(AlignOf<Use>::Alignment >= AlignOf<User>::Alignment,
+static_assert(alignof(Use) >= alignof(User),
               "Alignment is insufficient after objects prepended to User");
-static_assert(AlignOf<Use *>::Alignment >= AlignOf<User>::Alignment,
+static_assert(alignof(Use *) >= alignof(User),
               "Alignment is insufficient after objects prepended to User");
 
 template<> struct simplify_type<User::op_iterator> {

Modified: llvm/trunk/include/llvm/Object/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF.h?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELF.h (original)
+++ llvm/trunk/include/llvm/Object/ELF.h Thu Oct 20 10:02:18 2016
@@ -337,7 +337,7 @@ ELFFile<ELFT>::ELFFile(StringRef Object,
     return;
   }
 
-  if (SectionTableOffset & (AlignOf<Elf_Shdr>::Alignment - 1)) {
+  if (SectionTableOffset & (alignof(Elf_Shdr) - 1)) {
     // Invalid address alignment of section headers
     EC = object_error::parse_failed;
     return;

Modified: llvm/trunk/include/llvm/Support/Allocator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Allocator.h?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Allocator.h (original)
+++ llvm/trunk/include/llvm/Support/Allocator.h Thu Oct 20 10:02:18 2016
@@ -22,7 +22,6 @@
 #define LLVM_SUPPORT_ALLOCATOR_H
 
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/AlignOf.h"
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/Memory.h"
@@ -74,7 +73,7 @@ public:
 
   /// \brief Allocate space for a sequence of objects without constructing them.
   template <typename T> T *Allocate(size_t Num = 1) {
-    return static_cast<T *>(Allocate(Num * sizeof(T), AlignOf<T>::Alignment));
+    return static_cast<T *>(Allocate(Num * sizeof(T), alignof(T)));
   }
 
   /// \brief Deallocate space for a sequence of objects without constructing them.
@@ -381,7 +380,7 @@ public:
   /// all memory allocated so far.
   void DestroyAll() {
     auto DestroyElements = [](char *Begin, char *End) {
-      assert(Begin == (char*)alignAddr(Begin, alignOf<T>()));
+      assert(Begin == (char *)alignAddr(Begin, alignof(T)));
       for (char *Ptr = Begin; Ptr + sizeof(T) <= End; Ptr += sizeof(T))
         reinterpret_cast<T *>(Ptr)->~T();
     };
@@ -390,7 +389,7 @@ public:
          ++I) {
       size_t AllocatedSlabSize = BumpPtrAllocator::computeSlabSize(
           std::distance(Allocator.Slabs.begin(), I));
-      char *Begin = (char*)alignAddr(*I, alignOf<T>());
+      char *Begin = (char *)alignAddr(*I, alignof(T));
       char *End = *I == Allocator.Slabs.back() ? Allocator.CurPtr
                                                : (char *)*I + AllocatedSlabSize;
 
@@ -400,7 +399,7 @@ public:
     for (auto &PtrAndSize : Allocator.CustomSizedSlabs) {
       void *Ptr = PtrAndSize.first;
       size_t Size = PtrAndSize.second;
-      DestroyElements((char*)alignAddr(Ptr, alignOf<T>()), (char *)Ptr + Size);
+      DestroyElements((char *)alignAddr(Ptr, alignof(T)), (char *)Ptr + Size);
     }
 
     Allocator.Reset();

Modified: llvm/trunk/include/llvm/Support/ArrayRecycler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ArrayRecycler.h?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ArrayRecycler.h (original)
+++ llvm/trunk/include/llvm/Support/ArrayRecycler.h Thu Oct 20 10:02:18 2016
@@ -26,15 +26,14 @@ namespace llvm {
 /// Arrays are allocated in a small number of fixed sizes. For each supported
 /// array size, the ArrayRecycler keeps a free list of available arrays.
 ///
-template<class T, size_t Align = AlignOf<T>::Alignment>
-class ArrayRecycler {
+template <class T, size_t Align = alignof(T)> class ArrayRecycler {
   // The free list for a given array size is a simple singly linked list.
   // We can't use iplist or Recycler here since those classes can't be copied.
   struct FreeList {
     FreeList *Next;
   };
 
-  static_assert(Align >= AlignOf<FreeList>::Alignment, "Object underaligned");
+  static_assert(Align >= alignof(FreeList), "Object underaligned");
   static_assert(sizeof(T) >= sizeof(FreeList), "Objects are too small");
 
   // Keep a free list for each array size.

Modified: llvm/trunk/include/llvm/Support/Endian.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Endian.h?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Endian.h (original)
+++ llvm/trunk/include/llvm/Support/Endian.h Thu Oct 20 10:02:18 2016
@@ -14,7 +14,6 @@
 #ifndef LLVM_SUPPORT_ENDIAN_H
 #define LLVM_SUPPORT_ENDIAN_H
 
-#include "llvm/Support/AlignOf.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/SwapByteOrder.h"
 
@@ -29,7 +28,7 @@ namespace detail {
   /// \brief ::value is either alignment, or alignof(T) if alignment is 0.
   template<class T, int alignment>
   struct PickAlignment {
-    enum {value = alignment == 0 ? AlignOf<T>::Alignment : alignment};
+    enum { value = alignment == 0 ? alignof(T) : alignment };
   };
 } // end namespace detail
 

Modified: llvm/trunk/include/llvm/Support/OnDiskHashTable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/OnDiskHashTable.h?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/OnDiskHashTable.h (original)
+++ llvm/trunk/include/llvm/Support/OnDiskHashTable.h Thu Oct 20 10:02:18 2016
@@ -14,7 +14,6 @@
 #ifndef LLVM_SUPPORT_ONDISKHASHTABLE_H
 #define LLVM_SUPPORT_ONDISKHASHTABLE_H
 
-#include "llvm/Support/AlignOf.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/EndianStream.h"
@@ -208,7 +207,7 @@ public:
 
     // Pad with zeros so that we can start the hashtable at an aligned address.
     offset_type TableOff = Out.tell();
-    uint64_t N = llvm::OffsetToAlignment(TableOff, alignOf<offset_type>());
+    uint64_t N = llvm::OffsetToAlignment(TableOff, alignof(offset_type));
     TableOff += N;
     while (N--)
       LE.write<uint8_t>(0);

Modified: llvm/trunk/include/llvm/Support/PointerLikeTypeTraits.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PointerLikeTypeTraits.h?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/PointerLikeTypeTraits.h (original)
+++ llvm/trunk/include/llvm/Support/PointerLikeTypeTraits.h Thu Oct 20 10:02:18 2016
@@ -15,8 +15,8 @@
 #ifndef LLVM_SUPPORT_POINTERLIKETYPETRAITS_H
 #define LLVM_SUPPORT_POINTERLIKETYPETRAITS_H
 
-#include "llvm/Support/AlignOf.h"
 #include "llvm/Support/DataTypes.h"
+#include <type_traits>
 
 namespace llvm {
 
@@ -42,9 +42,7 @@ public:
   static inline void *getAsVoidPointer(T *P) { return P; }
   static inline T *getFromVoidPointer(void *P) { return static_cast<T *>(P); }
 
-  enum {
-    NumLowBitsAvailable = detail::ConstantLog2<AlignOf<T>::Alignment>::value
-  };
+  enum { NumLowBitsAvailable = detail::ConstantLog2<alignof(T)>::value };
 };
 
 template <> class PointerLikeTypeTraits<void *> {

Modified: llvm/trunk/include/llvm/Support/Recycler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Recycler.h?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Recycler.h (original)
+++ llvm/trunk/include/llvm/Support/Recycler.h Thu Oct 20 10:02:18 2016
@@ -16,7 +16,6 @@
 #define LLVM_SUPPORT_RECYCLER_H
 
 #include "llvm/ADT/ilist.h"
-#include "llvm/Support/AlignOf.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/ErrorHandling.h"
 #include <cassert>
@@ -32,7 +31,7 @@ void PrintRecyclerStats(size_t Size, siz
 /// and facilitates reusing deallocated memory in place of allocating
 /// new memory.
 ///
-template<class T, size_t Size = sizeof(T), size_t Align = AlignOf<T>::Alignment>
+template <class T, size_t Size = sizeof(T), size_t Align = alignof(T)>
 class Recycler {
   struct FreeNode {
     FreeNode *Next;
@@ -80,7 +79,7 @@ public:
 
   template<class SubClass, class AllocatorType>
   SubClass *Allocate(AllocatorType &Allocator) {
-    static_assert(AlignOf<SubClass>::Alignment <= Align,
+    static_assert(alignof(SubClass) <= Align,
                   "Recycler allocation alignment is less than object align!");
     static_assert(sizeof(SubClass) <= Size,
                   "Recycler allocation size is less than object size!");

Modified: llvm/trunk/include/llvm/Support/RecyclingAllocator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/RecyclingAllocator.h?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/RecyclingAllocator.h (original)
+++ llvm/trunk/include/llvm/Support/RecyclingAllocator.h Thu Oct 20 10:02:18 2016
@@ -22,8 +22,8 @@ namespace llvm {
 /// RecyclingAllocator - This class wraps an Allocator, adding the
 /// functionality of recycling deleted objects.
 ///
-template<class AllocatorType, class T,
-         size_t Size = sizeof(T), size_t Align = AlignOf<T>::Alignment>
+template <class AllocatorType, class T, size_t Size = sizeof(T),
+          size_t Align = alignof(T)>
 class RecyclingAllocator {
 private:
   /// Base - Implementation details.

Modified: llvm/trunk/include/llvm/Support/TrailingObjects.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TrailingObjects.h?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/TrailingObjects.h (original)
+++ llvm/trunk/include/llvm/Support/TrailingObjects.h Thu Oct 20 10:02:18 2016
@@ -62,7 +62,7 @@ namespace trailing_objects_internal {
 template <typename First, typename... Rest> class AlignmentCalcHelper {
 private:
   enum {
-    FirstAlignment = AlignOf<First>::Alignment,
+    FirstAlignment = alignof(First),
     RestAlignment = AlignmentCalcHelper<Rest...>::Alignment,
   };
 
@@ -74,7 +74,7 @@ public:
 
 template <typename First> class AlignmentCalcHelper<First> {
 public:
-  enum { Alignment = AlignOf<First>::Alignment };
+  enum { Alignment = alignof(First) };
 };
 
 /// The base class for TrailingObjects* classes.
@@ -143,8 +143,7 @@ class TrailingObjectsImpl<Align, BaseTy,
       ParentType;
 
   struct RequiresRealignment {
-    static const bool value =
-        llvm::AlignOf<PrevTy>::Alignment < llvm::AlignOf<NextTy>::Alignment;
+    static const bool value = alignof(PrevTy) < alignof(NextTy);
   };
 
   static LLVM_CONSTEXPR bool requiresRealignment() {
@@ -174,7 +173,7 @@ protected:
 
     if (requiresRealignment())
       return reinterpret_cast<const NextTy *>(
-          llvm::alignAddr(Ptr, llvm::alignOf<NextTy>()));
+          llvm::alignAddr(Ptr, alignof(NextTy)));
     else
       return reinterpret_cast<const NextTy *>(Ptr);
   }
@@ -188,8 +187,7 @@ protected:
                     Obj, TrailingObjectsBase::OverloadToken<PrevTy>());
 
     if (requiresRealignment())
-      return reinterpret_cast<NextTy *>(
-          llvm::alignAddr(Ptr, llvm::alignOf<NextTy>()));
+      return reinterpret_cast<NextTy *>(llvm::alignAddr(Ptr, alignof(NextTy)));
     else
       return reinterpret_cast<NextTy *>(Ptr);
   }
@@ -201,9 +199,8 @@ protected:
       size_t SizeSoFar, size_t Count1,
       typename ExtractSecondType<MoreTys, size_t>::type... MoreCounts) {
     return ParentType::additionalSizeToAllocImpl(
-        (requiresRealignment()
-             ? llvm::alignTo<llvm::AlignOf<NextTy>::Alignment>(SizeSoFar)
-             : SizeSoFar) +
+        (requiresRealignment() ? llvm::alignTo<alignof(NextTy)>(SizeSoFar)
+                               : SizeSoFar) +
             sizeof(NextTy) * Count1,
         MoreCounts...);
   }
@@ -216,10 +213,9 @@ protected:
     static_assert(sizeof...(MoreTys) == sizeof...(MoreCounts),
                   "Number of counts do not match number of types");
     static const size_t value = ParentType::template AdditionalSizeToAllocImpl<
-        (RequiresRealignment::value
-             ? llvm::AlignTo<llvm::AlignOf<NextTy>::Alignment>::
-                   template from_value<SizeSoFar>::value
-             : SizeSoFar) +
+        (RequiresRealignment::value ? llvm::AlignTo<alignof(NextTy)>::
+                                          template from_value<SizeSoFar>::value
+                                    : SizeSoFar) +
             sizeof(NextTy) * Count1,
         MoreCounts...>::value;
   };
@@ -407,9 +403,7 @@ public:
       enum {
         Size = TotalSizeToAlloc<Tys...>::template with_counts<Counts...>::value
       };
-      typedef llvm::AlignedCharArray<
-          llvm::AlignOf<BaseTy>::Alignment, Size
-          > type;
+      typedef llvm::AlignedCharArray<alignof(BaseTy), Size> type;
     };
   };
 

Modified: llvm/trunk/include/llvm/Transforms/Utils/SSAUpdaterImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/SSAUpdaterImpl.h?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/SSAUpdaterImpl.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/SSAUpdaterImpl.h Thu Oct 20 10:02:18 2016
@@ -120,9 +120,8 @@ public:
       if (Info->NumPreds == 0)
         Info->Preds = nullptr;
       else
-        Info->Preds = static_cast<BBInfo**>
-          (Allocator.Allocate(Info->NumPreds * sizeof(BBInfo*),
-                              AlignOf<BBInfo*>::Alignment));
+        Info->Preds = static_cast<BBInfo **>(Allocator.Allocate(
+            Info->NumPreds * sizeof(BBInfo *), alignof(BBInfo *)));
 
       for (unsigned p = 0; p != Info->NumPreds; ++p) {
         BlkT *Pred = Preds[p];

Modified: llvm/trunk/lib/Analysis/GlobalsModRef.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/GlobalsModRef.cpp?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/GlobalsModRef.cpp (original)
+++ llvm/trunk/lib/Analysis/GlobalsModRef.cpp Thu Oct 20 10:02:18 2016
@@ -78,7 +78,7 @@ class GlobalsAAResult::FunctionInfo {
       return (AlignedMap *)P;
     }
     enum { NumLowBitsAvailable = 3 };
-    static_assert(AlignOf<AlignedMap>::Alignment >= (1 << NumLowBitsAvailable),
+    static_assert(alignof(AlignedMap) >= (1 << NumLowBitsAvailable),
                   "AlignedMap insufficiently aligned to have enough low bits.");
   };
 

Modified: llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp Thu Oct 20 10:02:18 2016
@@ -18,7 +18,6 @@
 #include "llvm/CodeGen/MachineInstr.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
-#include "llvm/Support/AlignOf.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"

Modified: llvm/trunk/lib/IR/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Metadata.cpp?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Metadata.cpp (original)
+++ llvm/trunk/lib/IR/Metadata.cpp Thu Oct 20 10:02:18 2016
@@ -434,7 +434,7 @@ StringRef MDString::getString() const {
 // prepended to them.
 #define HANDLE_MDNODE_LEAF(CLASS)                                              \
   static_assert(                                                               \
-      llvm::AlignOf<uint64_t>::Alignment >= llvm::AlignOf<CLASS>::Alignment,   \
+      alignof(uint64_t) >= alignof(CLASS),                                     \
       "Alignment is insufficient after objects prepended to " #CLASS);
 #include "llvm/IR/Metadata.def"
 
@@ -442,7 +442,7 @@ void *MDNode::operator new(size_t Size,
   size_t OpSize = NumOps * sizeof(MDOperand);
   // uint64_t is the most aligned type we need support (ensured by static_assert
   // above)
-  OpSize = alignTo(OpSize, llvm::alignOf<uint64_t>());
+  OpSize = alignTo(OpSize, alignof(uint64_t));
   void *Ptr = reinterpret_cast<char *>(::operator new(OpSize + Size)) + OpSize;
   MDOperand *O = static_cast<MDOperand *>(Ptr);
   for (MDOperand *E = O - NumOps; O != E; --O)
@@ -453,7 +453,7 @@ void *MDNode::operator new(size_t Size,
 void MDNode::operator delete(void *Mem) {
   MDNode *N = static_cast<MDNode *>(Mem);
   size_t OpSize = N->NumOperands * sizeof(MDOperand);
-  OpSize = alignTo(OpSize, llvm::alignOf<uint64_t>());
+  OpSize = alignTo(OpSize, alignof(uint64_t));
 
   MDOperand *O = static_cast<MDOperand *>(Mem);
   for (MDOperand *E = O - N->NumOperands; O != E; --O)

Modified: llvm/trunk/lib/IR/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Type.cpp?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Type.cpp (original)
+++ llvm/trunk/lib/IR/Type.cpp Thu Oct 20 10:02:18 2016
@@ -296,9 +296,9 @@ FunctionType *FunctionType::get(Type *Re
   FunctionType *FT;
 
   if (I == pImpl->FunctionTypes.end()) {
-    FT = (FunctionType*) pImpl->TypeAllocator.
-      Allocate(sizeof(FunctionType) + sizeof(Type*) * (Params.size() + 1),
-               AlignOf<FunctionType>::Alignment);
+    FT = (FunctionType *)pImpl->TypeAllocator.Allocate(
+        sizeof(FunctionType) + sizeof(Type *) * (Params.size() + 1),
+        alignof(FunctionType));
     new (FT) FunctionType(ReturnType, Params, isVarArg);
     pImpl->FunctionTypes.insert(FT);
   } else {

Modified: llvm/trunk/lib/IR/User.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/User.cpp?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/lib/IR/User.cpp (original)
+++ llvm/trunk/lib/IR/User.cpp Thu Oct 20 10:02:18 2016
@@ -43,10 +43,9 @@ void User::replaceUsesOfWith(Value *From
 void User::allocHungoffUses(unsigned N, bool IsPhi) {
   assert(HasHungOffUses && "alloc must have hung off uses");
 
-  static_assert(AlignOf<Use>::Alignment >= AlignOf<Use::UserRef>::Alignment,
+  static_assert(alignof(Use) >= alignof(Use::UserRef),
                 "Alignment is insufficient for 'hung-off-uses' pieces");
-  static_assert(AlignOf<Use::UserRef>::Alignment >=
-                    AlignOf<BasicBlock *>::Alignment,
+  static_assert(alignof(Use::UserRef) >= alignof(BasicBlock *),
                 "Alignment is insufficient for 'hung-off-uses' pieces");
 
   // Allocate the array of Uses, followed by a pointer (with bottom bit set) to

Modified: llvm/trunk/lib/MC/MCSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSymbol.cpp?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCSymbol.cpp (original)
+++ llvm/trunk/lib/MC/MCSymbol.cpp Thu Oct 20 10:02:18 2016
@@ -31,10 +31,9 @@ void *MCSymbol::operator new(size_t s, c
   // For safety, ensure that the alignment of a pointer is enough for an
   // MCSymbol.  This also ensures we don't need padding between the name and
   // symbol.
-  static_assert((unsigned)AlignOf<MCSymbol>::Alignment <=
-                AlignOf<NameEntryStorageTy>::Alignment,
+  static_assert((unsigned)alignof(MCSymbol) <= alignof(NameEntryStorageTy),
                 "Bad alignment of MCSymbol");
-  void *Storage = Ctx.allocate(Size, alignOf<NameEntryStorageTy>());
+  void *Storage = Ctx.allocate(Size, alignof(NameEntryStorageTy));
   NameEntryStorageTy *Start = static_cast<NameEntryStorageTy*>(Storage);
   NameEntryStorageTy *End = Start + (Name ? 1 : 0);
   return End;

Modified: llvm/trunk/lib/ProfileData/InstrProfReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProfReader.cpp?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/InstrProfReader.cpp (original)
+++ llvm/trunk/lib/ProfileData/InstrProfReader.cpp Thu Oct 20 10:02:18 2016
@@ -289,7 +289,7 @@ Error RawInstrProfReader<IntPtrT>::readN
   if (CurrentPos + sizeof(RawInstrProf::Header) > End)
     return make_error<InstrProfError>(instrprof_error::malformed);
   // The writer ensures each profile is padded to start at an aligned address.
-  if (reinterpret_cast<size_t>(CurrentPos) % alignOf<uint64_t>())
+  if (reinterpret_cast<size_t>(CurrentPos) % alignof(uint64_t))
     return make_error<InstrProfError>(instrprof_error::malformed);
   // The magic should have the same byte order as in the previous header.
   uint64_t Magic = *reinterpret_cast<const uint64_t *>(CurrentPos);

Modified: llvm/trunk/unittests/Support/TrailingObjectsTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/TrailingObjectsTest.cpp?rev=284733&r1=284732&r2=284733&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/TrailingObjectsTest.cpp (original)
+++ llvm/trunk/unittests/Support/TrailingObjectsTest.cpp Thu Oct 20 10:02:18 2016
@@ -112,20 +112,16 @@ TEST(TrailingObjects, OneArg) {
   EXPECT_EQ(Class1::additionalSizeToAlloc<short>(1), sizeof(short));
   EXPECT_EQ(Class1::additionalSizeToAlloc<short>(3), sizeof(short) * 3);
 
-  EXPECT_EQ(
-      llvm::alignOf<Class1>(),
-      llvm::alignOf<Class1::FixedSizeStorage<short>::with_counts<1>::type>());
+  EXPECT_EQ(alignof(Class1),
+            alignof(Class1::FixedSizeStorage<short>::with_counts<1>::type));
   EXPECT_EQ(sizeof(Class1::FixedSizeStorage<short>::with_counts<1>::type),
-            llvm::alignTo(Class1::totalSizeToAlloc<short>(1),
-                          llvm::alignOf<Class1>()));
+            llvm::alignTo(Class1::totalSizeToAlloc<short>(1), alignof(Class1)));
   EXPECT_EQ(Class1::totalSizeToAlloc<short>(1), sizeof(Class1) + sizeof(short));
 
-  EXPECT_EQ(
-      llvm::alignOf<Class1>(),
-      llvm::alignOf<Class1::FixedSizeStorage<short>::with_counts<3>::type>());
+  EXPECT_EQ(alignof(Class1),
+            alignof(Class1::FixedSizeStorage<short>::with_counts<3>::type));
   EXPECT_EQ(sizeof(Class1::FixedSizeStorage<short>::with_counts<3>::type),
-            llvm::alignTo(Class1::totalSizeToAlloc<short>(3),
-                          llvm::alignOf<Class1>()));
+            llvm::alignTo(Class1::totalSizeToAlloc<short>(3), alignof(Class1)));
   EXPECT_EQ(Class1::totalSizeToAlloc<short>(3),
             sizeof(Class1) + sizeof(short) * 3);
 
@@ -139,9 +135,8 @@ TEST(TrailingObjects, TwoArg) {
   Class2 *C1 = Class2::create(4);
   Class2 *C2 = Class2::create(0, 4.2);
 
-  EXPECT_EQ(sizeof(Class2),
-            llvm::alignTo(sizeof(bool) * 2, llvm::alignOf<double>()));
-  EXPECT_EQ(llvm::alignOf<Class2>(), llvm::alignOf<double>());
+  EXPECT_EQ(sizeof(Class2), llvm::alignTo(sizeof(bool) * 2, alignof(double)));
+  EXPECT_EQ(alignof(Class2), alignof(double));
 
   EXPECT_EQ((Class2::additionalSizeToAlloc<double, short>(1, 0)),
             sizeof(double));
@@ -151,13 +146,13 @@ TEST(TrailingObjects, TwoArg) {
             sizeof(double) * 3 + sizeof(short));
 
   EXPECT_EQ(
-      llvm::alignOf<Class2>(),
-      (llvm::alignOf<
-          Class2::FixedSizeStorage<double, short>::with_counts<1, 1>::type>()));
+      alignof(Class2),
+      (alignof(
+          Class2::FixedSizeStorage<double, short>::with_counts<1, 1>::type)));
   EXPECT_EQ(
       sizeof(Class2::FixedSizeStorage<double, short>::with_counts<1, 1>::type),
       llvm::alignTo(Class2::totalSizeToAlloc<double, short>(1, 1),
-                    llvm::alignOf<Class2>()));
+                    alignof(Class2)));
   EXPECT_EQ((Class2::totalSizeToAlloc<double, short>(1, 1)),
             sizeof(Class2) + sizeof(double) + sizeof(short));
 
@@ -191,16 +186,17 @@ class Class3 final : public TrailingObje
 TEST(TrailingObjects, ThreeArg) {
   EXPECT_EQ((Class3::additionalSizeToAlloc<double, short, bool>(1, 1, 3)),
             sizeof(double) + sizeof(short) + 3 * sizeof(bool));
-  EXPECT_EQ(sizeof(Class3), llvm::alignTo(1, llvm::alignOf<double>()));
+  EXPECT_EQ(sizeof(Class3), llvm::alignTo(1, alignof(double)));
 
-  EXPECT_EQ(llvm::alignOf<Class3>(),
-            (llvm::alignOf<Class3::FixedSizeStorage<
-                 double, short, bool>::with_counts<1, 1, 3>::type>()));
+  EXPECT_EQ(
+      alignof(Class3),
+      (alignof(Class3::FixedSizeStorage<double, short,
+                                        bool>::with_counts<1, 1, 3>::type)));
   EXPECT_EQ(
       sizeof(Class3::FixedSizeStorage<double, short,
                                       bool>::with_counts<1, 1, 3>::type),
       llvm::alignTo(Class3::totalSizeToAlloc<double, short, bool>(1, 1, 3),
-                    llvm::alignOf<Class3>()));
+                    alignof(Class3)));
 
   std::unique_ptr<char[]> P(new char[1000]);
   Class3 *C = reinterpret_cast<Class3 *>(P.get());
@@ -221,23 +217,22 @@ class Class4 final : public TrailingObje
 
 TEST(TrailingObjects, Realignment) {
   EXPECT_EQ((Class4::additionalSizeToAlloc<char, long>(1, 1)),
-            llvm::alignTo(sizeof(long) + 1, llvm::alignOf<long>()));
-  EXPECT_EQ(sizeof(Class4), llvm::alignTo(1, llvm::alignOf<long>()));
+            llvm::alignTo(sizeof(long) + 1, alignof(long)));
+  EXPECT_EQ(sizeof(Class4), llvm::alignTo(1, alignof(long)));
 
   EXPECT_EQ(
-      llvm::alignOf<Class4>(),
-      (llvm::alignOf<
-          Class4::FixedSizeStorage<char, long>::with_counts<1, 1>::type>()));
+      alignof(Class4),
+      (alignof(Class4::FixedSizeStorage<char, long>::with_counts<1, 1>::type)));
   EXPECT_EQ(
       sizeof(Class4::FixedSizeStorage<char, long>::with_counts<1, 1>::type),
       llvm::alignTo(Class4::totalSizeToAlloc<char, long>(1, 1),
-                    llvm::alignOf<Class4>()));
+                    alignof(Class4)));
 
   std::unique_ptr<char[]> P(new char[1000]);
   Class4 *C = reinterpret_cast<Class4 *>(P.get());
   EXPECT_EQ(C->getTrailingObjects<char>(), reinterpret_cast<char *>(C + 1));
   EXPECT_EQ(C->getTrailingObjects<long>(),
             reinterpret_cast<long *>(llvm::alignAddr(
-                reinterpret_cast<char *>(C + 1) + 1, llvm::alignOf<long>())));
+                reinterpret_cast<char *>(C + 1) + 1, alignof(long))));
 }
 }




More information about the llvm-commits mailing list