https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88917

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fw at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, perhaps easiest is to revert the PR87414 changes and just error out on
-fasynchronous-unwind-tables with -mindirect-branch=thunk-inline.

The following testcase shows various cases:
void foo (char *);

int
f1 (int (*f) (void))
{
  return f ();
}

int
f2 (int (*f) (void))
{
  foo (0);
  return f ();
}

int
f3 (int (*f) (void))
{
  foo (0);
  return f () + 1;
}

int
f4 (int (*f) (void), int x)
{
  char buf[x];
  foo (buf);
  return f () + 1;
}

__attribute__((optimize ("no-omit-frame-pointer"))) int
f5 (int (*f) (void))
{
  foo (0);
  return f ();
}

The unwind info is incorrect in f3 (the CFA is already %rsp+16 before the call,
so for the mov + ret instruction we need %rsp+24 and then revert), f4 (CFA is
%rbp, so we shouldn't change CFA offset at all).
So, we'd need to figure out if CFA is sp or bp at the instruction (is it call
always?) for which we emit the thunk and only if it is sp, increase offset by
word size and decrease afterwards.
Furthermore, for -fno-dwarf2-cfi-asm, we likely need to search the CFI
instruction array and find where exactly to insert the new CFI, rather than
appending it.  What a mess!

Reply via email to