Skip to content

Commit 4247175

Browse files
[nfc]For InstrProfData.inc, clang-format functions and opt-out of formatting on the rest (llvm#82057)
Without this, each time `InstrProfData.inc` is modified (like in llvm#81691), pre-commit CI clang-format aggressively formats many lines in an unreadable way. Pull request with red pre-commit checks are usually frowned upon. * Use `// clang-format:<reason>` instead of `/* clang-format */`. The former [allows](https://github.com/llvm/llvm-project/blob/563ef306017a47d387f1c36dd562b172c1ad0626/clang/lib/Format/Format.cpp#L4108-L4113) specifying a reason but the latter is [not](https://github.com/llvm/llvm-project/blob/563ef306017a47d387f1c36dd562b172c1ad0626/clang/lib/Format/Format.cpp#L4105-L4106). - Filed llvm#82426 to track the issue in clang-format.
1 parent 966b026 commit 4247175

File tree

2 files changed

+40
-26
lines changed

2 files changed

+40
-26
lines changed

compiler-rt/include/profile/InstrProfData.inc

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
#define INSTR_PROF_VISIBILITY
6363
#endif
6464

65+
// clang-format off:consider re-enabling clang-format if auto-formatted C macros
66+
// are readable (e.g., after `issue #82426` is fixed)
6567
/* INSTR_PROF_DATA start. */
6668
/* Definition of member fields of the per-function control structure. */
6769
#ifndef INSTR_PROF_DATA
@@ -494,12 +496,14 @@ getValueProfRecordHeaderSize(uint32_t NumValueSites);
494496
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
495497
#endif
496498

499+
// clang-format on
500+
497501
/*!
498502
* Return the \c ValueProfRecord header size including the
499503
* padding bytes.
500504
*/
501-
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
502-
uint32_t getValueProfRecordHeaderSize(uint32_t NumValueSites) {
505+
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint32_t
506+
getValueProfRecordHeaderSize(uint32_t NumValueSites) {
503507
uint32_t Size = offsetof(ValueProfRecord, SiteCountArray) +
504508
sizeof(uint8_t) * NumValueSites;
505509
/* Round the size to multiple of 8 bytes. */
@@ -511,27 +515,26 @@ uint32_t getValueProfRecordHeaderSize(uint32_t NumValueSites) {
511515
* Return the total size of the value profile record including the
512516
* header and the value data.
513517
*/
514-
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
515-
uint32_t getValueProfRecordSize(uint32_t NumValueSites,
516-
uint32_t NumValueData) {
518+
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint32_t
519+
getValueProfRecordSize(uint32_t NumValueSites, uint32_t NumValueData) {
517520
return getValueProfRecordHeaderSize(NumValueSites) +
518521
sizeof(InstrProfValueData) * NumValueData;
519522
}
520523

521524
/*!
522525
* Return the pointer to the start of value data array.
523526
*/
524-
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
525-
InstrProfValueData *getValueProfRecordValueData(ValueProfRecord *This) {
527+
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE InstrProfValueData *
528+
getValueProfRecordValueData(ValueProfRecord *This) {
526529
return (InstrProfValueData *)((char *)This + getValueProfRecordHeaderSize(
527530
This->NumValueSites));
528531
}
529532

530533
/*!
531534
* Return the total number of value data for \c This record.
532535
*/
533-
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
534-
uint32_t getValueProfRecordNumValueData(ValueProfRecord *This) {
536+
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint32_t
537+
getValueProfRecordNumValueData(ValueProfRecord *This) {
535538
uint32_t NumValueData = 0;
536539
uint32_t I;
537540
for (I = 0; I < This->NumValueSites; I++)
@@ -542,8 +545,8 @@ uint32_t getValueProfRecordNumValueData(ValueProfRecord *This) {
542545
/*!
543546
* Use this method to advance to the next \c This \c ValueProfRecord.
544547
*/
545-
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
546-
ValueProfRecord *getValueProfRecordNext(ValueProfRecord *This) {
548+
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE ValueProfRecord *
549+
getValueProfRecordNext(ValueProfRecord *This) {
547550
uint32_t NumValueData = getValueProfRecordNumValueData(This);
548551
return (ValueProfRecord *)((char *)This +
549552
getValueProfRecordSize(This->NumValueSites,
@@ -553,8 +556,8 @@ ValueProfRecord *getValueProfRecordNext(ValueProfRecord *This) {
553556
/*!
554557
* Return the first \c ValueProfRecord instance.
555558
*/
556-
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
557-
ValueProfRecord *getFirstValueProfRecord(ValueProfData *This) {
559+
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE ValueProfRecord *
560+
getFirstValueProfRecord(ValueProfData *This) {
558561
return (ValueProfRecord *)((char *)This + sizeof(ValueProfData));
559562
}
560563

@@ -637,6 +640,8 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
637640

638641
/*============================================================================*/
639642

643+
// clang-format off:consider re-enabling clang-format if auto-formatted C macros
644+
// are readable (e.g., after `issue #82426` is fixed)
640645
#ifndef INSTR_PROF_DATA_DEFINED
641646

642647
#ifndef INSTR_PROF_DATA_INC
@@ -903,6 +908,8 @@ int InstProfPopcountll(unsigned long long X) { return __builtin_popcountll(X); }
903908

904909
#endif /* defined(_MSC_VER) && !defined(__clang__) */
905910

911+
// clang-format on
912+
906913
/* Map an (observed) memop size value to the representative value of its range.
907914
* For example, 5 -> 5, 22 -> 17, 99 -> 65, 256 -> 256, 1001 -> 513. */
908915
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint64_t

llvm/include/llvm/ProfileData/InstrProfData.inc

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
#define INSTR_PROF_VISIBILITY
6363
#endif
6464

65+
// clang-format off:consider re-enabling clang-format if auto-formatted C macros
66+
// are readable (e.g., after `issue #82426` is fixed)
6567
/* INSTR_PROF_DATA start. */
6668
/* Definition of member fields of the per-function control structure. */
6769
#ifndef INSTR_PROF_DATA
@@ -494,12 +496,14 @@ getValueProfRecordHeaderSize(uint32_t NumValueSites);
494496
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
495497
#endif
496498

499+
// clang-format on
500+
497501
/*!
498502
* Return the \c ValueProfRecord header size including the
499503
* padding bytes.
500504
*/
501-
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
502-
uint32_t getValueProfRecordHeaderSize(uint32_t NumValueSites) {
505+
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint32_t
506+
getValueProfRecordHeaderSize(uint32_t NumValueSites) {
503507
uint32_t Size = offsetof(ValueProfRecord, SiteCountArray) +
504508
sizeof(uint8_t) * NumValueSites;
505509
/* Round the size to multiple of 8 bytes. */
@@ -511,27 +515,26 @@ uint32_t getValueProfRecordHeaderSize(uint32_t NumValueSites) {
511515
* Return the total size of the value profile record including the
512516
* header and the value data.
513517
*/
514-
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
515-
uint32_t getValueProfRecordSize(uint32_t NumValueSites,
516-
uint32_t NumValueData) {
518+
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint32_t
519+
getValueProfRecordSize(uint32_t NumValueSites, uint32_t NumValueData) {
517520
return getValueProfRecordHeaderSize(NumValueSites) +
518521
sizeof(InstrProfValueData) * NumValueData;
519522
}
520523

521524
/*!
522525
* Return the pointer to the start of value data array.
523526
*/
524-
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
525-
InstrProfValueData *getValueProfRecordValueData(ValueProfRecord *This) {
527+
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE InstrProfValueData *
528+
getValueProfRecordValueData(ValueProfRecord *This) {
526529
return (InstrProfValueData *)((char *)This + getValueProfRecordHeaderSize(
527530
This->NumValueSites));
528531
}
529532

530533
/*!
531534
* Return the total number of value data for \c This record.
532535
*/
533-
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
534-
uint32_t getValueProfRecordNumValueData(ValueProfRecord *This) {
536+
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint32_t
537+
getValueProfRecordNumValueData(ValueProfRecord *This) {
535538
uint32_t NumValueData = 0;
536539
uint32_t I;
537540
for (I = 0; I < This->NumValueSites; I++)
@@ -542,8 +545,8 @@ uint32_t getValueProfRecordNumValueData(ValueProfRecord *This) {
542545
/*!
543546
* Use this method to advance to the next \c This \c ValueProfRecord.
544547
*/
545-
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
546-
ValueProfRecord *getValueProfRecordNext(ValueProfRecord *This) {
548+
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE ValueProfRecord *
549+
getValueProfRecordNext(ValueProfRecord *This) {
547550
uint32_t NumValueData = getValueProfRecordNumValueData(This);
548551
return (ValueProfRecord *)((char *)This +
549552
getValueProfRecordSize(This->NumValueSites,
@@ -553,8 +556,8 @@ ValueProfRecord *getValueProfRecordNext(ValueProfRecord *This) {
553556
/*!
554557
* Return the first \c ValueProfRecord instance.
555558
*/
556-
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE
557-
ValueProfRecord *getFirstValueProfRecord(ValueProfData *This) {
559+
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE ValueProfRecord *
560+
getFirstValueProfRecord(ValueProfData *This) {
558561
return (ValueProfRecord *)((char *)This + sizeof(ValueProfData));
559562
}
560563

@@ -637,6 +640,8 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
637640

638641
/*============================================================================*/
639642

643+
// clang-format off:consider re-enabling clang-format if auto-formatted C macros
644+
// are readable (e.g., after `issue #82426` is fixed)
640645
#ifndef INSTR_PROF_DATA_DEFINED
641646

642647
#ifndef INSTR_PROF_DATA_INC
@@ -903,6 +908,8 @@ int InstProfPopcountll(unsigned long long X) { return __builtin_popcountll(X); }
903908

904909
#endif /* defined(_MSC_VER) && !defined(__clang__) */
905910

911+
// clang-format on
912+
906913
/* Map an (observed) memop size value to the representative value of its range.
907914
* For example, 5 -> 5, 22 -> 17, 99 -> 65, 256 -> 256, 1001 -> 513. */
908915
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint64_t

0 commit comments

Comments
 (0)