[llvm] r207133 - [modules] "Specialize" a function by actually specializing a function template

Richard Smith richard-llvm at metafoo.co.uk
Thu Apr 24 11:27:29 PDT 2014


Author: rsmith
Date: Thu Apr 24 13:27:29 2014
New Revision: 207133

URL: http://llvm.org/viewvc/llvm-project?rev=207133&view=rev
Log:
[modules] "Specialize" a function by actually specializing a function template
rather than by adding an overload and hoping that it's declared before the code
that calls it. (In a modules build, it isn't.)

Modified:
    llvm/trunk/include/llvm/CodeGen/EdgeBundles.h
    llvm/trunk/lib/CodeGen/EdgeBundles.cpp

Modified: llvm/trunk/include/llvm/CodeGen/EdgeBundles.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/EdgeBundles.h?rev=207133&r1=207132&r2=207133&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/EdgeBundles.h (original)
+++ llvm/trunk/include/llvm/CodeGen/EdgeBundles.h Thu Apr 24 13:27:29 2014
@@ -59,11 +59,6 @@ private:
   void getAnalysisUsage(AnalysisUsage&) const override;
 };
 
-/// Specialize WriteGraph, the standard implementation won't work.
-raw_ostream &WriteGraph(raw_ostream &O, const EdgeBundles &G,
-                        bool ShortNames = false,
-                        const Twine &Title = "");
-
 } // end namespace llvm
 
 #endif

Modified: llvm/trunk/lib/CodeGen/EdgeBundles.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/EdgeBundles.cpp?rev=207133&r1=207132&r2=207133&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/EdgeBundles.cpp (original)
+++ llvm/trunk/lib/CodeGen/EdgeBundles.cpp Thu Apr 24 13:27:29 2014
@@ -69,15 +69,11 @@ bool EdgeBundles::runOnMachineFunction(M
   return false;
 }
 
-/// view - Visualize the annotated bipartite CFG with Graphviz.
-void EdgeBundles::view() const {
-  ViewGraph(*this, "EdgeBundles");
-}
-
 /// Specialize WriteGraph, the standard implementation won't work.
-raw_ostream &llvm::WriteGraph(raw_ostream &O, const EdgeBundles &G,
-                              bool ShortNames,
-                              const Twine &Title) {
+template<>
+raw_ostream &llvm::WriteGraph<>(raw_ostream &O, const EdgeBundles &G,
+                                bool ShortNames,
+                                const Twine &Title) {
   const MachineFunction *MF = G.getMachineFunction();
 
   O << "digraph {\n";
@@ -95,3 +91,8 @@ raw_ostream &llvm::WriteGraph(raw_ostrea
   O << "}\n";
   return O;
 }
+
+/// view - Visualize the annotated bipartite CFG with Graphviz.
+void EdgeBundles::view() const {
+  ViewGraph(*this, "EdgeBundles");
+}





More information about the llvm-commits mailing list