[PATCH] D13517: ValueTracking: use getAlignment in isAligned

Artur Pilipenko via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 9 09:00:25 PDT 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL249841: ValueTracking: use getAlignment in isAligned (authored by apilipenko).

Changed prior to commit:
  http://reviews.llvm.org/D13517?vs=36759&id=36956#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13517

Files:
  llvm/trunk/lib/Analysis/ValueTracking.cpp

Index: llvm/trunk/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp
@@ -2998,20 +2998,7 @@
 
 static bool isAligned(const Value *Base, APInt Offset, unsigned Align,
                       const DataLayout &DL) {
-  APInt BaseAlign(Offset.getBitWidth(), 0);
-  if (const AllocaInst *AI = dyn_cast<AllocaInst>(Base))
-    BaseAlign = AI->getAlignment();
-  else if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(Base))
-    BaseAlign = GV->getAlignment();
-  else if (const Argument *A = dyn_cast<Argument>(Base))
-    BaseAlign = A->getParamAlignment();
-  else if (auto CS = ImmutableCallSite(Base))
-    BaseAlign = CS.getAttributes().getParamAlignment(AttributeSet::ReturnIndex);
-  else if (const LoadInst *LI = dyn_cast<LoadInst>(Base))
-    if (MDNode *MD = LI->getMetadata(LLVMContext::MD_align)) {
-      ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
-      BaseAlign = CI->getLimitedValue();
-    }
+  APInt BaseAlign(Offset.getBitWidth(), getAlignment(Base, DL));
 
   if (!BaseAlign) {
     Type *Ty = Base->getType()->getPointerElementType();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13517.36956.patch
Type: text/x-patch
Size: 1223 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151009/7afef77c/attachment.bin>


More information about the llvm-commits mailing list