RFC: IR metadata format for MemProf

Actually, thinking through it with callsites reminds me of why I was handling direct recursion differently. Consider this case:

A() {
  if (...)
     A(); // callsite a1
  new(); // callsite a2
}

With the direct recursion flattening, contexts with a regex like a1->[a1->]*->a2 all become a1->a2. There is no cycle in the CCG graph. Assuming that all the profiled
recursive contexts that collapse to the same thing have the same memory coldness, we should be able to create the cloned code:

A.memprof.1() {
  if (...)
     A.memprof.1(); // callsite a1'
  new(COLD hint); // callsite a2'
}
1 Like