[compiler-rt] d2aa34e - [NFC][sanitizer] Move ChainedOriginDepotNode into cpp file

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 8 13:43:47 PDT 2021


Author: Vitaly Buka
Date: 2021-10-08T13:43:29-07:00
New Revision: d2aa34e8d91b25a3c469928f71668014b431643e

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

LOG: [NFC][sanitizer] Move ChainedOriginDepotNode into cpp file

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.cpp
index 7479050fd2d0..12fe5b98bea0 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.cpp
@@ -13,20 +13,65 @@
 
 namespace __sanitizer {
 
+namespace {
+struct ChainedOriginDepotDesc {
+  u32 here_id;
+  u32 prev_id;
+};
+
+struct ChainedOriginDepotNode {
+  using hash_type = u32;
+  ChainedOriginDepotNode *link;
+  u32 id;
+  u32 here_id;
+  u32 prev_id;
+
+  typedef ChainedOriginDepotDesc args_type;
+
+  bool eq(hash_type hash, const args_type &args) const;
+
+  static uptr allocated();
+
+  static ChainedOriginDepotNode *allocate(const args_type &args);
+
+  static hash_type hash(const args_type &args);
+
+  static bool is_valid(const args_type &args);
+
+  void store(const args_type &args, hash_type other_hash);
+
+  args_type load() const;
+
+  struct Handle {
+    ChainedOriginDepotNode *node_;
+    Handle() : node_(nullptr) {}
+    explicit Handle(ChainedOriginDepotNode *node) : node_(node) {}
+    bool valid() { return node_; }
+    u32 id() { return node_->id; }
+    int here_id() { return node_->here_id; }
+    int prev_id() { return node_->prev_id; }
+  };
+
+  Handle get_handle();
+
+  typedef Handle handle_type;
+};
+
+}  // namespace
+
 static PersistentAllocator allocator;
 
-bool ChainedOriginDepot::ChainedOriginDepotNode::eq(
-    hash_type hash, const args_type &args) const {
+static StackDepotBase<ChainedOriginDepotNode, 4, 20> depot;
+
+bool ChainedOriginDepotNode::eq(hash_type hash, const args_type &args) const {
   return here_id == args.here_id && prev_id == args.prev_id;
 }
 
-uptr ChainedOriginDepot::ChainedOriginDepotNode::allocated() {
-  return allocator.allocated();
-}
+uptr ChainedOriginDepotNode::allocated() { return allocator.allocated(); }
 
-ChainedOriginDepot::ChainedOriginDepotNode *
-ChainedOriginDepot::ChainedOriginDepotNode::allocate(const args_type &args) {
-  return static_cast<ChainedOriginDepot::ChainedOriginDepotNode *>(
+ChainedOriginDepotNode *ChainedOriginDepotNode::allocate(
+    const args_type &args) {
+  return static_cast<ChainedOriginDepotNode *>(
       allocator.alloc(sizeof(ChainedOriginDepotNode)));
 }
 
@@ -43,8 +88,8 @@ ChainedOriginDepot::ChainedOriginDepotNode::allocate(const args_type &args) {
    split, or one of two reserved values (-1) or (-2). Either case can
    dominate depending on the workload.
 */
-ChainedOriginDepot::ChainedOriginDepotNode::hash_type
-ChainedOriginDepot::ChainedOriginDepotNode::hash(const args_type &args) {
+ChainedOriginDepotNode::hash_type ChainedOriginDepotNode::hash(
+    const args_type &args) {
   const u32 m = 0x5bd1e995;
   const u32 seed = 0x9747b28c;
   const u32 r = 24;
@@ -69,25 +114,20 @@ ChainedOriginDepot::ChainedOriginDepotNode::hash(const args_type &args) {
   return h;
 }
 
-bool ChainedOriginDepot::ChainedOriginDepotNode::is_valid(
-    const args_type &args) {
-  return true;
-}
+bool ChainedOriginDepotNode::is_valid(const args_type &args) { return true; }
 
-void ChainedOriginDepot::ChainedOriginDepotNode::store(const args_type &args,
-                                                       hash_type other_hash) {
+void ChainedOriginDepotNode::store(const args_type &args,
+                                   hash_type other_hash) {
   here_id = args.here_id;
   prev_id = args.prev_id;
 }
 
-ChainedOriginDepot::ChainedOriginDepotNode::args_type
-ChainedOriginDepot::ChainedOriginDepotNode::load() const {
+ChainedOriginDepotNode::args_type ChainedOriginDepotNode::load() const {
   args_type ret = {here_id, prev_id};
   return ret;
 }
 
-ChainedOriginDepot::ChainedOriginDepotNode::Handle
-ChainedOriginDepot::ChainedOriginDepotNode::get_handle() {
+ChainedOriginDepotNode::Handle ChainedOriginDepotNode::get_handle() {
   return Handle(this);
 }
 

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h b/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h
index be4190dc735d..edbfb34134c8 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h
@@ -38,51 +38,6 @@ class ChainedOriginDepot {
   void UnlockAll();
 
  private:
-  struct ChainedOriginDepotDesc {
-    u32 here_id;
-    u32 prev_id;
-  };
-
-  struct ChainedOriginDepotNode {
-    using hash_type = u32;
-    ChainedOriginDepotNode *link;
-    u32 id;
-    u32 here_id;
-    u32 prev_id;
-
-    typedef ChainedOriginDepotDesc args_type;
-
-    bool eq(hash_type hash, const args_type &args) const;
-
-    static uptr allocated();
-
-    static ChainedOriginDepotNode *allocate(const args_type &args);
-
-    static hash_type hash(const args_type &args);
-
-    static bool is_valid(const args_type &args);
-
-    void store(const args_type &args, hash_type other_hash);
-
-    args_type load() const;
-
-    struct Handle {
-      ChainedOriginDepotNode *node_;
-      Handle() : node_(nullptr) {}
-      explicit Handle(ChainedOriginDepotNode *node) : node_(node) {}
-      bool valid() { return node_; }
-      u32 id() { return node_->id; }
-      int here_id() { return node_->here_id; }
-      int prev_id() { return node_->prev_id; }
-    };
-
-    Handle get_handle();
-
-    typedef Handle handle_type;
-  };
-
-  StackDepotBase<ChainedOriginDepotNode, 4, 20> depot;
-
   ChainedOriginDepot(const ChainedOriginDepot &) = delete;
   void operator=(const ChainedOriginDepot &) = delete;
 };


        


More information about the llvm-commits mailing list