[libc] Fix global constructor being emitted for the RPC client
authorJoseph Huber <jhuber6@vols.utk.edu>
Wed, 19 Jul 2023 15:58:45 +0000 (10:58 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Wed, 19 Jul 2023 16:38:46 +0000 (11:38 -0500)
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

libc/src/__support/RPC/rpc.h

index d91a5c8..9f5c842 100644 (file)
@@ -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};