diff --git a/include/llvm/CodeGen/PMLExport.h b/include/llvm/CodeGen/PMLExport.h
index b5729f437ed03c5b46d60f86a407763041f725ec..417c2b78f82fe934ee41b4b047e75ae80674f858 100644
--- a/include/llvm/CodeGen/PMLExport.h
+++ b/include/llvm/CodeGen/PMLExport.h
@@ -277,6 +277,7 @@ namespace llvm {
     StringRef   OutFileName;
     std::string BitcodeFile;
     StringList  Roots;
+    bool        SerializeAll;
 
     MFSet   FoundFunctions;
     MFQueue Queue;
@@ -286,7 +287,7 @@ namespace llvm {
     /// class. You need to setup a PMLInstrInfo using setPMLInstrInfo before
     /// using the exporter.
     PMLModuleExportPass(char &ID, TargetMachine &TM, StringRef filename,
-                        ArrayRef<std::string> roots);
+                        ArrayRef<std::string> roots, bool SerializeAll);
 
     /// Set the PMLInstrInfo to be used. Takes ownership over the
     /// InstrInfo object.
@@ -296,7 +297,8 @@ namespace llvm {
     /// Construct a new PML export pass. The pass will take ownership of the
     /// given PMLInstrInfo.
     PMLModuleExportPass(TargetMachine &TM, StringRef filename,
-                        ArrayRef<std::string> roots, PMLInstrInfo *pii);
+                        ArrayRef<std::string> roots, PMLInstrInfo *pii,
+                        bool SerializeAll);
 
     virtual~PMLModuleExportPass() {
       while(!Exporters.empty()) {
diff --git a/include/llvm/CodeGen/Passes.h b/include/llvm/CodeGen/Passes.h
index 74fd44c3b082ef995c2acc7d62aa54f9b56741dd..70747ac0a43d6baa306e1eca83feb44e5392f4e0 100644
--- a/include/llvm/CodeGen/Passes.h
+++ b/include/llvm/CodeGen/Passes.h
@@ -221,9 +221,8 @@ public:
 
   /// addSerializePass - Install a pass that serializes the internal representation
   /// of the compiler to PML format
-  virtual void addSerializePass(std::string& OutFile,
-                                ArrayRef<std::string> Roots,
-                                std::string &BitcodeFile);
+  virtual void addSerializePass(std::string& OutFile, ArrayRef<std::string> Roots,
+                                std::string &BitcodeFile, bool SerializeAll);
 
   /// Add the complete, standard set of LLVM CodeGen passes.
   /// Fully developed targets will not generally override this.
@@ -400,7 +399,8 @@ namespace llvm {
   /// PMLExport pass - this pass exports the internal LLVM information (machinecode)
   /// to the given stream in PML format
   MachineModulePass *
-  createPMLExportPass(TargetMachine &TM, std::string& FileName, std::string& BitcodeFile, ArrayRef<std::string> Roots);
+  createPMLExportPass(TargetMachine &TM, std::string& FileName, std::string& BitcodeFile,
+                      ArrayRef<std::string> Roots, bool SerializeAll);
 
   /// AtomicExpandID -- Lowers atomic operations in terms of either cmpxchg
   /// load-linked/store-conditional loops.
diff --git a/lib/CodeGen/PMLExport.cpp b/lib/CodeGen/PMLExport.cpp
index 924ea391b99be71ca69b1bf26393302c0397d053..8a1ba42d229b797a5e6534cf783953b4b15fc923 100644
--- a/lib/CodeGen/PMLExport.cpp
+++ b/lib/CodeGen/PMLExport.cpp
@@ -1167,14 +1167,15 @@ isBackEdge(MachineBasicBlock *Source, MachineBasicBlock *Target)
 
 PMLModuleExportPass::PMLModuleExportPass(char &id, TargetMachine &TM,
                               StringRef filename,
-                              ArrayRef<std::string> roots)
-  : MachineModulePass(id), PII(0), OutFileName(filename), Roots(roots)
+                                         ArrayRef<std::string> roots,
+                                         bool SerializeAll)
+  : MachineModulePass(id), PII(0), OutFileName(filename), Roots(roots), SerializeAll(SerializeAll)
 {
 }
 
 PMLModuleExportPass::PMLModuleExportPass(TargetMachine &TM, StringRef filename,
-                              ArrayRef<std::string> roots, PMLInstrInfo *pii)
-  : MachineModulePass(ID), PII(pii), OutFileName(filename), Roots(roots)
+                              ArrayRef<std::string> roots, PMLInstrInfo *pii, bool SerializeAll)
+  : MachineModulePass(ID), PII(pii), OutFileName(filename), Roots(roots), SerializeAll(SerializeAll)
 {
 }
 
@@ -1194,12 +1195,20 @@ bool PMLModuleExportPass::runOnMachineModule(const Module &M)
   // get the machine-level module information.
   MachineModuleInfo &MMI(getAnalysis<MachineModuleInfo>());
 
-  // Queue roots
   FoundFunctions.clear();
   Queue.clear();
+  if (SerializeAll) {
+    // Queue all functions
+    for (Module::const_iterator it = M.begin(); it != M.end(); ++it) {
+      const Function &F = *it;
+      addToQueue(MMI.getMachineFunction(&F));
+    }
+  } else {
+    // Queue roots
   for (size_t i=0; i < Roots.size(); i++) {
     addToQueue(M, MMI, Roots[i]);
   }
+}
 
   // follow roots until no new methods are found
   while (!Queue.empty()) {
@@ -1312,11 +1321,12 @@ char PMLModuleExportPass::ID = 0;
 /// Returns a newly-created PML export pass.
 MachineModulePass *
 createPMLExportPass(TargetMachine &TM, std::string& FileName,
-                    std::string& BitcodeFileName, ArrayRef<std::string> Roots)
+                    std::string& BitcodeFileName, ArrayRef<std::string> Roots,
+                    bool SerializeAll)
 {
   PMLInstrInfo *pii = new PMLInstrInfo();
 
-  PMLModuleExportPass *PEP = new PMLModuleExportPass(TM, FileName, Roots, pii);
+  PMLModuleExportPass *PEP = new PMLModuleExportPass(TM, FileName, Roots, pii, SerializeAll);
 
   PEP->addExporter( new PMLBitcodeExport(TM, *PEP) );
   PEP->addExporter( new PMLMachineExport(TM, *PEP) );
diff --git a/lib/CodeGen/Passes.cpp b/lib/CodeGen/Passes.cpp
index 35eb3444ad086c5f65700a07bd4c14af79365a34..4e74b49400dbdf0e54b46fb84491ef536b497de0 100644
--- a/lib/CodeGen/Passes.cpp
+++ b/lib/CodeGen/Passes.cpp
@@ -94,6 +94,9 @@ static cl::opt<std::string> SerializeMachineCode("mserialize",
 static cl::list<std::string>SerializeRoots("mserialize-roots",
    cl::desc("Export only methods reachable from given functions"),
    cl::CommaSeparated, cl::Hidden);
+static cl::opt<bool> SerializeMachineCodeAll("mserialize-all",
+   cl::desc("Export PML specification for all generated functions"),
+   cl::init(false));
 static cl::opt<std::string> SerializePreemitBitcode("mpreemit-bitcode",
   cl::desc("Write the final bitcode representation (before emit) to FILE"),
   cl::init(""));
@@ -613,7 +616,7 @@ void TargetPassConfig::addMachinePasses() {
 
   // Serialize machine code
   if (isSerializing()) {
-    addSerializePass(SerializeMachineCode, SerializeRoots, SerializePreemitBitcode);
+    addSerializePass(SerializeMachineCode, SerializeRoots, SerializePreemitBitcode, SerializeMachineCodeAll);
   }
 
   AddingMachinePasses = false;
@@ -626,9 +629,10 @@ bool TargetPassConfig::isSerializing() const {
 /// Add standard serialization to PML format
 void TargetPassConfig::addSerializePass(std::string& OutFile,
                                         ArrayRef<std::string> Roots,
-                                        std::string &BitcodeFile)
+                                        std::string &BitcodeFile,
+										bool SerializeAll)
 {
-  addPass(createPMLExportPass(*TM, OutFile, BitcodeFile, Roots));
+  addPass(createPMLExportPass(*TM, OutFile, BitcodeFile, Roots, SerializeAll));
 }
 
 /// Add passes that optimize machine instructions in SSA form.
diff --git a/lib/Target/Patmos/Patmos.h b/lib/Target/Patmos/Patmos.h
index cef2f318ba7f88b9ad1df62fe3543ff0c934a0ae..c01330597816ac1e7746122bf2302958fd602d9e 100644
--- a/lib/Target/Patmos/Patmos.h
+++ b/lib/Target/Patmos/Patmos.h
@@ -51,7 +51,8 @@ namespace llvm {
   ModulePass *createPatmosModuleExportPass(PatmosTargetMachine &TM,
                                            std::string& Filename,
                                            std::string& BitcodeFilename,
-                                           ArrayRef<std::string> Roots);
+                                           ArrayRef<std::string> Roots,
+					   bool SerializeAll);
   ModulePass *createPatmosCallGraphBuilder();
   ModulePass *createPatmosStackCacheAnalysis();
   ModulePass *createPatmosStackCacheAnalysisInfo();
diff --git a/lib/Target/Patmos/PatmosExport.cpp b/lib/Target/Patmos/PatmosExport.cpp
index 96dc858a5548373aadf46ff0388dcb19099de741..ac08ac174731c41f9f169ee7b52f479abc85ef85 100644
--- a/lib/Target/Patmos/PatmosExport.cpp
+++ b/lib/Target/Patmos/PatmosExport.cpp
@@ -318,8 +318,8 @@ namespace llvm {
 
   public:
     PatmosModuleExportPass(PatmosTargetMachine &tm, StringRef filename,
-                           ArrayRef<std::string> roots)
-      : PMLModuleExportPass(ID, tm, filename, roots)
+                           ArrayRef<std::string> roots, bool SerializeAll)
+      : PMLModuleExportPass(ID, tm, filename, roots, SerializeAll)
     {
       initializePatmosCallGraphBuilderPass(*PassRegistry::getPassRegistry());
 
@@ -356,10 +356,11 @@ namespace llvm {
   ModulePass *createPatmosModuleExportPass(PatmosTargetMachine &TM,
                                            std::string& Filename,
                                            std::string& BitcodeFilename,
-                                           ArrayRef<std::string> Roots)
+                                           ArrayRef<std::string> Roots,
+					   bool SerializeAll)
   {
     PatmosModuleExportPass *PEP =
-                      new PatmosModuleExportPass(TM, Filename, Roots);
+                      new PatmosModuleExportPass(TM, Filename, Roots, SerializeAll);
 
     // Add our own export passes
     PEP->addExporter( new PatmosMachineExport(TM, *PEP, PEP->getPatmosInstrInfo()));
diff --git a/lib/Target/Patmos/PatmosTargetMachine.cpp b/lib/Target/Patmos/PatmosTargetMachine.cpp
index cc6864e14521efa3ef667ab6db3674b5e473f0b3..ecea683eecef61c34d8ffb42ee68c5c94d53e907 100644
--- a/lib/Target/Patmos/PatmosTargetMachine.cpp
+++ b/lib/Target/Patmos/PatmosTargetMachine.cpp
@@ -250,12 +250,14 @@ namespace {
     /// of the compiler to PML format
     virtual void addSerializePass(std::string& OutFile,
                                   ArrayRef<std::string> Roots,
-                                  std::string &BitcodeFile) {
+                                  std::string &BitcodeFile,
+								  bool SerializeAll) {
 
       addPass(createPatmosModuleExportPass(
           getPatmosTargetMachine(),
           OutFile, BitcodeFile,
-          Roots.empty() ? ArrayRef<std::string>(DefaultRoot) : Roots
+          Roots.empty() ? ArrayRef<std::string>(DefaultRoot) : Roots,
+          SerializeAll
           ));
     }
 
@@ -304,4 +306,3 @@ PatmosTargetMachine::getSubtargetImpl(const Function &F) const {
 TargetPassConfig *PatmosTargetMachine::createPassConfig(PassManagerBase &PM) {
   return new PatmosPassConfig(this, PM);
 }
-