[compiler-rt] [llvm] [nfc]For InstrProfData.inc, clang-format functions and opt-out of formatting on the rest (PR #82057)

Mingming Liu via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 16 16:59:08 PST 2024


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

>From b7dcefe13d44b1d539c9880c309c0537bc8a0584 Mon Sep 17 00:00:00 2001
From: mingmingl <mingmingl at google.com>
Date: Fri, 16 Feb 2024 14:40:10 -0800
Subject: [PATCH] [nfc]For InstrProfData.inc, clang-format functions and
 opt-out of formatting on the rest

---
 compiler-rt/include/profile/InstrProfData.inc | 32 +++++++++++--------
 .../llvm/ProfileData/InstrProfData.inc        | 31 ++++++++++--------
 2 files changed, 36 insertions(+), 27 deletions(-)

diff --git a/compiler-rt/include/profile/InstrProfData.inc b/compiler-rt/include/profile/InstrProfData.inc
index 25df899b3f3619..9147c70ff0a1ba 100644
--- a/compiler-rt/include/profile/InstrProfData.inc
+++ b/compiler-rt/include/profile/InstrProfData.inc
@@ -62,6 +62,7 @@
 #define INSTR_PROF_VISIBILITY
 #endif
 
+/* clang-format off */
 /* INSTR_PROF_DATA start. */
 /* Definition of member fields of the per-function control structure. */
 #ifndef INSTR_PROF_DATA
@@ -307,7 +308,6 @@ INSTR_PROF_SECT_ENTRY(IPSK_covname, \
 #undef INSTR_PROF_SECT_ENTRY
 #endif
 
-
 #ifdef INSTR_PROF_VALUE_PROF_DATA
 #define INSTR_PROF_DATA_DEFINED
 
@@ -494,12 +494,14 @@ getValueProfRecordHeaderSize(uint32_t NumValueSites);
 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
 #endif
 
+/* clang-format on */
+
 /*!
  * Return the \c ValueProfRecord header size including the
  * padding bytes.
  */
-INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
-uint32_t getValueProfRecordHeaderSize(uint32_t NumValueSites) {
+INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint32_t
+getValueProfRecordHeaderSize(uint32_t NumValueSites) {
   uint32_t Size = offsetof(ValueProfRecord, SiteCountArray) +
                   sizeof(uint8_t) * NumValueSites;
   /* Round the size to multiple of 8 bytes. */
@@ -511,9 +513,8 @@ uint32_t getValueProfRecordHeaderSize(uint32_t NumValueSites) {
  * Return the total size of the value profile record including the
  * header and the value data.
  */
-INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
-uint32_t getValueProfRecordSize(uint32_t NumValueSites,
-                                uint32_t NumValueData) {
+INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint32_t
+getValueProfRecordSize(uint32_t NumValueSites, uint32_t NumValueData) {
   return getValueProfRecordHeaderSize(NumValueSites) +
          sizeof(InstrProfValueData) * NumValueData;
 }
@@ -521,8 +522,8 @@ uint32_t getValueProfRecordSize(uint32_t NumValueSites,
 /*!
  * Return the pointer to the start of value data array.
  */
-INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
-InstrProfValueData *getValueProfRecordValueData(ValueProfRecord *This) {
+INSTR_PROF_VISIBILITY INSTR_PROF_INLINE InstrProfValueData *
+getValueProfRecordValueData(ValueProfRecord *This) {
   return (InstrProfValueData *)((char *)This + getValueProfRecordHeaderSize(
                                                    This->NumValueSites));
 }
@@ -530,8 +531,8 @@ InstrProfValueData *getValueProfRecordValueData(ValueProfRecord *This) {
 /*!
  * Return the total number of value data for \c This record.
  */
-INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
-uint32_t getValueProfRecordNumValueData(ValueProfRecord *This) {
+INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint32_t
+getValueProfRecordNumValueData(ValueProfRecord *This) {
   uint32_t NumValueData = 0;
   uint32_t I;
   for (I = 0; I < This->NumValueSites; I++)
@@ -542,8 +543,8 @@ uint32_t getValueProfRecordNumValueData(ValueProfRecord *This) {
 /*!
  * Use this method to advance to the next \c This \c ValueProfRecord.
  */
-INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
-ValueProfRecord *getValueProfRecordNext(ValueProfRecord *This) {
+INSTR_PROF_VISIBILITY INSTR_PROF_INLINE ValueProfRecord *
+getValueProfRecordNext(ValueProfRecord *This) {
   uint32_t NumValueData = getValueProfRecordNumValueData(This);
   return (ValueProfRecord *)((char *)This +
                              getValueProfRecordSize(This->NumValueSites,
@@ -553,8 +554,8 @@ ValueProfRecord *getValueProfRecordNext(ValueProfRecord *This) {
 /*!
  * Return the first \c ValueProfRecord instance.
  */
-INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
-ValueProfRecord *getFirstValueProfRecord(ValueProfData *This) {
+INSTR_PROF_VISIBILITY INSTR_PROF_INLINE ValueProfRecord *
+getFirstValueProfRecord(ValueProfData *This) {
   return (ValueProfRecord *)((char *)This + sizeof(ValueProfData));
 }
 
@@ -637,6 +638,7 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
 
 /*============================================================================*/
 
+/* clang-format off */
 #ifndef INSTR_PROF_DATA_DEFINED
 
 #ifndef INSTR_PROF_DATA_INC
@@ -903,6 +905,8 @@ int InstProfPopcountll(unsigned long long X) { return __builtin_popcountll(X); }
 
 #endif  /* defined(_MSC_VER) && !defined(__clang__) */
 
+/* clang-format on */
+
 /* Map an (observed) memop size value to the representative value of its range.
  * For example, 5 -> 5, 22 -> 17, 99 -> 65, 256 -> 256, 1001 -> 513. */
 INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint64_t
diff --git a/llvm/include/llvm/ProfileData/InstrProfData.inc b/llvm/include/llvm/ProfileData/InstrProfData.inc
index 25df899b3f3619..0b3c581344a633 100644
--- a/llvm/include/llvm/ProfileData/InstrProfData.inc
+++ b/llvm/include/llvm/ProfileData/InstrProfData.inc
@@ -62,6 +62,7 @@
 #define INSTR_PROF_VISIBILITY
 #endif
 
+/* clang-format off */
 /* INSTR_PROF_DATA start. */
 /* Definition of member fields of the per-function control structure. */
 #ifndef INSTR_PROF_DATA
@@ -494,12 +495,14 @@ getValueProfRecordHeaderSize(uint32_t NumValueSites);
 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
 #endif
 
+/* clang-format on */
+
 /*!
  * Return the \c ValueProfRecord header size including the
  * padding bytes.
  */
-INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
-uint32_t getValueProfRecordHeaderSize(uint32_t NumValueSites) {
+INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint32_t
+getValueProfRecordHeaderSize(uint32_t NumValueSites) {
   uint32_t Size = offsetof(ValueProfRecord, SiteCountArray) +
                   sizeof(uint8_t) * NumValueSites;
   /* Round the size to multiple of 8 bytes. */
@@ -511,9 +514,8 @@ uint32_t getValueProfRecordHeaderSize(uint32_t NumValueSites) {
  * Return the total size of the value profile record including the
  * header and the value data.
  */
-INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
-uint32_t getValueProfRecordSize(uint32_t NumValueSites,
-                                uint32_t NumValueData) {
+INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint32_t
+getValueProfRecordSize(uint32_t NumValueSites, uint32_t NumValueData) {
   return getValueProfRecordHeaderSize(NumValueSites) +
          sizeof(InstrProfValueData) * NumValueData;
 }
@@ -521,8 +523,8 @@ uint32_t getValueProfRecordSize(uint32_t NumValueSites,
 /*!
  * Return the pointer to the start of value data array.
  */
-INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
-InstrProfValueData *getValueProfRecordValueData(ValueProfRecord *This) {
+INSTR_PROF_VISIBILITY INSTR_PROF_INLINE InstrProfValueData *
+getValueProfRecordValueData(ValueProfRecord *This) {
   return (InstrProfValueData *)((char *)This + getValueProfRecordHeaderSize(
                                                    This->NumValueSites));
 }
@@ -530,8 +532,8 @@ InstrProfValueData *getValueProfRecordValueData(ValueProfRecord *This) {
 /*!
  * Return the total number of value data for \c This record.
  */
-INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
-uint32_t getValueProfRecordNumValueData(ValueProfRecord *This) {
+INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint32_t
+getValueProfRecordNumValueData(ValueProfRecord *This) {
   uint32_t NumValueData = 0;
   uint32_t I;
   for (I = 0; I < This->NumValueSites; I++)
@@ -542,8 +544,8 @@ uint32_t getValueProfRecordNumValueData(ValueProfRecord *This) {
 /*!
  * Use this method to advance to the next \c This \c ValueProfRecord.
  */
-INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
-ValueProfRecord *getValueProfRecordNext(ValueProfRecord *This) {
+INSTR_PROF_VISIBILITY INSTR_PROF_INLINE ValueProfRecord *
+getValueProfRecordNext(ValueProfRecord *This) {
   uint32_t NumValueData = getValueProfRecordNumValueData(This);
   return (ValueProfRecord *)((char *)This +
                              getValueProfRecordSize(This->NumValueSites,
@@ -553,8 +555,8 @@ ValueProfRecord *getValueProfRecordNext(ValueProfRecord *This) {
 /*!
  * Return the first \c ValueProfRecord instance.
  */
-INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
-ValueProfRecord *getFirstValueProfRecord(ValueProfData *This) {
+INSTR_PROF_VISIBILITY INSTR_PROF_INLINE ValueProfRecord *
+getFirstValueProfRecord(ValueProfData *This) {
   return (ValueProfRecord *)((char *)This + sizeof(ValueProfData));
 }
 
@@ -637,6 +639,7 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
 
 /*============================================================================*/
 
+/* clang-format off */
 #ifndef INSTR_PROF_DATA_DEFINED
 
 #ifndef INSTR_PROF_DATA_INC
@@ -903,6 +906,8 @@ int InstProfPopcountll(unsigned long long X) { return __builtin_popcountll(X); }
 
 #endif  /* defined(_MSC_VER) && !defined(__clang__) */
 
+/* clang-format on */
+
 /* Map an (observed) memop size value to the representative value of its range.
  * For example, 5 -> 5, 22 -> 17, 99 -> 65, 256 -> 256, 1001 -> 513. */
 INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint64_t



More information about the llvm-commits mailing list