<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 23, 2016 at 1:58 PM, Matthias Braun via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: matze<br>
Date: Tue Aug 23 15:58:29 2016<br>
New Revision: 279564<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=279564&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=279564&view=rev</a><br>
Log:<br>
CodeGen: Remove MachineFunctionAnalysis => Enable (Machine)ModulePasses<br>
<br>
Re-apply this commit with the deletion of a MachineFunction delegated to<br>
a separate pass to avoid use after free when doing this directly in<br>
AsmPrinter.<br>
<br>
This patch removes the MachineFunctionAnalysis. Instead we keep a<br>
map from IR Function to MachineFunction in the MachineModuleInfo.<br>
<br>
This allows the insertion of ModulePasses into the codegen pipeline<br>
without breaking it because the MachineFunctionAnalysis gets dropped<br>
before a module pass.<br>
<br>
Peak memory should stay unchanged without a ModulePass in the codegen<br>
pipeline: Previously the MachineFunction was freed at the end of a codegen<br>
function pipeline because the MachineFunctionAnalysis was dropped; With<br>
this patch the MachineFunction is freed after the AsmPrinter has<br>
finished.<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D23736" rel="noreferrer" target="_blank">http://reviews.llvm.org/D23736</a><br>
<br>
Removed:<br>
    llvm/trunk/include/llvm/<wbr>CodeGen/<wbr>MachineFunctionAnalysis.h<br>
    llvm/trunk/lib/CodeGen/<wbr>MachineFunctionAnalysis.cpp<br>
Modified:<br>
    llvm/trunk/include/llvm/<wbr>CodeGen/MachineModuleInfo.h<br>
    llvm/trunk/include/llvm/<wbr>CodeGen/Passes.h<br>
    llvm/trunk/include/llvm/<wbr>Target/TargetMachine.h<br>
    llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/AsmPrinter.cpp<br>
    llvm/trunk/lib/CodeGen/<wbr>CMakeLists.txt<br>
    llvm/trunk/lib/CodeGen/<wbr>LLVMTargetMachine.cpp<br>
    llvm/trunk/lib/CodeGen/<wbr>MachineFunctionPass.cpp<br>
    llvm/trunk/lib/CodeGen/<wbr>MachineModuleInfo.cpp<br>
    llvm/trunk/lib/CodeGen/<wbr>StackMapLivenessAnalysis.cpp<br>
    llvm/trunk/lib/Target/AMDGPU/<wbr>AMDILCFGStructurizer.cpp<br>
    llvm/trunk/lib/Target/Hexagon/<wbr>HexagonCommonGEP.cpp<br>
    llvm/trunk/lib/Target/Hexagon/<wbr>HexagonGenExtract.cpp<br>
    llvm/trunk/lib/Target/Hexagon/<wbr>HexagonNewValueJump.cpp<br>
    llvm/trunk/lib/Target/Hexagon/<wbr>HexagonOptimizeSZextends.cpp<br>
    llvm/trunk/lib/Target/Hexagon/<wbr>HexagonVLIWPacketizer.cpp<br>
    llvm/trunk/lib/Target/NVPTX/<wbr>NVPTXAllocaHoisting.cpp<br>
    llvm/trunk/lib/Target/NVPTX/<wbr>NVPTXGenericToNVVM.cpp<br>
    llvm/trunk/lib/Target/NVPTX/<wbr>NVPTXLowerAggrCopies.cpp<br>
    llvm/trunk/lib/Target/NVPTX/<wbr>NVPTXTargetMachine.cpp<br>
    llvm/trunk/test/CodeGen/<wbr>Generic/stop-after.ll<br>
    llvm/trunk/test/CodeGen/X86/<wbr>hidden-vis-pic.ll<br>
    llvm/trunk/tools/llc/llc.cpp<br>
    llvm/trunk/unittests/MI/<wbr>LiveIntervalTest.cpp<br>
<br>
Removed: llvm/trunk/include/llvm/<wbr>CodeGen/<wbr>MachineFunctionAnalysis.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunctionAnalysis.h?rev=279563&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/CodeGen/<wbr>MachineFunctionAnalysis.h?rev=<wbr>279563&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/<wbr>CodeGen/<wbr>MachineFunctionAnalysis.h (original)<br>
+++ llvm/trunk/include/llvm/<wbr>CodeGen/<wbr>MachineFunctionAnalysis.h (removed)<br>
@@ -1,55 +0,0 @@<br>
-//===-- MachineFunctionAnalysis.h - Owner of MachineFunctions ----*-C++ -*-===//<br>
-//<br>
-//                     The LLVM Compiler Infrastructure<br>
-//<br>
-// This file is distributed under the University of Illinois Open Source<br>
-// License. See LICENSE.TXT for details.<br>
-//<br>
-//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
-//<br>
-// This file declares the MachineFunctionAnalysis class.<br>
-//<br>
-//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
-<br>
-#ifndef LLVM_CODEGEN_<wbr>MACHINEFUNCTIONANALYSIS_H<br>
-#define LLVM_CODEGEN_<wbr>MACHINEFUNCTIONANALYSIS_H<br>
-<br>
-#include "llvm/Pass.h"<br>
-<br>
-namespace llvm {<br>
-<br>
-class MachineFunction;<br>
-class MachineFunctionInitializer;<br>
-class TargetMachine;<br>
-<br>
-/// MachineFunctionAnalysis - This class is a Pass that manages a<br>
-/// MachineFunction object.<br>
-struct MachineFunctionAnalysis : public FunctionPass {<br>
-private:<br>
-  const TargetMachine &TM;<br>
-  MachineFunction *MF;<br>
-  unsigned NextFnNum;<br>
-  MachineFunctionInitializer *MFInitializer;<br>
-<br>
-public:<br>
-  static char ID;<br>
-  explicit MachineFunctionAnalysis(const TargetMachine &tm,<br>
-                                   MachineFunctionInitializer *MFInitializer);<br>
-  ~MachineFunctionAnalysis() override;<br>
-<br>
-  MachineFunction &getMF() const { return *MF; }<br>
-<br>
-  const char* getPassName() const override {<br>
-    return "Machine Function Analysis";<br>
-  }<br>
-<br>
-private:<br>
-  bool doInitialization(Module &M) override;<br>
-  bool runOnFunction(Function &F) override;<br>
-  void releaseMemory() override;<br>
-  void getAnalysisUsage(AnalysisUsage &AU) const override;<br>
-};<br>
-<br>
-} // End llvm namespace<br>
-<br>
-#endif<br>
<br>
Modified: llvm/trunk/include/llvm/<wbr>CodeGen/MachineModuleInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/CodeGen/<wbr>MachineModuleInfo.h?rev=<wbr>279564&r1=279563&r2=279564&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/<wbr>CodeGen/MachineModuleInfo.h (original)<br>
+++ llvm/trunk/include/llvm/<wbr>CodeGen/MachineModuleInfo.h Tue Aug 23 15:58:29 2016<br>
@@ -54,6 +54,7 @@ class BlockAddress;<br>
 class MDNode;<br>
 class MMIAddrLabelMap;<br>
 class MachineBasicBlock;<br>
