xiaoxiang781216 commented on code in PR #14557:
URL: https://github.com/apache/nuttx/pull/14557#discussion_r1837896302


##########
libs/libbuiltin/Kconfig:
##########
@@ -29,11 +29,30 @@ config BUILTIN_TOOLCHAIN
 
 endchoice
 
+choice
+       prompt "Code coverage analysis support"
+       default COVERAGE_TOOLCHAIN
+       ---help---
+               Select the code coverage analysis library
+
 config COVERAGE_COMPILER_RT
        bool "Builtin libclang_rt.profile"
        select LIB_BUILTIN
        select LIB_COMPILER_RT
-       default n
+
+config COVERAGE_COMPILER_RT_MINI
+       bool "Builtin mini rt.profile"

Review Comment:
   update the prompt and help string



##########
libs/libbuiltin/Kconfig:
##########
@@ -29,11 +29,30 @@ config BUILTIN_TOOLCHAIN
 
 endchoice
 
+choice
+       prompt "Code coverage analysis support"
+       default COVERAGE_TOOLCHAIN
+       ---help---
+               Select the code coverage analysis library
+
 config COVERAGE_COMPILER_RT
        bool "Builtin libclang_rt.profile"
        select LIB_BUILTIN
        select LIB_COMPILER_RT
-       default n
+
+config COVERAGE_COMPILER_RT_MINI

Review Comment:
   COVERAGE_MINI to support both libgcc and compiler_rt



##########
libs/libbuiltin/compiler-rt/gcov/profile.c:
##########
@@ -0,0 +1,324 @@
+/****************************************************************************
+ * libs/libbuiltin/compiler-rt/gcov/profile.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <inttypes.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <fcntl.h>
+#include <nuttx/fs/fs.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define INSTR_PROF_RAW_VERSION 8
+#define INSTR_PROF_RAW_VERSION_VAR __llvm_profile_raw_version
+#define INSTR_PROF_PROFILE_RUNTIME_VAR __llvm_profile_runtime
+
+/* Magic number to detect file format and endianness.
+ * Use 255 at one end, since no UTF-8 file can use that character.  Avoid 0,
+ * so that utilities, like strings, don't grab it as a string.  129 is also
+ * invalid UTF-8, and high enough to be interesting.
+ * Use "lprofr" in the centre to stand for "LLVM Profile Raw", or "lprofR"
+ * for 32-bit platforms.
+ */
+
+#define INSTR_PROF_RAW_MAGIC_64                                                
\
+  (uint64_t)255 << 56 | (uint64_t)'l' << 48 | (uint64_t)'p' << 40 |            
\
+      (uint64_t)'r' << 32 | (uint64_t)'o' << 24 | (uint64_t)'f' << 16 |        
\
+      (uint64_t)'r' << 8 | (uint64_t)129
+
+#define INSTR_PROF_RAW_MAGIC_32                                                
\
+  (uint64_t)255 << 56 | (uint64_t)'l' << 48 | (uint64_t)'p' << 40 |            
\
+      (uint64_t)'r' << 32 | (uint64_t)'o' << 24 | (uint64_t)'f' << 16 |        
\
+      (uint64_t)'R' << 8 | (uint64_t)129
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+enum value_kind
+{
+  IPVK_INDIRECT_CALL_TARGET = 0,
+  IPVK_MEM_OP_SIZE = 1,
+  IPVK_FIRST = IPVK_INDIRECT_CALL_TARGET,
+  IPVK_LAST = IPVK_MEM_OP_SIZE,
+};
+
+typedef struct __attribute__((aligned(8))) __llvm_profile_data

Review Comment:
   aligned_data(8)



##########
libs/libbuiltin/compiler-rt/gcov/profile.c:
##########
@@ -0,0 +1,324 @@
+/****************************************************************************
+ * libs/libbuiltin/compiler-rt/gcov/profile.c

Review Comment:
   remove gcov 



##########
libs/libbuiltin/compiler-rt/Make.defs:
##########
@@ -101,6 +104,14 @@ FLAGS += -DCOMPILER_RT_HAS_UNAME
 CSRCS += $(wildcard compiler-rt/compiler-rt/lib/profile/*.c)
 CPPSRCS += $(wildcard compiler-rt/compiler-rt/lib/profile/*.cpp)
 CSRCS += compiler-rt/InstrProfilingPlatform.c
+
+else ifeq ($(CONFIG_COVERAGE_COMPILER_RT_MINI),y)

Review Comment:
   let's both check toolchain and MINI



##########
libs/libbuiltin/compiler-rt/gcov/profile.c:
##########
@@ -0,0 +1,324 @@
+/****************************************************************************
+ * libs/libbuiltin/compiler-rt/gcov/profile.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <inttypes.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <fcntl.h>
+#include <nuttx/fs/fs.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define INSTR_PROF_RAW_VERSION 8
+#define INSTR_PROF_RAW_VERSION_VAR __llvm_profile_raw_version
+#define INSTR_PROF_PROFILE_RUNTIME_VAR __llvm_profile_runtime
+
+/* Magic number to detect file format and endianness.
+ * Use 255 at one end, since no UTF-8 file can use that character.  Avoid 0,
+ * so that utilities, like strings, don't grab it as a string.  129 is also
+ * invalid UTF-8, and high enough to be interesting.
+ * Use "lprofr" in the centre to stand for "LLVM Profile Raw", or "lprofR"
+ * for 32-bit platforms.
+ */
+
+#define INSTR_PROF_RAW_MAGIC_64                                                
\
+  (uint64_t)255 << 56 | (uint64_t)'l' << 48 | (uint64_t)'p' << 40 |            
\
+      (uint64_t)'r' << 32 | (uint64_t)'o' << 24 | (uint64_t)'f' << 16 |        
\

Review Comment:
   remove extra spaces



##########
libs/libbuiltin/compiler-rt/Make.defs:
##########
@@ -101,6 +104,14 @@ FLAGS += -DCOMPILER_RT_HAS_UNAME
 CSRCS += $(wildcard compiler-rt/compiler-rt/lib/profile/*.c)
 CPPSRCS += $(wildcard compiler-rt/compiler-rt/lib/profile/*.cpp)
 CSRCS += compiler-rt/InstrProfilingPlatform.c
+
+else ifeq ($(CONFIG_COVERAGE_COMPILER_RT_MINI),y)
+
+CSRCS += profile.c
+
+DEPPATH += --dep-path compiler-rt/gcov

Review Comment:
   remove



##########
libs/libbuiltin/Makefile:
##########
@@ -26,9 +26,8 @@ BINDIR ?= bin
 KBIN = libkbuiltin$(LIBEXT)
 KBINDIR = kbin
 
-ifeq ($(CONFIG_LIB_COMPILER_RT),y)
 include compiler-rt/Make.defs
-endif
+include libgcc/Make.defs

Review Comment:
   why add



##########
libs/libbuiltin/compiler-rt/Make.defs:
##########
@@ -101,6 +104,14 @@ FLAGS += -DCOMPILER_RT_HAS_UNAME
 CSRCS += $(wildcard compiler-rt/compiler-rt/lib/profile/*.c)
 CPPSRCS += $(wildcard compiler-rt/compiler-rt/lib/profile/*.cpp)
 CSRCS += compiler-rt/InstrProfilingPlatform.c
+
+else ifeq ($(CONFIG_COVERAGE_COMPILER_RT_MINI),y)
+
+CSRCS += profile.c
+
+DEPPATH += --dep-path compiler-rt/gcov
+VPATH += :compiler-rt/gcov

Review Comment:
   remove



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to