[PATCH] Use new getPointerTypeSizeInBits in DataLayout
Eli Friedman
eli.friedman at gmail.com
Mon Jul 22 18:42:22 PDT 2013
I'm not sure what the point of the change to DataLayout::getIntPtrType is.
The other change is fine, I guess... but it's missing a test.
On Mon, Jul 22, 2013 at 6:02 PM, Matt Arsenault
<Matthew.Arsenault at amd.com> wrote:
> Use new function added by http://llvm-reviews.chandlerc.com/D1197
>
> http://llvm-reviews.chandlerc.com/D1198
>
> Files:
> lib/IR/DataLayout.cpp
> lib/Transforms/Utils/Local.cpp
>
> Index: lib/IR/DataLayout.cpp
> ===================================================================
> --- lib/IR/DataLayout.cpp
> +++ lib/IR/DataLayout.cpp
> @@ -618,7 +618,7 @@
> Type *DataLayout::getIntPtrType(Type *Ty) const {
> assert(Ty->isPtrOrPtrVectorTy() &&
> "Expected a pointer or pointer vector type.");
> - unsigned NumBits = getTypeSizeInBits(Ty->getScalarType());
> + unsigned NumBits = getPointerTypeSizeInBits(Ty);
> IntegerType *IntTy = IntegerType::get(Ty->getContext(), NumBits);
> if (VectorType *VecTy = dyn_cast<VectorType>(Ty))
> return VectorType::get(IntTy, VecTy->getNumElements());
> Index: lib/Transforms/Utils/Local.cpp
> ===================================================================
> --- lib/Transforms/Utils/Local.cpp
> +++ lib/Transforms/Utils/Local.cpp
> @@ -928,12 +928,12 @@
> /// and it is more than the alignment of the ultimate object, see if we can
> /// increase the alignment of the ultimate object, making this check succeed.
> unsigned llvm::getOrEnforceKnownAlignment(Value *V, unsigned PrefAlign,
> - const DataLayout *TD) {
> + const DataLayout *DL) {
> assert(V->getType()->isPointerTy() &&
> "getOrEnforceKnownAlignment expects a pointer!");
> - unsigned BitWidth = TD ? TD->getPointerSizeInBits() : 64;
> + unsigned BitWidth = DL ? DL->getPointerTypeSizeInBits(V) : 64;
> APInt KnownZero(BitWidth, 0), KnownOne(BitWidth, 0);
> - ComputeMaskedBits(V, KnownZero, KnownOne, TD);
> + ComputeMaskedBits(V, KnownZero, KnownOne, DL);
> unsigned TrailZ = KnownZero.countTrailingOnes();
>
> // Avoid trouble with rediculously large TrailZ values, such as
> @@ -946,7 +946,7 @@
> Align = std::min(Align, +Value::MaximumAlignment);
>
> if (PrefAlign > Align)
> - Align = enforceKnownAlignment(V, Align, PrefAlign, TD);
> + Align = enforceKnownAlignment(V, Align, PrefAlign, DL);
>
> // We don't need to make any adjustment.
> return Align;
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list