[profile] Move assertIsZero to InstrProfilingUtil.c

... and rename it to 'warnIfNonZero' to better-reflect what it actually
does.

The goal is to minimize the amount of logic that's conditionally
compiled under '#if __APPLE__'.
This commit is contained in:
Vedant Kumar 2021-08-02 14:44:51 -07:00
parent 52c87e0437
commit 3b0a9e7b39
3 changed files with 9 additions and 6 deletions

View File

@ -428,11 +428,6 @@ static void truncateCurrentFile(void) {
// TODO: Move these functions into InstrProfilingPlatform* files.
#if defined(__APPLE__)
static void assertIsZero(int *i) {
if (*i)
PROF_WARN("Expected flag to be 0, but got: %d\n", *i);
}
/* Write a partial profile to \p Filename, which is required to be backed by
* the open file object \p File. */
static int writeProfileWithFileObject(const char *Filename, FILE *File) {
@ -495,7 +490,7 @@ static void initializeProfileForContinuousMode(void) {
/* Whether an exclusive lock on the profile must be dropped after init.
* Use a cleanup to warn if the unlock does not occur. */
COMPILER_RT_CLEANUP(assertIsZero) int ProfileRequiresUnlock = 0;
COMPILER_RT_CLEANUP(warnIfNonZero) int ProfileRequiresUnlock = 0;
if (!doMerging()) {
/* We are not merging profiles, so open the raw profile in append mode. */

View File

@ -353,3 +353,8 @@ COMPILER_RT_VISIBILITY int lprofReleaseMemoryPagesToOS(uintptr_t Begin,
}
return 0;
}
COMPILER_RT_VISIBILITY void warnIfNonZero(int *i) {
if (*i)
PROF_WARN("Expected flag to be 0, but got: %d\n", *i);
}

View File

@ -84,4 +84,7 @@ static inline size_t lprofRoundDownTo(size_t x, size_t boundary) {
int lprofReleaseMemoryPagesToOS(uintptr_t Begin, uintptr_t End);
/// Noisly warn if *i is non-zero. Intended for use with COMPILER_RT_CLEANUP.
void warnIfNonZero(int *i);
#endif /* PROFILE_INSTRPROFILINGUTIL_H */