[llvm] 3e11ae6 - [ORC] Merge ostream operators for SymbolStringPtrs into SymbolStringPool.h. NFC.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 3 21:06:54 PST 2024


Author: Lang Hames
Date: 2024-12-04T16:06:46+11:00
New Revision: 3e11ae69abd17a80759ae1d9565d555f6a869304

URL: https://github.com/llvm/llvm-project/commit/3e11ae69abd17a80759ae1d9565d555f6a869304
DIFF: https://github.com/llvm/llvm-project/commit/3e11ae69abd17a80759ae1d9565d555f6a869304.diff

LOG: [ORC] Merge ostream operators for SymbolStringPtrs into SymbolStringPool.h. NFC.

These are simple and commonly used. Having them in the SymbolStringPool header
saves clients from having to #include "DebugUtils.h" everywhere.

Added: 
    

Modified: 
    llvm/include/llvm/ExecutionEngine/Orc/DebugUtils.h
    llvm/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h
    llvm/lib/ExecutionEngine/Orc/Core.cpp
    llvm/lib/ExecutionEngine/Orc/DebugUtils.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/DebugUtils.h b/llvm/include/llvm/ExecutionEngine/Orc/DebugUtils.h
index 035139578e08f8..fb66bf812f6109 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/DebugUtils.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/DebugUtils.h
@@ -29,12 +29,6 @@ namespace orc {
 
 // --raw_ostream operators for ORC types--
 
-/// Render a SymbolStringPtr.
-raw_ostream &operator<<(raw_ostream &OS, const SymbolStringPtr &Sym);
-
-/// Render a NonOwningSymbolStringPtr.
-raw_ostream &operator<<(raw_ostream &OS, NonOwningSymbolStringPtr Sym);
-
 /// Render a SymbolNameSet.
 raw_ostream &operator<<(raw_ostream &OS, const SymbolNameSet &Symbols);
 

diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h b/llvm/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h
index f47956a65f2e78..85f08b53f74a36 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h
@@ -92,6 +92,9 @@ class SymbolStringPtrBase {
     return LHS.S < RHS.S;
   }
 
+  friend raw_ostream &operator<<(raw_ostream &OS,
+                                 const SymbolStringPtrBase &Sym);
+
 #ifndef NDEBUG
   // Returns true if the pool entry's ref count is above zero (or if the entry
   // is an empty or tombstone value). Useful for debugging and testing -- this

diff  --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp
index 85022870164136..df04b86bda1480 100644
--- a/llvm/lib/ExecutionEngine/Orc/Core.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Core.cpp
@@ -14,6 +14,7 @@
 #include "llvm/ExecutionEngine/Orc/Shared/OrcError.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/MSVCErrorWorkarounds.h"
+#include "llvm/Support/raw_ostream.h"
 
 #include <condition_variable>
 #include <future>
@@ -37,6 +38,10 @@ char LookupTask::ID = 0;
 RegisterDependenciesFunction NoDependenciesToRegister =
     RegisterDependenciesFunction();
 
+raw_ostream &operator<<(raw_ostream &OS, const SymbolStringPtrBase &Sym) {
+  return (OS << Sym.S->first());
+}
+
 void MaterializationUnit::anchor() {}
 
 ResourceTracker::ResourceTracker(JITDylibSP JD) {

diff  --git a/llvm/lib/ExecutionEngine/Orc/DebugUtils.cpp b/llvm/lib/ExecutionEngine/Orc/DebugUtils.cpp
index de8d003408871c..6ced8c76b037c4 100644
--- a/llvm/lib/ExecutionEngine/Orc/DebugUtils.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/DebugUtils.cpp
@@ -137,14 +137,6 @@ struct PrintSymbolMapElemsMatchingCLOpts {
 namespace llvm {
 namespace orc {
 
-raw_ostream &operator<<(raw_ostream &OS, const SymbolStringPtr &Sym) {
-  return OS << *Sym;
-}
-
-raw_ostream &operator<<(raw_ostream &OS, NonOwningSymbolStringPtr Sym) {
-  return OS << *Sym;
-}
-
 raw_ostream &operator<<(raw_ostream &OS, const SymbolNameSet &Symbols) {
   return OS << printSequence(Symbols, '{', '}', PrintAll<SymbolStringPtr>());
 }


        


More information about the llvm-commits mailing list