https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108656
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #7) > (In reply to Richard Biener from comment #6) > > (In reply to Jakub Jelinek from comment #5) > > > Created attachment 54412 [details] > > > gcc13-pr108656.patch > > > > > > So shall we fix it like this then? > > > > But isn't this the wrong "side"? returns_twice means it is the abnormal > > control _receiver_, it doesn't perform an abnormal goto itself. > > > > stmt_starts_bb_p is correct here, so where does it go wrong? > > I think it needs both. The thing is, when it returns the second time, it > does that again by returning from itself, not through returning from some > unrelated function. > Say, if we have pure + returns_twice call and no other call in a function, > the abnormal edge to the pure + returns_twice call would be optimized away, > even when the call remains, because there would be no edge from some call to > the .ABNORMAL_DISPATCHER block. > __attribute__((pure, returns_twice)) int foo (void); > > int > bar (void) > { > for (int i = 0; i < 64; ++i) > { > int x = foo (); > if (x == 26) > return -42; > } > return 42; > } > doesn't even have because of this any abnormal edges created. > Or, if there is some other non-pure call somewhere else, we model through > the abnormal > edges that that other call can pass control back to the start of the > returns_twice call to make it return again. Ah, but then the issue is that we assume that 'foo' doesn't longjmp, independent on whether it is returns_twice or not? Can a setjmp () function perform a longjmp () to its own context? Would it even appear as returning twice then? Would calling setjmp in a loop like above and then jumping to another iteration via longjmp even be valid? That said, for your example I would think not having any abnormal edges is correct - there's no frame that could transfer control back to the returns_twice receiver, no?