[compiler-rt] r207784 - profile: Fix the build with gcc 4.9

Reid Kleckner reid at kleckner.net
Thu May 1 11:52:15 PDT 2014


Author: rnk
Date: Thu May  1 13:52:14 2014
New Revision: 207784

URL: http://llvm.org/viewvc/llvm-project?rev=207784&view=rev
Log:
profile: Fix the build with gcc 4.9

GCC -pedantic warns that the initialization of Header is not constant:
InstrProfilingFile.c:31:5: error: initializer element is not computable at load time [-Werror]

LLVM defaults to enabling -pedantic.  If this warning is unhelpful, we
can consider revisiting that decision.

Modified:
    compiler-rt/trunk/lib/profile/InstrProfilingBuffer.c
    compiler-rt/trunk/lib/profile/InstrProfilingFile.c

Modified: compiler-rt/trunk/lib/profile/InstrProfilingBuffer.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingBuffer.c?rev=207784&r1=207783&r2=207784&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingBuffer.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingBuffer.c Thu May  1 13:52:14 2014
@@ -35,15 +35,14 @@ int __llvm_profile_write_buffer(char *Bu
   const uint64_t NamesSize = NamesEnd - NamesBegin;
 
   /* Create the header. */
-  uint64_t Header[PROFILE_HEADER_SIZE] = {
-    __llvm_profile_get_magic(),
-    __llvm_profile_get_version(),
-    DataSize,
-    CountersSize,
-    NamesSize,
-    (uintptr_t)CountersBegin,
-    (uintptr_t)NamesBegin
-  };
+  uint64_t Header[PROFILE_HEADER_SIZE];
+  Header[0] = __llvm_profile_get_magic();
+  Header[1] = __llvm_profile_get_version();
+  Header[2] = DataSize;
+  Header[3] = CountersSize;
+  Header[4] = NamesSize;
+  Header[5] = (uintptr_t)CountersBegin;
+  Header[6] = (uintptr_t)NamesBegin;
 
   /* Write the data. */
 #define UPDATE_memcpy(Data, Size) \

Modified: compiler-rt/trunk/lib/profile/InstrProfilingFile.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingFile.c?rev=207784&r1=207783&r2=207784&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingFile.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingFile.c Thu May  1 13:52:14 2014
@@ -27,15 +27,14 @@ static int writeFile(FILE *File) {
   const uint64_t NamesSize = NamesEnd - NamesBegin;
 
   /* Create the header. */
-  uint64_t Header[PROFILE_HEADER_SIZE] = {
-    __llvm_profile_get_magic(),
-    __llvm_profile_get_version(),
-    DataSize,
-    CountersSize,
-    NamesSize,
-    (uintptr_t)CountersBegin,
-    (uintptr_t)NamesBegin
-  };
+  uint64_t Header[PROFILE_HEADER_SIZE];
+  Header[0] = __llvm_profile_get_magic();
+  Header[1] = __llvm_profile_get_version();
+  Header[2] = DataSize;
+  Header[3] = CountersSize;
+  Header[4] = NamesSize;
+  Header[5] = (uintptr_t)CountersBegin;
+  Header[6] = (uintptr_t)NamesBegin;
 
   /* Write the data. */
 #define CHECK_fwrite(Data, Size, Length, File) \





More information about the llvm-commits mailing list