diff --git a/llvm/include/llvm/IR/DataLayout.h b/llvm/include/llvm/IR/DataLayout.h --- a/llvm/include/llvm/IR/DataLayout.h +++ b/llvm/include/llvm/IR/DataLayout.h @@ -518,7 +518,7 @@ /// Returns the minimum ABI-required alignment for the specified type. /// FIXME: Deprecate this function once migration to Align is over. - unsigned getABITypeAlignment(Type *Ty) const; + uint64_t getABITypeAlignment(Type *Ty) const; /// Returns the minimum ABI-required alignment for the specified type. Align getABITypeAlign(Type *Ty) const; @@ -541,7 +541,7 @@ /// /// This is always at least as good as the ABI alignment. /// FIXME: Deprecate this function once migration to Align is over. - unsigned getPrefTypeAlignment(Type *Ty) const; + uint64_t getPrefTypeAlignment(Type *Ty) const; /// Returns the preferred stack/global alignment for the specified /// type. diff --git a/llvm/include/llvm/IR/GlobalObject.h b/llvm/include/llvm/IR/GlobalObject.h --- a/llvm/include/llvm/IR/GlobalObject.h +++ b/llvm/include/llvm/IR/GlobalObject.h @@ -68,7 +68,7 @@ GlobalObject(const GlobalObject &) = delete; /// FIXME: Remove this function once transition to Align is over. - unsigned getAlignment() const { + uint64_t getAlignment() const { MaybeAlign Align = getAlign(); return Align ? Align->value() : 0; } diff --git a/llvm/include/llvm/IR/Instruction.h b/llvm/include/llvm/IR/Instruction.h --- a/llvm/include/llvm/IR/Instruction.h +++ b/llvm/include/llvm/IR/Instruction.h @@ -59,11 +59,11 @@ // Template alias so that all Instruction storing alignment use the same // definiton. // Valid alignments are powers of two from 2^0 to 2^MaxAlignmentExponent = - // 2^30. We store them as Log2(Alignment), so we need 5 bits to encode the 31 + // 2^32. We store them as Log2(Alignment), so we need 6 bits to encode the 33 // possible values. template using AlignmentBitfieldElementT = - typename Bitfield::Element; template diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h --- a/llvm/include/llvm/IR/Instructions.h +++ b/llvm/include/llvm/IR/Instructions.h @@ -126,7 +126,7 @@ } // FIXME: Remove this one transition to Align is over. - unsigned getAlignment() const { return getAlign().value(); } + uint64_t getAlignment() const { return getAlign().value(); } /// Return true if this alloca is in the entry block of the function and is a /// constant size. If so, the code generator will fold it into the @@ -217,7 +217,7 @@ /// Return the alignment of the access that is being performed. /// FIXME: Remove this function once transition to Align is over. /// Use getAlign() instead. - unsigned getAlignment() const { return getAlign().value(); } + uint64_t getAlignment() const { return getAlign().value(); } /// Return the alignment of the access that is being performed. Align getAlign() const { @@ -348,7 +348,7 @@ /// Return the alignment of the access that is being performed /// FIXME: Remove this function once transition to Align is over. /// Use getAlign() instead. - unsigned getAlignment() const { return getAlign().value(); } + uint64_t getAlignment() const { return getAlign().value(); } Align getAlign() const { return Align(1ULL << (getSubclassData())); diff --git a/llvm/include/llvm/IR/Value.h b/llvm/include/llvm/IR/Value.h --- a/llvm/include/llvm/IR/Value.h +++ b/llvm/include/llvm/IR/Value.h @@ -785,8 +785,8 @@ /// /// This is the greatest alignment value supported by load, store, and alloca /// instructions, and global values. - static constexpr unsigned MaxAlignmentExponent = 30; - static constexpr unsigned MaximumAlignment = 1u << MaxAlignmentExponent; + static constexpr uint64_t MaxAlignmentExponent = 32; + static constexpr uint64_t MaximumAlignment = 1ULL << MaxAlignmentExponent; /// Mutate the type of this Value to be of the specified type. /// diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h --- a/llvm/include/llvm/Transforms/IPO/Attributor.h +++ b/llvm/include/llvm/Transforms/IPO/Attributor.h @@ -3413,7 +3413,7 @@ }; using AAAlignmentStateType = - IncIntegerState; + IncIntegerState; /// An abstract interface for all align attributes. struct AAAlign : public IRAttribute< Attribute::Alignment, @@ -3421,10 +3421,10 @@ AAAlign(const IRPosition &IRP, Attributor &A) : IRAttribute(IRP) {} /// Return assumed alignment. - unsigned getAssumedAlign() const { return getAssumed(); } + uint64_t getAssumedAlign() const { return getAssumed(); } /// Return known alignment. - unsigned getKnownAlign() const { return getKnown(); } + uint64_t getKnownAlign() const { return getKnown(); } /// See AbstractAttribute::getName() const std::string getName() const override { return "AAAlign"; } diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -1927,7 +1927,7 @@ if (!EatIfPresent(lltok::kw_align)) return false; LocTy AlignLoc = Lex.getLoc(); - uint32_t Value = 0; + uint64_t Value = 0; LocTy ParenLoc = Lex.getLoc(); bool HaveParens = false; @@ -1936,13 +1936,13 @@ HaveParens = true; } - if (parseUInt32(Value)) + if (parseUInt64(Value)) return true; if (HaveParens && !EatIfPresent(lltok::rparen)) return error(ParenLoc, "expected ')'"); - if (!isPowerOf2_32(Value)) + if (!isPowerOf2_64(Value)) return error(AlignLoc, "alignment is not a power of two"); if (Value > Value::MaximumAlignment) return error(AlignLoc, "huge alignments are not supported yet"); diff --git a/llvm/lib/CodeGen/SafeStack.cpp b/llvm/lib/CodeGen/SafeStack.cpp --- a/llvm/lib/CodeGen/SafeStack.cpp +++ b/llvm/lib/CodeGen/SafeStack.cpp @@ -147,7 +147,7 @@ /// /// 16 seems like a reasonable upper bound on the alignment of objects that we /// might expect to appear on the stack on most common targets. - enum { StackAlignment = 16 }; + static constexpr uint64_t StackAlignment = 16; /// Return the value of the stack canary. Value *getStackGuard(IRBuilder<> &IRB, Function &F); @@ -544,8 +544,7 @@ Size = 1; // Don't create zero-sized stack objects. // Ensure the object is properly aligned. - unsigned Align = - std::max((unsigned)DL.getPrefTypeAlignment(Ty), AI->getAlignment()); + uint64_t Align = std::max(DL.getPrefTypeAlignment(Ty), AI->getAlignment()); SSL.addObject(AI, Size, Align, ClColoring ? SSC.getLiveRange(AI) : NoColoringRange); @@ -676,9 +675,9 @@ SP = IRB.CreateSub(SP, Size); // Align the SP value to satisfy the AllocaInst, type and stack alignments. - unsigned Align = std::max( - std::max((unsigned)DL.getPrefTypeAlignment(Ty), AI->getAlignment()), - (unsigned)StackAlignment); + uint64_t Align = + std::max(std::max(DL.getPrefTypeAlignment(Ty), AI->getAlignment()), + StackAlignment); assert(isPowerOf2_32(Align)); Value *NewTop = IRB.CreateIntToPtr( diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp --- a/llvm/lib/IR/DataLayout.cpp +++ b/llvm/lib/IR/DataLayout.cpp @@ -819,7 +819,7 @@ } /// TODO: Remove this function once the transition to Align is over. -unsigned DataLayout::getABITypeAlignment(Type *Ty) const { +uint64_t DataLayout::getABITypeAlignment(Type *Ty) const { return getABITypeAlign(Ty).value(); } @@ -828,7 +828,7 @@ } /// TODO: Remove this function once the transition to Align is over. -unsigned DataLayout::getPrefTypeAlignment(Type *Ty) const { +uint64_t DataLayout::getPrefTypeAlignment(Type *Ty) const { return getPrefTypeAlign(Ty).value(); } diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -176,7 +176,7 @@ // Accesses sizes are powers of two: 1, 2, 4, 8, 16. static const size_t kNumberOfAccessSizes = 5; -static const unsigned kAllocaRzSize = 32; +static const uint64_t kAllocaRzSize = 32; // ASanAccessInfo implementation constants. constexpr size_t kCompileKernelShift = 0; @@ -3577,7 +3577,7 @@ void FunctionStackPoisoner::handleDynamicAllocaCall(AllocaInst *AI) { IRBuilder<> IRB(AI); - const unsigned Alignment = std::max(kAllocaRzSize, AI->getAlignment()); + const uint64_t Alignment = std::max(kAllocaRzSize, AI->getAlignment()); const uint64_t AllocaRedzoneMask = kAllocaRzSize - 1; Value *Zero = Constant::getNullValue(IntptrTy); diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp @@ -356,7 +356,7 @@ bool WithFrameRecord; void init(Triple &TargetTriple, bool InstrumentWithCalls); - unsigned getObjectAlignment() const { return 1U << Scale; } + uint64_t getObjectAlignment() const { return 1ULL << Scale; } }; ShadowMapping Mapping; diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -1349,14 +1349,15 @@ "getOrEnforceKnownAlignment expects a pointer!"); KnownBits Known = computeKnownBits(V, DL, 0, AC, CxtI, DT); - unsigned TrailZ = Known.countMinTrailingZeros(); + uint64_t TrailZ = Known.countMinTrailingZeros(); // Avoid trouble with ridiculously large TrailZ values, such as // those computed from a null pointer. // LLVM doesn't support alignments larger than (1 << MaxAlignmentExponent). TrailZ = std::min(TrailZ, +Value::MaxAlignmentExponent); - Align Alignment = Align(1ull << std::min(Known.getBitWidth() - 1, TrailZ)); + Align Alignment = + Align(1ull << std::min(uint64_t(Known.getBitWidth() - 1), TrailZ)); if (PrefAlign && *PrefAlign > Alignment) Alignment = std::max(Alignment, tryEnforceAlignment(V, *PrefAlign, DL));