Make DataLayout Non-Optional in the Module
[oota-llvm.git] / lib / Analysis / Loads.cpp
index aaaf75f3015c8bed1be78f439a92d2b3f005ca57..315a42ef37692e7bd5b2777113efd8eead356ac1 100644 (file)
@@ -179,11 +179,10 @@ Value *llvm::FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB,
 
   // Try to get the DataLayout for this module. This may be null, in which case
   // the optimizations will be limited.
-  const DataLayout *DL = ScanBB->getModule()->getDataLayout();
+  const DataLayout &DL = ScanBB->getModule()->getDataLayout();
 
   // Try to get the store size for the type.
-  uint64_t AccessSize = DL ? DL->getTypeStoreSize(AccessTy)
-                           : AA ? AA->getTypeStoreSize(AccessTy) : 0;
+  uint64_t AccessSize = DL.getTypeStoreSize(AccessTy);
 
   Value *StrippedPtr = Ptr->stripPointerCasts();
 
@@ -208,7 +207,7 @@ Value *llvm::FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB,
     if (LoadInst *LI = dyn_cast<LoadInst>(Inst))
       if (AreEquivalentAddressValues(
               LI->getPointerOperand()->stripPointerCasts(), StrippedPtr) &&
-          CastInst::isBitOrNoopPointerCastable(LI->getType(), AccessTy, DL)) {
+          CastInst::isBitOrNoopPointerCastable(LI->getType(), AccessTy, &DL)) {
         if (AATags)
           LI->getAAMetadata(*AATags);
         return LI;
@@ -221,7 +220,7 @@ Value *llvm::FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB,
       // those cases are unlikely.)
       if (AreEquivalentAddressValues(StorePtr, StrippedPtr) &&
           CastInst::isBitOrNoopPointerCastable(SI->getValueOperand()->getType(),
-                                               AccessTy, DL)) {
+                                               AccessTy, &DL)) {
         if (AATags)
           SI->getAAMetadata(*AATags);
         return SI->getOperand(0);