[compiler-rt] 51c8cac - [InstrProf] Ignore -Wcast-qual after D153911 to fix build failure (NFC)
Jie Fu via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 19 03:00:14 PDT 2023
Author: Jie Fu
Date: 2023-07-19T18:00:05+08:00
New Revision: 51c8cacafd47b59e66816b10be357a9877187bc3
URL: https://github.com/llvm/llvm-project/commit/51c8cacafd47b59e66816b10be357a9877187bc3
DIFF: https://github.com/llvm/llvm-project/commit/51c8cacafd47b59e66816b10be357a9877187bc3.diff
LOG: [InstrProf] Ignore -Wcast-qual after D153911 to fix build failure (NFC)
/data/llvm-project/compiler-rt/lib/profile/InstrProfilingMerge.c:46:60: error: cast from 'const char *' to 'struct __llvm_profile_header *' drops const qualifier [-Werror,-Wcast-qual]
__llvm_profile_header *Header = (__llvm_profile_header *)ProfileData;
^
/data/llvm-project/compiler-rt/lib/profile/InstrProfilingMerge.c:49:30: error: cast from 'const char *' to 'struct __llvm_profile_data *' drops const qualifier [-Werror,-Wcast-qual]
(__llvm_profile_data *)(ProfileData + sizeof(__llvm_profile_header) +
^
/data/llvm-project/compiler-rt/lib/profile/InstrProfilingMerge.c:77:41: error: cast from 'const struct __llvm_profile_data *' to 'struct __llvm_profile_data *' drops const qualifier [-Werror,-Wcast-qual]
DstData = (__llvm_profile_data *)__llvm_profile_begin_data();
^
/data/llvm-project/compiler-rt/lib/profile/InstrProfilingMerge.c:109:60: error: cast from 'const char *' to 'struct __llvm_profile_header *' drops const qualifier [-Werror,-Wcast-qual]
__llvm_profile_header *Header = (__llvm_profile_header *)ProfileData;
^
/data/llvm-project/compiler-rt/lib/profile/InstrProfilingMerge.c:116:30: error: cast from 'const char *' to 'struct __llvm_profile_data *' drops const qualifier [-Werror,-Wcast-qual]
(__llvm_profile_data *)(ProfileData + sizeof(__llvm_profile_header) +
^
/data/llvm-project/compiler-rt/lib/profile/InstrProfilingMerge.c:129:40: error: cast from 'const struct __llvm_profile_data *' to 'struct __llvm_profile_data *' drops const qualifier [-Werror,-Wcast-qual]
DstData = (__llvm_profile_data *)__llvm_profile_begin_data(),
^
/data/llvm-project/compiler-rt/lib/profile/InstrProfilingMerge.c:179:34: error: cast from 'const char *' to 'struct ValueProfData *' drops const qualifier [-Werror,-Wcast-qual]
VPMergeHook((ValueProfData *)SrcValueProfData, DstData);
^
/data/llvm-project/compiler-rt/lib/profile/InstrProfilingMerge.c:181:46: error: cast from 'const char *' to 'struct ValueProfData *' drops const qualifier [-Werror,-Wcast-qual]
SrcValueProfData + ((ValueProfData *)SrcValueProfData)->TotalSize;
^
...
Added:
Modified:
compiler-rt/lib/profile/InstrProfilingFile.c
compiler-rt/lib/profile/InstrProfilingMerge.c
compiler-rt/lib/profile/InstrProfilingValue.c
Removed:
################################################################################
diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c b/compiler-rt/lib/profile/InstrProfilingFile.c
index 5666607ff457b0..54e3030d589921 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -649,7 +649,14 @@ static void initializeProfileForContinuousMode(void) {
static const char *DefaultProfileName = "default.profraw";
static void resetFilenameToDefault(void) {
if (lprofCurFilename.FilenamePat && lprofCurFilename.OwnsFilenamePat) {
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-qual"
+#endif
free((void *)lprofCurFilename.FilenamePat);
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
}
memset(&lprofCurFilename, 0, sizeof(lprofCurFilename));
lprofCurFilename.FilenamePat = DefaultProfileName;
@@ -691,6 +698,10 @@ static int parseFilenamePattern(const char *FilenamePat,
int MergingEnabled = 0;
int FilenamePatLen = strlen(FilenamePat);
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-qual"
+#endif
/* Clean up cached prefix and filename. */
if (lprofCurFilename.ProfilePathPrefix)
free((void *)lprofCurFilename.ProfilePathPrefix);
@@ -698,6 +709,9 @@ static int parseFilenamePattern(const char *FilenamePat,
if (lprofCurFilename.FilenamePat && lprofCurFilename.OwnsFilenamePat) {
free((void *)lprofCurFilename.FilenamePat);
}
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
memset(&lprofCurFilename, 0, sizeof(lprofCurFilename));
diff --git a/compiler-rt/lib/profile/InstrProfilingMerge.c b/compiler-rt/lib/profile/InstrProfilingMerge.c
index 4da88b7d7bdb53..432e824955f8a7 100644
--- a/compiler-rt/lib/profile/InstrProfilingMerge.c
+++ b/compiler-rt/lib/profile/InstrProfilingMerge.c
@@ -38,6 +38,11 @@ uint64_t lprofGetLoadModuleSignature(void) {
__llvm_profile_get_magic();
}
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-qual"
+#endif
+
/* Returns 1 if profile is not structurally compatible. */
COMPILER_RT_VISIBILITY
int __llvm_profile_check_compatibility(const char *ProfileData,
@@ -183,3 +188,7 @@ int __llvm_profile_merge_from_buffer(const char *ProfileData,
return 0;
}
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/compiler-rt/lib/profile/InstrProfilingValue.c b/compiler-rt/lib/profile/InstrProfilingValue.c
index c819a38553f368..3d7c245f795fe5 100644
--- a/compiler-rt/lib/profile/InstrProfilingValue.c
+++ b/compiler-rt/lib/profile/InstrProfilingValue.c
@@ -59,7 +59,14 @@ COMPILER_RT_VISIBILITY void lprofSetMaxValsPerSite(uint32_t MaxVals) {
COMPILER_RT_VISIBILITY void
__llvm_profile_set_num_value_sites(__llvm_profile_data *Data,
uint32_t ValueKind, uint16_t NumValueSites) {
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-qual"
+#endif
*((uint16_t *)&Data->NumValueSites[ValueKind]) = NumValueSites;
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
}
/* This method is only used in value profiler mock testing. */
More information about the llvm-commits
mailing list