[compiler-rt] [compiler-rt]Return size 0 when both pointers are NULL (PR #81789)

Mingming Liu via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 14 13:06:28 PST 2024


https://github.com/minglotus-6 updated https://github.com/llvm/llvm-project/pull/81789

>From 5513047493925e5ca08c31a0f5b17250e079fe4f Mon Sep 17 00:00:00 2001
From: mingmingl <mingmingl at google.com>
Date: Wed, 14 Feb 2024 12:54:10 -0800
Subject: [PATCH 1/2] [compiler-rt]Return size 0 when both pointers are NULL

---
 compiler-rt/lib/profile/InstrProfilingBuffer.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/compiler-rt/lib/profile/InstrProfilingBuffer.c b/compiler-rt/lib/profile/InstrProfilingBuffer.c
index af52804b2b532c..50da9124259e00 100644
--- a/compiler-rt/lib/profile/InstrProfilingBuffer.c
+++ b/compiler-rt/lib/profile/InstrProfilingBuffer.c
@@ -93,11 +93,15 @@ uint64_t __llvm_profile_get_counters_size(const char *Begin, const char *End) {
 COMPILER_RT_VISIBILITY
 uint64_t __llvm_profile_get_num_bitmap_bytes(const char *Begin,
                                              const char *End) {
+    if (Begin == NULL && End == NULL)
+    return 0;
   return (End - Begin);
 }
 
 COMPILER_RT_VISIBILITY
 uint64_t __llvm_profile_get_name_size(const char *Begin, const char *End) {
+  if (Begin == NULL && End == NULL)
+    return 0;
   return End - Begin;
 }
 

>From 793f6fddab6dff71bdd98b7db8403de2d26b1afe Mon Sep 17 00:00:00 2001
From: mingmingl <mingmingl at google.com>
Date: Wed, 14 Feb 2024 13:06:03 -0800
Subject: [PATCH 2/2] fix format

---
 compiler-rt/lib/profile/InstrProfilingBuffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/lib/profile/InstrProfilingBuffer.c b/compiler-rt/lib/profile/InstrProfilingBuffer.c
index 50da9124259e00..faaa9dfb55ada3 100644
--- a/compiler-rt/lib/profile/InstrProfilingBuffer.c
+++ b/compiler-rt/lib/profile/InstrProfilingBuffer.c
@@ -93,7 +93,7 @@ uint64_t __llvm_profile_get_counters_size(const char *Begin, const char *End) {
 COMPILER_RT_VISIBILITY
 uint64_t __llvm_profile_get_num_bitmap_bytes(const char *Begin,
                                              const char *End) {
-    if (Begin == NULL && End == NULL)
+  if (Begin == NULL && End == NULL)
     return 0;
   return (End - Begin);
 }



More information about the llvm-commits mailing list