<div dir="ltr">In the future, I'd also suggest doing clang-format first, and separately.</div><br><div class="gmail_quote"><div dir="ltr">On Sat, Jun 4, 2016 at 10:07 PM Xinliang David Li via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">yes.  The change extract the transformation into its own class (to be reusable) and make a new class for the legacy pass as a wrapper to the newly extracted one.  (the larger diff is caused by clang-format).</div><div dir="ltr"><div><br></div><div>David</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jun 4, 2016 at 9:40 PM, Chandler Carruth 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"><div dir="ltr"><div class="gmail_quote"><span><div dir="ltr">On Sat, Jun 4, 2016 at 8:46 PM Xinliang David Li via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: davidxl<br>
Date: Sat Jun  4 22:40:03 2016<br>
New Revision: 271822<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=271822&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=271822&view=rev</a><br>
Log:<br>
[PM] code refactoring /NFC<br></blockquote><div><br></div></span><div>Please write somewhat more detailed commit messages? For example, what refactoring? To what end? That makes it much easier to do code review.</div><div><div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified:<br>
    llvm/trunk/include/llvm/InitializePasses.h<br>
    llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp<br>
    llvm/trunk/lib/Transforms/Instrumentation/Instrumentation.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/InitializePasses.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializePasses.h?rev=271822&r1=271821&r2=271822&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializePasses.h?rev=271822&r1=271821&r2=271822&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/InitializePasses.h (original)<br>
