Index: include/llvm/Support/MathExtras.h =================================================================== --- include/llvm/Support/MathExtras.h +++ include/llvm/Support/MathExtras.h @@ -687,6 +687,12 @@ return (Value + Align - 1) / Align * Align; } +inline uint64_t alignToPowerOf2(uint64_t Value, uint64_t Align) { + assert(Align != 0 && (Align & Align - 1) == 0 && + "Align must be a power of 2"); + return (Value + Align - 1) & -Align; +} + /// Returns the integer ceil(Numerator / Denominator). inline uint64_t divideCeil(uint64_t Numerator, uint64_t Denominator) { return alignTo(Numerator, Denominator) / Denominator;