[compiler-rt] r204556 - InstrProf: Indicate pointer size in raw profile

Duncan P. N. Exon Smith dexonsmith at apple.com
Sat Mar 22 20:38:05 PDT 2014


Author: dexonsmith
Date: Sat Mar 22 22:38:05 2014
New Revision: 204556

URL: http://llvm.org/viewvc/llvm-project?rev=204556&view=rev
Log:
InstrProf: Indicate pointer size in raw profile

Since the profile can come from 32-bit machines, the reader needs to
check the pointer size.  Change the magic number to facilitate this.

<rdar://problem/16400648>

Modified:
    compiler-rt/trunk/lib/profile/InstrProfiling.c

Modified: compiler-rt/trunk/lib/profile/InstrProfiling.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfiling.c?rev=204556&r1=204555&r2=204556&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfiling.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfiling.c Sat Mar 22 22:38:05 2014
@@ -14,11 +14,13 @@ uint64_t __llvm_profile_get_magic(void)
   /* Magic number to detect file format and endianness.
    *
    * Use 255 at one end, since no UTF-8 file can use that character.  Avoid 0,
-   * so that utilities like strings doesn't grab it as a string.  129 is high
-   * enough to be interesting.
+   * so that utilities, like strings, don't grab it as a string.  129 is also
+   * invalid UTF-8, and high enough to be interesting.
    *
-   * Use "lprofr" in the centre to stand for "LLVM Profile Raw".
+   * Use "lprofr" in the centre to stand for "LLVM Profile Raw", or "lprofR"
+   * for 32-bit platforms.
    */
+  unsigned char R = sizeof(void *) == sizeof(uint64_t) ? 'r' : 'R';
   return
     (uint64_t)255 << 56 |
     (uint64_t)'l' << 48 |
@@ -26,7 +28,7 @@ uint64_t __llvm_profile_get_magic(void)
     (uint64_t)'r' << 32 |
     (uint64_t)'o' << 24 |
     (uint64_t)'f' << 16 |
-    (uint64_t)'r' <<  8 |
+    (uint64_t) R  <<  8 |
     (uint64_t)129;
 }
 





More information about the llvm-commits mailing list