+class MachineFunctionInitializer;<br>
 class MachineFunction;<br>
 class Module;<br>
 class PointerType;<br>
@@ -107,6 +108,8 @@ protected:<br>
 /// schemes and reformated for specific use.<br>
 ///<br>
 class MachineModuleInfo : public ImmutablePass {<br>
+  const TargetMachine &TM;<br>
+<br>
   /// Context - This is the MCContext used for the entire code generator.<br>
   MCContext Context;<br>
<br>
@@ -184,6 +187,14 @@ class MachineModuleInfo : public Immutab<br>
<br>
   EHPersonality PersonalityTypeCache;<br>
<br>
+  MachineFunctionInitializer *MFInitializer;<br>
+  /// Maps IR Functions to their corresponding MachineFunctions.<br>
+  DenseMap<const Function*, std::unique_ptr<<wbr>MachineFunction>> MachineFunctions;<br>
+  /// Next unique number available for a MachineFunction.<br>
+  unsigned NextFnNum = 0;<br>
+  const Function *LastRequest = nullptr; ///< Used for shortcut/cache.<br>
+  MachineFunction *LastResult = nullptr; ///< Used for shortcut/cache.<br>
+<br>
 public:<br>
   static char ID; // Pass identification, replacement for typeid<br>
<br>
@@ -202,8 +213,9 @@ public:<br>
<br>
   MachineModuleInfo();  // DUMMY CONSTRUCTOR, DO NOT CALL.<br>
   // Real constructor.<br>
-  MachineModuleInfo(const MCAsmInfo &MAI, const MCRegisterInfo &MRI,<br>
-                    const MCObjectFileInfo *MOFI);<br>
+  MachineModuleInfo(const TargetMachine &TM, const MCAsmInfo &MAI,<br>
+                    const MCRegisterInfo &MRI, const MCObjectFileInfo *MOFI,<br>
+                    MachineFunctionInitializer *MFInitializer = nullptr);<br>
   ~MachineModuleInfo() override;<br>
<br>
   // Initialization and Finalization<br>
@@ -220,6 +232,15 @@ public:<br>
   void setModule(const Module *M) { TheModule = M; }<br>
   const Module *getModule() const { return TheModule; }<br>
<br>
+  /// Returns the MachineFunction constructed for the IR function \p F.<br>
+  /// Creates a new MachineFunction and runs the MachineFunctionInitializer<br>
+  /// if none exists yet.<br>
+  MachineFunction &getMachineFunction(const Function &F);<br>
+<br>
+  /// \brief Delete the MachineFunction \p MF and reset the link in the IR<br>
+  /// Function to Machine Function map.<br>
+  void deleteMachineFunctionFor(<wbr>Function &F);<br>
+<br>
   /// getInfo - Keep track of various per-function pieces of information for<br>
   /// backends that would like to do so.<br>
   ///<br>
<br>
Modified: llvm/trunk/include/llvm/<wbr>CodeGen/Passes.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/CodeGen/Passes.h?rev=<wbr>279564&r1=279563&r2=279564&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/<wbr>CodeGen/Passes.h (original)<br>
+++ llvm/trunk/include/llvm/<wbr>CodeGen/Passes.h Tue Aug 23 15:58:29 2016<br>
@@ -377,6 +377,9 @@ namespace llvm {<br>
<br>
   /// This pass performs software pipelining on machine instructions.<br>
   extern char &MachinePipelinerID;<br>
+<br>
+  /// This pass frees the memory occupied by the MachineFunction.<br>
+  FunctionPass *<wbr>createFreeMachineFunctionPass(<wbr>);<br>
 } // End llvm namespace<br>
<br>
 /// Target machine pass initializer for passes with dependencies. Use with<br>
<br>
Modified: llvm/trunk/include/llvm/<wbr>Target/TargetMachine.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/Target/TargetMachine.h?<wbr>rev=279564&r1=279563&r2=<wbr>279564&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/<wbr>Target/TargetMachine.h (original)<br>
+++ llvm/trunk/include/llvm/<wbr>Target/TargetMachine.h Tue Aug 23 15:58:29 2016<br>
@@ -314,11 +314,8 @@ public:<br>
                          bool DisableVerify = true) override;<br>
<br>
   /// Add MachineModuleInfo pass to pass manager.<br>
-  MachineModuleInfo &addMachineModuleInfo(<wbr>PassManagerBase &PM) const;<br>
-<br>
-  /// Add MachineFunctionAnalysis pass to pass manager.<br>
-  void addMachineFunctionAnalysis(<wbr>PassManagerBase &PM,<br>
-      MachineFunctionInitializer *MFInitializer) const;<br>
+  MachineModuleInfo &addMachineModuleInfo(<wbr>PassManagerBase &PM,<br>
+      MachineFunctionInitializer *MFI = nullptr) const;<br>
 };<br>
