Add in the first iteration of support for llvm/clang/lldb to allow variable per addre...
[oota-llvm.git] / lib / Transforms / Utils / Local.cpp
index a954d82c05bfe89e90d91c6ef8426db811792c0e..9729687a83eff584d3aaf1d630ef2ef4ac6c2382 100644 (file)
@@ -806,7 +806,8 @@ unsigned llvm::getOrEnforceKnownAlignment(Value *V, unsigned PrefAlign,
                                           const DataLayout *TD) {
   assert(V->getType()->isPointerTy() &&
          "getOrEnforceKnownAlignment expects a pointer!");
-  unsigned BitWidth = TD ? TD->getPointerSizeInBits() : 64;
+  unsigned AS = cast<PointerType>(V->getType())->getAddressSpace();
+  unsigned BitWidth = TD ? TD->getPointerSizeInBits(AS) : 64;
   APInt KnownZero(BitWidth, 0), KnownOne(BitWidth, 0);
   ComputeMaskedBits(V, KnownZero, KnownOne, TD);
   unsigned TrailZ = KnownZero.countTrailingOnes();