Index: examples/ExceptionDemo/ExceptionDemo.cpp
===================================================================
--- examples/ExceptionDemo/ExceptionDemo.cpp
+++ examples/ExceptionDemo/ExceptionDemo.cpp
@@ -1973,7 +1973,6 @@
     // Start with registering info about how the
     // target lays out data structures.
     module->setDataLayout(executionEngine->getDataLayout());
-    fpm.add(new llvm::DataLayoutPass());
 
     // Optimizations turned on
 #ifdef ADD_OPT_PASSES
Index: examples/Kaleidoscope/Chapter4/toy.cpp
===================================================================
--- examples/Kaleidoscope/Chapter4/toy.cpp
+++ examples/Kaleidoscope/Chapter4/toy.cpp
@@ -561,7 +561,6 @@
     // Set up the optimizer pipeline.  Start with registering info about how the
     // target lays out data structures.
     OpenModule->setDataLayout(NewEngine->getDataLayout());
-    FPM->add(new DataLayoutPass());
     // Provide basic AliasAnalysis support for GVN.
     FPM->add(createBasicAliasAnalysisPass());
     // Promote allocas to registers.
Index: examples/Kaleidoscope/Chapter5/toy.cpp
===================================================================
--- examples/Kaleidoscope/Chapter5/toy.cpp
+++ examples/Kaleidoscope/Chapter5/toy.cpp
@@ -914,7 +914,6 @@
   // Set up the optimizer pipeline.  Start with registering info about how the
   // target lays out data structures.
   TheModule->setDataLayout(TheExecutionEngine->getDataLayout());
-  OurFPM.add(new DataLayoutPass());
   // Provide basic AliasAnalysis support for GVN.
   OurFPM.add(createBasicAliasAnalysisPass());
   // Do simple "peephole" optimizations and bit-twiddling optzns.
Index: examples/Kaleidoscope/Chapter6/toy.cpp
===================================================================
--- examples/Kaleidoscope/Chapter6/toy.cpp
+++ examples/Kaleidoscope/Chapter6/toy.cpp
@@ -1035,7 +1035,6 @@
   // Set up the optimizer pipeline.  Start with registering info about how the
   // target lays out data structures.
   TheModule->setDataLayout(TheExecutionEngine->getDataLayout());
-  OurFPM.add(new DataLayoutPass());
   // Provide basic AliasAnalysis support for GVN.
   OurFPM.add(createBasicAliasAnalysisPass());
   // Do simple "peephole" optimizations and bit-twiddling optzns.
Index: examples/Kaleidoscope/Chapter7/toy.cpp
===================================================================
--- examples/Kaleidoscope/Chapter7/toy.cpp
+++ examples/Kaleidoscope/Chapter7/toy.cpp
@@ -1209,7 +1209,6 @@
   // Set up the optimizer pipeline.  Start with registering info about how the
   // target lays out data structures.
   TheModule->setDataLayout(TheExecutionEngine->getDataLayout());
-  OurFPM.add(new DataLayoutPass());
   // Provide basic AliasAnalysis support for GVN.
   OurFPM.add(createBasicAliasAnalysisPass());
   // Promote allocas to registers.
Index: examples/Kaleidoscope/Chapter8/toy.cpp
===================================================================
--- examples/Kaleidoscope/Chapter8/toy.cpp
+++ examples/Kaleidoscope/Chapter8/toy.cpp
@@ -1460,7 +1460,6 @@
   // Set up the optimizer pipeline.  Start with registering info about how the
   // target lays out data structures.
   TheModule->setDataLayout(TheExecutionEngine->getDataLayout());
-  OurFPM.add(new DataLayoutPass());
 #if 0
   // Provide basic AliasAnalysis support for GVN.
   OurFPM.add(createBasicAliasAnalysisPass());
Index: include/llvm/Analysis/AliasAnalysis.h
===================================================================
--- include/llvm/Analysis/AliasAnalysis.h
+++ include/llvm/Analysis/AliasAnalysis.h
@@ -68,7 +68,7 @@
   /// typically called by the run* methods of these subclasses.  This may be
   /// called multiple times.
   ///
-  void InitializeAliasAnalysis(Pass *P);
+  void InitializeAliasAnalysis(Pass *P, const DataLayout *DL);
 
   /// getAnalysisUsage - All alias analysis implementations should invoke this
   /// directly (using AliasAnalysis::getAnalysisUsage(AU)).
Index: include/llvm/Analysis/LibCallAliasAnalysis.h
===================================================================
--- include/llvm/Analysis/LibCallAliasAnalysis.h
+++ include/llvm/Analysis/LibCallAliasAnalysis.h
@@ -15,6 +15,7 @@
 #define LLVM_ANALYSIS_LIBCALLALIASANALYSIS_H
 
 #include "llvm/Analysis/AliasAnalysis.h"