<br>
 } // End llvm namespace<br>
<br>
Modified: llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/AsmPrinter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>CodeGen/AsmPrinter/AsmPrinter.<wbr>cpp?rev=279564&r1=279563&r2=<wbr>279564&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/AsmPrinter.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/AsmPrinter.cpp Tue Aug 23 15:58:29 2016<br>
@@ -2571,8 +2571,6 @@ isBlockOnlyReachableByFallthro<wbr>ugh(const<br>
   return true;<br>
 }<br>
<br>
-<br>
-<br>
 GCMetadataPrinter *AsmPrinter::<wbr>GetOrCreateGCPrinter(<wbr>GCStrategy &S) {<br>
   if (!S.usesMetadata())<br>
     return nullptr;<br>
<br>
Modified: llvm/trunk/lib/CodeGen/<wbr>CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CMakeLists.txt?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>CodeGen/CMakeLists.txt?rev=<wbr>279564&r1=279563&r2=279564&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/CodeGen/<wbr>CMakeLists.txt (original)<br>
+++ llvm/trunk/lib/CodeGen/<wbr>CMakeLists.txt Tue Aug 23 15:58:29 2016<br>
@@ -59,7 +59,6 @@ add_llvm_library(LLVMCodeGen<br>
   MachineCSE.cpp<br>
   MachineDominanceFrontier.cpp<br>
   MachineDominators.cpp<br>
-  MachineFunctionAnalysis.cpp<br>
   MachineFunction.cpp<br>
   MachineFunctionPass.cpp<br>
   MachineFunctionPrinterPass.cpp<br>
<br>
Modified: llvm/trunk/lib/CodeGen/<wbr>LLVMTargetMachine.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>CodeGen/LLVMTargetMachine.cpp?<wbr>rev=279564&r1=279563&r2=<wbr>279564&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/CodeGen/<wbr>LLVMTargetMachine.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/<wbr>LLVMTargetMachine.cpp Tue Aug 23 15:58:29 2016<br>
@@ -15,7 +15,6 @@<br>
 #include "llvm/Analysis/Passes.h"<br>
 #include "llvm/CodeGen/AsmPrinter.h"<br>
 #include "llvm/CodeGen/BasicTTIImpl.h"<br>
-#include "llvm/CodeGen/<wbr>MachineFunctionAnalysis.h"<br>
 #include "llvm/CodeGen/<wbr>MachineModuleInfo.h"<br>
 #include "llvm/CodeGen/Passes.h"<br>
 #include "llvm/CodeGen/<wbr>TargetPassConfig.h"<br>
@@ -103,19 +102,15 @@ TargetIRAnalysis LLVMTargetMachine::getT<br>
 }<br>
<br>
 MachineModuleInfo &<br>
-LLVMTargetMachine::<wbr>addMachineModuleInfo(<wbr>PassManagerBase &PM) const {<br>
-  MachineModuleInfo *MMI = new MachineModuleInfo(*<wbr>getMCAsmInfo(),<br>
+LLVMTargetMachine::<wbr>addMachineModuleInfo(<wbr>PassManagerBase &PM,<br>
+                                        MachineFunctionInitializer *MFI) const {<br>
+  MachineModuleInfo *MMI = new MachineModuleInfo(*this, *getMCAsmInfo(),<br>
                                                  *getMCRegisterInfo(),<br>
-                                                 getObjFileLowering());<br>
+                                                 getObjFileLowering(), MFI);<br>
   PM.add(MMI);<br>
   return *MMI;<br>
 }<br>
<br>
-void LLVMTargetMachine::<wbr>addMachineFunctionAnalysis(<wbr>PassManagerBase &PM,<br>
-    MachineFunctionInitializer *MFInitializer) const {<br>
-  PM.add(new MachineFunctionAnalysis(*this, MFInitializer));<br>
-}<br>
-<br>
 /// addPassesToX helper drives creation and initialization of TargetPassConfig.<br>
 static MCContext *<br>
 addPassesToGenerateCode(<wbr>LLVMTargetMachine *TM, PassManagerBase &PM,<br>
@@ -150,8 +145,7 @@ addPassesToGenerateCode(<wbr>LLVMTargetMachin<br>
<br>
   PassConfig->addISelPrepare();<br>
<br>
-  MachineModuleInfo &MMI = TM->addMachineModuleInfo(PM);<br>
-  TM-><wbr>addMachineFunctionAnalysis(PM, MFInitializer);<br>
+  MachineModuleInfo &MMI = TM->addMachineModuleInfo(PM, MFInitializer);<br>
<br>
   // Enable FastISel with -fast, but allow that to be overridden.<br>
   TM->setO0WantsFastISel(<wbr>EnableFastISelOption != cl::BOU_FALSE);<br>
@@ -273,6 +267,7 @@ bool LLVMTargetMachine::<wbr>addPassesToEmitF<br>
     return true;<br>
<br>
   PM.add(Printer);<br>
+  PM.add(<wbr>createFreeMachineFunctionPass(<wbr>));<br>
<br>
   return false;<br>
 }<br>
@@ -319,6 +314,7 @@ bool LLVMTargetMachine::<wbr>addPassesToEmitM<br>
     return true;<br>
<br>
   PM.add(Printer);<br>
+  PM.add(<wbr>createFreeMachineFunctionPass(<wbr>));<br>
<br>
   return false; // success!<br>
 }<br>
<br>
Removed: llvm/trunk/lib/CodeGen/<wbr>MachineFunctionAnalysis.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunctionAnalysis.cpp?rev=279563&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>CodeGen/<wbr>MachineFunctionAnalysis.cpp?<wbr>rev=279563&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/CodeGen/<wbr>MachineFunctionAnalysis.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/<wbr>MachineFunctionAnalysis.cpp (removed)<br>
@@ -1,62 +0,0 @@<br>
-//===-- MachineFunctionAnalysis.cpp ------------------------------<wbr>---------===//<br>
-//<br>
-//                     The LLVM Compiler Infrastructure<br>
-//<br>
-// This file is distributed under the University of Illinois Open Source<br>
-// License. See LICENSE.TXT for details.<br>
-//<br>
-//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
-//<br>
-// This file contains the definitions of the MachineFunctionAnalysis members.<br>
-//<br>
-//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
-<br>
-#include "llvm/CodeGen/<wbr>MachineFunctionAnalysis.h"<br>
-#include "llvm/CodeGen/GCMetadata.h"<br>
-#include "llvm/CodeGen/MachineFunction.<wbr>h"<br>
-#include "llvm/CodeGen/<wbr>MachineModuleInfo.h"<br>
-#include "llvm/CodeGen/<wbr>MachineFunctionInitializer.h"<br>
-using namespace llvm;<br>
-<br>
-char MachineFunctionAnalysis::ID = 0;<br>
-<br>
-MachineFunctionAnalysis::<wbr>MachineFunctionAnalysis(<br>
-    const TargetMachine &tm, MachineFunctionInitializer *MFInitializer)<br>
-    : FunctionPass(ID), TM(tm), MF(nullptr), MFInitializer(MFInitializer) {<br>
-  initializeMachineModuleInfoPas<wbr>s(*PassRegistry::<wbr>getPassRegistry());<br>
-}<br>
-<br>
-MachineFunctionAnalysis::~<wbr>MachineFunctionAnalysis() {<br>
-  releaseMemory();<br>
-  assert(!MF && "MachineFunctionAnalysis left initialized!");<br>
-}<br>
-<br>
-void MachineFunctionAnalysis::<wbr>getAnalysisUsage(AnalysisUsage &AU) const {<br>
-  AU.setPreservesAll();<br>
-  AU.addRequired<<wbr>MachineModuleInfo>();<br>
-}<br>
-<br>
-bool MachineFunctionAnalysis::<wbr>doInitialization(Module &M) {<br>
-  MachineModuleInfo *MMI = getAnalysisIfAvailable<<wbr>MachineModuleInfo>();<br>
-  assert(MMI && "MMI not around yet??");<br>
-  MMI->setModule(&M);<br>
-  NextFnNum = 0;<br>
-  return false;<br>
-}<br>
-<br>
-<br>
-bool MachineFunctionAnalysis::<wbr>runOnFunction(Function &F) {<br>
-  assert(!MF && "MachineFunctionAnalysis already initialized!");<br>
-  MF = new MachineFunction(&F, TM, NextFnNum++,<br>
-                           getAnalysis<MachineModuleInfo><wbr>());<br>
-  if (MFInitializer) {<br>
-    if (MFInitializer-><wbr>initializeMachineFunction(*MF)<wbr>)<br>
-      report_fatal_error("Unable to initialize machine function");<br>
-  }<br>
-  return false;<br>
-}<br>
-<br>
-void MachineFunctionAnalysis::<wbr>releaseMemory() {<br>
-  delete MF;<br>
-  MF = nullptr;<br>
-}<br>
<br>
Modified: llvm/trunk/lib/CodeGen/<wbr>MachineFunctionPass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>CodeGen/MachineFunctionPass.<wbr>cpp?rev=279564&r1=279563&r2=<wbr>279564&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/CodeGen/<wbr>MachineFunctionPass.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/<wbr>MachineFunctionPass.cpp Tue Aug 23 15:58:29 2016<br>
@@ -22,7 +22,7 @@<br>
 #include "llvm/Analysis/<wbr>ScalarEvolution.h"<br>
 #include "llvm/Analysis/<wbr>ScalarEvolutionAliasAnalysis.<wbr>h"<br>
 #include "llvm/CodeGen/MachineFunction.<wbr>h"<br>
-#include "llvm/CodeGen/<wbr>MachineFunctionAnalysis.h"<br>
+#include "llvm/CodeGen/<wbr>MachineModuleInfo.h"<br>
 #include "llvm/CodeGen/Passes.h"<br>
 #include "llvm/CodeGen/StackProtector.<wbr>h"<br>
 #include "llvm/IR/Dominators.h"<br>
@@ -41,7 +41,9 @@ bool MachineFunctionPass::<wbr>runOnFunction(<br>
   if (F.<wbr>hasAvailableExternallyLinkage(<wbr>))<br>
     return false;<br>
<br>
-  MachineFunction &MF = getAnalysis<<wbr>MachineFunctionAnalysis>().<wbr>getMF();<br>
+  MachineModuleInfo &MMI = getAnalysis<MachineModuleInfo><wbr>();<br>
+  MachineFunction &MF = MMI.getMachineFunction(F);<br>
+<br>
   MachineFunctionProperties &MFProps = MF.getProperties();<br>
<br>
 #ifndef NDEBUG<br>
@@ -65,8 +67,8 @@ bool MachineFunctionPass::<wbr>runOnFunction(<br>
 }<br>
<br>
 void MachineFunctionPass::<wbr>getAnalysisUsage(AnalysisUsage &AU) const {<br>
-  AU.addRequired<<wbr>MachineFunctionAnalysis>();<br>
-  AU.addPreserved<<wbr>MachineFunctionAnalysis>();<br>
+  AU.addRequired<<wbr>MachineModuleInfo>();<br>
+  AU.addPreserved<<wbr>MachineModuleInfo>();<br>
<br>
   // MachineFunctionPass preserves all LLVM IR passes, but there's no<br>
   // high-level way to express this. Instead, just list a bunch of<br>
<br>
Modified: llvm/trunk/lib/CodeGen/<wbr>MachineModuleInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>CodeGen/MachineModuleInfo.cpp?<wbr>rev=279564&r1=279563&r2=<wbr>279564&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/CodeGen/<wbr>MachineModuleInfo.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/<wbr>MachineModuleInfo.cpp Tue Aug 23 15:58:29 2016<br>
@@ -13,6 +13,7 @@<br>
 #include "llvm/Analysis/<wbr>EHPersonalities.h"<br>
 #include "llvm/Analysis/ValueTracking.<wbr>h"<br>
 #include "llvm/CodeGen/MachineFunction.<wbr>h"<br>
+#include "llvm/CodeGen/<wbr>MachineFunctionInitializer.h"<br>
 #include "llvm/CodeGen/<wbr>MachineFunctionPass.h"<br>
 #include "llvm/CodeGen/Passes.h"<br>
 #include "llvm/IR/Constants.h"<br>
@@ -186,15 +187,19 @@ void MMIAddrLabelMapCallbackPtr::<wbr>allUses<br>
<br>
 //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
<br>
-MachineModuleInfo::<wbr>MachineModuleInfo(const MCAsmInfo &MAI,<br>
+MachineModuleInfo::<wbr>MachineModuleInfo(const TargetMachine &TM,<br>
+                                     const MCAsmInfo &MAI,<br>
                                      const MCRegisterInfo &MRI,<br>
-                                     const MCObjectFileInfo *MOFI)<br>
-  : ImmutablePass(ID), Context(&MAI, &MRI, MOFI, nullptr, false) {<br>
+                                     const MCObjectFileInfo *MOFI,<br>
+                                     MachineFunctionInitializer *MFI)<br>
+  : ImmutablePass(ID), TM(TM), Context(&MAI, &MRI, MOFI, nullptr, false),<br>
+    MFInitializer(MFI) {<br>
   initializeMachineModuleInfoPas<wbr>s(*PassRegistry::<wbr>getPassRegistry());<br>
 }<br>
<br>
 MachineModuleInfo::<wbr>MachineModuleInfo()<br>
-  : ImmutablePass(ID), Context(nullptr, nullptr, nullptr) {<br>
+  : ImmutablePass(ID), TM(*((TargetMachine*)nullptr))<wbr>,<br></blockquote><div><br></div><div>This (binding a reference to a dereferenced null pointer) is not OK; it breaks -Werror builds, and LLVM will optimize on the assumption that this is undefined behavior.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+    Context(nullptr, nullptr, nullptr) {<br>
   llvm_unreachable("This MachineModuleInfo constructor should never be called, "<br>
                    "MMI should always be explicitly constructed by "<br>
                    "LLVMTargetMachine");<br>
@@ -213,7 +218,7 @@ bool MachineModuleInfo::<wbr>doInitialization<br>
   DbgInfoAvailable = UsesVAFloatArgument = UsesMorestackAddr = false;<br>
   PersonalityTypeCache = EHPersonality::Unknown;<br>
   AddrLabelSymbols = nullptr;<br>
-  TheModule = nullptr;<br>
+  TheModule = &M;<br>
<br>
   return false;<br>
 }<br>
@@ -461,3 +466,63 @@ try_next:;<br>
   FilterIds.push_back(0); // terminator<br>
   return FilterID;<br>
 }<br>
+<br>
+MachineFunction &MachineModuleInfo::<wbr>getMachineFunction(const Function &F) {<br>
+  // Shortcut for the common case where a sequence of MachineFunctionPasses<br>
+  // all query for the same Function.<br>
+  if (LastRequest == &F)<br>
+    return *LastResult;<br>
+<br>
+  auto I = MachineFunctions.insert(<br>
+      std::make_pair(&F, std::unique_ptr<<wbr>MachineFunction>()));<br>
+  MachineFunction *MF;<br>
+  if (I.second) {<br>
+    // No pre-existing machine function, create a new one.<br>
+    MF = new MachineFunction(&F, TM, NextFnNum++, *this);<br>
+    // Update the set entry.<br>
+    I.first->second.reset(MF);<br>
+<br>
+    if (MFInitializer)<br>
+      if (MFInitializer-><wbr>initializeMachineFunction(*MF)<wbr>)<br>
+        report_fatal_error("Unable to initialize machine function");<br>
+  } else {<br>
+    MF = I.first->second.get();<br>
+  }<br>
+<br>
+  LastRequest = &F;<br>
+  LastResult = MF;<br>
+  return *MF;<br>
+}<br>
+<br>
+void MachineModuleInfo::<wbr>deleteMachineFunctionFor(<wbr>Function &F) {<br>
+  MachineFunctions.erase(&F);<br>
+  LastRequest = nullptr;<br>
+  LastResult = nullptr;<br>
+}<br>
+<br>
+namespace {<br>
+/// This pass frees the MachineFunction object associated with a Function.<br>
+class FreeMachineFunction : public FunctionPass {<br>
+public:<br>
+  static char ID;<br>
+  FreeMachineFunction() : FunctionPass(ID) {}<br>
+<br>
+  void getAnalysisUsage(AnalysisUsage &AU) const override {<br>
+    AU.addRequired<<wbr>MachineModuleInfo>();<br>
+    AU.addPreserved<<wbr>MachineModuleInfo>();<br>
+  }<br>
+<br>
+  bool runOnFunction(Function &F) override {<br>
+    MachineModuleInfo &MMI = getAnalysis<MachineModuleInfo><wbr>();<br>
+    MMI.deleteMachineFunctionFor(<wbr>F);<br>
+    return true;<br>
+  }<br>
+};<br>
+char FreeMachineFunction::ID;<br>
+} // end anonymous namespace<br>
+<br>
+namespace llvm {<br>
+FunctionPass *<wbr>createFreeMachineFunctionPass(<wbr>) {<br>
+  return new FreeMachineFunction();<br>
+}<br>
+} // end namespace llvm<br>
<br>
Modified: llvm/trunk/lib/CodeGen/<wbr>StackMapLivenessAnalysis.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StackMapLivenessAnalysis.cpp?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>CodeGen/<wbr>StackMapLivenessAnalysis.cpp?<wbr>rev=279564&r1=279563&r2=<wbr>279564&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/CodeGen/<wbr>StackMapLivenessAnalysis.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/<wbr>StackMapLivenessAnalysis.cpp Tue Aug 23 15:58:29 2016<br>
@@ -17,7 +17,6 @@<br>
 #include "llvm/CodeGen/LivePhysRegs.h"<br>
 #include "llvm/CodeGen/<wbr>MachineFrameInfo.h"<br>
 #include "llvm/CodeGen/MachineFunction.<wbr>h"<br>
-#include "llvm/CodeGen/<wbr>MachineFunctionAnalysis.h"<br>
 #include "llvm/CodeGen/<wbr>MachineFunctionPass.h"<br>
 #include "llvm/CodeGen/Passes.h"<br>
 #include "llvm/Support/CommandLine.h"<br>
<br>
Modified: llvm/trunk/lib/Target/AMDGPU/<wbr>AMDILCFGStructurizer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>AMDGPU/AMDILCFGStructurizer.<wbr>cpp?rev=279564&r1=279563&r2=<wbr>279564&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/AMDGPU/<wbr>AMDILCFGStructurizer.cpp (original)<br>
+++ llvm/trunk/lib/Target/AMDGPU/<wbr>AMDILCFGStructurizer.cpp Tue Aug 23 15:58:29 2016<br>
@@ -18,7 +18,6 @@<br>
 #include "llvm/ADT/Statistic.h"<br>
 #include "llvm/CodeGen/<wbr>MachineDominators.h"<br>
 #include "llvm/CodeGen/MachineFunction.<wbr>h"<br>
-#include "llvm/CodeGen/<wbr>MachineFunctionAnalysis.h"<br>
 #include "llvm/CodeGen/<wbr>MachineFunctionPass.h"<br>
 #include "llvm/CodeGen/<wbr>MachineInstrBuilder.h"<br>
 #include "llvm/CodeGen/<wbr>MachineJumpTableInfo.h"<br>
@@ -144,11 +143,10 @@ public:<br>
   }<br>
<br>
   void getAnalysisUsage(AnalysisUsage &AU) const override {<br>
-    AU.addPreserved<<wbr>MachineFunctionAnalysis>();<br>
-    AU.addRequired<<wbr>MachineFunctionAnalysis>();<br>
     AU.addRequired<<wbr>MachineDominatorTree>();<br>
     AU.addRequired<<wbr>MachinePostDominatorTree>();<br>
     AU.addRequired<<wbr>MachineLoopInfo>();<br>
+    MachineFunctionPass::<wbr>getAnalysisUsage(AU);<br>
   }<br>
<br>
   /// Perform the CFG structurization<br>
<br>
Modified: llvm/trunk/lib/Target/Hexagon/<wbr>HexagonCommonGEP.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonCommonGEP.cpp?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>Hexagon/HexagonCommonGEP.cpp?<wbr>rev=279564&r1=279563&r2=<wbr>279564&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/Hexagon/<wbr>HexagonCommonGEP.cpp (original)<br>
+++ llvm/trunk/lib/Target/Hexagon/<wbr>HexagonCommonGEP.cpp Tue Aug 23 15:58:29 2016<br>
@@ -14,7 +14,6 @@<br>
 #include "llvm/ADT/STLExtras.h"<br>
 #include "llvm/Analysis/LoopInfo.h"<br>
 #include "llvm/Analysis/PostDominators.<wbr>h"<br>
-#include "llvm/CodeGen/<wbr>MachineFunctionAnalysis.h"<br>
 #include "llvm/IR/Constants.h"<br>
 #include "llvm/IR/Dominators.h"<br>
 #include "llvm/IR/Function.h"<br>
<br>
Modified: llvm/trunk/lib/Target/Hexagon/<wbr>HexagonGenExtract.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonGenExtract.cpp?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>Hexagon/HexagonGenExtract.cpp?<wbr>rev=279564&r1=279563&r2=<wbr>279564&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/Hexagon/<wbr>HexagonGenExtract.cpp (original)<br>
+++ llvm/trunk/lib/Target/Hexagon/<wbr>HexagonGenExtract.cpp Tue Aug 23 15:58:29 2016<br>
@@ -8,7 +8,6 @@<br>
 //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
<br>
 #include "llvm/ADT/STLExtras.h"<br>
-#include "llvm/CodeGen/<wbr>MachineFunctionAnalysis.h"<br>
 #include "llvm/IR/Constants.h"<br>
 #include "llvm/IR/Dominators.h"<br>
 #include "llvm/IR/Function.h"<br>
@@ -60,7 +59,6 @@ namespace {<br>
     virtual void getAnalysisUsage(AnalysisUsage &AU) const override {<br>
       AU.addRequired<<wbr>DominatorTreeWrapperPass>();<br>
       AU.addPreserved<<wbr>DominatorTreeWrapperPass>();<br>
-      AU.addPreserved<<wbr>MachineFunctionAnalysis>();<br>
       FunctionPass::<wbr>getAnalysisUsage(AU);<br>
     }<br>
   private:<br>
<br>
Modified: llvm/trunk/lib/Target/Hexagon/<wbr>HexagonNewValueJump.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonNewValueJump.cpp?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>Hexagon/HexagonNewValueJump.<wbr>cpp?rev=279564&r1=279563&r2=<wbr>279564&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/Hexagon/<wbr>HexagonNewValueJump.cpp (original)<br>
+++ llvm/trunk/lib/Target/Hexagon/<wbr>HexagonNewValueJump.cpp Tue Aug 23 15:58:29 2016<br>
@@ -29,7 +29,6 @@<br>
 #include "HexagonTargetMachine.h"<br>
 #include "llvm/ADT/Statistic.h"<br>
 #include "llvm/CodeGen/LiveVariables.h"<br>
-#include "llvm/CodeGen/<wbr>MachineFunctionAnalysis.h"<br>
 #include "llvm/CodeGen/<wbr>MachineFunctionPass.h"<br>
 #include "llvm/CodeGen/<wbr>MachineInstrBuilder.h"<br>
 #include "llvm/CodeGen/<wbr>MachineRegisterInfo.h"<br>
<br>
Modified: llvm/trunk/lib/Target/Hexagon/<wbr>HexagonOptimizeSZextends.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonOptimizeSZextends.cpp?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>Hexagon/<wbr>HexagonOptimizeSZextends.cpp?<wbr>rev=279564&r1=279563&r2=<wbr>279564&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/Hexagon/<wbr>HexagonOptimizeSZextends.cpp (original)<br>
+++ llvm/trunk/lib/Target/Hexagon/<wbr>HexagonOptimizeSZextends.cpp Tue Aug 23 15:58:29 2016<br>
@@ -12,7 +12,6 @@<br>
 //<br>
 //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
<br>
-#include "llvm/CodeGen/<wbr>MachineFunctionAnalysis.h"<br>
 #include "llvm/CodeGen/StackProtector.<wbr>h"<br>
 #include "llvm/IR/Function.h"<br>
 #include "llvm/IR/Instructions.h"<br>
@@ -43,8 +42,6 @@ namespace {<br>
     }<br>
<br>
     void getAnalysisUsage(AnalysisUsage &AU) const override {<br>
-      AU.addRequired<<wbr>MachineFunctionAnalysis>();<br>
-      AU.addPreserved<<wbr>MachineFunctionAnalysis>();<br>
       AU.addPreserved<<wbr>StackProtector>();<br>
       FunctionPass::<wbr>getAnalysisUsage(AU);<br>
     }<br>
<br>
Modified: llvm/trunk/lib/Target/Hexagon/<wbr>HexagonVLIWPacketizer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>Hexagon/HexagonVLIWPacketizer.<wbr>cpp?rev=279564&r1=279563&r2=<wbr>279564&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/Hexagon/<wbr>HexagonVLIWPacketizer.cpp (original)<br>
+++ llvm/trunk/lib/Target/Hexagon/<wbr>HexagonVLIWPacketizer.cpp Tue Aug 23 15:58:29 2016<br>
@@ -22,7 +22,6 @@<br>
 #include "HexagonVLIWPacketizer.h"<br>
 #include "llvm/Analysis/AliasAnalysis.<wbr>h"<br>
 #include "llvm/CodeGen/<wbr>MachineDominators.h"<br>
-#include "llvm/CodeGen/<wbr>MachineFunctionAnalysis.h"<br>
 #include "llvm/CodeGen/<wbr>MachineFunctionPass.h"<br>
 #include "llvm/CodeGen/MachineLoopInfo.<wbr>h"<br>
 #include "llvm/CodeGen/<wbr>MachineRegisterInfo.h"<br>
<br>
Modified: llvm/trunk/lib/Target/NVPTX/<wbr>NVPTXAllocaHoisting.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXAllocaHoisting.cpp?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>NVPTX/NVPTXAllocaHoisting.cpp?<wbr>rev=279564&r1=279563&r2=<wbr>279564&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/NVPTX/<wbr>NVPTXAllocaHoisting.cpp (original)<br>
+++ llvm/trunk/lib/Target/NVPTX/<wbr>NVPTXAllocaHoisting.cpp Tue Aug 23 15:58:29 2016<br>
@@ -12,7 +12,6 @@<br>
 //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
<br>
 #include "NVPTXAllocaHoisting.h"<br>
-#include "llvm/CodeGen/<wbr>MachineFunctionAnalysis.h"<br>
 #include "llvm/CodeGen/StackProtector.<wbr>h"<br>
 #include "llvm/IR/Constants.h"<br>
 #include "llvm/IR/Function.h"<br>
@@ -28,7 +27,6 @@ public:<br>
   NVPTXAllocaHoisting() : FunctionPass(ID) {}<br>
<br>
   void getAnalysisUsage(AnalysisUsage &AU) const override {<br>
-    AU.addPreserved<<wbr>MachineFunctionAnalysis>();<br>
     AU.addPreserved<<wbr>StackProtector>();<br>
   }<br>
<br>
<br>
Modified: llvm/trunk/lib/Target/NVPTX/<wbr>NVPTXGenericToNVVM.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>NVPTX/NVPTXGenericToNVVM.cpp?<wbr>rev=279564&r1=279563&r2=<wbr>279564&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/NVPTX/<wbr>NVPTXGenericToNVVM.cpp (original)<br>
+++ llvm/trunk/lib/Target/NVPTX/<wbr>NVPTXGenericToNVVM.cpp Tue Aug 23 15:58:29 2016<br>
@@ -15,7 +15,6 @@<br>
 #include "NVPTX.h"<br>
 #include "MCTargetDesc/NVPTXBaseInfo.h"<br>
 #include "NVPTXUtilities.h"<br>
-#include "llvm/CodeGen/<wbr>MachineFunctionAnalysis.h"<br>
 #include "llvm/CodeGen/ValueTypes.h"<br>
 #include "llvm/IR/Constants.h"<br>
 #include "llvm/IR/DerivedTypes.h"<br>
<br>
Modified: llvm/trunk/lib/Target/NVPTX/<wbr>NVPTXLowerAggrCopies.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>NVPTX/NVPTXLowerAggrCopies.<wbr>cpp?rev=279564&r1=279563&r2=<wbr>279564&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/NVPTX/<wbr>NVPTXLowerAggrCopies.cpp (original)<br>
+++ llvm/trunk/lib/Target/NVPTX/<wbr>NVPTXLowerAggrCopies.cpp Tue Aug 23 15:58:29 2016<br>
@@ -14,7 +14,6 @@<br>
 //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
<br>
 #include "NVPTXLowerAggrCopies.h"<br>
-#include "llvm/CodeGen/<wbr>MachineFunctionAnalysis.h"<br>
 #include "llvm/CodeGen/StackProtector.<wbr>h"<br>
 #include "llvm/IR/Constants.h"<br>
 #include "llvm/IR/DataLayout.h"<br>
@@ -41,7 +40,6 @@ struct NVPTXLowerAggrCopies : public Fun<br>
   NVPTXLowerAggrCopies() : FunctionPass(ID) {}<br>
<br>
   void getAnalysisUsage(AnalysisUsage &AU) const override {<br>
-    AU.addPreserved<<wbr>MachineFunctionAnalysis>();<br>
     AU.addPreserved<<wbr>StackProtector>();<br>
   }<br>
<br>
<br>
Modified: llvm/trunk/lib/Target/NVPTX/<wbr>NVPTXTargetMachine.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXTargetMachine.cpp?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>NVPTX/NVPTXTargetMachine.cpp?<wbr>rev=279564&r1=279563&r2=<wbr>279564&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/NVPTX/<wbr>NVPTXTargetMachine.cpp (original)<br>
+++ llvm/trunk/lib/Target/NVPTX/<wbr>NVPTXTargetMachine.cpp Tue Aug 23 15:58:29 2016<br>
@@ -20,7 +20,6 @@<br>
 #include "NVPTXTargetTransformInfo.h"<br>
 #include "llvm/Analysis/Passes.h"<br>
 #include "llvm/CodeGen/AsmPrinter.h"<br>
-#include "llvm/CodeGen/<wbr>MachineFunctionAnalysis.h"<br>
 #include "llvm/CodeGen/<wbr>MachineModuleInfo.h"<br>
 #include "llvm/CodeGen/Passes.h"<br>
 #include "llvm/CodeGen/<wbr>TargetPassConfig.h"<br>
<br>
Modified: llvm/trunk/test/CodeGen/<wbr>Generic/stop-after.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Generic/stop-after.ll?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/test/<wbr>CodeGen/Generic/stop-after.ll?<wbr>rev=279564&r1=279563&r2=<wbr>279564&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/test/CodeGen/<wbr>Generic/stop-after.ll (original)<br>
+++ llvm/trunk/test/CodeGen/<wbr>Generic/stop-after.ll Tue Aug 23 15:58:29 2016<br>
@@ -3,7 +3,6 @@<br>
<br>
 ; STOP: -loop-reduce<br>
 ; STOP: Loop Strength Reduction<br>
-; STOP-NEXT: Machine Function Analysis<br>
 ; STOP-NEXT: MIR Printing Pass<br>
<br>
 ; START: -machine-branch-prob -pre-isel-intrinsic-lowering<br>
<br>
Modified: llvm/trunk/test/CodeGen/X86/<wbr>hidden-vis-pic.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/hidden-vis-pic.ll?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/test/<wbr>CodeGen/X86/hidden-vis-pic.ll?<wbr>rev=279564&r1=279563&r2=<wbr>279564&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/test/CodeGen/X86/<wbr>hidden-vis-pic.ll (original)<br>
+++ llvm/trunk/test/CodeGen/X86/<wbr>hidden-vis-pic.ll Tue Aug 23 15:58:29 2016<br>
@@ -17,7 +17,7 @@ entry:<br>
<br>
 ; This must use movl of the stub, not an lea, since the function isn't being<br>
 ; emitted here.<br>
-; CHECK: movl L__ZNSbIcED1Ev$non_lazy_ptr-<wbr>L1$pb(<br>
+; CHECK: movl L__ZNSbIcED1Ev$non_lazy_ptr-<wbr>L0$pb(<br>
<br>
<br>
<br>
<br>
Modified: llvm/trunk/tools/llc/llc.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/tools/llc/<wbr>llc.cpp?rev=279564&r1=279563&<wbr>r2=279564&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/tools/llc/llc.cpp (original)<br>
+++ llvm/trunk/tools/llc/llc.cpp Tue Aug 23 15:58:29 2016<br>
@@ -450,8 +450,7 @@ static int compileModule(char **argv, LL<br>
       LLVMTargetMachine &LLVMTM = static_cast<LLVMTargetMachine&<wbr>>(*Target);<br>
       TargetPassConfig &TPC = *LLVMTM.createPassConfig(PM);<br>
       PM.add(&TPC);<br>
-      LLVMTM.addMachineModuleInfo(<wbr>PM);<br>
-      LLVMTM.<wbr>addMachineFunctionAnalysis(PM, MIR.get());<br>
+      LLVMTM.addMachineModuleInfo(<wbr>PM, MIR.get());<br>
       TPC.printAndVerify("");<br>
<br>
       for (const std::string &RunPassName : *RunPassNames) {<br>
<br>
Modified: llvm/trunk/unittests/MI/<wbr>LiveIntervalTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/MI/LiveIntervalTest.cpp?rev=279564&r1=279563&r2=279564&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/unittests/<wbr>MI/LiveIntervalTest.cpp?rev=<wbr>279564&r1=279563&r2=279564&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/unittests/MI/<wbr>LiveIntervalTest.cpp (original)<br>
+++ llvm/trunk/unittests/MI/<wbr>LiveIntervalTest.cpp Tue Aug 23 15:58:29 2016<br>
@@ -70,8 +70,7 @@ std::unique_ptr<Module> parseMIR(LLVMCon<br>
     return nullptr;<br>
<br>
   const LLVMTargetMachine &LLVMTM = static_cast<const LLVMTargetMachine&>(TM);<br>
-  LLVMTM.addMachineModuleInfo(<wbr>PM);<br>
-  LLVMTM.<wbr>addMachineFunctionAnalysis(PM, MIR.get());<br>
+  LLVMTM.addMachineModuleInfo(<wbr>PM, MIR.get());<br>
<br>
   return M;<br>
 }<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>