[PATCH] Teach getOrEnforceKnownAlignment about address spaces

Matt Arsenault Matthew.Arsenault at amd.com
Thu Aug 1 14:24:32 PDT 2013


This is required for http://llvm-reviews.chandlerc.com/D1250

I also don't have a test for this until other pieces are in

http://llvm-reviews.chandlerc.com/D1263

Files:
  lib/Transforms/Utils/Local.cpp

Index: lib/Transforms/Utils/Local.cpp
===================================================================
--- lib/Transforms/Utils/Local.cpp
+++ lib/Transforms/Utils/Local.cpp
@@ -928,12 +928,13 @@
 /// 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->getType()) : 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 ridiculously large TrailZ values, such as
@@ -946,7 +947,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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1263.1.patch
Type: text/x-patch
Size: 1366 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130801/d70cd3e7/attachment.bin>


More information about the llvm-commits mailing list