#include "diagnostic-core.h"
#include "profile.h"
#include "langhooks.h"
+#include "context.h"
+#include "pass_manager.h"
#include "cfgloop.h"
#include "tree-cfg.h"
#include "tree-cfgcleanup.h"
/* Read in the function/callsite profile, and store it in local
data structure. */
unsigned function_num = gcov_read_unsigned ();
+ int profile_pass_num
+ = g->get_passes ()->get_pass_auto_profile ()->static_pass_number;
+ g->get_dumps ()->dump_start (profile_pass_num, NULL);
for (unsigned i = 0; i < function_num; i++)
{
function_instance::function_instance_stack stack;
if (map_.count (fun_id) == 0)
map_[fun_id] = s;
else
- map_[fun_id]->merge (s);
+ {
+ /* Since this is invoked very early, before the pass
+ manager, we need to set up the dumping explicitly. This is
+ similar to the handling in finish_optimization_passes. */
+ if (dump_enabled_p ())
+ {
+ dump_user_location_t loc
+ = dump_user_location_t::from_location_t (input_location);
+ dump_printf_loc (MSG_NOTE, loc, "Merging profile for %s\n",
+ afdo_string_table->get_name (s->name ()));
+ }
+ map_[fun_id]->merge (s);
+ }
}
+ g->get_dumps ()->dump_finish (profile_pass_num);
return true;
}
}
opt_pass *get_pass_peephole2 () const { return m_pass_peephole2_1; }
opt_pass *get_pass_profile () const { return m_pass_profile_1; }
+ opt_pass *get_pass_auto_profile () const { return m_pass_ipa_auto_profile_1; }
void register_pass_name (opt_pass *pass, const char *name);
--- /dev/null
+/* { dg-options "-O3 -fno-early-inlining -fdump-ipa-afdo-all" } */
+__attribute__ ((used))
+int a[1000];
+
+__attribute__ ((noinline))
+void
+test2(int sz)
+{
+ a[sz]++;
+ asm volatile (""::"m"(a));
+}
+
+__attribute__ ((noinline))
+void
+test1 (int sz)
+{
+ for (int i = 0; i < 1000; i++)
+ if (i % 2)
+ test2 (sz);
+ else
+ test2 (i);
+
+}
+int main()
+{
+ for (int i = 0; i < 1000; i++)
+ test1 (1000);
+ return 0;
+}
+/* We will have profiles for test2 and test2.constprop.0 that will have to be
+ merged, */
+/* { dg-final-use-autofdo { scan-ipa-dump "note: Merging profile for test2" "afdo"} } */