<div dir="ltr">You should remove O3 in clang_pgogen command or add O3 in clang_profuse step. IR PGO requires matching pipelines.<div><br></div><div>David</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 29, 2017 at 10:31 AM, Vedant Kumar via Phabricator <span dir="ltr"><<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">vsk updated this revision to Diff 104678.<br>
vsk added a comment.<br>
<br>
Address David's review comment. I could not use the exact same test structure for IR PGO due to what seems like a spurious hash mismatch (see the FIXME).<br>
<span class=""><br>
<br>
<a href="https://reviews.llvm.org/D34797" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D34797</a><br>
<br>
Files:<br>
  lib/profile/CMakeLists.txt<br>
  lib/profile/InstrProfiling.c<br>
  lib/profile/<wbr>InstrProfilingNameVar.c<br>
  test/profile/instrprof-<wbr>override-filename.c<br>
<br>
<br>
Index: test/profile/instrprof-<wbr>override-filename.c<br>
==============================<wbr>==============================<wbr>=======<br>
--- test/profile/instrprof-<wbr>override-filename.c<br>
+++ test/profile/instrprof-<wbr>override-filename.c<br>
</span>@@ -1,14 +1,24 @@<br>
<span class="">-// RUN: %clang_profgen=%t.profraw -o %t -O3 %s<br>
-// RUN: %run %t %t.profraw<br>
-// RUN: llvm-profdata merge -o %t.profdata %t.profraw<br>
</span>-// RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s<br>
<span class="">+// RUN: rm -rf %t.dir && mkdir -p %t.dir<br>
+// RUN: cd %t.dir<br>
+//<br>
+// RUN: %clang_profgen=P_RAW -o %t -O3 %s<br>
+// RUN: %run %t P_RAW<br>
+// RUN: llvm-profdata merge -o %t.profdata P_RAW<br>
</span>+// RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s --check-prefix=FE<br>
+//<br>
+// RUN: %clang_pgogen=I_RAW -o %t.2 -O3 %s<br>
+// RUN: %run %t.2 I_RAW<br>
+// RUN: llvm-profdata merge -o %t2.profdata I_RAW<br>
+//<br>
+// FIXME: IRPGO states that there is a hash mismatch in main, and does not produce<br>
+// branch weight metadata: %clang_profuse=%t2.profdata -o - -S -emit-llvm %s<br>
<br>
 void bar() {}<br>
 int main(int argc, const char *argv[]) {<br>
-  // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD1:[0-9]+]]<br>
+  // FE: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD1:[0-9]+]]<br>
   if (argc < 2)<br>
     return 1;<br>
   bar();<br>
   return 0;<br>
 }<br>
-// CHECK: ![[PD1]] = !{!"branch_weights", i32 1, i32 2}<br>
+// FE: ![[PD1]] = !{!"branch_weights", i32 1, i32 2}<br>
<div class="HOEnZb"><div class="h5">Index: lib/profile/<wbr>InstrProfilingNameVar.c<br>
==============================<wbr>==============================<wbr>=======<br>
--- /dev/null<br>
+++ lib/profile/<wbr>InstrProfilingNameVar.c<br>
@@ -0,0 +1,18 @@<br>
+//===- InstrProfilingNameVar.c - profile name variable setup --------------===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+#include "InstrProfiling.h"<br>
+<br>
+/* char __llvm_profile_filename[1]<br>
+ *<br>
+ * The runtime should only provide its own definition of this symbol when the<br>
+ * user has not specified one. Set this up by moving the runtime's copy of this<br>
+ * symbol to an object file within the archive.<br>
+ */<br>
+COMPILER_RT_WEAK char INSTR_PROF_PROFILE_NAME_VAR[1] = {0};<br>
Index: lib/profile/InstrProfiling.c<br>
==============================<wbr>==============================<wbr>=======<br>
--- lib/profile/InstrProfiling.c<br>
+++ lib/profile/InstrProfiling.c<br>
@@ -19,8 +19,6 @@<br>
<br>
 COMPILER_RT_WEAK uint64_t INSTR_PROF_RAW_VERSION_VAR = INSTR_PROF_RAW_VERSION;<br>
<br>
-COMPILER_RT_WEAK char INSTR_PROF_PROFILE_NAME_VAR[1] = {0};<br>
-<br>
 COMPILER_RT_VISIBILITY uint64_t __llvm_profile_get_magic(void) {<br>
   return sizeof(void *) == sizeof(uint64_t) ? (INSTR_PROF_RAW_MAGIC_64)<br>
                                             : (INSTR_PROF_RAW_MAGIC_32);<br>
Index: lib/profile/CMakeLists.txt<br>
==============================<wbr>==============================<wbr>=======<br>
--- lib/profile/CMakeLists.txt<br>
+++ lib/profile/CMakeLists.txt<br>
@@ -48,6 +48,7 @@<br>
   InstrProfilingFile.c<br>
   InstrProfilingMerge.c<br>
   InstrProfilingMergeFile.c<br>
+  InstrProfilingNameVar.c<br>
   InstrProfilingWriter.c<br>
   InstrProfilingPlatformDarwin.c<br>
   InstrProfilingPlatformLinux.c<br>
<br>
<br>
</div></div></blockquote></div><br></div>