[Bug target/83292] __builtin_apply(), __builtin_return() trigger x87 stack exception on 32-bit x86

ubizjak at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Dec 6 07:31:00 GMT 2017


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

--- Comment #4 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Andrew Church from comment #3)
> I use __builtin_return(__builtin_apply(...)) in library function wrappers
> for failure injection in tests, so that I don't need to explicitly write out
> all the arguments multiple times for each wrapped function.  As such, I
> don't need the full functionality of __builtin_apply() in being able to save
> and later return an arbitrary value, but it would be useful to have an
> equivalent to the combination __builtin_return(__builtin_apply(...)) --
> perhaps something which restored the register/stack state to that at
> function entry and jumped to the target function (e.g., jmp *%eax/rax on
> x86).

You can use __attribute__((__target__("no-mmx"))):

(from gcc.target/i386/builtin-apply-mmx.c):

--cut here--
double
foo (double arg)
{
  if (arg != 116.0)
    abort ();

  return arg + 1.0;
}

inline double
__attribute__((__target__("no-mmx")))
bar (double arg)
{
  foo (arg);
  __builtin_return (__builtin_apply ((void (*)()) foo,
                                     __builtin_apply_args (), 16));
}

static void
mmx_test (void)
{
  if (bar (116.0) != 117.0)
    abort ();
}
--cut here--


More information about the Gcc-bugs mailing list