From b7dcefe13d44b1d539c9880c309c0537bc8a0584 Mon Sep 17 00:00:00 2001 From: mingmingl Date: Fri, 16 Feb 2024 14:40:10 -0800 Subject: [PATCH 1/3] [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 25df899b3f361..9147c70ff0a1b 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 25df899b3f361..0b3c581344a63 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 From f635619c4747e5c628250f8d0f0b40cd6d1d5b42 Mon Sep 17 00:00:00 2001 From: mingmingl Date: Tue, 20 Feb 2024 14:17:45 -0800 Subject: [PATCH 2/3] add a reason to opt-out of clang-format --- compiler-rt/include/profile/InstrProfData.inc | 9 +++++---- llvm/include/llvm/ProfileData/InstrProfData.inc | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/compiler-rt/include/profile/InstrProfData.inc b/compiler-rt/include/profile/InstrProfData.inc index 9147c70ff0a1b..322ce1e1a77b7 100644 --- a/compiler-rt/include/profile/InstrProfData.inc +++ b/compiler-rt/include/profile/InstrProfData.inc @@ -62,7 +62,7 @@ #define INSTR_PROF_VISIBILITY #endif -/* clang-format off */ +// clang-format off:re-enable clang-format after `issue #82426` is fixed /* INSTR_PROF_DATA start. */ /* Definition of member fields of the per-function control structure. */ #ifndef INSTR_PROF_DATA @@ -308,6 +308,7 @@ INSTR_PROF_SECT_ENTRY(IPSK_covname, \ #undef INSTR_PROF_SECT_ENTRY #endif + #ifdef INSTR_PROF_VALUE_PROF_DATA #define INSTR_PROF_DATA_DEFINED @@ -494,7 +495,7 @@ getValueProfRecordHeaderSize(uint32_t NumValueSites); #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #endif -/* clang-format on */ +// clang-format on /*! * Return the \c ValueProfRecord header size including the @@ -638,7 +639,7 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure, /*============================================================================*/ -/* clang-format off */ +// clang-format off:re-enable clang-format after `issue #82426` is fixed #ifndef INSTR_PROF_DATA_DEFINED #ifndef INSTR_PROF_DATA_INC @@ -905,7 +906,7 @@ int InstProfPopcountll(unsigned long long X) { return __builtin_popcountll(X); } #endif /* defined(_MSC_VER) && !defined(__clang__) */ -/* clang-format on */ +// 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. */ diff --git a/llvm/include/llvm/ProfileData/InstrProfData.inc b/llvm/include/llvm/ProfileData/InstrProfData.inc index 0b3c581344a63..322ce1e1a77b7 100644 --- a/llvm/include/llvm/ProfileData/InstrProfData.inc +++ b/llvm/include/llvm/ProfileData/InstrProfData.inc @@ -62,7 +62,7 @@ #define INSTR_PROF_VISIBILITY #endif -/* clang-format off */ +// clang-format off:re-enable clang-format after `issue #82426` is fixed /* INSTR_PROF_DATA start. */ /* Definition of member fields of the per-function control structure. */ #ifndef INSTR_PROF_DATA @@ -495,7 +495,7 @@ getValueProfRecordHeaderSize(uint32_t NumValueSites); #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #endif -/* clang-format on */ +// clang-format on /*! * Return the \c ValueProfRecord header size including the @@ -639,7 +639,7 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure, /*============================================================================*/ -/* clang-format off */ +// clang-format off:re-enable clang-format after `issue #82426` is fixed #ifndef INSTR_PROF_DATA_DEFINED #ifndef INSTR_PROF_DATA_INC @@ -906,7 +906,7 @@ int InstProfPopcountll(unsigned long long X) { return __builtin_popcountll(X); } #endif /* defined(_MSC_VER) && !defined(__clang__) */ -/* clang-format on */ +// 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. */ From 9e055e2aaa7802a221a615588f0d76133de8c7cc Mon Sep 17 00:00:00 2001 From: mingmingl Date: Tue, 20 Feb 2024 16:57:14 -0800 Subject: [PATCH 3/3] reword re why turn off clang-format --- compiler-rt/include/profile/InstrProfData.inc | 6 ++++-- llvm/include/llvm/ProfileData/InstrProfData.inc | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/compiler-rt/include/profile/InstrProfData.inc b/compiler-rt/include/profile/InstrProfData.inc index 322ce1e1a77b7..c907a9736f316 100644 --- a/compiler-rt/include/profile/InstrProfData.inc +++ b/compiler-rt/include/profile/InstrProfData.inc @@ -62,7 +62,8 @@ #define INSTR_PROF_VISIBILITY #endif -// clang-format off:re-enable clang-format after `issue #82426` is fixed +// clang-format off:consider re-enabling clang-format if auto-formatted C macros +// are readable (e.g., after `issue #82426` is fixed) /* INSTR_PROF_DATA start. */ /* Definition of member fields of the per-function control structure. */ #ifndef INSTR_PROF_DATA @@ -639,7 +640,8 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure, /*============================================================================*/ -// clang-format off:re-enable clang-format after `issue #82426` is fixed +// clang-format off:consider re-enabling clang-format if auto-formatted C macros +// are readable (e.g., after `issue #82426` is fixed) #ifndef INSTR_PROF_DATA_DEFINED #ifndef INSTR_PROF_DATA_INC diff --git a/llvm/include/llvm/ProfileData/InstrProfData.inc b/llvm/include/llvm/ProfileData/InstrProfData.inc index 322ce1e1a77b7..c907a9736f316 100644 --- a/llvm/include/llvm/ProfileData/InstrProfData.inc +++ b/llvm/include/llvm/ProfileData/InstrProfData.inc @@ -62,7 +62,8 @@ #define INSTR_PROF_VISIBILITY #endif -// clang-format off:re-enable clang-format after `issue #82426` is fixed +// clang-format off:consider re-enabling clang-format if auto-formatted C macros +// are readable (e.g., after `issue #82426` is fixed) /* INSTR_PROF_DATA start. */ /* Definition of member fields of the per-function control structure. */ #ifndef INSTR_PROF_DATA @@ -639,7 +640,8 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure, /*============================================================================*/ -// clang-format off:re-enable clang-format after `issue #82426` is fixed +// clang-format off:consider re-enabling clang-format if auto-formatted C macros +// are readable (e.g., after `issue #82426` is fixed) #ifndef INSTR_PROF_DATA_DEFINED #ifndef INSTR_PROF_DATA_INC