+#include "llvm/IR/Module.h"
 #include "llvm/Pass.h"
 
 namespace llvm {
@@ -48,10 +49,7 @@
 
     void getAnalysisUsage(AnalysisUsage &AU) const override;
 
-    bool runOnFunction(Function &F) override {
-      InitializeAliasAnalysis(this);                 // set up super class
-      return false;
-    }
+    bool runOnFunction(Function &F) override;
     
     /// getAdjustedAnalysisPointer - This method is used when a pass implements
     /// an analysis interface through multiple inheritance.  If needed, it
Index: include/llvm/IR/DataLayout.h
===================================================================
--- include/llvm/IR/DataLayout.h
+++ include/llvm/IR/DataLayout.h
@@ -116,6 +116,9 @@
   /// \brief Primitive type alignment data.
   SmallVector<LayoutAlignElem, 16> Alignments;
 
+  /// \brief The string representation used to create this DataLayout
+  std::string StringRepresentation;
+
   typedef SmallVector<PointerAlignElem, 8> PointersTy;
   PointersTy Pointers;
 
@@ -185,6 +188,7 @@
 
   DataLayout &operator=(const DataLayout &DL) {
     clear();
+    StringRepresentation = DL.StringRepresentation;
     BigEndian = DL.isBigEndian();
     StackNaturalAlign = DL.StackNaturalAlign;
     ManglingMode = DL.ManglingMode;
@@ -209,8 +213,16 @@
   /// \brief Returns the string representation of the DataLayout.
   ///
   /// This representation is in the same format accepted by the string
-  /// constructor above.
-  std::string getStringRepresentation() const;
+  /// constructor above. This should not be used to compare two DataLayout as
+  /// different string can represent the same layout.
+  std::string getStringRepresentation() const {
+    return StringRepresentation;
+  }
+
+  /// \brief Test if the DataLayout was constructed from an empty string.
+  bool isDefault() const {
+    return StringRepresentation.empty();
+  }
 
   /// \brief Returns true if the specified type is known to be a native integer
   /// type supported by the CPU.
@@ -451,22 +463,6 @@
   return reinterpret_cast<LLVMTargetDataRef>(const_cast<DataLayout *>(P));
 }
 
-class DataLayoutPass : public ImmutablePass {
-  DataLayout DL;
-
-public:
-  /// This has to exist, because this is a pass, but it should never be used.
-  DataLayoutPass();
-  ~DataLayoutPass();
-
-  const DataLayout &getDataLayout() const { return DL; }
-
-  static char ID; // Pass identification, replacement for typeid
-
-  bool doFinalization(Module &M) override;
-  bool doInitialization(Module &M) override;
-};
-
 /// Used to lazily calculate structure layout information for a target machine,
 /// based on the DataLayout structure.
 class StructLayout {
Index: include/llvm/IR/Module.h
===================================================================
--- include/llvm/IR/Module.h
+++ include/llvm/IR/Module.h
@@ -219,14 +219,7 @@
   std::string TargetTriple;       ///< Platform target triple Module compiled on
                                   ///< Format: (arch)(sub)-(vendor)-(sys0-(abi)
   void *NamedMDSymTab;            ///< NamedMDNode names.
-
-  // We need to keep the string because the C API expects us to own the string
-  // representation.
-  // Since we have it, we also use an empty string to represent a module without
-  // a DataLayout. If it has a DataLayout, these variables are in sync and the
-  // string is just a cache of getDataLayout()->getStringRepresentation().
-  std::string DataLayoutStr;
-  DataLayout DL;
+  DataLayout DL;                  ///< DataLayout associated with the module
 
   friend class Constant;
 
@@ -256,7 +249,9 @@
 
   /// Get the data layout string for the module's target platform. This is
   /// equivalent to getDataLayout()->getStringRepresentation().
-  const std::string &getDataLayoutStr() const { return DataLayoutStr; }
+  const std::string getDataLayoutStr() const {
+    return DL.getStringRepresentation();
+  }
 
   /// Get the data layout for the module's target platform.
   const DataLayout *getDataLayout() const;
Index: include/llvm/Transforms/Utils/Cloning.h
===================================================================
--- include/llvm/Transforms/Utils/Cloning.h
+++ include/llvm/Transforms/Utils/Cloning.h
@@ -192,15 +192,13 @@
 class InlineFunctionInfo {
 public:
   explicit InlineFunctionInfo(CallGraph *cg = nullptr,
-                              const DataLayout *DL = nullptr,
                               AliasAnalysis *AA = nullptr,
                               AssumptionCacheTracker *ACT = nullptr)
-      : CG(cg), DL(DL), AA(AA), ACT(ACT) {}
+      : CG(cg), AA(AA), ACT(ACT) {}
 
   /// CG - If non-null, InlineFunction will update the callgraph to reflect the
   /// changes it makes.
   CallGraph *CG;
-  const DataLayout *DL;
   AliasAnalysis *AA;
   AssumptionCacheTracker *ACT;
 
Index: lib/Analysis/AliasAnalysis.cpp
===================================================================
--- lib/Analysis/AliasAnalysis.cpp
+++ lib/Analysis/AliasAnalysis.cpp
@@ -462,9 +462,8 @@
 /// InitializeAliasAnalysis - Subclasses must call this method to initialize the
 /// AliasAnalysis interface before any other methods are called.
 ///
-void AliasAnalysis::InitializeAliasAnalysis(Pass *P) {
-  DataLayoutPass *DLP = P->getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+void AliasAnalysis::InitializeAliasAnalysis(Pass *P, const DataLayout *NewDL) {
+  DL = NewDL;
   auto *TLIP = P->getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
   TLI = TLIP ? &TLIP->getTLI() : nullptr;
   AA = &P->getAnalysis<AliasAnalysis>();
Index: lib/Analysis/AliasAnalysisCounter.cpp
===================================================================
--- lib/Analysis/AliasAnalysisCounter.cpp
+++ lib/Analysis/AliasAnalysisCounter.cpp
@@ -14,6 +14,7 @@
 
 #include "llvm/Analysis/Passes.h"
 #include "llvm/Analysis/AliasAnalysis.h"
+#include "llvm/IR/Module.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
@@ -76,7 +77,7 @@
 
     bool runOnModule(Module &M) override {
       this->M = &M;
-      InitializeAliasAnalysis(this);
+      InitializeAliasAnalysis(this, M.getDataLayout());
       return false;
     }
 
Index: lib/Analysis/AliasDebugger.cpp
===================================================================
--- lib/Analysis/AliasDebugger.cpp
+++ lib/Analysis/AliasDebugger.cpp
@@ -44,7 +44,7 @@
     }
 
     bool runOnModule(Module &M) override {
-      InitializeAliasAnalysis(this);                 // set up super class
+      InitializeAliasAnalysis(this, M.getDataLayout()); // set up super class
 
       for(Module::global_iterator I = M.global_begin(),
             E = M.global_end(); I != E; ++I) {
Index: lib/Analysis/BasicAliasAnalysis.cpp
===================================================================
--- lib/Analysis/BasicAliasAnalysis.cpp
+++ lib/Analysis/BasicAliasAnalysis.cpp
@@ -461,9 +461,7 @@
       initializeBasicAliasAnalysisPass(*PassRegistry::getPassRegistry());
     }
 
-    void initializePass() override {
-      InitializeAliasAnalysis(this);
-    }
+    bool doInitialization(Module &M) override;
 
     void getAnalysisUsage(AnalysisUsage &AU) const override {
       AU.addRequired<AliasAnalysis>();
@@ -815,6 +813,11 @@
   return false;
 }
 
+bool BasicAliasAnalysis::doInitialization(Module &M) {
+  InitializeAliasAnalysis(this, M.getDataLayout());
+  return true;
+}
+
 /// getModRefInfo - Check to see if the specified callsite can clobber the
 /// specified memory object.  Since we only look at local properties of this
 /// function, we really can't say much about this query.  We do, however, use
Index: lib/Analysis/CFLAliasAnalysis.cpp
===================================================================
--- lib/Analysis/CFLAliasAnalysis.cpp
+++ lib/Analysis/CFLAliasAnalysis.cpp
@@ -240,7 +240,7 @@
     return QueryResult;
   }
 
-  void initializePass() override { InitializeAliasAnalysis(this); }
+  bool doInitialization(Module &M) override;
 };
 
 void FunctionHandle::removeSelfFromCache() {
@@ -1034,3 +1034,9 @@
 
   return AliasAnalysis::NoAlias;
 }
+
+bool CFLAliasAnalysis::doInitialization(Module &M) {
+  InitializeAliasAnalysis(this, M.getDataLayout());
+  return true;
+}
+
Index: lib/Analysis/IPA/GlobalsModRef.cpp
===================================================================
--- lib/Analysis/IPA/GlobalsModRef.cpp
+++ lib/Analysis/IPA/GlobalsModRef.cpp
@@ -96,7 +96,7 @@
     }
 
     bool runOnModule(Module &M) override {
-      InitializeAliasAnalysis(this);
+      InitializeAliasAnalysis(this, M.getDataLayout());
 
       // Find non-addr taken globals.
       AnalyzeGlobals(M);
Index: lib/Analysis/IVUsers.cpp
===================================================================
--- lib/Analysis/IVUsers.cpp
+++ lib/Analysis/IVUsers.cpp
@@ -253,8 +253,7 @@
   LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
   DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
   SE = &getAnalysis<ScalarEvolution>();
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+  DL = L->getHeader()->getParent()->getDataLayout();
 
   // Find all uses of induction variables in this loop, and categorize
   // them by stride.  Start by finding all of the PHI nodes in the header for
Index: lib/Analysis/LazyValueInfo.cpp
===================================================================
--- lib/Analysis/LazyValueInfo.cpp
+++ lib/Analysis/LazyValueInfo.cpp
@@ -1117,8 +1117,7 @@
       getAnalysisIfAvailable<DominatorTreeWrapperPass>();
   DT = DTWP ? &DTWP->getDomTree() : nullptr;
 
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+  DL = F.getDataLayout();
 
   TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
 
Index: lib/Analysis/LibCallAliasAnalysis.cpp
===================================================================
--- lib/Analysis/LibCallAliasAnalysis.cpp
+++ lib/Analysis/LibCallAliasAnalysis.cpp
@@ -36,6 +36,11 @@
   AU.setPreservesAll();                         // Does not transform code
 }
 
+bool LibCallAliasAnalysis::runOnFunction(Function &F) {
+  // set up super class
+  InitializeAliasAnalysis(this, F.getParent()->getDataLayout());
+  return false;
+}
 
 
 /// AnalyzeLibCallDetails - Given a call to a function with the specified
Index: lib/Analysis/Lint.cpp
===================================================================
--- lib/Analysis/Lint.cpp
+++ lib/Analysis/Lint.cpp
@@ -184,8 +184,7 @@
   AA = &getAnalysis<AliasAnalysis>();
   AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
   DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+  DL = F.getDataLayout();
   TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
   visit(F);
   dbgs() << MessagesStr.str();
Index: lib/Analysis/MemDerefPrinter.cpp
===================================================================
--- lib/Analysis/MemDerefPrinter.cpp
+++ lib/Analysis/MemDerefPrinter.cpp
@@ -27,7 +27,6 @@
       initializeMemDerefPrinterPass(*PassRegistry::getPassRegistry());
     }
     void getAnalysisUsage(AnalysisUsage &AU) const override {
-      AU.addRequired<DataLayoutPass>();
       AU.setPreservesAll();
     }
     bool runOnFunction(Function &F) override;
@@ -41,7 +40,6 @@
 char MemDerefPrinter::ID = 0;
 INITIALIZE_PASS_BEGIN(MemDerefPrinter, "print-memderefs",
                       "Memory Dereferenciblity of pointers in function", false, true)
-INITIALIZE_PASS_DEPENDENCY(DataLayoutPass)
 INITIALIZE_PASS_END(MemDerefPrinter, "print-memderefs",
                     "Memory Dereferenciblity of pointers in function", false, true)
 
@@ -50,7 +48,8 @@
 }
 
 bool MemDerefPrinter::runOnFunction(Function &F) {
-  const DataLayout *DL = &getAnalysis<DataLayoutPass>().getDataLayout();
+  const DataLayout *DL = F.getDataLayout();
+  if(!DL) return false;
   for (auto &I: inst_range(F)) {
     if (LoadInst *LI = dyn_cast<LoadInst>(&I)) {
       Value *PO = LI->getPointerOperand();
Index: lib/Analysis/MemoryDependenceAnalysis.cpp
===================================================================
--- lib/Analysis/MemoryDependenceAnalysis.cpp
+++ lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -93,8 +93,7 @@
 bool MemoryDependenceAnalysis::runOnFunction(Function &F) {
   AA = &getAnalysis<AliasAnalysis>();
   AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+  DL = F.getDataLayout();
   DominatorTreeWrapperPass *DTWP =
       getAnalysisIfAvailable<DominatorTreeWrapperPass>();
   DT = DTWP ? &DTWP->getDomTree() : nullptr;
Index: lib/Analysis/NoAliasAnalysis.cpp
===================================================================
--- lib/Analysis/NoAliasAnalysis.cpp
+++ lib/Analysis/NoAliasAnalysis.cpp
@@ -16,6 +16,7 @@
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
 #include "llvm/Pass.h"
 using namespace llvm;
 
@@ -33,11 +34,11 @@
 
     void getAnalysisUsage(AnalysisUsage &AU) const override {}
 
-    void initializePass() override {
+    bool doInitialization(Module &M) override {
       // Note: NoAA does not call InitializeAliasAnalysis because it's
       // special and does not support chaining.
-      DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-      DL = DLP ? &DLP->getDataLayout() : nullptr;
+      DL = M.getDataLayout();
+      return true;
     }
 
     AliasResult alias(const Location &LocA, const Location &LocB) override {
Index: lib/Analysis/ScalarEvolution.cpp
===================================================================
--- lib/Analysis/ScalarEvolution.cpp
+++ lib/Analysis/ScalarEvolution.cpp
@@ -7956,8 +7956,7 @@
   this->F = &F;
   AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
   LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+  DL = F.getDataLayout();
   TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
   DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
   return false;
Index: lib/Analysis/ScalarEvolutionAliasAnalysis.cpp
===================================================================
--- lib/Analysis/ScalarEvolutionAliasAnalysis.cpp
+++ lib/Analysis/ScalarEvolutionAliasAnalysis.cpp
@@ -22,6 +22,7 @@
 #include "llvm/Analysis/Passes.h"
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
+#include "llvm/IR/Module.h"
 #include "llvm/Pass.h"
 using namespace llvm;
 
@@ -79,7 +80,7 @@
 
 bool
 ScalarEvolutionAliasAnalysis::runOnFunction(Function &F) {
-  InitializeAliasAnalysis(this);
+  InitializeAliasAnalysis(this, F.getParent()->getDataLayout());
   SE = &getAnalysis<ScalarEvolution>();
   return false;
 }
Index: lib/Analysis/ScopedNoAliasAA.cpp
===================================================================
--- lib/Analysis/ScopedNoAliasAA.cpp
+++ lib/Analysis/ScopedNoAliasAA.cpp
@@ -80,7 +80,7 @@
     initializeScopedNoAliasAAPass(*PassRegistry::getPassRegistry());
   }
 
-  void initializePass() override { InitializeAliasAnalysis(this); }
+  bool doInitialization(Module &M) override;
 
   /// getAdjustedAnalysisPointer - This method is used when a pass implements
   /// an analysis interface through multiple inheritance.  If needed, it
@@ -119,6 +119,11 @@
   return new ScopedNoAliasAA();
 }
 
+bool ScopedNoAliasAA::doInitialization(Module &M) {
+  InitializeAliasAnalysis(this, M.getDataLayout());
+  return true;
+}
+
 void
 ScopedNoAliasAA::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.setPreservesAll();
Index: lib/Analysis/TypeBasedAliasAnalysis.cpp
===================================================================
--- lib/Analysis/TypeBasedAliasAnalysis.cpp
+++ lib/Analysis/TypeBasedAliasAnalysis.cpp
@@ -282,9 +282,7 @@
       initializeTypeBasedAliasAnalysisPass(*PassRegistry::getPassRegistry());
     }
 
-    void initializePass() override {
-      InitializeAliasAnalysis(this);
-    }
+    bool doInitialization(Module &M) override;
 
     /// getAdjustedAnalysisPointer - This method is used when a pass implements
     /// an analysis interface through multiple inheritance.  If needed, it
@@ -321,6 +319,11 @@
   return new TypeBasedAliasAnalysis();
 }
 
+bool TypeBasedAliasAnalysis::doInitialization(Module &M) {
+  InitializeAliasAnalysis(this, M.getDataLayout());
+  return true;
+}
+
 void
 TypeBasedAliasAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.setPreservesAll();
Index: lib/ExecutionEngine/MCJIT/MCJIT.cpp
===================================================================
--- lib/ExecutionEngine/MCJIT/MCJIT.cpp
+++ lib/ExecutionEngine/MCJIT/MCJIT.cpp
@@ -138,7 +138,6 @@
   legacy::PassManager PM;
 
   M->setDataLayout(TM->getDataLayout());
-  PM.add(new DataLayoutPass());
 
   // The RuntimeDyld will take ownership of this shortly
   SmallVector<char, 4096> ObjBufferSV;
Index: lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
===================================================================
--- lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
+++ lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
@@ -133,7 +133,7 @@
 
     // If this module doesn't have a DataLayout attached then attach the
     // default.
-    if (!M->getDataLayout())
+    if (M->getDataLayout()->isDefault())
       M->setDataLayout(getDataLayout());
 
     Modules.push_back(std::move(M));
Index: lib/IR/DataLayout.cpp
===================================================================
--- lib/IR/DataLayout.cpp
+++ lib/IR/DataLayout.cpp
@@ -33,11 +33,6 @@
 #include <cstdlib>
 using namespace llvm;
 
-// Handle the Pass registration stuff necessary to use DataLayout's.
-
-INITIALIZE_PASS(DataLayoutPass, "datalayout", "Data Layout", false, true)
-char DataLayoutPass::ID = 0;
-
 //===----------------------------------------------------------------------===//
 // Support for StructLayout
 //===----------------------------------------------------------------------===//
@@ -221,6 +216,7 @@
 }
 
 void DataLayout::parseSpecifier(StringRef Desc) {
+  StringRepresentation = Desc;
   while (!Desc.empty()) {
     // Split at '-'.
     std::pair<StringRef, StringRef> Split = split(Desc, '-');
@@ -381,7 +377,7 @@
              ManglingMode == Other.ManglingMode &&
              LegalIntWidths == Other.LegalIntWidths &&
              Alignments == Other.Alignments && Pointers == Other.Pointers;
-  assert(Ret == (getStringRepresentation() == Other.getStringRepresentation()));
+  // Note: getStringRepresentation() might differs, it is not canonicalized
   return Ret;
 }
 
@@ -552,68 +548,6 @@
   return L;
 }
 
-std::string DataLayout::getStringRepresentation() const {
-  std::string Result;
-  raw_string_ostream OS(Result);
-
-  OS << (BigEndian ? "E" : "e");
-
-  switch (ManglingMode) {
-  case MM_None:
-    break;
-  case MM_ELF:
-    OS << "-m:e";
-    break;
-  case MM_MachO:
-    OS << "-m:o";
-    break;
-  case MM_WINCOFF:
-    OS << "-m:w";
-    break;
-  case MM_Mips:
-    OS << "-m:m";
-    break;
-  }
-
-  for (const PointerAlignElem &PI : Pointers) {
-    // Skip default.
-    if (PI.AddressSpace == 0 && PI.ABIAlign == 8 && PI.PrefAlign == 8 &&
-        PI.TypeByteWidth == 8)
-      continue;
-
-    OS << "-p";
-    if (PI.AddressSpace) {
-      OS << PI.AddressSpace;
-    }
-    OS << ":" << PI.TypeByteWidth*8 << ':' << PI.ABIAlign*8;
-    if (PI.PrefAlign != PI.ABIAlign)
-      OS << ':' << PI.PrefAlign*8;
-  }
-
-  for (const LayoutAlignElem &AI : Alignments) {
-    if (std::find(std::begin(DefaultAlignments), std::end(DefaultAlignments),
-                  AI) != std::end(DefaultAlignments))
-      continue;
-    OS << '-' << (char)AI.AlignType;
-    if (AI.TypeBitWidth)
-      OS << AI.TypeBitWidth;
-    OS << ':' << AI.ABIAlign*8;
-    if (AI.ABIAlign != AI.PrefAlign)
-      OS << ':' << AI.PrefAlign*8;
-  }
-
-  if (!LegalIntWidths.empty()) {
-    OS << "-n" << (unsigned)LegalIntWidths[0];
-
-    for (unsigned i = 1, e = LegalIntWidths.size(); i != e; ++i)
-      OS << ':' << (unsigned)LegalIntWidths[i];
-  }
-
-  if (StackNaturalAlign)
-    OS << "-S" << StackNaturalAlign*8;
-
-  return OS.str();
-}
 
 unsigned DataLayout::getPointerABIAlignment(unsigned AS) const {
   PointersTy::const_iterator I = findPointerLowerBound(AS);
@@ -829,18 +763,3 @@
   return Log2_32(getPreferredAlignment(GV));
 }
 
-DataLayoutPass::DataLayoutPass() : ImmutablePass(ID), DL("") {
-  initializeDataLayoutPassPass(*PassRegistry::getPassRegistry());
-}
-
-DataLayoutPass::~DataLayoutPass() {}
-
-bool DataLayoutPass::doInitialization(Module &M) {
-  DL.init(&M);
-  return false;
-}
-
-bool DataLayoutPass::doFinalization(Module &M) {
-  DL.reset("");
-  return false;
-}
Index: lib/IR/Module.cpp
===================================================================
--- lib/IR/Module.cpp
+++ lib/IR/Module.cpp
@@ -365,29 +365,17 @@
 
 void Module::setDataLayout(StringRef Desc) {
   DL.reset(Desc);
-
-  if (Desc.empty()) {
-    DataLayoutStr = "";
-  } else {
-    DataLayoutStr = DL.getStringRepresentation();
-    // DataLayoutStr is now equivalent to Desc, but since the representation
-    // is not unique, they may not be identical.
-  }
 }
 
 void Module::setDataLayout(const DataLayout *Other) {
   if (!Other) {
-    DataLayoutStr = "";
     DL.reset("");
   } else {
     DL = *Other;
-    DataLayoutStr = DL.getStringRepresentation();
   }
 }
 
 const DataLayout *Module::getDataLayout() const {
-  if (DataLayoutStr.empty())
-    return nullptr;
   return &DL;
 }
 
Index: lib/LTO/LTOCodeGenerator.cpp
===================================================================
--- lib/LTO/LTOCodeGenerator.cpp
+++ lib/LTO/LTOCodeGenerator.cpp
@@ -531,7 +531,6 @@
   // Add an appropriate DataLayout instance for this module...
   mergedModule->setDataLayout(TargetMach->getDataLayout());
 
-  passes.add(new DataLayoutPass());
   passes.add(
       createTargetTransformInfoWrapperPass(TargetMach->getTargetIRAnalysis()));
 
@@ -567,8 +566,6 @@
 
   legacy::PassManager codeGenPasses;
 
-  codeGenPasses.add(new DataLayoutPass());
-
   formatted_raw_ostream Out(out);
 
   // If the bitcode files contain ARC code and were compiled with optimization,
Index: lib/Linker/LinkModules.cpp
===================================================================
--- lib/Linker/LinkModules.cpp
+++ lib/Linker/LinkModules.cpp
@@ -1482,11 +1482,10 @@
 
   // Inherit the target data from the source module if the destination module
   // doesn't have one already.
-  if (!DstM->getDataLayout() && SrcM->getDataLayout())
+  if (DstM->getDataLayout()->isDefault())
     DstM->setDataLayout(SrcM->getDataLayout());
 
-  if (SrcM->getDataLayout() && DstM->getDataLayout() &&
-      *SrcM->getDataLayout() != *DstM->getDataLayout()) {
+  if (*SrcM->getDataLayout() != *DstM->getDataLayout()) {
     emitWarning("Linking two modules of different data layouts: '" +
                 SrcM->getModuleIdentifier() + "' is '" +
                 SrcM->getDataLayoutStr() + "' whereas '" +
Index: lib/Target/NVPTX/NVPTXAllocaHoisting.h
===================================================================
--- lib/Target/NVPTX/NVPTXAllocaHoisting.h
+++ lib/Target/NVPTX/NVPTXAllocaHoisting.h
@@ -32,7 +32,6 @@
   NVPTXAllocaHoisting() : FunctionPass(ID) {}
 
   void getAnalysisUsage(AnalysisUsage &AU) const override {
-    AU.addRequired<DataLayoutPass>();
     AU.addPreserved<MachineFunctionAnalysis>();
     AU.addPreserved<StackProtector>();
   }
Index: lib/Target/NVPTX/NVPTXLowerAggrCopies.h
===================================================================
--- lib/Target/NVPTX/NVPTXLowerAggrCopies.h
+++ lib/Target/NVPTX/NVPTXLowerAggrCopies.h
@@ -29,7 +29,6 @@
   NVPTXLowerAggrCopies() : FunctionPass(ID) {}
 
   void getAnalysisUsage(AnalysisUsage &AU) const override {
-    AU.addRequired<DataLayoutPass>();
     AU.addPreserved<MachineFunctionAnalysis>();
     AU.addPreserved<StackProtector>();
   }
Index: lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp
===================================================================
--- lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp
+++ lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp
@@ -22,6 +22,9 @@
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
+#include "llvm/Support/Debug.h"
+
+#define DEBUG_TYPE "nvptx"
 
 using namespace llvm;
 
@@ -104,7 +107,11 @@
   SmallVector<MemTransferInst *, 4> aggrMemcpys;
   SmallVector<MemSetInst *, 4> aggrMemsets;
 
-  const DataLayout *DL = &getAnalysis<DataLayoutPass>().getDataLayout();
+  const DataLayout *DL = F.getDataLayout();
+  if (!DL) {
+    DEBUG(dbgs() << "Abort NVPTXLowerAggrCopies, missing DataLayout\n");
+    return false;
+  }
   LLVMContext &Context = F.getParent()->getContext();
 
   //
Index: lib/Target/PowerPC/PPCCTRLoops.cpp
===================================================================
--- lib/Target/PowerPC/PPCCTRLoops.cpp
+++ lib/Target/PowerPC/PPCCTRLoops.cpp
@@ -171,8 +171,7 @@
   LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
   SE = &getAnalysis<ScalarEvolution>();
   DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+  DL = F.getDataLayout();
   auto *TLIP = getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
   LibInfo = TLIP ? &TLIP->getTLI() : nullptr;
 
Index: lib/Target/PowerPC/PPCLoopPreIncPrep.cpp
===================================================================
--- lib/Target/PowerPC/PPCLoopPreIncPrep.cpp
+++ lib/Target/PowerPC/PPCLoopPreIncPrep.cpp
@@ -141,8 +141,7 @@
   LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
   SE = &getAnalysis<ScalarEvolution>();
 
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : 0;
+  DL = F.getDataLayout();
 
   bool MadeChange = false;
 
Index: lib/Target/Target.cpp
===================================================================
--- lib/Target/Target.cpp
+++ lib/Target/Target.cpp
@@ -34,7 +34,6 @@
 }
 
 void llvm::initializeTarget(PassRegistry &Registry) {
-  initializeDataLayoutPassPass(Registry);
   initializeTargetLibraryInfoWrapperPassPass(Registry);
   initializeTargetTransformInfoWrapperPassPass(Registry);
 }
@@ -48,9 +47,6 @@
 }
 
 void LLVMAddTargetData(LLVMTargetDataRef TD, LLVMPassManagerRef PM) {
-  // The DataLayoutPass must now be in sync with the module. Unfortunatelly we
-  // cannot enforce that from the C api.
-  unwrap(PM)->add(new DataLayoutPass());
 }
 
 void LLVMAddTargetLibraryInfo(LLVMTargetLibraryInfoRef TLI,
Index: lib/Target/TargetMachineC.cpp
===================================================================
--- lib/Target/TargetMachineC.cpp
+++ lib/Target/TargetMachineC.cpp
@@ -199,7 +199,6 @@
     return true;
   }
   Mod->setDataLayout(td);
-  pass.add(new DataLayoutPass());
 
   TargetMachine::CodeGenFileType ft;
   switch (codegen) {
Index: lib/Transforms/IPO/ArgumentPromotion.cpp
===================================================================
--- lib/Transforms/IPO/ArgumentPromotion.cpp
+++ lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -109,9 +109,6 @@
 bool ArgPromotion::runOnSCC(CallGraphSCC &SCC) {
   bool Changed = false, LocalChange;
 
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
-
   do {  // Iterate until we stop promoting from this SCC.
     LocalChange = false;
     // Attempt to promote arguments from all functions in this SCC.
@@ -210,6 +207,8 @@
   // Make sure that it is local to this module.
   if (!F || !F->hasLocalLinkage()) return nullptr;
 
+  DL = F->getParent()->getDataLayout();
+
   // First check: see if there are any pointer arguments!  If not, quick exit.
   SmallVector<Argument*, 16> PointerArgs;
   for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I)
Index: lib/Transforms/IPO/ConstantMerge.cpp
===================================================================
--- lib/Transforms/IPO/ConstantMerge.cpp
+++ lib/Transforms/IPO/ConstantMerge.cpp
@@ -103,8 +103,7 @@
 }
 
 bool ConstantMerge::runOnModule(Module &M) {
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+  DL = M.getDataLayout();
 
   // Find all the globals that are marked "used".  These cannot be merged.
   SmallPtrSet<const GlobalValue*, 8> UsedGlobals;
Index: lib/Transforms/IPO/GlobalOpt.cpp
===================================================================
--- lib/Transforms/IPO/GlobalOpt.cpp
+++ lib/Transforms/IPO/GlobalOpt.cpp
@@ -1804,9 +1804,8 @@
     ++NumMarked;
     return true;
   } else if (!GV->getInitializer()->getType()->isSingleValueType()) {
-    if (DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>()) {
-      const DataLayout &DL = DLP->getDataLayout();
-      if (GlobalVariable *FirstNewGV = SRAGlobal(GV, DL)) {
+    if(const DataLayout *DL = GV->getParent()->getDataLayout()) {
+      if (GlobalVariable *FirstNewGV = SRAGlobal(GV, *DL)) {
         GVI = FirstNewGV;  // Don't skip the newly produced globals!
         return true;
       }
@@ -3040,8 +3039,7 @@
 bool GlobalOpt::runOnModule(Module &M) {
   bool Changed = false;
 
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+  DL = M.getDataLayout();
   TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
 
   bool LocalChange = true;
Index: lib/Transforms/IPO/Inliner.cpp
===================================================================
--- lib/Transforms/IPO/Inliner.cpp
+++ lib/Transforms/IPO/Inliner.cpp
@@ -121,10 +121,10 @@
 /// any new allocas to the set if not possible.
 static bool InlineCallIfPossible(CallSite CS, InlineFunctionInfo &IFI,
                                  InlinedArrayAllocasTy &InlinedArrayAllocas,
-                                 int InlineHistory, bool InsertLifetime,
-                                 const DataLayout *DL) {
+                                 int InlineHistory, bool InsertLifetime) {
   Function *Callee = CS.getCalledFunction();
   Function *Caller = CS.getCaller();
+  const DataLayout *DL = Caller->getDataLayout();
 
   // Try to inline the function.  Get the list of static allocas that were
   // inlined.
@@ -432,8 +432,6 @@
 bool Inliner::runOnSCC(CallGraphSCC &SCC) {
   CallGraph &CG = getAnalysis<CallGraphWrapperPass>().getCallGraph();
   AssumptionCacheTracker *ACT = &getAnalysis<AssumptionCacheTracker>();
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  const DataLayout *DL = DLP ? &DLP->getDataLayout() : nullptr;
   auto *TLIP = getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
   const TargetLibraryInfo *TLI = TLIP ? &TLIP->getTLI() : nullptr;
   AliasAnalysis *AA = &getAnalysis<AliasAnalysis>();
@@ -495,7 +493,7 @@
 
   
   InlinedArrayAllocasTy InlinedArrayAllocas;
-  InlineFunctionInfo InlineInfo(&CG, DL, AA, ACT);
+  InlineFunctionInfo InlineInfo(&CG, AA, ACT);
 
   // Now that we have all of the call sites, loop over them and inline them if
   // it looks profitable to do so.
@@ -553,7 +551,7 @@
 
         // Attempt to inline the function.
         if (!InlineCallIfPossible(CS, InlineInfo, InlinedArrayAllocas,
-                                  InlineHistoryID, InsertLifetime, DL)) {
+                                  InlineHistoryID, InsertLifetime)) {
           emitOptimizationRemarkMissed(CallerCtx, DEBUG_TYPE, *Caller, DLoc,
                                        Twine(Callee->getName() +
                                              " will not be inlined into " +
Index: lib/Transforms/IPO/MergeFunctions.cpp
===================================================================
--- lib/Transforms/IPO/MergeFunctions.cpp
+++ lib/Transforms/IPO/MergeFunctions.cpp
@@ -1212,8 +1212,7 @@
 
 bool MergeFunctions::runOnModule(Module &M) {
   bool Changed = false;
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+  DL = M.getDataLayout();
 
   for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
     if (!I->isDeclaration() && !I->hasAvailableExternallyLinkage())
Index: lib/Transforms/InstCombine/InstructionCombining.cpp
===================================================================
--- lib/Transforms/InstCombine/InstructionCombining.cpp
+++ lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -2912,10 +2912,10 @@
 
 static bool combineInstructionsOverFunction(
     Function &F, InstCombineWorklist &Worklist, AssumptionCache &AC,
-    TargetLibraryInfo &TLI, DominatorTree &DT, const DataLayout *DL = nullptr,
-    LoopInfo *LI = nullptr) {
+    TargetLibraryInfo &TLI, DominatorTree &DT, LoopInfo *LI = nullptr) {
   // Minimizing size?
   bool MinimizeSize = F.hasFnAttribute(Attribute::MinSize);
+  const DataLayout *DL = F.getDataLayout();
 
   /// Builder - This is an IRBuilder that automatically inserts new
   /// instructions into the worklist when they are created.
@@ -2950,15 +2950,13 @@
 
 PreservedAnalyses InstCombinePass::run(Function &F,
                                        AnalysisManager<Function> *AM) {
-  auto *DL = F.getParent()->getDataLayout();
-
   auto &AC = AM->getResult<AssumptionAnalysis>(F);
   auto &DT = AM->getResult<DominatorTreeAnalysis>(F);
   auto &TLI = AM->getResult<TargetLibraryAnalysis>(F);
 
   auto *LI = AM->getCachedResult<LoopAnalysis>(F);
 
-  if (!combineInstructionsOverFunction(F, Worklist, AC, TLI, DT, DL, LI))
+  if (!combineInstructionsOverFunction(F, Worklist, AC, TLI, DT, LI))
     // No changes, all analyses are preserved.
     return PreservedAnalyses::all();
 
@@ -3007,12 +3005,10 @@
   auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
 
   // Optional analyses.
-  auto *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  auto *DL = DLP ? &DLP->getDataLayout() : nullptr;
   auto *LIWP = getAnalysisIfAvailable<LoopInfoWrapperPass>();
   auto *LI = LIWP ? &LIWP->getLoopInfo() : nullptr;
 
-  return combineInstructionsOverFunction(F, Worklist, AC, TLI, DT, DL, LI);
+  return combineInstructionsOverFunction(F, Worklist, AC, TLI, DT, LI);
 }
 
 char InstructionCombiningPass::ID = 0;
Index: lib/Transforms/Instrumentation/AddressSanitizer.cpp
===================================================================
--- lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1308,10 +1308,7 @@
 }
 
 bool AddressSanitizerModule::runOnModule(Module &M) {
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  if (!DLP)
-    return false;
-  DL = &DLP->getDataLayout();
+  DL = M.getDataLayout();
   C = &(M.getContext());
   int LongSize = DL->getPointerSizeInBits();
   IntptrTy = Type::getIntNTy(*C, LongSize);
@@ -1388,10 +1385,7 @@
 // virtual
 bool AddressSanitizer::doInitialization(Module &M) {
   // Initialize the private fields. No one has accessed them before.
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  if (!DLP)
-    report_fatal_error("data layout missing");
-  DL = &DLP->getDataLayout();
+  DL = M.getDataLayout();
 
   GlobalsMD.init(M);
 
Index: lib/Transforms/Instrumentation/BoundsChecking.cpp
===================================================================
--- lib/Transforms/Instrumentation/BoundsChecking.cpp
+++ lib/Transforms/Instrumentation/BoundsChecking.cpp
@@ -49,7 +49,6 @@
     bool runOnFunction(Function &F) override;
 
     void getAnalysisUsage(AnalysisUsage &AU) const override {
-      AU.addRequired<DataLayoutPass>();
       AU.addRequired<TargetLibraryInfoWrapperPass>();
     }
 
@@ -165,7 +164,7 @@
 }
 
 bool BoundsChecking::runOnFunction(Function &F) {
-  DL = &getAnalysis<DataLayoutPass>().getDataLayout();
+  DL = F.getParent()->getDataLayout();
   TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
 
   TrapBB = nullptr;
Index: lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===================================================================
--- lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -422,10 +422,9 @@
   bool IsMIPS64 = TargetTriple.getArch() == llvm::Triple::mips64 ||
                   TargetTriple.getArch() == llvm::Triple::mips64el;
 
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  if (!DLP)
+  DL = M.getDataLayout();
+  if (!DL)
     report_fatal_error("data layout missing");
-  DL = &DLP->getDataLayout();
 
   Mod = &M;
   Ctx = &M.getContext();
Index: lib/Transforms/Instrumentation/MemorySanitizer.cpp
===================================================================
--- lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -449,10 +449,9 @@
 ///
 /// inserts a call to __msan_init to the module's constructor list.
 bool MemorySanitizer::doInitialization(Module &M) {
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  if (!DLP)
+  DL = M.getDataLayout();
+  if (!DL)
     report_fatal_error("data layout missing");
-  DL = &DLP->getDataLayout();
 
   Triple TargetTriple(M.getTargetTriple());
   switch (TargetTriple.getOS()) {
Index: lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===================================================================
--- lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -94,10 +94,6 @@
     return "SanitizerCoverageModule";
   }
 
-  void getAnalysisUsage(AnalysisUsage &AU) const override {
-    AU.addRequired<DataLayoutPass>();
-  }
-
  private:
   void InjectCoverageForIndirectCalls(Function &F,
                                       ArrayRef<Instruction *> IndirCalls);
@@ -133,8 +129,12 @@
 bool SanitizerCoverageModule::runOnModule(Module &M) {
   if (!CoverageLevel) return false;
   C = &(M.getContext());
-  DataLayoutPass *DLP = &getAnalysis<DataLayoutPass>();
-  IntptrTy = Type::getIntNTy(*C, DLP->getDataLayout().getPointerSizeInBits());
+  auto *DL = M.getDataLayout();
+  if (!DL) {
+    DEBUG(dbgs() << "  Skipping SanitizerCoverageModule -- no target data!\n");
+    return false;
+  }
+  IntptrTy = Type::getIntNTy(*C, DL->getPointerSizeInBits());
   Type *VoidTy = Type::getVoidTy(*C);
   IRBuilder<> IRB(*C);
   Type *Int8PtrTy = PointerType::getUnqual(IRB.getInt8Ty());
Index: lib/Transforms/Instrumentation/ThreadSanitizer.cpp
===================================================================
--- lib/Transforms/Instrumentation/ThreadSanitizer.cpp
+++ lib/Transforms/Instrumentation/ThreadSanitizer.cpp
@@ -230,10 +230,9 @@
 }
 
 bool ThreadSanitizer::doInitialization(Module &M) {
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  if (!DLP)
+  DL = M.getDataLayout();
+  if (!DL)
     report_fatal_error("data layout missing");
-  DL = &DLP->getDataLayout();
 
   // Always insert a call to __tsan_init into the module's CTORs.
   IRBuilder<> IRB(M.getContext());
Index: lib/Transforms/ObjCARC/ObjCARCAliasAnalysis.h
===================================================================
--- lib/Transforms/ObjCARC/ObjCARCAliasAnalysis.h
+++ lib/Transforms/ObjCARC/ObjCARCAliasAnalysis.h
@@ -44,9 +44,7 @@
     }
 
   private:
-    void initializePass() override {
-      InitializeAliasAnalysis(this);
-    }
+    bool doInitialization(Module &M) override;
 
     /// This method is used when a pass implements an analysis interface through
     /// multiple inheritance.  If needed, it should override this to adjust the
Index: lib/Transforms/ObjCARC/ObjCARCAliasAnalysis.cpp
===================================================================
--- lib/Transforms/ObjCARC/ObjCARCAliasAnalysis.cpp
+++ lib/Transforms/ObjCARC/ObjCARCAliasAnalysis.cpp
@@ -46,6 +46,11 @@
   return new ObjCARCAliasAnalysis();
 }
 
+bool ObjCARCAliasAnalysis::doInitialization(Module &M) {
+  InitializeAliasAnalysis(this, M.getDataLayout());
+  return true;
+}
+
 void
 ObjCARCAliasAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.setPreservesAll();
Index: lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
===================================================================
--- lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
+++ lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
@@ -32,6 +32,7 @@
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/DataLayout.h"
+#include "llvm/IR/Module.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace llvm;
@@ -413,8 +414,7 @@
   auto &AC = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
   SE = &getAnalysis<ScalarEvolution>();
   DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+  DL = F.getParent()->getDataLayout();
 
   NewDestAlignments.clear();
   NewSrcAlignments.clear();
Index: lib/Transforms/Scalar/ConstantProp.cpp
===================================================================
--- lib/Transforms/Scalar/ConstantProp.cpp
+++ lib/Transforms/Scalar/ConstantProp.cpp
@@ -68,8 +68,7 @@
       WorkList.insert(&*i);
   }
   bool Changed = false;
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  const DataLayout *DL = DLP ? &DLP->getDataLayout() : nullptr;
+  const DataLayout *DL = F.getParent()->getDataLayout();
   TargetLibraryInfo *TLI =
       &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
 
Index: lib/Transforms/Scalar/EarlyCSE.cpp
===================================================================
--- lib/Transforms/Scalar/EarlyCSE.cpp
+++ lib/Transforms/Scalar/EarlyCSE.cpp
@@ -724,8 +724,7 @@
     if (skipOptnoneFunction(F))
       return false;
 
-    DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-    auto *DL = DLP ? &DLP->getDataLayout() : nullptr;
+    auto *DL = F.getParent()->getDataLayout();
     auto &TLI = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
     auto &TTI = getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
     auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
Index: lib/Transforms/Scalar/GVN.cpp
===================================================================
--- lib/Transforms/Scalar/GVN.cpp
+++ lib/Transforms/Scalar/GVN.cpp
@@ -2357,8 +2357,7 @@
   if (!NoLoads)
     MD = &getAnalysis<MemoryDependenceAnalysis>();
   DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+  DL = F.getParent()->getDataLayout();
   AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
   TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
   VN.setAliasAnalysis(&getAnalysis<AliasAnalysis>());
Index: lib/Transforms/Scalar/IndVarSimplify.cpp
===================================================================
--- lib/Transforms/Scalar/IndVarSimplify.cpp
+++ lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -1932,8 +1932,7 @@
   LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
   SE = &getAnalysis<ScalarEvolution>();
   DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+  DL = L->getHeader()->getParent()->getParent()->getDataLayout();
   auto *TLIP = getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
   TLI = TLIP ? &TLIP->getTLI() : nullptr;
   auto *TTIP = getAnalysisIfAvailable<TargetTransformInfoWrapperPass>();
Index: lib/Transforms/Scalar/JumpThreading.cpp
===================================================================
--- lib/Transforms/Scalar/JumpThreading.cpp
+++ lib/Transforms/Scalar/JumpThreading.cpp
@@ -159,8 +159,7 @@
     return false;
 
   DEBUG(dbgs() << "Jump threading on function '" << F.getName() << "'\n");
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+  DL = F.getDataLayout();
   TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
   LVI = &getAnalysis<LazyValueInfo>();
 
Index: lib/Transforms/Scalar/LICM.cpp
===================================================================
--- lib/Transforms/Scalar/LICM.cpp
+++ lib/Transforms/Scalar/LICM.cpp
@@ -181,8 +181,7 @@
   AA = &getAnalysis<AliasAnalysis>();
   DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
 
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+  DL = L->getHeader()->getParent()->getDataLayout();
   TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
 
   assert(L->isLCSSAForm(*DT) && "Loop is not in LCSSA form.");
Index: lib/Transforms/Scalar/LoadCombine.cpp
===================================================================
--- lib/Transforms/Scalar/LoadCombine.cpp
+++ lib/Transforms/Scalar/LoadCombine.cpp
@@ -85,12 +85,11 @@
 bool LoadCombine::doInitialization(Function &F) {
   DEBUG(dbgs() << "LoadCombine function: " << F.getName() << "\n");
   C = &F.getContext();
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  if (!DLP) {
+  DL = F.getDataLayout();
+  if (!DL) {
     DEBUG(dbgs() << "  Skipping LoadCombine -- no target data!\n");
     return false;
   }
-  DL = &DLP->getDataLayout();
   return true;
 }
 
Index: lib/Transforms/Scalar/LoopIdiomRecognize.cpp
===================================================================
--- lib/Transforms/Scalar/LoopIdiomRecognize.cpp
+++ lib/Transforms/Scalar/LoopIdiomRecognize.cpp
@@ -130,7 +130,6 @@
 
   class LoopIdiomRecognize : public LoopPass {
     Loop *CurLoop;
-    const DataLayout *DL;
     DominatorTree *DT;
     ScalarEvolution *SE;
     TargetLibraryInfo *TLI;
@@ -139,7 +138,7 @@
     static char ID;
     explicit LoopIdiomRecognize() : LoopPass(ID) {
       initializeLoopIdiomRecognizePass(*PassRegistry::getPassRegistry());
-      DL = nullptr; DT = nullptr; SE = nullptr; TLI = nullptr; TTI = nullptr;
+      DT = nullptr; SE = nullptr; TLI = nullptr; TTI = nullptr;
     }
 
     bool runOnLoop(Loop *L, LPPassManager &LPM) override;
@@ -179,14 +178,6 @@
       AU.addRequired<TargetTransformInfoWrapperPass>();
     }
 
-    const DataLayout *getDataLayout() {
-      if (DL)
-        return DL;
-      DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-      DL = DLP ? &DLP->getDataLayout() : nullptr;
-      return DL;
-    }
-
     DominatorTree *getDominatorTree() {
       return DT ? DT
                 : (DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree());
@@ -626,7 +617,7 @@
       return false;
 
   // We require target data for now.
-  if (!getDataLayout())
+  if (!CurLoop->getHeader()->getParent()->getDataLayout())
     return false;
 
   // set DT
@@ -742,6 +733,7 @@
   Value *StorePtr = SI->getPointerOperand();
 
   // Reject stores that are so large that they overflow an unsigned.
+  auto *DL = CurLoop->getHeader()->getParent()->getDataLayout();
   uint64_t SizeInBits = DL->getTypeSizeInBits(StoredVal->getType());
   if ((SizeInBits & 7) || (SizeInBits >> 32) != 0)
     return false;
@@ -917,7 +909,7 @@
   // but it can be turned into memset_pattern if the target supports it.
   Value *SplatValue = isBytewiseValue(StoredVal);
   Constant *PatternValue = nullptr;
-
+  auto *DL = CurLoop->getHeader()->getParent()->getDataLayout();
   unsigned DestAS = DestPtr->getType()->getPointerAddressSpace();
 
   // If we're allowed to form a memset, and the stored value would be acceptable
@@ -1085,6 +1077,7 @@
 
   // The # stored bytes is (BECount+1)*Size.  Expand the trip count out to
   // pointer size if it isn't already.
+  auto *DL = CurLoop->getHeader()->getParent()->getDataLayout();
   Type *IntPtrTy = Builder.getIntPtrTy(DL, SI->getPointerAddressSpace());
   BECount = SE->getTruncateOrZeroExtend(BECount, IntPtrTy);
 
Index: lib/Transforms/Scalar/LoopInstSimplify.cpp
===================================================================
--- lib/Transforms/Scalar/LoopInstSimplify.cpp
+++ lib/Transforms/Scalar/LoopInstSimplify.cpp
@@ -77,8 +77,7 @@
       getAnalysisIfAvailable<DominatorTreeWrapperPass>();
   DominatorTree *DT = DTWP ? &DTWP->getDomTree() : nullptr;
   LoopInfo *LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  const DataLayout *DL = DLP ? &DLP->getDataLayout() : nullptr;
+  const DataLayout *DL = L->getHeader()->getParent()->getDataLayout();
   const TargetLibraryInfo *TLI =
       &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
   auto &AC = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(
Index: lib/Transforms/Scalar/LoopRerollPass.cpp
===================================================================
--- lib/Transforms/Scalar/LoopRerollPass.cpp
+++ lib/Transforms/Scalar/LoopRerollPass.cpp
@@ -1477,8 +1477,7 @@
   LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
   SE = &getAnalysis<ScalarEvolution>();
   TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+  DL = L->getHeader()->getParent()->getDataLayout();
   DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
 
   BasicBlock *Header = L->getHeader();
Index: lib/Transforms/Scalar/MemCpyOptimizer.cpp
===================================================================
--- lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -1077,8 +1077,7 @@
 
   bool MadeChange = false;
   MD = &getAnalysis<MemoryDependenceAnalysis>();
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+  DL = F.getDataLayout();
   TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
 
   // If we don't have at least memset and memcpy, there is little point of doing
Index: lib/Transforms/Scalar/SCCP.cpp
===================================================================
--- lib/Transforms/Scalar/SCCP.cpp
+++ lib/Transforms/Scalar/SCCP.cpp
@@ -1561,8 +1561,7 @@
     return false;
 
   DEBUG(dbgs() << "SCCP on function '" << F.getName() << "'\n");
-  const DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  const DataLayout *DL = DLP ? &DLP->getDataLayout() : nullptr;
+  const DataLayout *DL = F.getDataLayout();
   const TargetLibraryInfo *TLI =
       &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
   SCCPSolver Solver(DL, TLI);
@@ -1691,8 +1690,7 @@
 }
 
 bool IPSCCP::runOnModule(Module &M) {
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  const DataLayout *DL = DLP ? &DLP->getDataLayout() : nullptr;
+  const DataLayout *DL = M.getDataLayout();
   const TargetLibraryInfo *TLI =
       &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
   SCCPSolver Solver(DL, TLI);
Index: lib/Transforms/Scalar/SROA.cpp
===================================================================
--- lib/Transforms/Scalar/SROA.cpp
+++ lib/Transforms/Scalar/SROA.cpp
@@ -4423,12 +4423,11 @@
 
   DEBUG(dbgs() << "SROA function: " << F.getName() << "\n");
   C = &F.getContext();
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  if (!DLP) {
+  DL = F.getDataLayout();
+  if (!DL) {
     DEBUG(dbgs() << "  Skipping SROA -- no target data!\n");
     return false;
   }
-  DL = &DLP->getDataLayout();
   DominatorTreeWrapperPass *DTWP =
       getAnalysisIfAvailable<DominatorTreeWrapperPass>();
   DT = DTWP ? &DTWP->getDomTree() : nullptr;
Index: lib/Transforms/Scalar/ScalarReplAggregates.cpp
===================================================================
--- lib/Transforms/Scalar/ScalarReplAggregates.cpp
+++ lib/Transforms/Scalar/ScalarReplAggregates.cpp
@@ -1032,8 +1032,7 @@
   if (skipOptnoneFunction(F))
     return false;
 
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+  DL = F.getDataLayout();
 
   bool Changed = performPromotion(F);
 
Index: lib/Transforms/Scalar/Scalarizer.cpp
===================================================================
--- lib/Transforms/Scalar/Scalarizer.cpp
+++ lib/Transforms/Scalar/Scalarizer.cpp
@@ -248,8 +248,7 @@
 }
 
 bool Scalarizer::runOnFunction(Function &F) {
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+  DL = F.getDataLayout();
   for (Function::iterator BBI = F.begin(), BBE = F.end(); BBI != BBE; ++BBI) {
     BasicBlock *BB = BBI;
     for (BasicBlock::iterator II = BB->begin(), IE = BB->end(); II != IE;) {
Index: lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
===================================================================
--- lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
+++ lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
@@ -312,16 +312,12 @@
   }
 
   void getAnalysisUsage(AnalysisUsage &AU) const override {
-    AU.addRequired<DataLayoutPass>();
     AU.addRequired<TargetTransformInfoWrapperPass>();
     AU.setPreservesCFG();
   }
 
   bool doInitialization(Module &M) override {
-    DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-    if (DLP == nullptr)
-      report_fatal_error("data layout missing");
-    DL = &DLP->getDataLayout();
+    DL = M.getDataLayout();
     return false;
   }
 
@@ -386,7 +382,6 @@
     "Split GEPs to a variadic base and a constant offset for better CSE", false,
     false)
 INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
-INITIALIZE_PASS_DEPENDENCY(DataLayoutPass)
 INITIALIZE_PASS_END(
     SeparateConstOffsetFromGEP, "separate-const-offset-from-gep",
     "Split GEPs to a variadic base and a constant offset for better CSE", false,
Index: lib/Transforms/Scalar/SimplifyCFGPass.cpp
===================================================================
--- lib/Transforms/Scalar/SimplifyCFGPass.cpp
+++ lib/Transforms/Scalar/SimplifyCFGPass.cpp
@@ -207,8 +207,7 @@
         &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
     const TargetTransformInfo &TTI =
         getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
-    DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-    const DataLayout *DL = DLP ? &DLP->getDataLayout() : nullptr;
+    const DataLayout *DL = F.getDataLayout();
     return simplifyFunctionCFG(F, TTI, DL, AC, BonusInstThreshold);
   }
 
Index: lib/Transforms/Scalar/Sink.cpp
===================================================================
--- lib/Transforms/Scalar/Sink.cpp
+++ lib/Transforms/Scalar/Sink.cpp
@@ -100,8 +100,7 @@
   DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
   LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
   AA = &getAnalysis<AliasAnalysis>();
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+  DL = F.getDataLayout();
 
   bool MadeChange, EverMadeChange = false;
 
Index: lib/Transforms/Utils/InlineFunction.cpp
===================================================================
--- lib/Transforms/Utils/InlineFunction.cpp
+++ lib/Transforms/Utils/InlineFunction.cpp
@@ -622,7 +622,8 @@
 /// If the inlined function has non-byval align arguments, then
 /// add @llvm.assume-based alignment assumptions to preserve this information.
 static void AddAlignmentAssumptions(CallSite CS, InlineFunctionInfo &IFI) {
-  if (!PreserveAlignmentAssumptions || !IFI.DL)
+  auto *DL = CS.getCaller()->getDataLayout();
+  if (!PreserveAlignmentAssumptions || !DL)
     return;
 
   // To avoid inserting redundant assumptions, we should check for assumptions
@@ -645,12 +646,12 @@
       // If we can already prove the asserted alignment in the context of the
       // caller, then don't bother inserting the assumption.
       Value *Arg = CS.getArgument(I->getArgNo());
-      if (getKnownAlignment(Arg, IFI.DL,
+      if (getKnownAlignment(Arg, DL,
                             &IFI.ACT->getAssumptionCache(*CalledFunc),
                             CS.getInstruction(), &DT) >= Align)
         continue;
 
-      IRBuilder<>(CS.getInstruction()).CreateAlignmentAssumption(*IFI.DL, Arg,
+      IRBuilder<>(CS.getInstruction()).CreateAlignmentAssumption(*DL, Arg,
                                                                  Align);
     }
   }
@@ -727,10 +728,11 @@
   IRBuilder<> Builder(InsertBlock->begin());
 
   Value *Size;
-  if (IFI.DL == nullptr)
+  auto *DL = M->getDataLayout();
+  if (DL == nullptr)
     Size = ConstantExpr::getSizeOf(AggTy);
   else
-    Size = Builder.getInt64(IFI.DL->getTypeStoreSize(AggTy));
+    Size = Builder.getInt64(DL->getTypeStoreSize(AggTy));
 
   // Always generate a memcpy of alignment 1 here because we don't know
   // the alignment of the src pointer.  Other optimizations can infer
@@ -761,7 +763,8 @@
 
     // If the pointer is already known to be sufficiently aligned, or if we can
     // round it up to a larger alignment, then we don't need a temporary.
-    if (getOrEnforceKnownAlignment(Arg, ByValAlignment, IFI.DL,
+    auto *DL = Caller->getDataLayout();
+    if (getOrEnforceKnownAlignment(Arg, ByValAlignment, DL,
                                    &IFI.ACT->getAssumptionCache(*Caller),
                                    TheCall) >= ByValAlignment)
       return Arg;
@@ -772,8 +775,8 @@
 
   // Create the alloca.  If we have DataLayout, use nice alignment.
   unsigned Align = 1;
-  if (IFI.DL)
-    Align = IFI.DL->getPrefTypeAlignment(AggTy);
+  if (auto *DL = Caller->getDataLayout())
+    Align = DL->getPrefTypeAlignment(AggTy);
   
   // If the byval had an alignment specified, we *must* use at least that
   // alignment, as it is required by the byval argument (and uses of the
@@ -1008,6 +1011,8 @@
     // Keep a list of pair (dst, src) to emit byval initializations.
     SmallVector<std::pair<Value*, Value*>, 4> ByValInit;
 
+    auto *DL = Caller->getDataLayout();
+
     assert(CalledFunc->arg_size() == CS.arg_size() &&
            "No varargs calls can be inlined!");
 
@@ -1044,7 +1049,7 @@
     // happy with whatever the cloner can do.
     CloneAndPruneFunctionInto(Caller, CalledFunc, VMap, 
                               /*ModuleLevelChanges=*/false, Returns, ".i",
-                              &InlinedFunctionInfo, IFI.DL, TheCall);
+                              &InlinedFunctionInfo, DL, TheCall);
 
     // Remember the first block that is newly cloned over.
     FirstNewBlock = LastBlock; ++FirstNewBlock;
@@ -1065,7 +1070,7 @@
     CloneAliasScopeMetadata(CS, VMap);
 
     // Add noalias metadata if necessary.
-    AddAliasScopeMetadata(CS, VMap, IFI.DL, IFI.AA);
+    AddAliasScopeMetadata(CS, VMap, DL, IFI.AA);
 
     // FIXME: We could register any cloned assumptions instead of clearing the
     // whole function's cache.
@@ -1173,9 +1178,9 @@
       ConstantInt *AllocaSize = nullptr;
       if (ConstantInt *AIArraySize =
           dyn_cast<ConstantInt>(AI->getArraySize())) {
-        if (IFI.DL) {
+        if (auto *DL = Caller->getDataLayout()) {
           Type *AllocaType = AI->getAllocatedType();
-          uint64_t AllocaTypeSize = IFI.DL->getTypeAllocSize(AllocaType);
+          uint64_t AllocaTypeSize = DL->getTypeAllocSize(AllocaType);
           uint64_t AllocaArraySize = AIArraySize->getLimitedValue();
           assert(AllocaArraySize > 0 && "array size of AllocaInst is zero");
           // Check that array size doesn't saturate uint64_t and doesn't
@@ -1445,7 +1450,8 @@
   // the entries are the same or undef).  If so, remove the PHI so it doesn't
   // block other optimizations.
   if (PHI) {
-    if (Value *V = SimplifyInstruction(PHI, IFI.DL, nullptr, nullptr,
+    auto *DL = Caller->getDataLayout();
+    if (Value *V = SimplifyInstruction(PHI, DL, nullptr, nullptr,
                                        &IFI.ACT->getAssumptionCache(*Caller))) {
       PHI->replaceAllUsesWith(V);
       PHI->eraseFromParent();
Index: lib/Transforms/Utils/LoopSimplify.cpp
===================================================================
--- lib/Transforms/Utils/LoopSimplify.cpp
+++ lib/Transforms/Utils/LoopSimplify.cpp
@@ -797,8 +797,7 @@
   LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
   DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
   SE = getAnalysisIfAvailable<ScalarEvolution>();
-  DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-  DL = DLP ? &DLP->getDataLayout() : nullptr;
+  DL = F.getDataLayout();
   AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
 
   // Simplify each loop nest in the function.
Index: lib/Transforms/Utils/LoopUnroll.cpp
===================================================================
--- lib/Transforms/Utils/LoopUnroll.cpp
+++ lib/Transforms/Utils/LoopUnroll.cpp
@@ -531,8 +531,7 @@
     if (!OuterL && !CompletelyUnroll)
       OuterL = L;
     if (OuterL) {
-      DataLayoutPass *DLP = PP->getAnalysisIfAvailable<DataLayoutPass>();
-      const DataLayout *DL = DLP ? &DLP->getDataLayout() : nullptr;
+      const DataLayout *DL = F->getDataLayout();
       simplifyLoop(OuterL, DT, LI, PP, /*AliasAnalysis*/ nullptr, SE, DL, AC);
 
       // LCSSA must be performed on the outermost affected loop. The unrolled
Index: lib/Transforms/Utils/SimplifyInstructions.cpp
===================================================================
--- lib/Transforms/Utils/SimplifyInstructions.cpp
+++ lib/Transforms/Utils/SimplifyInstructions.cpp
@@ -51,8 +51,7 @@
       const DominatorTreeWrapperPass *DTWP =
           getAnalysisIfAvailable<DominatorTreeWrapperPass>();
       const DominatorTree *DT = DTWP ? &DTWP->getDomTree() : nullptr;
-      DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-      const DataLayout *DL = DLP ? &DLP->getDataLayout() : nullptr;
+      const DataLayout *DL = F.getDataLayout();
       const TargetLibraryInfo *TLI =
           &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
       AssumptionCache *AC =
Index: lib/Transforms/Vectorize/BBVectorize.cpp
===================================================================
--- lib/Transforms/Vectorize/BBVectorize.cpp
+++ lib/Transforms/Vectorize/BBVectorize.cpp
@@ -39,6 +39,7 @@
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Metadata.h"
+#include "llvm/IR/Module.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/ValueHandle.h"
 #include "llvm/Pass.h"
@@ -206,8 +207,7 @@
       AA = &P->getAnalysis<AliasAnalysis>();
       DT = &P->getAnalysis<DominatorTreeWrapperPass>().getDomTree();
       SE = &P->getAnalysis<ScalarEvolution>();
-      DataLayoutPass *DLP = P->getAnalysisIfAvailable<DataLayoutPass>();
-      DL = DLP ? &DLP->getDataLayout() : nullptr;
+      DL = F.getParent()->getDataLayout();
       TTI = IgnoreTargetInfo
                 ? nullptr
                 : &P->getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
@@ -442,8 +442,7 @@
       AA = &getAnalysis<AliasAnalysis>();
       DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
       SE = &getAnalysis<ScalarEvolution>();
-      DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-      DL = DLP ? &DLP->getDataLayout() : nullptr;
+      DL = BB.getParent()->getParent()->getDataLayout();
       TTI = IgnoreTargetInfo
                 ? nullptr
                 : &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(
Index: lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- lib/Transforms/Vectorize/LoopVectorize.cpp
+++ lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1270,8 +1270,7 @@
 
   bool runOnFunction(Function &F) override {
     SE = &getAnalysis<ScalarEvolution>();
-    DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-    DL = DLP ? &DLP->getDataLayout() : nullptr;
+    DL = F.getDataLayout();
     LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
     TTI = &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
     DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
Index: lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -3064,8 +3064,7 @@
       return false;
 
     SE = &getAnalysis<ScalarEvolution>();
-    DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
-    DL = DLP ? &DLP->getDataLayout() : nullptr;
+    DL = F.getDataLayout();
     TTI = &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
     auto *TLIP = getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
     TLI = TLIP ? &TLIP->getTLI() : nullptr;
Index: test/Analysis/Delinearization/a.ll
===================================================================
--- test/Analysis/Delinearization/a.ll
+++ test/Analysis/Delinearization/a.ll
@@ -9,7 +9,7 @@
 
 ; AddRec: {{{(28 + (4 * (-4 + (3 * %m)) * %o) + %A),+,(8 * %m * %o)}<%for.i>,+,(12 * %o)}<%for.j>,+,20}<%for.k>
 ; CHECK: Base offset: %A
-; CHECK: ArrayDecl[UnknownSize][%m][%o] with elements of sizeof(i32) bytes.
+; CHECK: ArrayDecl[UnknownSize][%m][%o] with elements of 4 bytes.
 ; CHECK: ArrayRef[{3,+,2}<%for.i>][{-4,+,3}<%for.j>][{7,+,5}<%for.k>]
 
 define void @foo(i64 %n, i64 %m, i64 %o, i32* nocapture %A) #0 {
Index: test/Analysis/Delinearization/himeno_1.ll
===================================================================
--- test/Analysis/Delinearization/himeno_1.ll
+++ test/Analysis/Delinearization/himeno_1.ll
@@ -28,7 +28,7 @@
 
 ; AddRec: {{{(4 + (4 * (sext i32 %a.deps to i64) * (1 + (sext i32 %a.cols to i64))) + %a.base),+,(4 * (sext i32 %a.deps to i64) * (sext i32 %a.cols to i64))}<%for.i>,+,(4 * (sext i32 %a.deps to i64))}<%for.j>,+,4}<%for.k>
 ; CHECK: Base offset: %a.base
-; CHECK: ArrayDecl[UnknownSize][(sext i32 %a.cols to i64)][(sext i32 %a.deps to i64)] with elements of sizeof(float) bytes.
+; CHECK: ArrayDecl[UnknownSize][(sext i32 %a.cols to i64)][(sext i32 %a.deps to i64)] with elements of 4 bytes.
 ; CHECK: ArrayRef[{1,+,1}<nuw><nsw><%for.i>][{1,+,1}<nuw><nsw><%for.j>][{1,+,1}<nuw><nsw><%for.k>]
 
 %struct.Mat = type { float*, i32, i32, i32, i32 }
Index: test/Analysis/Delinearization/himeno_2.ll
===================================================================
--- test/Analysis/Delinearization/himeno_2.ll
+++ test/Analysis/Delinearization/himeno_2.ll
@@ -28,7 +28,7 @@
 
 ; AddRec: {{{(4 + (4 * (sext i32 %a.deps to i64) * (1 + (sext i32 %a.cols to i64))) + %a.base),+,(4 * (sext i32 %a.deps to i64) * (sext i32 %a.cols to i64))}<%for.i>,+,(4 * (sext i32 %a.deps to i64))}<%for.j>,+,4}<%for.k>
 ; CHECK: Base offset: %a.base
-; CHECK: ArrayDecl[UnknownSize][(sext i32 %a.cols to i64)][(sext i32 %a.deps to i64)] with elements of sizeof(float) bytes.
+; CHECK: ArrayDecl[UnknownSize][(sext i32 %a.cols to i64)][(sext i32 %a.deps to i64)] with elements of 4 bytes.
 ; CHECK: ArrayRef[{1,+,1}<nuw><nsw><%for.i>][{1,+,1}<nuw><nsw><%for.j>][{1,+,1}<nuw><nsw><%for.k>]
 
 %struct.Mat = type { float*, i32, i32, i32, i32 }
Index: test/Analysis/Delinearization/iv_times_constant_in_subscript.ll
===================================================================
--- test/Analysis/Delinearization/iv_times_constant_in_subscript.ll
+++ test/Analysis/Delinearization/iv_times_constant_in_subscript.ll
@@ -8,9 +8,9 @@
 ;       A[2i+b][2j] = 1.0;
 ; }
 
-; AddRec: {{((%m * %b * sizeof(double)) + %A),+,(2 * %m * sizeof(double))}<%for.i>,+,(2 * sizeof(double))}<%for.j>
+; AddRec: {{((%m * %b * 8) + %A),+,(2 * %m * 8)}<%for.i>,+,(2 * 8)}<%for.j>
 ; CHECK: Base offset: %A
-; CHECK: ArrayDecl[UnknownSize][%m] with elements of sizeof(double) bytes.
+; CHECK: ArrayDecl[UnknownSize][%m] with elements of 8 bytes.
 ; CHECK: ArrayRef[{%b,+,2}<%for.i>][{0,+,2}<%for.j>]
 
 
Index: test/Analysis/Delinearization/multidim_ivs_and_integer_offsets_3d.ll
===================================================================
--- test/Analysis/Delinearization/multidim_ivs_and_integer_offsets_3d.ll
+++ test/Analysis/Delinearization/multidim_ivs_and_integer_offsets_3d.ll
@@ -10,7 +10,7 @@
 
 ; AddRec: {{{(56 + (8 * (-4 + (3 * %m)) * %o) + %A),+,(8 * %m * %o)}<%for.i>,+,(8 * %o)}<%for.j>,+,8}<%for.k>
 ; CHECK: Base offset: %A
-; CHECK: ArrayDecl[UnknownSize][%m][%o] with elements of sizeof(double) bytes.
+; CHECK: ArrayDecl[UnknownSize][%m][%o] with elements of 8 bytes.
 ; CHECK: ArrayRef[{3,+,1}<nw><%for.i>][{-4,+,1}<nw><%for.j>][{7,+,1}<nw><%for.k>]
 
 define void @foo(i64 %n, i64 %m, i64 %o, double* %A) {
Index: test/Analysis/Delinearization/multidim_ivs_and_integer_offsets_nts_3d.ll
===================================================================
--- test/Analysis/Delinearization/multidim_ivs_and_integer_offsets_nts_3d.ll
+++ test/Analysis/Delinearization/multidim_ivs_and_integer_offsets_nts_3d.ll
@@ -10,7 +10,7 @@
 
 ; AddRec: {{{(56 + (8 * (-4 + (3 * %m)) * (%o + %p)) + %A),+,(8 * (%o + %p) * %m)}<%for.cond4.preheader.lr.ph.us>,+,(8 * (%o + %p))}<%for.body6.lr.ph.us.us>,+,8}<%for.body6.us.us>
 ; CHECK: Base offset: %A
-; CHECK: ArrayDecl[UnknownSize][%m][(%o + %p)] with elements of sizeof(double) bytes.
+; CHECK: ArrayDecl[UnknownSize][%m][(%o + %p)] with elements of 8 bytes.
 ; CHECK: ArrayRef[{3,+,1}<nw><%for.cond4.preheader.lr.ph.us>][{-4,+,1}<nw><%for.body6.lr.ph.us.us>][{7,+,1}<nw><%for.body6.us.us>]
 
 define void @foo(i64 %n, i64 %m, i64 %o, i64 %p, double* nocapture %A) nounwind uwtable {
Index: test/Analysis/Delinearization/multidim_ivs_and_parameteric_offsets_3d.ll
===================================================================
--- test/Analysis/Delinearization/multidim_ivs_and_parameteric_offsets_3d.ll
+++ test/Analysis/Delinearization/multidim_ivs_and_parameteric_offsets_3d.ll
@@ -10,7 +10,7 @@
 
 ; AddRec: {{{((8 * ((((%m * %p) + %q) * %o) + %r)) + %A),+,(8 * %m * %o)}<%for.i>,+,(8 * %o)}<%for.j>,+,8}<%for.k>
 ; CHECK: Base offset: %A
-; CHECK: ArrayDecl[UnknownSize][%m][%o] with elements of sizeof(double) bytes.
+; CHECK: ArrayDecl[UnknownSize][%m][%o] with elements of 8 bytes.
 ; CHECK: ArrayRef[{%p,+,1}<nw><%for.i>][{%q,+,1}<nw><%for.j>][{%r,+,1}<nw><%for.k>]
 
 define void @foo(i64 %n, i64 %m, i64 %o, double* %A, i64 %p, i64 %q, i64 %r) {
Index: test/Analysis/Delinearization/multidim_only_ivs_2d.ll
===================================================================
--- test/Analysis/Delinearization/multidim_only_ivs_2d.ll
+++ test/Analysis/Delinearization/multidim_only_ivs_2d.ll
@@ -10,16 +10,16 @@
 
 ; Inst:  %val = load double, double* %arrayidx
 ; In Loop with Header: for.j
-; AddRec: {{0,+,(%m * sizeof(double))}<%for.i>,+,sizeof(double)}<%for.j>
+; AddRec: {{0,+,(%m * 8)}<%for.i>,+,8}<%for.j>
 ; Base offset: %A
-; ArrayDecl[UnknownSize][%m] with elements of sizeof(double) bytes.
+; ArrayDecl[UnknownSize][%m] with elements of 8 bytes.
 ; ArrayRef[{0,+,1}<nuw><nsw><%for.i>][{0,+,1}<nuw><nsw><%for.j>]
 
 ; Inst:  store double %val, double* %arrayidx
 ; In Loop with Header: for.j
 ; AddRec: {{%A,+,(8 * %m)}<%for.i>,+,8}<%for.j>
 ; CHECK: Base offset: %A
-; CHECK: ArrayDecl[UnknownSize][%m] with elements of sizeof(double) bytes.
+; CHECK: ArrayDecl[UnknownSize][%m] with elements of 8 bytes.
 ; CHECK: ArrayRef[{0,+,1}<nuw><nsw><%for.i>][{0,+,1}<nuw><nsw><%for.j>]
 
 define void @foo(i64 %n, i64 %m, double* %A) {
Index: test/Analysis/Delinearization/multidim_only_ivs_3d.ll
===================================================================
--- test/Analysis/Delinearization/multidim_only_ivs_3d.ll
+++ test/Analysis/Delinearization/multidim_only_ivs_3d.ll
@@ -10,7 +10,7 @@
 
 ; AddRec: {{{%A,+,(8 * %m * %o)}<%for.i>,+,(8 * %o)}<%for.j>,+,8}<%for.k>
 ; CHECK: Base offset: %A
-; CHECK: ArrayDecl[UnknownSize][%m][%o] with elements of sizeof(double) bytes.
+; CHECK: ArrayDecl[UnknownSize][%m][%o] with elements of 8 bytes.
 ; CHECK: ArrayRef[{0,+,1}<nuw><nsw><%for.i>][{0,+,1}<nuw><nsw><%for.j>][{0,+,1}<nuw><nsw><%for.k>]
 
 define void @foo(i64 %n, i64 %m, i64 %o, double* %A) {
Index: test/Analysis/ScalarEvolution/max-trip-count.ll
===================================================================
--- test/Analysis/ScalarEvolution/max-trip-count.ll
+++ test/Analysis/ScalarEvolution/max-trip-count.ll
@@ -2,7 +2,7 @@
 
 ; ScalarEvolution should be able to understand the loop and eliminate the casts.
 
-; CHECK: {%d,+,sizeof(i32)}
+; CHECK: {%d,+,4}
 
 define void @foo(i32* nocapture %d, i32 %n) nounwind {
 entry:
@@ -39,7 +39,7 @@
 ; count, it should say so.
 
 ; PR7845
-; CHECK: Loop %for.cond: <multiple exits> Unpredictable backedge-taken count. 
+; CHECK: Loop %for.cond: <multiple exits> Unpredictable backedge-taken count.
 ; CHECK: Loop %for.cond: max backedge-taken count is 5
 
 @.str = private constant [4 x i8] c"%d\0A\00"     ; <[4 x i8]*> [#uses=2]
@@ -101,7 +101,7 @@
 
 ; PR19799: Indvars miscompile due to an incorrect max backedge taken count from SCEV.
 ; CHECK-LABEL: @pr19799
-; CHECK: Loop %for.body.i: <multiple exits> Unpredictable backedge-taken count. 
+; CHECK: Loop %for.body.i: <multiple exits> Unpredictable backedge-taken count.
 ; CHECK: Loop %for.body.i: max backedge-taken count is 1
 @a = common global i32 0, align 4
 
@@ -127,7 +127,7 @@
 
 ; PR18886: Indvars miscompile due to an incorrect max backedge taken count from SCEV.
 ; CHECK-LABEL: @pr18886
-; CHECK: Loop %for.body: <multiple exits> Unpredictable backedge-taken count. 
+; CHECK: Loop %for.body: <multiple exits> Unpredictable backedge-taken count.
 ; CHECK: Loop %for.body: max backedge-taken count is 3
 @aa = global i64 0, align 8
 
@@ -157,8 +157,8 @@
 ; before the check is forever skipped.
 ;
 ; CHECK-LABEL: @cannot_compute_mustexit
-; CHECK: Loop %for.body.i: <multiple exits> Unpredictable backedge-taken count. 
-; CHECK: Loop %for.body.i: Unpredictable max backedge-taken count. 
+; CHECK: Loop %for.body.i: <multiple exits> Unpredictable backedge-taken count.
+; CHECK: Loop %for.body.i: Unpredictable max backedge-taken count.
 @b = common global i32 0, align 4
 
 define i32 @cannot_compute_mustexit() {
@@ -186,7 +186,7 @@
 ; MaxBECount should be the minimum of them.
 ;
 ; CHECK-LABEL: @two_mustexit
-; CHECK: Loop %for.body.i: <multiple exits> Unpredictable backedge-taken count. 
+; CHECK: Loop %for.body.i: <multiple exits> Unpredictable backedge-taken count.
 ; CHECK: Loop %for.body.i: max backedge-taken count is 1
 define i32 @two_mustexit() {
 entry:
Index: test/Bitcode/highLevelStructure.3.2.ll
===================================================================
--- test/Bitcode/highLevelStructure.3.2.ll
+++ test/Bitcode/highLevelStructure.3.2.ll
@@ -5,7 +5,7 @@
 ; older bitcode files.
 
 ; Data Layout Test
-; CHECK: target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-f80:32-n8:16:32-S32"
+; CHECK: target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-a0:0:64-f80:32:32-n8:16:32-S32"
 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-a0:0:64-f80:32:32-n8:16:32-S32"
 
 ; Module-Level Inline Assembly Test
Index: test/CodeGen/Thumb2/2009-12-01-LoopIVUsers.ll
===================================================================
--- test/CodeGen/Thumb2/2009-12-01-LoopIVUsers.ll
+++ test/CodeGen/Thumb2/2009-12-01-LoopIVUsers.ll
@@ -1,6 +1,8 @@
 ; RUN: opt < %s -O3 | \
 ; RUN:   llc -mtriple=thumbv7-apple-darwin10 -mattr=+neon | FileCheck %s
 
+target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:64:64-v128:128:128-a0:0:32"
+
 define void @fred(i32 %three_by_three, i8* %in, double %dt1, i32 %x_size, i32 %y_size, i8* %bp) nounwind {
 entry:
 ; -- The loop following the load should only use a single add-literation
Index: test/Linker/comdat3.ll
===================================================================
--- test/Linker/comdat3.ll
+++ /dev/null
@@ -1,5 +0,0 @@
-; RUN: not llvm-link %s %p/Inputs/comdat2.ll -S -o - 2>&1 | FileCheck %s
-
-$foo = comdat largest
-@foo = global i32 43, comdat($foo)
-; CHECK: Linking COMDATs named 'foo': can't do size dependent selection without DataLayout!
Index: test/Linker/datalayout.ll
===================================================================
--- test/Linker/datalayout.ll
+++ test/Linker/datalayout.ll
@@ -1,13 +1,12 @@
 ; REQUIRES: shell
-; RUN: llvm-link %s %S/Inputs/datalayout-a.ll -S -o - 2>%t.a.err | FileCheck %s
+; RUN: llvm-link %s %S/Inputs/datalayout-a.ll -S -o - 2>%t.a.err
 ; RUN: (echo foo ;cat %t.a.err) | FileCheck --check-prefix=WARN-A %s
 
-; RUN: llvm-link %s %S/Inputs/datalayout-b.ll -S -o - 2>%t.b.err | FileCheck %s
+; RUN: llvm-link %s %S/Inputs/datalayout-b.ll -S -o - 2>%t.b.err
 ; RUN: cat %t.b.err | FileCheck --check-prefix=WARN-B %s
 
 target datalayout = "e"
 
-; CHECK: target datalayout = "e"
 
 ; WARN-A-NOT: WARNING
 
Index: test/Other/constant-fold-gep.ll
===================================================================
--- test/Other/constant-fold-gep.ll
+++ test/Other/constant-fold-gep.ll
@@ -1,8 +1,8 @@
-; "PLAIN" - No optimizations. This tests the target-independent
+; "PLAIN" - No optimizations. This tests the default target layout
 ; constant folder.
 ; RUN: opt -S -o - < %s | FileCheck --check-prefix=PLAIN %s
 
-; "OPT" - Optimizations but no targetdata. This tests target-independent
+; "OPT" - Optimizations but no targetdata. This tests default target layout
 ; folding in the optimizers.
 ; RUN: opt -S -o - -instcombine -globalopt < %s | FileCheck --check-prefix=OPT %s
 
@@ -10,7 +10,7 @@
 ; folding in the optimizers.
 ; RUN: opt -S -o - -instcombine -globalopt -default-data-layout="e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" < %s | FileCheck --check-prefix=TO %s
 
-; "SCEV" - ScalarEvolution but no targetdata.
+; "SCEV" - ScalarEvolution with default target layout
 ; RUN: opt -analyze -scalar-evolution < %s | FileCheck --check-prefix=SCEV %s
 
 
@@ -24,12 +24,12 @@
 ; PLAIN: @F1 = global i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -2)
 ; PLAIN: @H8 = global i8* getelementptr (i8* null, i32 -1)
 ; PLAIN: @H1 = global i1* getelementptr (i1* null, i32 -1)
-; OPT: @G8 = global i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -1)
-; OPT: @G1 = global i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -1)
-; OPT: @F8 = global i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -2)
-; OPT: @F1 = global i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -2)
-; OPT: @H8 = global i8* getelementptr (i8* null, i32 -1)
-; OPT: @H1 = global i1* getelementptr (i1* null, i32 -1)
+; OPT: @G8 = global i8* null
+; OPT: @G1 = global i1* null
+; OPT: @F8 = global i8* inttoptr (i64 -1 to i8*)
+; OPT: @F1 = global i1* inttoptr (i64 -1 to i1*)
+; OPT: @H8 = global i8* inttoptr (i64 -1 to i8*)
+; OPT: @H1 = global i1* inttoptr (i64 -1 to i1*)
 ; TO: @G8 = global i8* null
 ; TO: @G1 = global i1* null
 ; TO: @F8 = global i8* inttoptr (i64 -1 to i8*)
@@ -57,15 +57,15 @@
 ; PLAIN: @g = constant i64 ptrtoint (double* getelementptr ({ i1, double }* null, i64 0, i32 1) to i64)
 ; PLAIN: @h = constant i64 ptrtoint (i1** getelementptr (i1** null, i32 1) to i64)
 ; PLAIN: @i = constant i64 ptrtoint (i1** getelementptr ({ i1, i1* }* null, i64 0, i32 1) to i64)
-; OPT: @a = constant i64 mul (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 2310)
-; OPT: @b = constant i64 ptrtoint (double* getelementptr ({ i1, double }* null, i64 0, i32 1) to i64)
-; OPT: @c = constant i64 mul (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 2)
-; OPT: @d = constant i64 mul (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 11)
-; OPT: @e = constant i64 ptrtoint (double* getelementptr ({ double, float, double, double }* null, i64 0, i32 2) to i64)
+; OPT: @a = constant i64 18480
+; OPT: @b = constant i64 8
+; OPT: @c = constant i64 16
+; OPT: @d = constant i64 88
+; OPT: @e = constant i64 16
 ; OPT: @f = constant i64 1
-; OPT: @g = constant i64 ptrtoint (double* getelementptr ({ i1, double }* null, i64 0, i32 1) to i64)
-; OPT: @h = constant i64 ptrtoint (i1** getelementptr (i1** null, i32 1) to i64)
-; OPT: @i = constant i64 ptrtoint (i1** getelementptr ({ i1, i1* }* null, i64 0, i32 1) to i64)
+; OPT: @g = constant i64 8
+; OPT: @h = constant i64 8
+; OPT: @i = constant i64 8
 ; TO: @a = constant i64 18480
 ; TO: @b = constant i64 8
 ; TO: @c = constant i64 16
@@ -91,9 +91,9 @@
 ; PLAIN: @M = constant i64* getelementptr (i64* null, i32 1)
 ; PLAIN: @N = constant i64* getelementptr ({ i64, i64 }* null, i32 0, i32 1)
 ; PLAIN: @O = constant i64* getelementptr ([2 x i64]* null, i32 0, i32 1)
-; OPT: @M = constant i64* getelementptr (i64* null, i32 1)
-; OPT: @N = constant i64* getelementptr ({ i64, i64 }* null, i32 0, i32 1)
-; OPT: @O = constant i64* getelementptr ([2 x i64]* null, i32 0, i32 1)
+; OPT: @M = constant i64* inttoptr (i64 8 to i64*)
+; OPT: @N = constant i64* inttoptr (i64 8 to i64*)
+; OPT: @O = constant i64* inttoptr (i64 8 to i64*)
 ; TO: @M = constant i64* inttoptr (i64 8 to i64*)
 ; TO: @N = constant i64* inttoptr (i64 8 to i64*)
 ; TO: @O = constant i64* inttoptr (i64 8 to i64*)
@@ -107,7 +107,7 @@
 ; PLAIN: @Y = global [3 x { i32, i32 }]* getelementptr inbounds ([3 x { i32, i32 }]* @ext, i64 2)
 ; PLAIN: @Z = global i32* getelementptr inbounds (i32* getelementptr inbounds ([3 x { i32, i32 }]* @ext, i64 0, i64 1, i32 0), i64 1)
 ; OPT: @Y = global [3 x { i32, i32 }]* getelementptr ([3 x { i32, i32 }]* @ext, i64 2)
-; OPT: @Z = global i32* getelementptr (i32* getelementptr inbounds ([3 x { i32, i32 }]* @ext, i64 0, i64 1, i32 0), i64 1)
+; OPT: @Z = global i32* getelementptr inbounds ([3 x { i32, i32 }]* @ext, i64 0, i64 1, i32 1)
 ; TO: @Y = global [3 x { i32, i32 }]* getelementptr ([3 x { i32, i32 }]* @ext, i64 2)
 ; TO: @Z = global i32* getelementptr inbounds ([3 x { i32, i32 }]* @ext, i64 0, i64 1, i32 1)
 
@@ -143,22 +143,22 @@
 ; PLAIN:   ret i1* %t
 ; PLAIN: }
 ; OPT: define i8* @goo8() #0 {
-; OPT:   ret i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -1)
+; OPT:   ret i8* null
 ; OPT: }
 ; OPT: define i1* @goo1() #0 {
-; OPT:   ret i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -1)
+; OPT:   ret i1* null
 ; OPT: }
 ; OPT: define i8* @foo8() #0 {
-; OPT:   ret i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -2)
+; OPT:   ret i8* inttoptr (i64 -1 to i8*)
 ; OPT: }
 ; OPT: define i1* @foo1() #0 {
-; OPT:   ret i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -2)
+; OPT:   ret i1* inttoptr (i64 -1 to i1*)
 ; OPT: }
 ; OPT: define i8* @hoo8() #0 {
-; OPT:   ret i8* getelementptr (i8* null, i32 -1)
+; OPT:   ret i8* inttoptr (i64 -1 to i8*)
 ; OPT: }
 ; OPT: define i1* @hoo1() #0 {
-; OPT:   ret i1* getelementptr (i1* null, i32 -1)
+; OPT:   ret i1* inttoptr (i64 -1 to i1*)
 ; OPT: }
 ; TO: define i8* @goo8() #0 {
 ; TO:   ret i8* null
@@ -180,20 +180,20 @@
 ; TO: }
 ; SCEV: Classifying expressions for: @goo8
 ; SCEV:   %t = bitcast i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -1) to i8*
-; SCEV:   -->  ((-1 * sizeof(i8)) + inttoptr (i32 1 to i8*))
+; SCEV:   -->  (-1 + inttoptr (i32 1 to i8*))
 ; SCEV: Classifying expressions for: @goo1
 ; SCEV:   %t = bitcast i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -1) to i1*
-; SCEV:   -->  ((-1 * sizeof(i1)) + inttoptr (i32 1 to i1*))
+; SCEV:   -->  (-1 + inttoptr (i32 1 to i1*))
 ; SCEV: Classifying expressions for: @foo8
 ; SCEV:   %t = bitcast i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -2) to i8*
-; SCEV:   -->  ((-2 * sizeof(i8)) + inttoptr (i32 1 to i8*))
+; SCEV:   -->  (-2 + inttoptr (i32 1 to i8*))
 ; SCEV: Classifying expressions for: @foo1
 ; SCEV:   %t = bitcast i1* getelementptr (i1* inttoptr (i32 1 to i1*), i32 -2) to i1*
-; SCEV:   -->  ((-2 * sizeof(i1)) + inttoptr (i32 1 to i1*))
+; SCEV:   -->  (-2 + inttoptr (i32 1 to i1*))
 ; SCEV: Classifying expressions for: @hoo8
-; SCEV:   -->  (-1 * sizeof(i8))
+; SCEV:   -->  -1
 ; SCEV: Classifying expressions for: @hoo1
-; SCEV:   -->  (-1 * sizeof(i1))
+; SCEV:   -->  -1
 
 define i8* @goo8() nounwind {
   %t = bitcast i8* getelementptr (i8* inttoptr (i32 1 to i8*), i32 -1) to i8*
@@ -257,31 +257,31 @@
 ; PLAIN:   ret i64 %t
 ; PLAIN: }
 ; OPT: define i64 @fa() #0 {
-; OPT:   ret i64 mul (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 2310)
+; OPT:   ret i64 18480
 ; OPT: }
 ; OPT: define i64 @fb() #0 {
-; OPT:   ret i64 ptrtoint (double* getelementptr ({ i1, double }* null, i64 0, i32 1) to i64)
+; OPT:   ret i64 8
 ; OPT: }
 ; OPT: define i64 @fc() #0 {
-; OPT:   ret i64 mul (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 2)
+; OPT:   ret i64 16
 ; OPT: }
 ; OPT: define i64 @fd() #0 {
-; OPT:   ret i64 mul (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 11)
+; OPT:   ret i64 88
 ; OPT: }
 ; OPT: define i64 @fe() #0 {
-; OPT:   ret i64 ptrtoint (double* getelementptr ({ double, float, double, double }* null, i64 0, i32 2) to i64)
+; OPT:   ret i64 16
 ; OPT: }
 ; OPT: define i64 @ff() #0 {
 ; OPT:   ret i64 1
 ; OPT: }
 ; OPT: define i64 @fg() #0 {
-; OPT:   ret i64 ptrtoint (double* getelementptr ({ i1, double }* null, i64 0, i32 1) to i64)
+; OPT:   ret i64 8
 ; OPT: }
 ; OPT: define i64 @fh() #0 {
-; OPT:   ret i64 ptrtoint (i1** getelementptr (i1** null, i32 1) to i64)
+; OPT:   ret i64 8
 ; OPT: }
 ; OPT: define i64 @fi() #0 {
-; OPT:   ret i64 ptrtoint (i1** getelementptr ({ i1, i1* }* null, i64 0, i32 1) to i64)
+; OPT:   ret i64 8
 ; OPT: }
 ; TO: define i64 @fa() #0 {
 ; TO:   ret i64 18480
@@ -311,22 +311,22 @@
 ; TO:   ret i64 8
 ; TO: }
 ; SCEV: Classifying expressions for: @fa
-; SCEV:   %t = bitcast i64 mul (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 2310) to i64 
+; SCEV:   %t = bitcast i64 mul (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 2310) to i64
 ; SCEV:   -->  (2310 * sizeof(double))
 ; SCEV: Classifying expressions for: @fb
-; SCEV:   %t = bitcast i64 ptrtoint (double* getelementptr ({ i1, double }* null, i64 0, i32 1) to i64) to i64 
+; SCEV:   %t = bitcast i64 ptrtoint (double* getelementptr ({ i1, double }* null, i64 0, i32 1) to i64) to i64
 ; SCEV:   -->  alignof(double)
 ; SCEV: Classifying expressions for: @fc
-; SCEV:   %t = bitcast i64 mul nuw (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 2) to i64 
+; SCEV:   %t = bitcast i64 mul nuw (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 2) to i64
 ; SCEV:   -->  (2 * sizeof(double))
 ; SCEV: Classifying expressions for: @fd
-; SCEV:   %t = bitcast i64 mul nuw (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 11) to i64 
+; SCEV:   %t = bitcast i64 mul nuw (i64 ptrtoint (double* getelementptr (double* null, i32 1) to i64), i64 11) to i64
 ; SCEV:   -->  (11 * sizeof(double))
 ; SCEV: Classifying expressions for: @fe
-; SCEV:   %t = bitcast i64 ptrtoint (double* getelementptr ({ double, float, double, double }* null, i64 0, i32 2) to i64) to i64 
+; SCEV:   %t = bitcast i64 ptrtoint (double* getelementptr ({ double, float, double, double }* null, i64 0, i32 2) to i64) to i64
 ; SCEV:   -->  offsetof({ double, float, double, double }, 2)
 ; SCEV: Classifying expressions for: @ff
-; SCEV:   %t = bitcast i64 1 to i64 
+; SCEV:   %t = bitcast i64 1 to i64
 ; SCEV:   -->  1
 ; SCEV: Classifying expressions for: @fg
 ; SCEV:   %t = bitcast i64 ptrtoint (double* getelementptr ({ i1, double }* null, i64 0, i32 1) to i64) to i64
@@ -388,13 +388,13 @@
 ; PLAIN:   ret i64* %t
 ; PLAIN: }
 ; OPT: define i64* @fM() #0 {
-; OPT:   ret i64* getelementptr (i64* null, i32 1)
+; OPT:   ret i64* inttoptr (i64 8 to i64*)
 ; OPT: }
 ; OPT: define i64* @fN() #0 {
-; OPT:   ret i64* getelementptr ({ i64, i64 }* null, i32 0, i32 1)
+; OPT:   ret i64* inttoptr (i64 8 to i64*)
 ; OPT: }
 ; OPT: define i64* @fO() #0 {
-; OPT:   ret i64* getelementptr ([2 x i64]* null, i32 0, i32 1)
+; OPT:   ret i64* inttoptr (i64 8 to i64*)
 ; OPT: }
 ; TO: define i64* @fM() #0 {
 ; TO:   ret i64* inttoptr (i64 8 to i64*)
@@ -406,14 +406,14 @@
 ; TO:   ret i64* inttoptr (i64 8 to i64*)
 ; TO: }
 ; SCEV: Classifying expressions for: @fM
-; SCEV:   %t = bitcast i64* getelementptr (i64* null, i32 1) to i64* 
-; SCEV:   -->  sizeof(i64)
+; SCEV:   %t = bitcast i64* getelementptr (i64* null, i32 1) to i64*
+; SCEV:   -->  8
 ; SCEV: Classifying expressions for: @fN
-; SCEV:   %t = bitcast i64* getelementptr ({ i64, i64 }* null, i32 0, i32 1) to i64* 
-; SCEV:   -->  sizeof(i64)
+; SCEV:   %t = bitcast i64* getelementptr ({ i64, i64 }* null, i32 0, i32 1) to i64*
+; SCEV:   -->  8
 ; SCEV: Classifying expressions for: @fO
-; SCEV:   %t = bitcast i64* getelementptr ([2 x i64]* null, i32 0, i32 1) to i64* 
-; SCEV:   -->  sizeof(i64)
+; SCEV:   %t = bitcast i64* getelementptr ([2 x i64]* null, i32 0, i32 1) to i64*
+; SCEV:   -->  8
 
 define i64* @fM() nounwind {
   %t = bitcast i64* getelementptr (i64* null, i32 1) to i64*
@@ -433,14 +433,14 @@
 ; PLAIN:   ret i32* %t
 ; PLAIN: }
 ; OPT: define i32* @fZ() #0 {
-; OPT:   ret i32* getelementptr (i32* getelementptr inbounds ([3 x { i32, i32 }]* @ext, i64 0, i64 1, i32 0), i64 1)
+; OPT:   ret i32* getelementptr inbounds ([3 x { i32, i32 }]* @ext, i64 0, i64 1, i32 1)
 ; OPT: }
 ; TO: define i32* @fZ() #0 {
 ; TO:   ret i32* getelementptr inbounds ([3 x { i32, i32 }]* @ext, i64 0, i64 1, i32 1)
 ; TO: }
 ; SCEV: Classifying expressions for: @fZ
 ; SCEV:   %t = bitcast i32* getelementptr inbounds (i32* getelementptr inbounds ([3 x { i32, i32 }]* @ext, i64 0, i64 1, i32 0), i64 1) to i32*
-; SCEV:   -->  ((3 * sizeof(i32)) + @ext)
+; SCEV:   -->  (12 + @ext)
 
 define i32* @fZ() nounwind {
   %t = bitcast i32* getelementptr inbounds (i32* getelementptr inbounds ([3 x { i32, i32 }]* @ext, i64 0, i64 1, i32 0), i64 1) to i32*
@@ -457,14 +457,14 @@
   %p = getelementptr inbounds i8, i8* addrspacecast ([4 x i8] addrspace(12)* @p12 to i8*),
                                   i32 2
   ret i8* %p
-; OPT: ret i8* getelementptr (i8* addrspacecast (i8 addrspace(12)* getelementptr inbounds ([4 x i8] addrspace(12)* @p12, i32 0, i32 0) to i8*), i32 2)
+; OPT: ret i8* getelementptr ([4 x i8]* addrspacecast ([4 x i8] addrspace(12)* @p12 to [4 x i8]*), i64 0, i64 2)
 }
 
 define i8* @same_addrspace() nounwind noinline {
 ; OPT: same_addrspace
   %p = getelementptr inbounds i8, i8* bitcast ([4 x i8] * @p0 to i8*), i32 2
   ret i8* %p
-; OPT: ret i8* getelementptr inbounds ([4 x i8]* @p0, i32 0, i32 2)
+; OPT: ret i8* getelementptr inbounds ([4 x i8]* @p0, i64 0, i64 2)
 }
 
 @gv1 = internal global i32 1
Index: test/Transforms/ConstantMerge/merge-both.ll
===================================================================
--- test/Transforms/ConstantMerge/merge-both.ll
+++ test/Transforms/ConstantMerge/merge-both.ll
@@ -1,7 +1,6 @@
 ; RUN: opt -constmerge -S < %s | FileCheck %s
 ; Test that in one run var3 is merged into var2 and var1 into var4.
-; Test that we merge @var5 and @var6 into one with the higher alignment, and
-; don't merge var7/var8 into var5/var6.
+; Test that we merge @var5 and @var6 into one with the higher alignment
 
 declare void @zed(%struct.foobar*, %struct.foobar*)
 
@@ -23,8 +22,8 @@
 @var7 = internal constant [16 x i8] c"foo1bar2foo3bar\00"
 @var8 = private unnamed_addr constant [16 x i8] c"foo1bar2foo3bar\00"
 
-; CHECK-NEXT: @var6 = private constant [16 x i8] c"foo1bar2foo3bar\00", align 16
-; CHECK-NEXT: @var8 = private constant [16 x i8] c"foo1bar2foo3bar\00"
+; CHECK-NEXT: @var7 = internal constant [16 x i8] c"foo1bar2foo3bar\00"
+; CHECK-NEXT: @var8 = private constant [16 x i8] c"foo1bar2foo3bar\00", align 16
 
 @var4a = alias %struct.foobar* @var4
 @llvm.used = appending global [1 x %struct.foobar*] [%struct.foobar* @var4a], section "llvm.metadata"
Index: test/Transforms/GlobalOpt/externally-initialized-global-ctr.ll
===================================================================
--- test/Transforms/GlobalOpt/externally-initialized-global-ctr.ll
+++ test/Transforms/GlobalOpt/externally-initialized-global-ctr.ll
@@ -26,7 +26,7 @@
 declare void @test(i8*)
 
 define void @print() {
-; CHECK: %1 = load i8*, i8** getelementptr inbounds ([1 x %struct.ButtonInitData]* @_ZL14buttonInitData, i32 0, i32 0, i32 0), align 4
+; CHECK: %1 = load i8*, i8** @_ZL14buttonInitData.0.0, align 4
   %1 = load i8*, i8** getelementptr inbounds ([1 x %struct.ButtonInitData]* @_ZL14buttonInitData, i32 0, i32 0, i32 0), align 4
   call void @test(i8* %1)
   ret void
Index: test/Transforms/IndVarSimplify/2008-09-02-IVType.ll
===================================================================
--- test/Transforms/IndVarSimplify/2008-09-02-IVType.ll
+++ test/Transforms/IndVarSimplify/2008-09-02-IVType.ll
@@ -1,6 +1,10 @@
 ; RUN: opt < %s -indvars -S | grep sext | count 1
 ; ModuleID = '<stdin>'
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
+
 	%struct.App1Marker = type <{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }>
 	%struct.ComponentInstanceRecord = type <{ [1 x i32] }>
 	%struct.DCPredictors = type { [5 x i16] }
Index: test/Transforms/IndVarSimplify/2009-04-27-Floating.ll
===================================================================
--- test/Transforms/IndVarSimplify/2009-04-27-Floating.ll
+++ test/Transforms/IndVarSimplify/2009-04-27-Floating.ll
@@ -1,5 +1,9 @@
 ; RUN: opt < %s -indvars -S | FileCheck %s
 ; PR4086
+
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
 declare void @foo()
 
 define void @test() {
Index: test/Transforms/IndVarSimplify/iv-widen.ll
===================================================================
--- test/Transforms/IndVarSimplify/iv-widen.ll
+++ test/Transforms/IndVarSimplify/iv-widen.ll
@@ -1,5 +1,9 @@
 ; RUN: opt < %s -indvars -S | FileCheck %s
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
+
 target triple = "x86_64-apple-darwin"
 
 ; CHECK-LABEL: @sloop
Index: test/Transforms/IndVarSimplify/lftr-extend-const.ll
===================================================================
--- test/Transforms/IndVarSimplify/lftr-extend-const.ll
+++ test/Transforms/IndVarSimplify/lftr-extend-const.ll
@@ -1,5 +1,9 @@
 ;RUN: opt -S %s -indvars | FileCheck %s
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
+
 ; CHECK-LABEL: @foo(
 ; CHECK-NOT: %lftr.wideiv = trunc i32 %indvars.iv.next to i16
 ; CHECK: %exitcond = icmp ne i32 %indvars.iv.next, 512
Index: test/Transforms/IndVarSimplify/lftr_simple.ll
===================================================================
--- test/Transforms/IndVarSimplify/lftr_simple.ll
+++ test/Transforms/IndVarSimplify/lftr_simple.ll
@@ -1,7 +1,11 @@
-; LFTR should eliminate the need for the computation of i*i completely.  It 
+; LFTR should eliminate the need for the computation of i*i completely.  It
 ; is only used to compute the exit value.
 ; RUN: opt < %s -indvars -dce -S | not grep mul
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
+
 @A = external global i32                ; <i32*> [#uses=1]
 
 define i32 @quadratic_setlt() {
Index: test/Transforms/IndVarSimplify/pr20680.ll
===================================================================
--- test/Transforms/IndVarSimplify/pr20680.ll
+++ test/Transforms/IndVarSimplify/pr20680.ll
@@ -1,5 +1,9 @@
 ; RUN: opt < %s -indvars -S | FileCheck %s
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
+
 @a = common global i32 0, align 4
 @c = common global i32 0, align 4
 @b = common global i32 0, align 4
Index: test/Transforms/IndVarSimplify/preserve-signed-wrap.ll
===================================================================
--- test/Transforms/IndVarSimplify/preserve-signed-wrap.ll
+++ test/Transforms/IndVarSimplify/preserve-signed-wrap.ll
@@ -4,6 +4,10 @@
 ; sext for the addressing, however it shouldn't eliminate the sext
 ; on the other phi, since that value undergoes signed wrapping.
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
+
 define void @foo(i32* nocapture %d, i32 %n) nounwind {
 entry:
 	%0 = icmp sgt i32 %n, 0		; <i1> [#uses=1]
Index: test/Transforms/IndVarSimplify/promote-iv-to-eliminate-casts.ll
===================================================================
--- test/Transforms/IndVarSimplify/promote-iv-to-eliminate-casts.ll
+++ test/Transforms/IndVarSimplify/promote-iv-to-eliminate-casts.ll
@@ -1,5 +1,8 @@
-; RUN: opt < %s -indvars -S > %t
-; RUN: not grep sext %t
+; RUN: opt < %s -indvars -S | not grep sext
+
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
 
 define i64 @test(i64* nocapture %first, i32 %count) nounwind readonly {
 entry:
Index: test/Transforms/IndVarSimplify/signed-trip-count.ll
===================================================================
--- test/Transforms/IndVarSimplify/signed-trip-count.ll
+++ test/Transforms/IndVarSimplify/signed-trip-count.ll
@@ -2,6 +2,10 @@
 ; RUN: not grep sext %t
 ; RUN: grep phi %t | count 1
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
+
 define void @foo(i64* nocapture %x, i32 %n) nounwind {
 entry:
 	%tmp102 = icmp sgt i32 %n, 0		; <i1> [#uses=1]
Index: test/Transforms/IndVarSimplify/ult-sub-to-eq.ll
===================================================================
--- test/Transforms/IndVarSimplify/ult-sub-to-eq.ll
+++ test/Transforms/IndVarSimplify/ult-sub-to-eq.ll
@@ -1,5 +1,9 @@
 ; RUN: opt -S -indvars < %s | FileCheck %s
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
+
 define void @test1(float* nocapture %autoc, float* nocapture %data, float %d, i32 %data_len, i32 %sample) nounwind {
 entry:
   %sub = sub i32 %data_len, %sample
Index: test/Transforms/IndVarSimplify/widen-loop-comp.ll
===================================================================
--- test/Transforms/IndVarSimplify/widen-loop-comp.ll
+++ test/Transforms/IndVarSimplify/widen-loop-comp.ll
@@ -1,6 +1,10 @@
 ; RUN: opt < %s -indvars -S | FileCheck %s
 target triple = "aarch64--linux-gnu"
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
+
 ; Check the loop exit i32 compare instruction and operand are widened to i64
 ; instead of truncating IV before its use in the i32 compare instruction.
 
Index: test/Transforms/Inline/alloca-merge-align-nodl.ll
===================================================================
--- test/Transforms/Inline/alloca-merge-align-nodl.ll
+++ /dev/null
@@ -1,88 +0,0 @@
-; RUN: opt < %s -inline -S | FileCheck %s
-; This variant of the test has no data layout information.
-target triple = "powerpc64-unknown-linux-gnu"
-
-%struct.s = type { i32, i32 }
-
-define void @foo(%struct.s* byval nocapture readonly %a) {
-entry:
-  %x = alloca [2 x i32], align 4
-  %a1 = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 0
-  %0 = load i32, i32* %a1, align 4
-  %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 0
-  store i32 %0, i32* %arrayidx, align 4
-  %b = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 1
-  %1 = load i32, i32* %b, align 4
-  %arrayidx2 = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 1
-  store i32 %1, i32* %arrayidx2, align 4
-  call void @bar(i32* %arrayidx) #2
-  ret void
-}
-
-define void @foo0(%struct.s* byval nocapture readonly %a) {
-entry:
-  %x = alloca [2 x i32]
-  %a1 = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 0
-  %0 = load i32, i32* %a1, align 4
-  %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 0
-  store i32 %0, i32* %arrayidx, align 4
-  %b = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 1
-  %1 = load i32, i32* %b, align 4
-  %arrayidx2 = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 1
-  store i32 %1, i32* %arrayidx2, align 4
-  call void @bar(i32* %arrayidx) #2
-  ret void
-}
-
-declare void @bar(i32*) #1
-
-define void @goo(%struct.s* byval nocapture readonly %a) {
-entry:
-  %x = alloca [2 x i32], align 32
-  %a1 = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 0
-  %0 = load i32, i32* %a1, align 4
-  %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 0
-  store i32 %0, i32* %arrayidx, align 32
-  %b = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 1
-  %1 = load i32, i32* %b, align 4
-  %arrayidx2 = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 1
-  store i32 %1, i32* %arrayidx2, align 4
-  call void @bar(i32* %arrayidx) #2
-  ret void
-}
-
-; CHECK-LABEL: @main
-; CHECK: alloca [2 x i32], align 32
-; CHECK-NOT: alloca [2 x i32]
-; CHECK: ret i32 0
-
-define signext i32 @main() {
-entry:
-  %a = alloca i64, align 8
-  %tmpcast = bitcast i64* %a to %struct.s*
-  store i64 0, i64* %a, align 8
-  %a1 = bitcast i64* %a to i32*
-  store i32 1, i32* %a1, align 8
-  call void @foo(%struct.s* byval %tmpcast)
-  store i32 2, i32* %a1, align 8
-  call void @goo(%struct.s* byval %tmpcast)
-  ret i32 0
-}
-
-; CHECK-LABEL: @test0
-; CHECK: alloca [2 x i32], align 32
-; CHECK: alloca [2 x i32]
-; CHECK: ret i32 0
-
-define signext i32 @test0() {
-entry:
-  %a = alloca i64, align 8
-  %tmpcast = bitcast i64* %a to %struct.s*
-  store i64 0, i64* %a, align 8
-  %a1 = bitcast i64* %a to i32*
-  store i32 1, i32* %a1, align 8
-  call void @foo0(%struct.s* byval %tmpcast)
-  store i32 2, i32* %a1, align 8
-  call void @goo(%struct.s* byval %tmpcast)
-  ret i32 0
-}
Index: test/Transforms/Inline/lifetime-no-datalayout.ll
===================================================================
--- test/Transforms/Inline/lifetime-no-datalayout.ll
+++ test/Transforms/Inline/lifetime-no-datalayout.ll
@@ -8,13 +8,13 @@
   ret void
 }
 
-; Size in llvm.lifetime.X should be -1 (unknown).
+; Size in llvm.lifetime.X should be 1 (default for i8).
 define void @test() {
 ; CHECK-LABEL: @test(
 ; CHECK-NOT: lifetime
-; CHECK: llvm.lifetime.start(i64 -1
+; CHECK: llvm.lifetime.start(i64 1
 ; CHECK-NOT: lifetime
-; CHECK: llvm.lifetime.end(i64 -1
+; CHECK: llvm.lifetime.end(i64 1
   call void @helper()
 ; CHECK-NOT: lifetime
 ; CHECK: ret void
Index: test/Transforms/InstCombine/2012-09-24-MemcpyFromGlobalCrash.ll
===================================================================
--- test/Transforms/InstCombine/2012-09-24-MemcpyFromGlobalCrash.ll
+++ /dev/null
@@ -1,19 +0,0 @@
-; RUN: opt < %s -instcombine -S | FileCheck %s
-
-; Check we don't crash due to lack of target data.
-
-@G = constant [100 x i8] zeroinitializer
-
-declare void @bar(i8*)
-declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
-
-define void @test() {
-; CHECK-LABEL: @test(
-; CHECK: llvm.memcpy
-; CHECK: ret void
-  %A = alloca [100 x i8]
-  %a = getelementptr inbounds [100 x i8], [100 x i8]* %A, i64 0, i64 0
-  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* getelementptr inbounds ([100 x i8]* @G, i64 0, i32 0), i64 100, i32 4, i1 false)
-  call void @bar(i8* %a) readonly
-  ret void
-}
Index: test/Transforms/InstCombine/extractvalue.ll
===================================================================
--- test/Transforms/InstCombine/extractvalue.ll
+++ test/Transforms/InstCombine/extractvalue.ll
@@ -13,7 +13,7 @@
         %s1 = insertvalue {i32, i32} %s1.1, i32 %b, 1
         %v1 = extractvalue {i32, i32} %s1, 0
         %v2 = extractvalue {i32, i32} %s1, 1
-        
+
         ; Build a nested struct and pull a sub struct out of it
         ; This requires instcombine to insert a few insertvalue instructions
         %ns1.1 = insertvalue {i32, {i32, i32}} undef, i32 %v1, 0
@@ -40,7 +40,7 @@
 }
 
 ; CHECK-LABEL: define i32 @extract2gep(
-; CHECK-NEXT: [[GEP:%[a-z0-9]+]] = getelementptr inbounds {{.*}}, {{.*}}* %pair, i32 0, i32 1
+; CHECK-NEXT: [[GEP:%[a-z0-9]+]] = getelementptr inbounds {{.*}}, {{.*}}* %pair, i64 0, i32 1
 ; CHECK-NEXT: [[LOAD:%[A-Za-z0-9]+]] = load i32, i32* [[GEP]]
 ; CHECK-NEXT: store
 ; CHECK-NEXT: br label %loop
@@ -68,7 +68,7 @@
 }
 
 ; CHECK-LABEL: define i32 @doubleextract2gep(
-; CHECK-NEXT: [[GEP:%[a-z0-9]+]] = getelementptr inbounds {{.*}}, {{.*}}* %arg, i32 0, i32 1, i32 1
+; CHECK-NEXT: [[GEP:%[a-z0-9]+]] = getelementptr inbounds {{.*}}, {{.*}}* %arg, i64 0, i32 1, i32 1
 ; CHECK-NEXT: [[LOAD:%[A-Za-z0-9]+]] = load i32, i32* [[GEP]]
 ; CHECK-NEXT: ret i32 [[LOAD]]
 define i32 @doubleextract2gep({i32, {i32, i32}}* %arg) {
Index: test/Transforms/InstCombine/gc.relocate.ll
===================================================================
--- test/Transforms/InstCombine/gc.relocate.ll
+++ test/Transforms/InstCombine/gc.relocate.ll
@@ -1,4 +1,5 @@
-; RUN: opt < %s -datalayout -instcombine -S | FileCheck %s
+; RUN: opt < %s -instcombine -S | FileCheck %s
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
 
 ; Uses InstCombine with DataLayout to propagate dereferenceable
 ; attribute via gc.relocate: if the derived ptr is dereferenceable(N),
Index: test/Transforms/InstCombine/load-cmp.ll
===================================================================
--- test/Transforms/InstCombine/load-cmp.ll
+++ test/Transforms/InstCombine/load-cmp.ll
@@ -1,5 +1,4 @@
-; RUN: opt -instcombine -S < %s | FileCheck -check-prefix=NODL %s
-; RUN: opt -instcombine -S -default-data-layout="p:32:32:32-p1:16:16:16-n8:16:32:64" < %s | FileCheck -check-prefix=P32 %s
+; RUN: opt -instcombine -S -default-data-layout="p:32:32:32-p1:16:16:16-n8:16:32:64" < %s | FileCheck %s
 
 @G16 = internal constant [10 x i16] [i16 35, i16 82, i16 69, i16 81, i16 85,
                                      i16 73, i16 82, i16 69, i16 68, i16 0]
@@ -25,13 +24,9 @@
   %Q = load i16, i16* %P
   %R = icmp eq i16 %Q, 0
   ret i1 %R
-; NODL-LABEL: @test1(
-; NODL-NEXT: %R = icmp eq i32 %X, 9
-; NODL-NEXT: ret i1 %R
-
-; P32-LABEL: @test1(
-; P32-NEXT: %R = icmp eq i32 %X, 9
-; P32-NEXT: ret i1 %R
+; CHECK-LABEL: @test1(
+; CHECK-NEXT: %R = icmp eq i32 %X, 9
+; CHECK-NEXT: ret i1 %R
 }
 
 define i1 @test1_noinbounds(i32 %X) {
@@ -39,12 +34,9 @@
   %Q = load i16, i16* %P
   %R = icmp eq i16 %Q, 0
   ret i1 %R
-; NODL-LABEL: @test1_noinbounds(
-; NODL-NEXT: %P = getelementptr [10 x i16], [10 x i16]* @G16, i32 0, i32 %X
-
-; P32-LABEL: @test1_noinbounds(
-; P32-NEXT: %R = icmp eq i32 %X, 9
-; P32-NEXT: ret i1 %R
+; CHECK-LABEL: @test1_noinbounds(
+; CHECK-NEXT: %R = icmp eq i32 %X, 9
+; CHECK-NEXT: ret i1 %R
 }
 
 define i1 @test1_noinbounds_i64(i64 %X) {
@@ -52,12 +44,9 @@
   %Q = load i16, i16* %P
   %R = icmp eq i16 %Q, 0
   ret i1 %R
-; NODL-LABEL: @test1_noinbounds_i64(
-; NODL-NEXT: %P = getelementptr [10 x i16], [10 x i16]* @G16, i64 0, i64 %X
-
-; P32-LABEL: @test1_noinbounds_i64(
-; P32: %R = icmp eq i32 %1, 9
-; P32-NEXT: ret i1 %R
+; CHECK-LABEL: @test1_noinbounds_i64(
+; CHECK: %R = icmp eq i32 %1, 9
+; CHECK-NEXT: ret i1 %R
 }
 
 define i1 @test1_noinbounds_as1(i32 %x) {
@@ -66,10 +55,10 @@
   %r = icmp eq i16 %q, 0
   ret i1 %r
 
-; P32-LABEL: @test1_noinbounds_as1(
-; P32-NEXT: trunc i32 %x to i16
-; P32-NEXT: %r = icmp eq i16 %1, 9
-; P32-NEXT: ret i1 %r
+; CHECK-LABEL: @test1_noinbounds_as1(
+; CHECK-NEXT: trunc i32 %x to i16
+; CHECK-NEXT: %r = icmp eq i16 %1, 9
+; CHECK-NEXT: ret i1 %r
 }
 
 define i1 @test2(i32 %X) {
@@ -77,9 +66,9 @@
   %Q = load i16, i16* %P
   %R = icmp slt i16 %Q, 85
   ret i1 %R
-; NODL-LABEL: @test2(
-; NODL-NEXT: %R = icmp ne i32 %X, 4
-; NODL-NEXT: ret i1 %R
+; CHECK-LABEL: @test2(
+; CHECK-NEXT:  %R = icmp ne i32 %X, 4
+; CHECK-NEXT:  ret i1 %R
 }
 
 define i1 @test3(i32 %X) {
@@ -87,13 +76,9 @@
   %Q = load double, double* %P
   %R = fcmp oeq double %Q, 1.0
   ret i1 %R
-; NODL-LABEL: @test3(
-; NODL-NEXT: %R = icmp eq i32 %X, 1
-; NODL-NEXT: ret i1 %R
-
-; P32-LABEL: @test3(
-; P32-NEXT: %R = icmp eq i32 %X, 1
-; P32-NEXT: ret i1 %R
+; CHECK-LABEL: @test3(
+; CHECK-NEXT: %R = icmp eq i32 %X, 1
+; CHECK-NEXT: ret i1 %R
 
 }
 
@@ -102,17 +87,11 @@
   %Q = load i16, i16* %P
   %R = icmp sle i16 %Q, 73
   ret i1 %R
-; NODL-LABEL: @test4(
-; NODL-NEXT: lshr i32 933, %X
-; NODL-NEXT: and i32 {{.*}}, 1
-; NODL-NEXT: %R = icmp ne i32 {{.*}}, 0
-; NODL-NEXT: ret i1 %R
-
-; P32-LABEL: @test4(
-; P32-NEXT: lshr i32 933, %X
-; P32-NEXT: and i32 {{.*}}, 1
-; P32-NEXT: %R = icmp ne i32 {{.*}}, 0
-; P32-NEXT: ret i1 %R
+; CHECK-LABEL: @test4(
+; CHECK-NEXT: lshr i32 933, %X
+; CHECK-NEXT: and i32 {{.*}}, 1
+; CHECK-NEXT: %R = icmp ne i32 {{.*}}, 0
+; CHECK-NEXT: ret i1 %R
 }
 
 define i1 @test4_i16(i16 %X) {
@@ -120,19 +99,12 @@
   %Q = load i16, i16* %P
   %R = icmp sle i16 %Q, 73
   ret i1 %R
-
-; NODL-LABEL: @test4_i16(
-; NODL-NEXT: lshr i16 933, %X
-; NODL-NEXT: and i16 {{.*}}, 1
-; NODL-NEXT: %R = icmp ne i16 {{.*}}, 0
-; NODL-NEXT: ret i1 %R
-
-; P32-LABEL: @test4_i16(
-; P32-NEXT: sext i16 %X to i32
-; P32-NEXT: lshr i32 933, %1
-; P32-NEXT: and i32 {{.*}}, 1
-; P32-NEXT: %R = icmp ne i32 {{.*}}, 0
-; P32-NEXT: ret i1 %R
+; CHECK-LABEL: @test4_i16(
+; CHECK-NEXT: sext i16 %X to i32
+; CHECK-NEXT: lshr i32 933, %1
+; CHECK-NEXT: and i32 {{.*}}, 1
+; CHECK-NEXT: %R = icmp ne i32 {{.*}}, 0
+; CHECK-NEXT: ret i1 %R
 }
 
 define i1 @test5(i32 %X) {
@@ -140,17 +112,11 @@
   %Q = load i16, i16* %P
   %R = icmp eq i16 %Q, 69
   ret i1 %R
-; NODL-LABEL: @test5(
-; NODL-NEXT: icmp eq i32 %X, 2
-; NODL-NEXT: icmp eq i32 %X, 7
-; NODL-NEXT: %R = or i1
-; NODL-NEXT: ret i1 %R
-
-; P32-LABEL: @test5(
-; P32-NEXT: icmp eq i32 %X, 2
-; P32-NEXT: icmp eq i32 %X, 7
-; P32-NEXT: %R = or i1
-; P32-NEXT: ret i1 %R
+; CHECK-LABEL: @test5(
+; CHECK-NEXT: icmp eq i32 %X, 2
+; CHECK-NEXT: icmp eq i32 %X, 7
+; CHECK-NEXT: %R = or i1
+; CHECK-NEXT: ret i1 %R
 }
 
 define i1 @test6(i32 %X) {
@@ -158,15 +124,10 @@
   %Q = load double, double* %P
   %R = fcmp ogt double %Q, 0.0
   ret i1 %R
-; NODL-LABEL: @test6(
-; NODL-NEXT: add i32 %X, -1
-; NODL-NEXT: %R = icmp ult i32 {{.*}}, 3
-; NODL-NEXT: ret i1 %R
-
-; P32-LABEL: @test6(
-; P32-NEXT: add i32 %X, -1
-; P32-NEXT: %R = icmp ult i32 {{.*}}, 3
-; P32-NEXT: ret i1 %R
+; CHECK-LABEL: @test6(
+; CHECK-NEXT: add i32 %X, -1
+; CHECK-NEXT: %R = icmp ult i32 {{.*}}, 3
+; CHECK-NEXT: ret i1 %R
 }
 
 define i1 @test7(i32 %X) {
@@ -174,15 +135,10 @@
   %Q = load double, double* %P
   %R = fcmp olt double %Q, 0.0
   ret i1 %R
-; NODL-LABEL: @test7(
-; NODL-NEXT: add i32 %X, -1
-; NODL-NEXT: %R = icmp ugt i32 {{.*}}, 2
-; NODL-NEXT: ret i1 %R
-
-; P32-LABEL: @test7(
-; P32-NEXT: add i32 %X, -1
-; P32-NEXT: %R = icmp ugt i32 {{.*}}, 2
-; P32-NEXT: ret i1 %R
+; CHECK-LABEL: @test7(
+; CHECK-NEXT: add i32 %X, -1
+; CHECK-NEXT: %R = icmp ugt i32 {{.*}}, 2
+; CHECK-NEXT: ret i1 %R
 }
 
 define i1 @test8(i32 %X) {
@@ -191,15 +147,10 @@
   %R = and i16 %Q, 3
   %S = icmp eq i16 %R, 0
   ret i1 %S
-; NODL-LABEL: @test8(
-; NODL-NEXT: and i32 %X, -2
-; NODL-NEXT: icmp eq i32 {{.*}}, 8
-; NODL-NEXT: ret i1
-
-; P32-LABEL: @test8(
-; P32-NEXT: and i32 %X, -2
-; P32-NEXT: icmp eq i32 {{.*}}, 8
-; P32-NEXT: ret i1
+; CHECK-LABEL: @test8(
+; CHECK-NEXT: and i32 %X, -2
+; CHECK-NEXT: icmp eq i32 {{.*}}, 8
+; CHECK-NEXT: ret i1
 }
 
 @GA = internal constant [4 x { i32, i32 } ] [
@@ -214,23 +165,15 @@
   %Q = load i32, i32* %P
   %R = icmp eq i32 %Q, 1
   ret i1 %R
-; NODL-LABEL: @test9(
-; NODL-NEXT: add i32 %X, -1
-; NODL-NEXT: icmp ult i32 {{.*}}, 2
-; NODL-NEXT: ret i1
-
-; P32-LABEL: @test9(
-; P32-NEXT: add i32 %X, -1
-; P32-NEXT: icmp ult i32 {{.*}}, 2
-; P32-NEXT: ret i1
+; CHECK-LABEL: @test9(
+; CHECK-NEXT: add i32 %X, -1
+; CHECK-NEXT: icmp ult i32 {{.*}}, 2
+; CHECK-NEXT: ret i1
 }
 
 define i1 @test10_struct(i32 %x) {
-; NODL-LABEL: @test10_struct(
-; NODL: getelementptr inbounds %Foo, %Foo* @GS, i32 %x, i32 0
-
-; P32-LABEL: @test10_struct(
-; P32: ret i1 false
+; CHECK-LABEL: @test10_struct(
+; CHECK: ret i1 false
   %p = getelementptr inbounds %Foo, %Foo* @GS, i32 %x, i32 0
   %q = load i32, i32* %p
   %r = icmp eq i32 %q, 9
@@ -238,11 +181,8 @@
 }
 
 define i1 @test10_struct_noinbounds(i32 %x) {
-; NODL-LABEL: @test10_struct_noinbounds(
-; NODL: getelementptr %Foo, %Foo* @GS, i32 %x, i32 0
-
-; P32-LABEL: @test10_struct_noinbounds(
-; P32: getelementptr %Foo, %Foo* @GS, i32 %x, i32 0
+; CHECK-LABEL: @test10_struct_noinbounds(
+; CHECK: getelementptr %Foo, %Foo* @GS, i32 %x, i32 0
   %p = getelementptr %Foo, %Foo* @GS, i32 %x, i32 0
   %q = load i32, i32* %p
   %r = icmp eq i32 %q, 9
@@ -252,11 +192,8 @@
 ; Test that the GEP indices are converted before we ever get here
 ; Index < ptr size
 define i1 @test10_struct_i16(i16 %x){
-; NODL-LABEL: @test10_struct_i16(
-; NODL: getelementptr inbounds %Foo, %Foo* @GS, i16 %x, i32 0
-
-; P32-LABEL: @test10_struct_i16(
-; P32: ret i1 false
+; CHECK-LABEL: @test10_struct_i16(
+; CHECK: ret i1 false
   %p = getelementptr inbounds %Foo, %Foo* @GS, i16 %x, i32 0
   %q = load i32, i32* %p
   %r = icmp eq i32 %q, 0
@@ -266,11 +203,8 @@
 ; Test that the GEP indices are converted before we ever get here
 ; Index > ptr size
 define i1 @test10_struct_i64(i64 %x){
-; NODL-LABEL: @test10_struct_i64(
-; NODL: getelementptr inbounds %Foo, %Foo* @GS, i64 %x, i32 0
-
-; P32-LABEL: @test10_struct_i64(
-; P32: ret i1 false
+; CHECK-LABEL: @test10_struct_i64(
+; CHECK: ret i1 false
   %p = getelementptr inbounds %Foo, %Foo* @GS, i64 %x, i32 0
   %q = load i32, i32* %p
   %r = icmp eq i32 %q, 0
@@ -278,12 +212,9 @@
 }
 
 define i1 @test10_struct_noinbounds_i16(i16 %x) {
-; NODL-LABEL: @test10_struct_noinbounds_i16(
-; NODL: getelementptr %Foo, %Foo* @GS, i16 %x, i32 0
-
-; P32-LABEL: @test10_struct_noinbounds_i16(
-; P32: %1 = sext i16 %x to i32
-; P32: getelementptr %Foo, %Foo* @GS, i32 %1, i32 0
+; CHECK-LABEL: @test10_struct_noinbounds_i16(
+; CHECK: %1 = sext i16 %x to i32
+; CHECK: getelementptr %Foo, %Foo* @GS, i32 %1, i32 0
   %p = getelementptr %Foo, %Foo* @GS, i16 %x, i32 0
   %q = load i32, i32* %p
   %r = icmp eq i32 %q, 0
@@ -291,13 +222,9 @@
 }
 
 define i1 @test10_struct_arr(i32 %x) {
-; NODL-LABEL: @test10_struct_arr(
-; NODL-NEXT: %r = icmp ne i32 %x, 1
-; NODL-NEXT: ret i1 %r
-
-; P32-LABEL: @test10_struct_arr(
-; P32-NEXT: %r = icmp ne i32 %x, 1
-; P32-NEXT: ret i1 %r
+; CHECK-LABEL: @test10_struct_arr(
+; CHECK-NEXT: %r = icmp ne i32 %x, 1
+; CHECK-NEXT: ret i1 %r
   %p = getelementptr inbounds [4 x %Foo], [4 x %Foo]* @GStructArr, i32 0, i32 %x, i32 2
   %q = load i32, i32* %p
   %r = icmp eq i32 %q, 9
@@ -305,11 +232,8 @@
 }
 
 define i1 @test10_struct_arr_noinbounds(i32 %x) {
-; NODL-LABEL: @test10_struct_arr_noinbounds(
-; NODL-NEXT  %p = getelementptr [4 x %Foo], [4 x %Foo]* @GStructArr, i32 0, i32 %x, i32 2
-
-; P32-LABEL: @test10_struct_arr_noinbounds(
-; P32-NEXT  %p = getelementptr [4 x %Foo], [4 x %Foo]* @GStructArr, i32 0, i32 %x, i32 2
+; CHECK-LABEL: @test10_struct_arr_noinbounds(
+; CHECK-NEXT  %p = getelementptr [4 x %Foo], [4 x %Foo]* @GStructArr, i32 0, i32 %x, i32 2
   %p = getelementptr [4 x %Foo], [4 x %Foo]* @GStructArr, i32 0, i32 %x, i32 2
   %q = load i32, i32* %p
   %r = icmp eq i32 %q, 9
@@ -317,13 +241,9 @@
 }
 
 define i1 @test10_struct_arr_i16(i16 %x) {
-; NODL-LABEL: @test10_struct_arr_i16(
-; NODL-NEXT: %r = icmp ne i16 %x, 1
-; NODL-NEXT: ret i1 %r
-
-; P32-LABEL: @test10_struct_arr_i16(
-; P32-NEXT: %r = icmp ne i16 %x, 1
-; P32-NEXT: ret i1 %r
+; CHECK-LABEL: @test10_struct_arr_i16(
+; CHECK-NEXT: %r = icmp ne i16 %x, 1
+; CHECK-NEXT: ret i1 %r
   %p = getelementptr inbounds [4 x %Foo], [4 x %Foo]* @GStructArr, i16 0, i16 %x, i32 2
   %q = load i32, i32* %p
   %r = icmp eq i32 %q, 9
@@ -331,14 +251,10 @@
 }
 
 define i1 @test10_struct_arr_i64(i64 %x) {
-; NODL-LABEL: @test10_struct_arr_i64(
-; NODL-NEXT: %r = icmp ne i64 %x, 1
-; NODL-NEXT: ret i1 %r
-
-; P32-LABEL: @test10_struct_arr_i64(
-; P32-NEXT: trunc i64 %x to i32
-; P32-NEXT: %r = icmp ne i32 %1, 1
-; P32-NEXT: ret i1 %r
+; CHECK-LABEL: @test10_struct_arr_i64(
+; CHECK-NEXT: trunc i64 %x to i32
+; CHECK-NEXT: %r = icmp ne i32 %1, 1
+; CHECK-NEXT: ret i1 %r
   %p = getelementptr inbounds [4 x %Foo], [4 x %Foo]* @GStructArr, i64 0, i64 %x, i32 2
   %q = load i32, i32* %p
   %r = icmp eq i32 %q, 9
@@ -346,11 +262,8 @@
 }
 
 define i1 @test10_struct_arr_noinbounds_i16(i16 %x) {
-; NODL-LABEL: @test10_struct_arr_noinbounds_i16(
-; NODL-NEXT:  %p = getelementptr [4 x %Foo], [4 x %Foo]* @GStructArr, i32 0, i16 %x, i32 2
-
-; P32-LABEL: @test10_struct_arr_noinbounds_i16(
-; P32-NEXT: %r = icmp ne i16 %x, 1
+; CHECK-LABEL: @test10_struct_arr_noinbounds_i16(
+; CHECK-NEXT: %r = icmp ne i16 %x, 1
   %p = getelementptr [4 x %Foo], [4 x %Foo]* @GStructArr, i32 0, i16 %x, i32 2
   %q = load i32, i32* %p
   %r = icmp eq i32 %q, 9
@@ -358,13 +271,9 @@
 }
 
 define i1 @test10_struct_arr_noinbounds_i64(i64 %x) {
-; FIXME: Should be no trunc?
-; NODL-LABEL: @test10_struct_arr_noinbounds_i64(
-; NODL-NEXT:  %p = getelementptr [4 x %Foo], [4 x %Foo]* @GStructArr, i32 0, i64 %x, i32 2
-
-; P32-LABEL: @test10_struct_arr_noinbounds_i64(
-; P32: %r = icmp ne i32 %1, 1
-; P32-NEXT: ret i1 %r
+; CHECK-LABEL: @test10_struct_arr_noinbounds_i64(
+; CHECK: %r = icmp ne i32 %1, 1
+; CHECK-NEXT: ret i1 %r
   %p = getelementptr [4 x %Foo], [4 x %Foo]* @GStructArr, i32 0, i64 %x, i32 2
   %q = load i32, i32* %p
   %r = icmp eq i32 %q, 9
Index: test/Transforms/InstCombine/overflow-mul.ll
===================================================================
--- test/Transforms/InstCombine/overflow-mul.ll
+++ test/Transforms/InstCombine/overflow-mul.ll
@@ -1,5 +1,7 @@
 ; RUN: opt -S -instcombine < %s | FileCheck %s
 
+
+
 ; return mul(zext x, zext y) > MAX
 define i32 @pr4917_1(i32 %x, i32 %y) nounwind {
 ; CHECK-LABEL: @pr4917_1(
@@ -174,6 +176,10 @@
   ret <4 x i32> %vcgez.i
 }
 
+
+; Need this weird datalayout to keep the "and i32 %mul, 255" together
+target datalayout = "i32:8:8"
+
 @pr21445_data = external global i32
 define i1 @pr21445(i8 %a) {
 ; CHECK-LABEL: @pr21445(
Index: test/Transforms/InstCombine/pr21651.ll
===================================================================
--- test/Transforms/InstCombine/pr21651.ll
+++ test/Transforms/InstCombine/pr21651.ll
@@ -1,5 +1,9 @@
 ; RUN: opt < %s -instcombine -S | FileCheck %s
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
+
 define void @PR21651() {
   switch i2 0, label %out [
     i2 0, label %out
Index: test/Transforms/InstCombine/simplify-libcalls.ll
===================================================================
--- test/Transforms/InstCombine/simplify-libcalls.ll
+++ test/Transforms/InstCombine/simplify-libcalls.ll
@@ -1,4 +1,5 @@
 ; RUN: opt -S < %s -instcombine | FileCheck %s
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:128:128-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S32"
 
 @G = constant [3 x i8] c"%s\00"		; <[3 x i8]*> [#uses=1]
 
@@ -19,7 +20,7 @@
         ret i8* %tmp3
 
 ; CHECK-LABEL: @test1(
-; CHECK: ret i8* getelementptr inbounds ([5 x i8]* @str, i32 0, i64 3)
+; CHECK: ret i8* getelementptr inbounds ([5 x i8]* @str, i32 0, i32 3)
 }
 
 declare i8* @strchr(i8*, i32)
@@ -29,7 +30,7 @@
         ret i8* %tmp3
 
 ; CHECK-LABEL: @test2(
-; CHECK: ret i8* getelementptr inbounds ([8 x i8]* @str1, i32 0, i64 7)
+; CHECK: ret i8* getelementptr inbounds ([8 x i8]* @str1, i32 0, i32 7)
 }
 
 define i8* @test3() {
Index: test/Transforms/InstCombine/store.ll
===================================================================
--- test/Transforms/InstCombine/store.ll
+++ test/Transforms/InstCombine/store.ll
@@ -41,7 +41,7 @@
 ; CHECK-LABEL: @test3(
 ; CHECK-NOT: alloca
 ; CHECK: Cont:
-; CHECK-NEXT:  %storemerge = phi i32 [ 47, %Cond2 ], [ -987654321, %Cond ]
+; CHECK-NEXT:  %storemerge = phi i32 [ -987654321, %Cond ], [ 47, %Cond2 ]
 ; CHECK-NEXT:  ret i32 %storemerge
 }
 
Index: test/Transforms/InstCombine/type_pun.ll
===================================================================
--- test/Transforms/InstCombine/type_pun.ll
+++ test/Transforms/InstCombine/type_pun.ll
@@ -10,6 +10,10 @@
 ; cleaning up the alloca/store/GEP/load.
 
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "p:32:32"
+
+
 ; Extracting the zeroth element in an i32 array.
 define i32 @type_pun_zeroth(<16 x i8> %in) {
 ; CHECK-LABEL: @type_pun_zeroth(
Index: test/Transforms/LoopSimplify/preserve-scev.ll
===================================================================
--- test/Transforms/LoopSimplify/preserve-scev.ll
+++ test/Transforms/LoopSimplify/preserve-scev.ll
@@ -1,6 +1,9 @@
 ; RUN: opt -S < %s -indvars | opt -analyze -iv-users | grep "%cmp = icmp slt i32" | grep "= {%\.ph,+,1}<%for.cond>"
 ; PR8079
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
 ; LoopSimplify should invalidate indvars when splitting out the
 ; inner loop.
 
Index: test/Transforms/LoopStrengthReduce/2008-08-13-CmpStride.ll
===================================================================
--- test/Transforms/LoopStrengthReduce/2008-08-13-CmpStride.ll
+++ test/Transforms/LoopStrengthReduce/2008-08-13-CmpStride.ll
@@ -1,5 +1,9 @@
 ; RUN: opt < %s -loop-reduce -S | grep add | count 2
 ; PR 2662
+
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
 @g_3 = common global i16 0		; <i16*> [#uses=2]
 @"\01LC" = internal constant [4 x i8] c"%d\0A\00"		; <[4 x i8]*> [#uses=1]
 
Index: test/Transforms/LoopStrengthReduce/2008-09-09-Overflow.ll
===================================================================
--- test/Transforms/LoopStrengthReduce/2008-09-09-Overflow.ll
+++ test/Transforms/LoopStrengthReduce/2008-09-09-Overflow.ll
@@ -1,5 +1,9 @@
 ; RUN: opt < %s -loop-reduce -S | grep phi | count 2
 ; PR 2779
+
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
 @g_19 = common global i32 0		; <i32*> [#uses=3]
 @"\01LC" = internal constant [4 x i8] c"%d\0A\00"		; <[4 x i8]*> [#uses=1]
 
Index: test/Transforms/LoopStrengthReduce/2011-10-03-CritEdgeMerge.ll
===================================================================
--- test/Transforms/LoopStrengthReduce/2011-10-03-CritEdgeMerge.ll
+++ test/Transforms/LoopStrengthReduce/2011-10-03-CritEdgeMerge.ll
@@ -4,6 +4,10 @@
 
 target triple = "x86-apple-darwin"
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
+
 ; Verify that identical edges are merged. rdar://problem/6453893
 ; CHECK-LABEL: @test1(
 ; CHECK: bb89:
Index: test/Transforms/LoopStrengthReduce/2011-10-06-ReusePhi.ll
===================================================================
--- test/Transforms/LoopStrengthReduce/2011-10-06-ReusePhi.ll
+++ test/Transforms/LoopStrengthReduce/2011-10-06-ReusePhi.ll
@@ -5,6 +5,10 @@
 
 target triple = "x86-apple-darwin"
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
+
 ; CHECK-LABEL: @test(
 ; multiplies are hoisted out of the loop
 ; CHECK: while.body.lr.ph:
@@ -17,10 +21,10 @@
 ; CHECK: phi
 ; CHECK: phi
 ; CHECK-NOT: phi
-; CHECK: bitcast float* {{.*}} to i8*
-; CHECK: bitcast float* {{.*}} to i8*
-; CHECK: getelementptr i8, i8*
-; CHECK: getelementptr i8, i8*
+; CHECK: bitcast float* {{.*}} to i1*
+; CHECK: bitcast float* {{.*}} to i1*
+; CHECK: getelementptr i1, i1*
+; CHECK: getelementptr i1, i1*
 
 define float @test(float* nocapture %A, float* nocapture %B, i32 %N, i32 %IA, i32 %IB) nounwind uwtable readonly ssp {
 entry:
Index: test/Transforms/LoopStrengthReduce/2012-07-18-LimitReassociate.ll
===================================================================
--- test/Transforms/LoopStrengthReduce/2012-07-18-LimitReassociate.ll
+++ test/Transforms/LoopStrengthReduce/2012-07-18-LimitReassociate.ll
@@ -1,5 +1,4 @@
-; RUN: opt -loop-reduce -disable-output -debug-only=loop-reduce < %s 2> %t
-; RUN: FileCheck %s < %t
+; RUN: opt -loop-reduce -disable-output -debug-only=loop-reduce < %s 2>&1 | FileCheck %s
 ; REQUIRES: asserts
 ;
 ; PR13361: LSR + SCEV "hangs" on reasonably sized test with sequence of loops
@@ -18,6 +17,10 @@
 ; CHECK-NOT:reg
 ; CHECK: Filtering for use
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
+
 %struct.snork = type { %struct.fuga, i32, i32, i32, i32, i32, i32 }
 %struct.fuga = type { %struct.gork, i64 }
 %struct.gork = type { i8*, i32, i32, %struct.noot* }
Index: test/Transforms/LoopStrengthReduce/X86/2008-08-14-ShadowIV.ll
===================================================================
--- test/Transforms/LoopStrengthReduce/X86/2008-08-14-ShadowIV.ll
+++ test/Transforms/LoopStrengthReduce/X86/2008-08-14-ShadowIV.ll
@@ -1,5 +1,9 @@
 ; RUN: opt < %s -loop-reduce -S -mtriple=x86_64-unknown-unknown | grep "phi double" | count 1
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
+
 define void @foobar(i32 %n) nounwind {
 entry:
 	icmp eq i32 %n, 0		; <i1>:0 [#uses=2]
Index: test/Transforms/LoopStrengthReduce/X86/2011-07-20-DoubleIV.ll
===================================================================
--- test/Transforms/LoopStrengthReduce/X86/2011-07-20-DoubleIV.ll
+++ test/Transforms/LoopStrengthReduce/X86/2011-07-20-DoubleIV.ll
@@ -4,6 +4,10 @@
 ; nonzero initial value.
 ; rdar://9786536
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
+
 ; First, make sure LSR doesn't crash on an empty IVUsers list.
 ; CHECK-LABEL: @dummyIV(
 ; CHECK-NOT: phi
Index: test/Transforms/LoopStrengthReduce/count-to-zero.ll
===================================================================
--- test/Transforms/LoopStrengthReduce/count-to-zero.ll
+++ test/Transforms/LoopStrengthReduce/count-to-zero.ll
@@ -1,6 +1,9 @@
 ; RUN: opt < %s -loop-reduce -S | FileCheck %s
 ; rdar://7382068
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
 define void @t(i32 %c) nounwind optsize {
 entry:
   br label %bb6
Index: test/Transforms/LoopStrengthReduce/dont_reverse.ll
===================================================================
--- test/Transforms/LoopStrengthReduce/dont_reverse.ll
+++ test/Transforms/LoopStrengthReduce/dont_reverse.ll
@@ -4,6 +4,10 @@
 ; Don't reverse the iteration if the rhs of the compare is defined
 ; inside the loop.
 
+; Needs to provide legal integer type in the DataLayout
+; Declare i2 as legal so that IVUsers accepts to consider %indvar3451
+target datalayout = "n2:8:16:32:64"
+
 define void @Fill_Buffer(i2* %p) nounwind {
 entry:
 	br label %bb8
Index: test/Transforms/LoopStrengthReduce/ivchain.ll
===================================================================
--- test/Transforms/LoopStrengthReduce/ivchain.ll
+++ test/Transforms/LoopStrengthReduce/ivchain.ll
@@ -4,6 +4,10 @@
 ; A sign extend feeds an IVUser and cannot be hoisted into the AddRec.
 ; CollectIVChains should bailout on this case.
 
+
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
 %struct = type { i8*, i8*, i16, i64, i16, i16, i16, i64, i64, i16, i8*, i64, i64, i64 }
 
 ; CHECK-LABEL: @test(
Index: test/Transforms/LoopStrengthReduce/nested-reduce.ll
===================================================================
--- test/Transforms/LoopStrengthReduce/nested-reduce.ll
+++ test/Transforms/LoopStrengthReduce/nested-reduce.ll
@@ -1,5 +1,8 @@
 ; RUN: opt < %s -loop-reduce -S | not grep mul
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
 ; Make sure we don't get a multiply by 6 in this loop.
 
 define i32 @foo(i32 %A, i32 %B, i32 %C, i32 %D) {
Index: test/Transforms/LoopStrengthReduce/pr12691.ll
===================================================================
--- test/Transforms/LoopStrengthReduce/pr12691.ll
+++ test/Transforms/LoopStrengthReduce/pr12691.ll
@@ -1,5 +1,8 @@
 ; RUN: opt < %s -loop-reduce -S | FileCheck %s
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
 @d = common global i32 0, align 4
 
 define void @fn2(i32 %x) nounwind uwtable {
Index: test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll
===================================================================
--- test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll
+++ test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll
@@ -1,5 +1,8 @@
 ; RUN: opt < %s -analyze -iv-users | FileCheck %s
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
 ; The value of %r is dependent on a polynomial iteration expression.
 ;
 ; CHECK-LABEL: IV Users for loop %foo.loop
Index: test/Transforms/LoopStrengthReduce/remove_indvar.ll
===================================================================
--- test/Transforms/LoopStrengthReduce/remove_indvar.ll
+++ test/Transforms/LoopStrengthReduce/remove_indvar.ll
@@ -1,6 +1,9 @@
 ; Check that this test makes INDVAR and related stuff dead.
 ; RUN: opt < %s -loop-reduce -S | not grep INDVAR
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
 declare i1 @pred()
 
 define void @test(i32* %P) {
Index: test/Transforms/LoopStrengthReduce/variable_stride.ll
===================================================================
--- test/Transforms/LoopStrengthReduce/variable_stride.ll
+++ test/Transforms/LoopStrengthReduce/variable_stride.ll
@@ -1,6 +1,9 @@
 ; Check that variable strides are reduced to adds instead of multiplies.
 ; RUN: opt < %s -loop-reduce -S | not grep mul
 
+; Needs to provide legal integer type in the DataLayout
+target datalayout = "n8:16:32:64"
+
 declare i1 @pred(i32)
 
 define void @test([10000 x i32]* %P, i32 %STRIDE) {
Index: test/Transforms/PhaseOrdering/scev.ll
===================================================================
--- test/Transforms/PhaseOrdering/scev.ll
+++ test/Transforms/PhaseOrdering/scev.ll
@@ -7,7 +7,7 @@
 ; CHECK: test1
 ; The loop body contains two increments by %div.
 ; Make sure that 2*%div is recognizable, and not expressed as a bit mask of %d.
-; CHECK: -->  {%p,+,(2 * (%d /u 4) * sizeof(i32))}
+; CHECK: -->  {%p,+,(8 * (%d /u 4))}
 define void @test1(i64 %d, i32* %p) nounwind uwtable ssp {
 entry:
   %div = udiv i64 %d, 4
@@ -36,7 +36,7 @@
 
 ; CHECK: test1a
 ; Same thing as test1, but it is even more tempting to fold 2 * (%d /u 2)
-; CHECK: -->  {%p,+,(2 * (%d /u 2) * sizeof(i32))}
+; CHECK: -->  {%p,+,(8 * (%d /u 2))}
 define void @test1a(i64 %d, i32* %p) nounwind uwtable ssp {
 entry:
   %div = udiv i64 %d, 2
Index: test/Transforms/ScalarRepl/2007-11-03-bigendian_apint.ll
===================================================================
--- test/Transforms/ScalarRepl/2007-11-03-bigendian_apint.ll
+++ test/Transforms/ScalarRepl/2007-11-03-bigendian_apint.ll
@@ -1,5 +1,11 @@
 ; RUN: opt < %s -scalarrepl -S | not grep shr
 
+; FIXME: I think this test is no longer valid.
+; It was working because SROA was aborting when
+; no datalayout was supplied
+; XFAIL: *
+
+
 %struct.S = type { i16 }
 
 define zeroext i1 @f(i16 signext  %b)   {
Index: test/Transforms/Scalarizer/no-data-layout.ll
===================================================================
--- test/Transforms/Scalarizer/no-data-layout.ll
+++ /dev/null
@@ -1,25 +0,0 @@
-; RUN: opt %s -scalarizer -scalarize-load-store -S | FileCheck %s
-
-; Test the handling of loads and stores when no data layout is available.
-define void @f1(<4 x float> *%dest, <4 x float> *%src) {
-; CHECK: @f1(
-; CHECK: %val = load <4 x float>, <4 x float>* %src, align 4
-; CHECK: %val.i0 = extractelement <4 x float> %val, i32 0
-; CHECK: %add.i0 = fadd float %val.i0, %val.i0
-; CHECK: %val.i1 = extractelement <4 x float> %val, i32 1
-; CHECK: %add.i1 = fadd float %val.i1, %val.i1
-; CHECK: %val.i2 = extractelement <4 x float> %val, i32 2
-; CHECK: %add.i2 = fadd float %val.i2, %val.i2
-; CHECK: %val.i3 = extractelement <4 x float> %val, i32 3
-; CHECK: %add.i3 = fadd float %val.i3, %val.i3
-; CHECK: %add.upto0 = insertelement <4 x float> undef, float %add.i0, i32 0
-; CHECK: %add.upto1 = insertelement <4 x float> %add.upto0, float %add.i1, i32 1
-; CHECK: %add.upto2 = insertelement <4 x float> %add.upto1, float %add.i2, i32 2
-; CHECK: %add = insertelement <4 x float> %add.upto2, float %add.i3, i32 3
-; CHECK: store <4 x float> %add, <4 x float>* %dest, align 8
-; CHECK: ret void
-  %val = load <4 x float> , <4 x float> *%src, align 4
-  %add = fadd <4 x float> %val, %val
-  store <4 x float> %add, <4 x float> *%dest, align 8
-  ret void
-}
Index: tools/llc/llc.cpp
===================================================================
--- tools/llc/llc.cpp
+++ tools/llc/llc.cpp
@@ -307,7 +307,6 @@
   // Add the target data from the target machine, if it exists, or the module.
   if (const DataLayout *DL = Target->getDataLayout())
     M->setDataLayout(DL);
-  PM.add(new DataLayoutPass());
 
   if (RelaxAll.getNumOccurrences() > 0 &&
       FileType != TargetMachine::CGFT_ObjectFile)
Index: tools/llvm-extract/llvm-extract.cpp
===================================================================
--- tools/llvm-extract/llvm-extract.cpp
+++ tools/llvm-extract/llvm-extract.cpp
@@ -247,7 +247,6 @@
   // In addition to deleting all other functions, we also want to spiff it
   // up a little bit.  Do this now.
   legacy::PassManager Passes;
-  Passes.add(new DataLayoutPass()); // Use correct DataLayout
 
   std::vector<GlobalValue*> Gvs(GVs.begin(), GVs.end());
 
Index: tools/opt/opt.cpp
===================================================================
--- tools/opt/opt.cpp
+++ tools/opt/opt.cpp
@@ -420,14 +420,11 @@
 
   // Add an appropriate DataLayout instance for this module.
   const DataLayout *DL = M->getDataLayout();
-  if (!DL && !DefaultDataLayout.empty()) {
+  if (DL->isDefault() && !DefaultDataLayout.empty()) {
     M->setDataLayout(DefaultDataLayout);
     DL = M->getDataLayout();
   }
 
-  if (DL)
-    Passes.add(new DataLayoutPass());
-
   // Add internal analysis passes from the target machine.
   Passes.add(createTargetTransformInfoWrapperPass(TM ? TM->getTargetIRAnalysis()
                                                      : TargetIRAnalysis()));
@@ -435,8 +432,6 @@
   std::unique_ptr<legacy::FunctionPassManager> FPasses;
   if (OptLevelO1 || OptLevelO2 || OptLevelOs || OptLevelOz || OptLevelO3) {
     FPasses.reset(new legacy::FunctionPassManager(M.get()));
-    if (DL)
-      FPasses->add(new DataLayoutPass());
     FPasses->add(createTargetTransformInfoWrapperPass(
         TM ? TM->getTargetIRAnalysis() : TargetIRAnalysis()));
   }
Index: unittests/IR/LegacyPassManagerTest.cpp
===================================================================
--- unittests/IR/LegacyPassManagerTest.cpp
+++ unittests/IR/LegacyPassManagerTest.cpp
@@ -98,7 +98,6 @@
         initializeModuleNDMPass(*PassRegistry::getPassRegistry());
       }
       bool runOnModule(Module &M) override {
-        EXPECT_TRUE(getAnalysisIfAvailable<DataLayoutPass>());
         run++;
         return false;
       }
@@ -175,7 +174,6 @@
         initializeCGPassPass(*PassRegistry::getPassRegistry());
       }
       bool runOnSCC(CallGraphSCC &SCMM) override {
-        EXPECT_TRUE(getAnalysisIfAvailable<DataLayoutPass>());
         run();
         return false;
       }
@@ -214,7 +212,6 @@
         return false;
       }
       bool runOnLoop(Loop *L, LPPassManager &LPM) override {
-        EXPECT_TRUE(getAnalysisIfAvailable<DataLayoutPass>());
         run();
         return false;
       }
@@ -251,7 +248,6 @@
         return false;
       }
       bool runOnBasicBlock(BasicBlock &BB) override {
-        EXPECT_TRUE(getAnalysisIfAvailable<DataLayoutPass>());
         run();
         return false;
       }
@@ -276,7 +272,6 @@
         initializeFPassPass(*PassRegistry::getPassRegistry());
       }
       bool runOnModule(Module &M) override {
-        EXPECT_TRUE(getAnalysisIfAvailable<DataLayoutPass>());
         for (Module::iterator I=M.begin(),E=M.end(); I != E; ++I) {
           Function &F = *I;
           {
@@ -302,7 +297,6 @@
       mNDM->run = mNDNM->run = mDNM->run = mNDM2->run = 0;
 
       legacy::PassManager Passes;
-      Passes.add(new DataLayoutPass());
       Passes.add(mNDM2);
       Passes.add(mNDM);
       Passes.add(mNDNM);
@@ -326,7 +320,6 @@
       mNDM->run = mNDNM->run = mDNM->run = mNDM2->run = 0;
 
       legacy::PassManager Passes;
-      Passes.add(new DataLayoutPass());
       Passes.add(mNDM);
       Passes.add(mNDNM);
       Passes.add(mNDM2);// invalidates mNDM needed by mDNM
@@ -348,7 +341,6 @@
       std::unique_ptr<Module> M(makeLLVMModule());
       T *P = new T();
       legacy::PassManager Passes;
-      Passes.add(new DataLayoutPass());
       Passes.add(P);
       Passes.run(*M);
       T::finishedOK(run);
@@ -359,7 +351,6 @@
       Module *M = makeLLVMModule();
       T *P = new T();
       legacy::PassManager Passes;
-      Passes.add(new DataLayoutPass());
       Passes.add(P);
       Passes.run(*M);
       T::finishedOK(run, N);
@@ -397,7 +388,6 @@
         SCOPED_TRACE("Running OnTheFlyTest");
         struct OnTheFlyTest *O = new OnTheFlyTest();
         legacy::PassManager Passes;
-        Passes.add(new DataLayoutPass());
         Passes.add(O);
         Passes.run(*M);