> > > > Hmm. I do wonder whether your earlier patch was more "correct" in the > > sense that a tail call does not return to the calling function but its > > caller. > > That means it should not have a fallthru edge, so our representation > > with feeding a return value to a function-local return stmt isn't a good > > one. > > > > That said, the CFG hook you are patching is supposed to add edges when > > a function call can possibly not reach the return stmt and I think that's > > the case for tail-calls. So IMO the patch is wrong. Iff instead the > > instrumentation confuses later tail-call verification then this > > instrumentation > > should be either not emitted or handled there. > > For the edge profling algorithm to be able to fill in missing counters > correctly, every valid execution must correspond to a path from entry > block to exit block. So we need an edge here, but we can mark it as Just to be correct, For the profiling code, executions starting in entry and circulating forever in a loop are also OK, that makes it bit different from DCE which expects every execution path to be finite.
What is not OK is execution starting in entry and stopping somewhere in the middle (by exitting or, for example, by hidden infinite loop inside an asm statement) since resulting profile is not a circulation. Still I think it would be good idea to factor out the logic and share it for dce and other similar algorithms. I will try to find time to look into that. (But we don't need hookize it, since we have nothing doing this that works both on RTL and gimple). Honza