diff --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h --- a/clang/lib/CodeGen/Address.h +++ b/clang/lib/CodeGen/Address.h @@ -25,12 +25,7 @@ // Indicates whether a pointer is known not to be null. enum KnownNonNull_t { NotKnownNonNull, KnownNonNull }; -// We try to save some space by using 6 bits over two PointerIntPairs to store -// the alignment. However, some arches don't support 3 bits in a PointerIntPair -// so we fallback to storing the alignment separately. -template = 8> class AddressImpl {}; - -template class AddressImpl { +class AddressImpl { llvm::PointerIntPair PointerAndKnownNonNull; llvm::Type *ElementType; CharUnits Alignment; @@ -51,45 +46,9 @@ void setKnownNonNull() { PointerAndKnownNonNull.setInt(true); } }; -template class AddressImpl { - // Int portion stores the non-null bit and the upper 2 bits of the log of the - // alignment. - llvm::PointerIntPair Pointer; - // Int portion stores lower 3 bits of the log of the alignment. - llvm::PointerIntPair ElementType; - -public: - AddressImpl(llvm::Value *Pointer, llvm::Type *ElementType, - CharUnits Alignment, KnownNonNull_t IsKnownNonNull) - : Pointer(Pointer), ElementType(ElementType) { - if (Alignment.isZero()) { - this->Pointer.setInt(IsKnownNonNull << 2); - return; - } - // Currently the max supported alignment is exactly 1 << 32 and is - // guaranteed to be a power of 2, so we can store the log of the alignment - // into 5 bits. - assert(Alignment.isPowerOfTwo() && "Alignment cannot be zero"); - auto AlignLog = llvm::Log2_64(Alignment.getQuantity()); - assert(AlignLog < (1 << 5) && "cannot fit alignment into 5 bits"); - this->Pointer.setInt(IsKnownNonNull << 2 | AlignLog >> 3); - this->ElementType.setInt(AlignLog & 7); - } - llvm::Value *getPointer() const { return Pointer.getPointer(); } - llvm::Type *getElementType() const { return ElementType.getPointer(); } - CharUnits getAlignment() const { - unsigned AlignLog = ((Pointer.getInt() & 0x3) << 3) | ElementType.getInt(); - return CharUnits::fromQuantity(CharUnits::QuantityType(1) << AlignLog); - } - KnownNonNull_t isKnownNonNull() const { - return (KnownNonNull_t)(!!(Pointer.getInt() & 0x4)); - } - void setKnownNonNull() { Pointer.setInt(Pointer.getInt() | 0x4); } -}; - /// An aligned address. class Address { - AddressImpl A; + AddressImpl A; protected: Address(std::nullptr_t)