[llvm] r346681 - [MachineOutliner][NFC] Put suffix tree in buildCandidateList

Jessica Paquette via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 12 09:50:55 PST 2018


Author: paquette
Date: Mon Nov 12 09:50:55 2018
New Revision: 346681

URL: http://llvm.org/viewvc/llvm-project?rev=346681&view=rev
Log:
[MachineOutliner][NFC] Put suffix tree in buildCandidateList

It's only used there, so it doesn't make much sense to have it in runOnModule.

Modified:
    llvm/trunk/lib/CodeGen/MachineOutliner.cpp

Modified: llvm/trunk/lib/CodeGen/MachineOutliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineOutliner.cpp?rev=346681&r1=346680&r2=346681&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineOutliner.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineOutliner.cpp Mon Nov 12 09:50:55 2018
@@ -919,7 +919,7 @@ struct MachineOutliner : public ModulePa
   unsigned
   buildCandidateList(std::vector<std::shared_ptr<Candidate>> &CandidateList,
                      std::vector<OutlinedFunction> &FunctionList,
-                     SuffixTree &ST, InstructionMapper &Mapper);
+                     InstructionMapper &Mapper);
 
   /// Helper function for pruneOverlaps.
   /// Removes \p C from the candidate list, and updates its \p OutlinedFunction.
@@ -1263,8 +1263,10 @@ void MachineOutliner::pruneOverlaps(
 
 unsigned MachineOutliner::buildCandidateList(
     std::vector<std::shared_ptr<Candidate>> &CandidateList,
-    std::vector<OutlinedFunction> &FunctionList, SuffixTree &ST,
+    std::vector<OutlinedFunction> &FunctionList,
     InstructionMapper &Mapper) {
+  // Construct a suffix tree and use it to find candidates.
+  SuffixTree ST(Mapper.UnsignedVec);
 
   std::vector<unsigned> CandidateSequence; // Current outlining candidate.
   unsigned MaxCandidateLen = 0;            // Length of the longest candidate.
@@ -1628,15 +1630,12 @@ bool MachineOutliner::runOnModule(Module
 
   // Prepare instruction mappings for the suffix tree.
   populateMapper(Mapper, M, MMI);
-
-  // Construct a suffix tree, use it to find candidates, and then outline them.
-  SuffixTree ST(Mapper.UnsignedVec);
   std::vector<std::shared_ptr<Candidate>> CandidateList;
   std::vector<OutlinedFunction> FunctionList;
 
   // Find all of the outlining candidates.
   unsigned MaxCandidateLen =
-      buildCandidateList(CandidateList, FunctionList, ST, Mapper);
+      buildCandidateList(CandidateList, FunctionList, Mapper);
 
   // Remove candidates that overlap with other candidates.
   pruneOverlaps(CandidateList, FunctionList, Mapper, MaxCandidateLen);




More information about the llvm-commits mailing list