Functions with multiple entry points

Martin v. Loewis
Sun Feb 20 02:47:00 GMT 2000

When implementing C++, it would be helpful to have functions with more
than one entry point in a number of cases. The thunks mechanism is a
limited form, where the thunk can manipulate parameters. In some
cases, more complex operations are required.

For example, the new C++ ABI specifies that there are two destructors
for each class: one that deletes the memory, and the other that
doesn't. One approach would be to generate the destructor twice, but a
better solution would be to have only two different entry points:

void dtor_with_delete(){
  int do_delete = 1;
  goto common_code;

void dtor_without_delete(){
  int do_delete = 0;
  if (do_delete)

So each entry point would need to initialize an automatic variable in
the dtor, and then branch to the common code. The multiple entries
could be emitted close to each other, so that the unused entries could
be skipped with predication if supported by the processor.

Other applications of this feature would be the traditional
this-pointer adjusting thunks, adjusting covariant returns, control of
vbase construction (__in_charge), and perhaps others.

I think it would be helpful if the middle-end provided support for
such a general mechanism, thus enabling target-specific optimizations.

My question is: Was such a feature ever considered (and perhaps
rejected) for gcc? Are there plans to implement that feature?


More information about the Gcc mailing list