On Fri, 2020-01-10 at 08:53 -0700, Jeff Law wrote: > On Wed, 2020-01-08 at 04:02 -0500, David Malcolm wrote: > > Jeff reviewed an earlier version of this here: > > https://gcc.gnu.org/ml/gcc-patches/2019-12/msg00503.html > > My response: > > https://gcc.gnu.org/ml/gcc-patches/2019-12/msg00809.html > > I have followup patches that implement the function_set idea. > > > > TODO: > > I haven't yet addressed the is_setjmp_call_p/is_longjmp_call_p > > concerns > > > > Changed in v5: > > - update ChangeLog path > > - updated copyright years to include 2020 > > > > Changed in v4: > > - Remove include of gcc-plugin.h, reworking includes accordingly. > > - Wrap everything in #if ENABLE_ANALYZER > > - Remove /// comment lines > > - Update is_named_call_p to support function pointers: > > https://gcc.gnu.org/ml/gcc-patches/2019-12/msg00178.html > > > > gcc/analyzer/ChangeLog: > > * analyzer.cc: New file. > > * analyzer.h: New file. > So there's a lot more ways to write setjmp. Some don't even look > like > setjmp. sigsetjmp, savectx, vfork, getcontext all have setjmp like > qualities (returning twice). They may have an underscore prefix > IIRC. > > So if what you're really looking for is functions that may return > twice, I think that's the canonical list :-)
Thanks - but I don't think "returns twice" is exactly what's needed here. I think the needs of code generation/optimization are slightly different from that of the analyzer here. I'm special-casing setjmp/longjmp, which have very particular behavior. Beyond the "returns twice" property the analyzer has special-case knowledge of things like: "the return value from the 2nd return from setjmp is that passed to longjmp, unless 0 was passed, in which case return 1" That holds for sigsetjmp/siglongjmp, but not for the other functions, which have their own behaviors (e.g. getcontext/setcontext can fail and set errno). So from the analyzer's point-of-view, those various other functions are *not* setjmp/longjmp; they are different returns-twice functions. I picked setjmp/longjmp as being high-priority to model correctly. Some of the others in the list you give are rather obscure e.g. savectx appears to be Solaris-specific and I have no great desire to track down Solaris documentation and figure out what its behaviors are meant to be. So I think this code could be generalized to sigsetjmp/siglongjmp fairly easily using the setjmp/longjmp logic. For the other returns- twice functions, the analyzer's not handling the 2nd return will mean it will silently fail to explore execution paths involving the 2nd return, which seems acceptable to me (otherwise there could be state assumptions we fail to inject, leading to false warnings on paths that are actually-infeasible). Dave