summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2016-10-20 15:02:18 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2016-10-20 15:02:18 +0000
commitcb58e1e3bce2898afcd189005154089f4211b005 (patch)
tree8b703ea8f4675edcfd8ac8c9dc2ebe9dcfc6a552
parent2913220dd601f5593de5c88a52fd07018885e738 (diff)
Retire llvm::alignOf in favor of C++11 alignof.
No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284733 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/ADT/IntervalMap.h2
-rw-r--r--include/llvm/ADT/StringMap.h2
-rw-r--r--include/llvm/CodeGen/LiveInterval.h1
-rw-r--r--include/llvm/CodeGen/SelectionDAG.h4
-rw-r--r--include/llvm/CodeGen/SlotIndexes.h5
-rw-r--r--include/llvm/IR/DerivedTypes.h2
-rw-r--r--include/llvm/IR/User.h5
-rw-r--r--include/llvm/Object/ELF.h2
-rw-r--r--include/llvm/Support/Allocator.h9
-rw-r--r--include/llvm/Support/ArrayRecycler.h5
-rw-r--r--include/llvm/Support/Endian.h3
-rw-r--r--include/llvm/Support/OnDiskHashTable.h3
-rw-r--r--include/llvm/Support/PointerLikeTypeTraits.h6
-rw-r--r--include/llvm/Support/Recycler.h5
-rw-r--r--include/llvm/Support/RecyclingAllocator.h4
-rw-r--r--include/llvm/Support/TrailingObjects.h28
-rw-r--r--include/llvm/Transforms/Utils/SSAUpdaterImpl.h5
-rw-r--r--lib/Analysis/GlobalsModRef.cpp2
-rw-r--r--lib/CodeGen/MachineSSAUpdater.cpp1
-rw-r--r--lib/IR/Metadata.cpp6
-rw-r--r--lib/IR/Type.cpp6
-rw-r--r--lib/IR/User.cpp5
-rw-r--r--lib/MC/MCSymbol.cpp5
-rw-r--r--lib/ProfileData/InstrProfReader.cpp2
-rw-r--r--unittests/Support/TrailingObjectsTest.cpp53
25 files changed, 73 insertions, 98 deletions
diff --git a/include/llvm/ADT/IntervalMap.h b/include/llvm/ADT/IntervalMap.h
index f8843b2a4e5..cd721f8e783 100644
--- a/include/llvm/ADT/IntervalMap.h
+++ b/include/llvm/ADT/IntervalMap.h
@@ -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();
}
diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h
index 5c048b174dc..8bb7ef05b96 100644
--- a/include/llvm/ADT/StringMap.h
+++ b/include/llvm/ADT/StringMap.h
@@ -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));
diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h
index 278bd764483..b3e72dc5463 100644
--- a/include/llvm/CodeGen/LiveInterval.h
+++ b/include/llvm/CodeGen/LiveInterval.h
@@ -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>
diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h
index 4367bf10ce3..6cc1f5095fa 100644
--- a/include/llvm/CodeGen/SelectionDAG.h
+++ b/include/llvm/CodeGen/SelectionDAG.h
@@ -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;
diff --git a/include/llvm/CodeGen/SlotIndexes.h b/include/llvm/CodeGen/SlotIndexes.h
index f6cacae9ea0..984b5f3eed4 100644
--- a/include/llvm/CodeGen/SlotIndexes.h
+++ b/include/llvm/CodeGen/SlotIndexes.h
@@ -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);
diff --git a/include/llvm/IR/DerivedTypes.h b/include/llvm/IR/DerivedTypes.h
index a59049b22e8..7459d06f56d 100644
--- a/include/llvm/IR/DerivedTypes.h
+++ b/include/llvm/IR/DerivedTypes.h
@@ -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 {
diff --git a/include/llvm/IR/User.h b/include/llvm/IR/User.h
index 4d6b30cd112..c628c82cbed 100644
--- a/include/llvm/IR/User.h
+++ b/include/llvm/IR/User.h
@@ -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> {
diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h
index b7ae0012177..7aee6b17574 100644
--- a/include/llvm/Object/ELF.h
+++ b/include/llvm/Object/ELF.h
@@ -337,7 +337,7 @@ ELFFile<ELFT>::ELFFile(StringRef Object, std::error_code &EC)
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;
diff --git a/include/llvm/Support/Allocator.h b/include/llvm/Support/Allocator.h
index 1c9508661d6..023c94cb663 100644
--- a/include/llvm/Support/Allocator.h
+++ b/include/llvm/Support/Allocator.h
@@ -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();
diff --git a/include/llvm/Support/ArrayRecycler.h b/include/llvm/Support/ArrayRecycler.h
index 36f644af288..4698f12b3bb 100644
--- a/include/llvm/Support/ArrayRecycler.h
+++ b/include/llvm/Support/ArrayRecycler.h
@@ -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.
diff --git a/include/llvm/Support/Endian.h b/include/llvm/Support/Endian.h
index cb5cd8e511b..cbe3d67b1f9 100644
--- a/include/llvm/Support/Endian.h
+++ b/include/llvm/Support/Endian.h
@@ -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
diff --git a/include/llvm/Support/OnDiskHashTable.h b/include/llvm/Support/OnDiskHashTable.h
index c28fcabe78f..e9c28daf03b 100644
--- a/include/llvm/Support/OnDiskHashTable.h
+++ b/include/llvm/Support/OnDiskHashTable.h
@@ -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);
diff --git a/include/llvm/Support/PointerLikeTypeTraits.h b/include/llvm/Support/PointerLikeTypeTraits.h
index 96cdaed142c..9ff894edbeb 100644
--- a/include/llvm/Support/PointerLikeTypeTraits.h
+++ b/include/llvm/Support/PointerLikeTypeTraits.h
@@ -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 *> {
diff --git a/include/llvm/Support/Recycler.h b/include/llvm/Support/Recycler.h
index a38050d8190..1523aad38d4 100644
--- a/include/llvm/Support/Recycler.h
+++ b/include/llvm/Support/Recycler.h
@@ -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, size_t Align, size_t FreeListSize);
/// 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!");
diff --git a/include/llvm/Support/RecyclingAllocator.h b/include/llvm/Support/RecyclingAllocator.h
index 001d1cf7c3d..32b033b1794 100644
--- a/include/llvm/Support/RecyclingAllocator.h
+++ b/include/llvm/Support/RecyclingAllocator.h
@@ -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.
diff --git a/include/llvm/Support/TrailingObjects.h b/include/llvm/Support/TrailingObjects.h
index 427ae1cb3f6..316307ac762 100644
--- a/include/llvm/Support/TrailingObjects.h
+++ b/include/llvm/Support/TrailingObjects.h
@@ -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, TopTrailingObj, PrevTy, NextTy,
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;
};
};
diff --git a/include/llvm/Transforms/Utils/SSAUpdaterImpl.h b/include/llvm/Transforms/Utils/SSAUpdaterImpl.h
index b5f4ac82b60..b0448fed9f4 100644
--- a/include/llvm/Transforms/Utils/SSAUpdaterImpl.h
+++ b/include/llvm/Transforms/Utils/SSAUpdaterImpl.h
@@ -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];
diff --git a/lib/Analysis/GlobalsModRef.cpp b/lib/Analysis/GlobalsModRef.cpp
index d29b9703e9c..a0fa181518d 100644
--- a/lib/Analysis/GlobalsModRef.cpp
+++ b/lib/Analysis/GlobalsModRef.cpp
@@ -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.");
};
diff --git a/lib/CodeGen/MachineSSAUpdater.cpp b/lib/CodeGen/MachineSSAUpdater.cpp
index 47ad60c5dd5..e9b47559309 100644
--- a/lib/CodeGen/MachineSSAUpdater.cpp
+++ b/lib/CodeGen/MachineSSAUpdater.cpp
@@ -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"
diff --git a/lib/IR/Metadata.cpp b/lib/IR/Metadata.cpp
index 3e07b3a7c94..17aa1216b3e 100644
--- a/lib/IR/Metadata.cpp
+++ b/lib/IR/Metadata.cpp
@@ -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, unsigned NumOps) {
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, unsigned NumOps) {
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)
diff --git a/lib/IR/Type.cpp b/lib/IR/Type.cpp
index 5c97a4ea070..700f9391714 100644
--- a/lib/IR/Type.cpp
+++ b/lib/IR/Type.cpp
@@ -296,9 +296,9 @@ FunctionType *FunctionType::get(Type *ReturnType,
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 {
diff --git a/lib/IR/User.cpp b/lib/IR/User.cpp
index a75abe6938c..497b4aa1764 100644
--- a/lib/IR/User.cpp
+++ b/lib/IR/User.cpp
@@ -43,10 +43,9 @@ void User::replaceUsesOfWith(Value *From, Value *To) {
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
diff --git a/lib/MC/MCSymbol.cpp b/lib/MC/MCSymbol.cpp
index 52f053238bc..20d985df7ea 100644
--- a/lib/MC/MCSymbol.cpp
+++ b/lib/MC/MCSymbol.cpp
@@ -31,10 +31,9 @@ void *MCSymbol::operator new(size_t s, const StringMapEntry<bool> *Name,
// 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;
diff --git a/lib/ProfileData/InstrProfReader.cpp b/lib/ProfileData/InstrProfReader.cpp
index ed927a98604..ad407f07957 100644
--- a/lib/ProfileData/InstrProfReader.cpp
+++ b/lib/ProfileData/InstrProfReader.cpp
@@ -289,7 +289,7 @@ Error RawInstrProfReader<IntPtrT>::readNextHeader(const char *CurrentPos) {
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);
diff --git a/unittests/Support/TrailingObjectsTest.cpp b/unittests/Support/TrailingObjectsTest.cpp
index 65fdcb93623..cb5c47d1b25 100644
--- a/unittests/Support/TrailingObjectsTest.cpp
+++ b/unittests/Support/TrailingObjectsTest.cpp
@@ -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 TrailingObjects<Class3, double, short, bool> {
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 TrailingObjects<Class4, char, long> {
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))));
}
}