https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65400
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Both patches look wrong to me. For the first change, it is wrong to add TSAN_FUNC_EXIT (), you should never add it out of nothing. First of all, you might consider allowing TSAN_FUNC_EXIT () in find_return_bb - there is no reason why any harm would be done if it is considered a part of a return bb. On your first testcase that is not the case though, so instead you need to either duplicate or move it. I'd say best would be to bail out early with fnsplitting if TSAN_FUNC_EXIT is present in a bb that is not return_bb itself or one of its predecessors; or when it is present in one of the predecessors of return_bb and not in all the other predecessors. The case when TSAN_FUNC_EXIT is in the return_bb (after you change find_return_bb) should work fine without any extra work, and for the case when it is in the predecessors of return_bb, add it. The second change doesn't make any sense at all, but from the testcase it isn't obvious what you are trying to do at all. If the problem is that fnsplit has set tail call flag and you've added the TSAN_FUNC_EXIT after it, then that should be where you clear the flag; if it is something different, please explain what you are trying to do and why.