[modules] "Specialize" a function by actually specializing a function template
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 24 Apr 2014 18:27:29 +0000 (18:27 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 24 Apr 2014 18:27:29 +0000 (18:27 +0000)
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.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207133 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/EdgeBundles.h
lib/CodeGen/EdgeBundles.cpp

index 2899fe1ab44790e802403932e964bd48e45a76bf..c31fad246c9632e6fa19d934b42dcd5ec30c5a02 100644 (file)
@@ -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
index 3bb04657b58a5c67cc49eebd94a1aa21e283db34..83d1517f9f73dbc12f6d89e7795241f74272c86d 100644 (file)
@@ -69,15 +69,11 @@ bool EdgeBundles::runOnMachineFunction(MachineFunction &mf) {
   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_ostream &O, const EdgeBundles &G,
   O << "}\n";
   return O;
 }
+
+/// view - Visualize the annotated bipartite CFG with Graphviz.
+void EdgeBundles::view() const {
+  ViewGraph(*this, "EdgeBundles");
+}