[PATCH] Set function entry count.

Diego Novillo dnovillo at google.com
Tue May 26 13:20:23 PDT 2015


On Tue, May 26, 2015 at 1:43 PM, Justin Bogner <mail at justinbogner.com> wrote:

> In any case, PR23499 is a bug with or without the setEntryCount, so can
> we split this into a patch that fixes that and another that sets the
> count? Presumably we can test for PR23499 independently (though probably
> only in the compiler-rt tests, since it depends on linker behaviour).

Sure. A simple change to the existing test is enough.  If I make the
template function bar() do something other than trivially return, the
compiler emits profile annotations for the branch that trigger the
bug.  Would this be fine, or do you prefer a separate test?

diff --git a/test/profile/Inputs/instrprof-dynamic-header.h
b/test/profile/Inputs/instrprof-dynamic-header.h
index 1dc2e37..4d4a513 100644
--- a/test/profile/Inputs/instrprof-dynamic-header.h
+++ b/test/profile/Inputs/instrprof-dynamic-header.h
@@ -1,5 +1,8 @@
+extern int X;
 template <class T> void bar() {
-  if (true) {}
+  if (X) {
+    X *= 4;
+  }
 }
 void a();
 void b();
diff --git a/test/profile/Inputs/instrprof-dynamic-main.cpp
b/test/profile/Inputs/instrprof-dynamic-main.cpp
index 0dd6021..5ba46ad 100644
--- a/test/profile/Inputs/instrprof-dynamic-main.cpp
+++ b/test/profile/Inputs/instrprof-dynamic-main.cpp
@@ -1,7 +1,9 @@
 #include "instrprof-dynamic-header.h"
+int X = 0;
 void foo(int K) { if (K) {} }
 int main(int argc, char *argv[]) {
   foo(5);
+  X++;
   bar<void>();
   a();
   b();



More information about the cfe-commits mailing list