[PATCH] D15541: [PGO] generate different version for FE instrumentation and IR level instrumentation profiles

Rong Xu via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 17 15:12:46 PST 2015


xur updated this revision to Diff 43190.
xur added a comment.

Integrated David's comments.


http://reviews.llvm.org/D15541

Files:
  lib/profile/InstrProfData.inc
  lib/profile/InstrProfiling.c

Index: lib/profile/InstrProfiling.c
===================================================================
--- lib/profile/InstrProfiling.c
+++ lib/profile/InstrProfiling.c
@@ -18,6 +18,9 @@
 
 char *(*GetEnvHook)(const char *) = 0;
 
+/* IR level instrumentation declares a strong symbol and sets the value to 1. */
+COMPILER_RT_WEAK int IR_LEVEL_PROF_VARNAME = 0;
+
 COMPILER_RT_VISIBILITY uint64_t __llvm_profile_get_magic(void) {
   return sizeof(void *) == sizeof(uint64_t) ? (INSTR_PROF_RAW_MAGIC_64)
                                             : (INSTR_PROF_RAW_MAGIC_32);
@@ -32,6 +35,8 @@
 }
 
 COMPILER_RT_VISIBILITY uint64_t __llvm_profile_get_version(void) {
+  if (IR_LEVEL_PROF_VARNAME)
+    return INSTR_PROF_RAW_VERSION | VARIANT_MASK_IR_PROF;
   return INSTR_PROF_RAW_VERSION;
 }
 
Index: lib/profile/InstrProfData.inc
===================================================================
--- lib/profile/InstrProfData.inc
+++ lib/profile/InstrProfData.inc
@@ -678,6 +678,18 @@
 /* Raw profile format version. */
 #define INSTR_PROF_RAW_VERSION 2
 
+/* Profile version is always of type uint_64_t. Reserve the upper 8 bits in the
+ * version for other variants of profile. We set the lowest bit of the upper 8
+ * bits (i.e. bit 56) to 1 to indicate if this is an IR-level instrumentaiton
+ * generated profile, and 0 if this is a Clang FE generated profile.
+ */
+#define VARIANT_MASKS_ALL 0xff00000000000000ULL
+#define VARIANT_MASK_IR_PROF (0x1ULL << 56)
+#define GET_VERSION(V) ((V)&~VARIANT_MASKS_ALL)
+#define IR_LEVEL_PROF_VARNAME __llvm_profile_ir_level
+#define IR_LEVEL_PROF_STRINGFY(s) #s
+#define IR_LEVEL_PROF_STRING(s) IR_LEVEL_PROF_STRINGFY(s)
+
 /* Runtime section names and name strings.  */
 #define INSTR_PROF_DATA_SECT_NAME __llvm_prf_data
 #define INSTR_PROF_NAME_SECT_NAME __llvm_prf_names


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15541.43190.patch
Type: text/x-patch
Size: 1825 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151217/49acee94/attachment.bin>


More information about the llvm-commits mailing list