Skip to content

[nfc]For InstrProfData.inc, clang-format functions and opt-out of formatting on the rest #82057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions compiler-rt/include/profile/InstrProfData.inc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
#define INSTR_PROF_VISIBILITY
#endif

// 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
Expand Down Expand Up @@ -494,12 +496,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. */
Expand All @@ -511,27 +515,26 @@ 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;
}

/*!
* 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));
}

/*!
* 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++)
Expand All @@ -542,8 +545,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,
Expand All @@ -553,8 +556,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));
}

Expand Down Expand Up @@ -637,6 +640,8 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,

/*============================================================================*/

// 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
Expand Down Expand Up @@ -903,6 +908,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
Expand Down
33 changes: 20 additions & 13 deletions llvm/include/llvm/ProfileData/InstrProfData.inc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
#define INSTR_PROF_VISIBILITY
#endif

// 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
Expand Down Expand Up @@ -494,12 +496,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. */
Expand All @@ -511,27 +515,26 @@ 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;
}

/*!
* 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));
}

/*!
* 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++)
Expand All @@ -542,8 +545,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,
Expand All @@ -553,8 +556,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));
}

Expand Down Expand Up @@ -637,6 +640,8 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,

/*============================================================================*/

// 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
Expand Down Expand Up @@ -903,6 +908,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
Expand Down