[libc-commits] [libc] 90eea57 - [libc] Fix global constructor being emitted for the RPC client

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Wed Jul 19 09:38:56 PDT 2023


Author: Joseph Huber
Date: 2023-07-19T11:38:46-05:00
New Revision: 90eea57d755c570437cd8f5cf3599198997c592e

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

LOG: [libc] Fix global constructor being emitted for the RPC client

The indirection here is for some reason causing an unnecessary
constructor. If we leave this uninitialized we will get the default
constructor which simply zero initliaizes the global. I've checked the
output and confirmed that it uses the `zeroinitializer` so this should
be safe.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D155720

Added: 
    

Modified: 
    libc/src/__support/RPC/rpc.h

Removed: 
    


################################################################################
diff  --git a/libc/src/__support/RPC/rpc.h b/libc/src/__support/RPC/rpc.h
index d91a5c8b8dba14..9f5c8426364562 100644
--- a/libc/src/__support/RPC/rpc.h
+++ b/libc/src/__support/RPC/rpc.h
@@ -82,10 +82,10 @@ template <bool Invert, typename Packet> struct Process {
   LIBC_INLINE Process &operator=(Process &&) = default;
   LIBC_INLINE ~Process() = default;
 
-  uint64_t port_count;
-  cpp::Atomic<uint32_t> *inbox;
-  cpp::Atomic<uint32_t> *outbox;
-  Packet *packet;
+  uint64_t port_count = 0;
+  cpp::Atomic<uint32_t> *inbox = nullptr;
+  cpp::Atomic<uint32_t> *outbox = nullptr;
+  Packet *packet = nullptr;
 
   cpp::Atomic<uint32_t> lock[DEFAULT_PORT_COUNT] = {0};
 


        


More information about the libc-commits mailing list