+++ llvm/trunk/include/llvm/InitializePasses.h Sat Jun  4 22:40:03 2016<br>
@@ -123,7 +123,7 @@ void initializeEarlyIfConverterPass(Pass<br>
 void initializeEdgeBundlesPass(PassRegistry&);<br>
 void initializeExpandPostRAPass(PassRegistry&);<br>
 void initializeAAResultsWrapperPassPass(PassRegistry &);<br>
-void initializeGCOVProfilerPass(PassRegistry&);<br>
+void initializeGCOVProfilerLegacyPassPass(PassRegistry&);<br>
 void initializePGOInstrumentationGenLegacyPassPass(PassRegistry&);<br>
 void initializePGOInstrumentationUseLegacyPassPass(PassRegistry&);<br>
 void initializePGOIndirectCallPromotionLegacyPassPass(PassRegistry&);<br>
<br>
Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=271822&r1=271821&r2=271822&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=271822&r1=271821&r2=271822&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Sat Jun  4 22:40:03 2016<br>
@@ -68,85 +68,95 @@ GCOVOptions GCOVOptions::getDefault() {<br>
 }<br>
<br>
 namespace {<br>
-  class GCOVFunction;<br>
+class GCOVFunction;<br>
<br>
-  class GCOVProfiler : public ModulePass {<br>
-  public:<br>
-    static char ID;<br>
-    GCOVProfiler() : GCOVProfiler(GCOVOptions::getDefault()) {}<br>
-    GCOVProfiler(const GCOVOptions &Opts) : ModulePass(ID), Options(Opts) {<br>
-      assert((Options.EmitNotes || Options.EmitData) &&<br>
-             "GCOVProfiler asked to do nothing?");<br>
-      ReversedVersion[0] = Options.Version[3];<br>
-      ReversedVersion[1] = Options.Version[2];<br>
-      ReversedVersion[2] = Options.Version[1];<br>
-      ReversedVersion[3] = Options.Version[0];<br>
-      ReversedVersion[4] = '\0';<br>
-      initializeGCOVProfilerPass(*PassRegistry::getPassRegistry());<br>
-    }<br>
-    const char *getPassName() const override {<br>
-      return "GCOV Profiler";<br>
-    }<br>
-<br>
-  private:<br>
-    bool runOnModule(Module &M) override;<br>
-<br>
-    // Create the .gcno files for the Module based on DebugInfo.<br>
-    void emitProfileNotes();<br>
-<br>
-    // Modify the program to track transitions along edges and call into the<br>
-    // profiling runtime to emit .gcda files when run.<br>
-    bool emitProfileArcs();<br>
-<br>
-    // Get pointers to the functions in the runtime library.<br>
-    Constant *getStartFileFunc();<br>
-    Constant *getIncrementIndirectCounterFunc();<br>
-    Constant *getEmitFunctionFunc();<br>
-    Constant *getEmitArcsFunc();<br>
-    Constant *getSummaryInfoFunc();<br>
-    Constant *getDeleteWriteoutFunctionListFunc();<br>
-    Constant *getDeleteFlushFunctionListFunc();<br>
-    Constant *getEndFileFunc();<br>
-<br>
-    // Create or retrieve an i32 state value that is used to represent the<br>
-    // pred block number for certain non-trivial edges.<br>
-    GlobalVariable *getEdgeStateValue();<br>
-<br>
-    // Produce a table of pointers to counters, by predecessor and successor<br>
-    // block number.<br>
-    GlobalVariable *buildEdgeLookupTable(Function *F,<br>
-                                         GlobalVariable *Counter,<br>
-                                         const UniqueVector<BasicBlock *>&Preds,<br>
-                                         const UniqueVector<BasicBlock*>&Succs);<br>
-<br>
-    // Add the function to write out all our counters to the global destructor<br>
-    // list.<br>
-    Function *insertCounterWriteout(ArrayRef<std::pair<GlobalVariable*,<br>
-                                                       MDNode*> >);<br>
-    Function *insertFlush(ArrayRef<std::pair<GlobalVariable*, MDNode*> >);<br>
-    void insertIndirectCounterIncrement();<br>
-<br>
-    std::string mangleName(const DICompileUnit *CU, const char *NewStem);<br>
-<br>
-    GCOVOptions Options;<br>
-<br>
-    // Reversed, NUL-terminated copy of Options.Version.<br>
-    char ReversedVersion[5];<br>
-    // Checksum, produced by hash of EdgeDestinations<br>
-    SmallVector<uint32_t, 4> FileChecksums;<br>
-<br>
-    Module *M;<br>
-    LLVMContext *Ctx;<br>
-    SmallVector<std::unique_ptr<GCOVFunction>, 16> Funcs;<br>
-  };<br>
+class GCOVProfiler {<br>
+public:<br>
+  GCOVProfiler() : GCOVProfiler(GCOVOptions::getDefault()) {}<br>
+  GCOVProfiler(const GCOVOptions &Opts) : Options(Opts) {<br>
+    assert((Options.EmitNotes || Options.EmitData) &&<br>
+           "GCOVProfiler asked to do nothing?");<br>
+    ReversedVersion[0] = Options.Version[3];<br>
+    ReversedVersion[1] = Options.Version[2];<br>
+    ReversedVersion[2] = Options.Version[1];<br>
+    ReversedVersion[3] = Options.Version[0];<br>
+    ReversedVersion[4] = '\0';<br>
+  }<br>
+  bool runOnModule(Module &M);<br>
+<br>
+private:<br>
+  // Create the .gcno files for the Module based on DebugInfo.<br>
+  void emitProfileNotes();<br>
+<br>
+  // Modify the program to track transitions along edges and call into the<br>
+  // profiling runtime to emit .gcda files when run.<br>
+  bool emitProfileArcs();<br>
+<br>
+  // Get pointers to the functions in the runtime library.<br>
+  Constant *getStartFileFunc();<br>
+  Constant *getIncrementIndirectCounterFunc();<br>
+  Constant *getEmitFunctionFunc();<br>
+  Constant *getEmitArcsFunc();<br>
+  Constant *getSummaryInfoFunc();<br>
+  Constant *getDeleteWriteoutFunctionListFunc();<br>
+  Constant *getDeleteFlushFunctionListFunc();<br>
+  Constant *getEndFileFunc();<br>
+<br>
+  // Create or retrieve an i32 state value that is used to represent the<br>
+  // pred block number for certain non-trivial edges.<br>
+  GlobalVariable *getEdgeStateValue();<br>
+<br>
+  // Produce a table of pointers to counters, by predecessor and successor<br>
+  // block number.<br>
+  GlobalVariable *buildEdgeLookupTable(Function *F, GlobalVariable *Counter,<br>
+                                       const UniqueVector<BasicBlock *> &Preds,<br>
+                                       const UniqueVector<BasicBlock *> &Succs);<br>
+<br>
+  // Add the function to write out all our counters to the global destructor<br>
+  // list.<br>
+  Function *<br>
+  insertCounterWriteout(ArrayRef<std::pair<GlobalVariable *, MDNode *>>);<br>
+  Function *insertFlush(ArrayRef<std::pair<GlobalVariable *, MDNode *>>);<br>
+  void insertIndirectCounterIncrement();<br>
+<br>
+  std::string mangleName(const DICompileUnit *CU, const char *NewStem);<br>
+<br>
+  GCOVOptions Options;<br>
+<br>
+  // Reversed, NUL-terminated copy of Options.Version.<br>
+  char ReversedVersion[5];<br>
+  // Checksum, produced by hash of EdgeDestinations<br>
+  SmallVector<uint32_t, 4> FileChecksums;<br>
+<br>
+  Module *M;<br>
+  LLVMContext *Ctx;<br>
+  SmallVector<std::unique_ptr<GCOVFunction>, 16> Funcs;<br>
+};<br>
+<br>
+class GCOVProfilerLegacyPass : public ModulePass {<br>
+public:<br>
+  static char ID;<br>
+  GCOVProfilerLegacyPass()<br>
+      : GCOVProfilerLegacyPass(GCOVOptions::getDefault()) {}<br>
+  GCOVProfilerLegacyPass(const GCOVOptions &Opts)<br>
+      : ModulePass(ID), Profiler(Opts) {<br>
+    initializeGCOVProfilerLegacyPassPass(*PassRegistry::getPassRegistry());<br>
+  }<br>
+  const char *getPassName() const override { return "GCOV Profiler"; }<br>
+<br>
+  bool runOnModule(Module &M) override { return Profiler.runOnModule(M); }<br>
+<br>
+private:<br>
+  GCOVProfiler Profiler;<br>
+};<br>
 }<br>
<br>
-char GCOVProfiler::ID = 0;<br>
-INITIALIZE_PASS(GCOVProfiler, "insert-gcov-profiling",<br>
+char GCOVProfilerLegacyPass::ID = 0;<br>
+INITIALIZE_PASS(GCOVProfilerLegacyPass, "insert-gcov-profiling",<br>
                 "Insert instrumentation for GCOV profiling", false, false)<br>
<br>
 ModulePass *llvm::createGCOVProfilerPass(const GCOVOptions &Options) {<br>
-  return new GCOVProfiler(Options);<br>
+  return new GCOVProfilerLegacyPass(Options);<br>
 }<br>
<br>
 static StringRef getFunctionName(const DISubprogram *SP) {<br>
<br>
Modified: llvm/trunk/lib/Transforms/Instrumentation/Instrumentation.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/Instrumentation.cpp?rev=271822&r1=271821&r2=271822&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/Instrumentation.cpp?rev=271822&r1=271821&r2=271822&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/Instrumentation/Instrumentation.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Instrumentation/Instrumentation.cpp Sat Jun  4 22:40:03 2016<br>
@@ -59,7 +59,7 @@ void llvm::initializeInstrumentation(Pas<br>
   initializeAddressSanitizerPass(Registry);<br>
   initializeAddressSanitizerModulePass(Registry);<br>
   initializeBoundsCheckingPass(Registry);<br>
-  initializeGCOVProfilerPass(Registry);<br>
+  initializeGCOVProfilerLegacyPassPass(Registry);<br>
   initializePGOInstrumentationGenLegacyPassPass(Registry);<br>
   initializePGOInstrumentationUseLegacyPassPass(Registry);<br>
   initializePGOIndirectCallPromotionLegacyPassPass(Registry);<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">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/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div></div></div>
<br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">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/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">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/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>