diff options
author | H.J. Lu <hongjiu.lu@intel.com> | 2018-07-19 10:47:23 +0000 |
---|---|---|
committer | H.J. Lu <hjl@gcc.gnu.org> | 2018-07-19 03:47:23 -0700 |
commit | 39a6a24334f95e047dcd7e0b27c2f27f6340bdc6 (patch) | |
tree | f141ecfb1fd3de14a2fdecf3ec8f06e0d7e8793b /gcc/testsuite | |
parent | e0c27d52dd783affbc95bdb53630b35ae044e620 (diff) | |
download | gcc-39a6a24334f95e047dcd7e0b27c2f27f6340bdc6.zip gcc-39a6a24334f95e047dcd7e0b27c2f27f6340bdc6.tar.gz gcc-39a6a24334f95e047dcd7e0b27c2f27f6340bdc6.tar.bz2 |
i386: Change indirect_return to function type attribute
In
struct ucontext;
typedef struct ucontext ucontext_t;
extern int (*bar) (ucontext_t *__restrict __oucp,
const ucontext_t *__restrict __ucp)
__attribute__((__indirect_return__));
extern int res;
void
foo (ucontext_t *oucp, ucontext_t *ucp)
{
res = bar (oucp, ucp);
}
bar() may return via indirect branch. This patch changes indirect_return
to type attribute to allow indirect_return attribute on variable or type
of function pointer so that ENDBR can be inserted after call to bar().
gcc/
PR target/86560
* config/i386/i386.c (rest_of_insert_endbranch): Lookup
indirect_return as function type attribute.
(ix86_attribute_table): Change indirect_return to function
type attribute.
* doc/extend.texi: Update indirect_return attribute.
gcc/testsuite/
PR target/86560
* gcc.target/i386/pr86560-1.c: New test.
* gcc.target/i386/pr86560-2.c: Likewise.
* gcc.target/i386/pr86560-3.c: Likewise.
From-SVN: r262877
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr86560-1.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr86560-2.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr86560-3.c | 17 |
4 files changed, 56 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f78a7c8..8c60524 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-07-19 H.J. Lu <hongjiu.lu@intel.com> + + PR target/86560 + * gcc.target/i386/pr86560-1.c: New test. + * gcc.target/i386/pr86560-2.c: Likewise. + * gcc.target/i386/pr86560-3.c: Likewise. + 2018-07-19 Kyrylo Tkachov <kyrylo.tkachov@arm.com> * gfortran.dg/max_fmax_aarch64.f90: New test. diff --git a/gcc/testsuite/gcc.target/i386/pr86560-1.c b/gcc/testsuite/gcc.target/i386/pr86560-1.c new file mode 100644 index 0000000..a2b70269 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr86560-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcf-protection" } */ +/* { dg-final { scan-assembler-times {\mendbr} 2 } } */ + +struct ucontext; + +extern int (*bar) (struct ucontext *) + __attribute__((__indirect_return__)); + +extern int res; + +void +foo (struct ucontext *oucp) +{ + res = bar (oucp); +} diff --git a/gcc/testsuite/gcc.target/i386/pr86560-2.c b/gcc/testsuite/gcc.target/i386/pr86560-2.c new file mode 100644 index 0000000..6f01b38 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr86560-2.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcf-protection" } */ +/* { dg-final { scan-assembler-times {\mendbr} 2 } } */ + +struct ucontext; + +typedef int (*bar_p) (struct ucontext *) + __attribute__((__indirect_return__)); + +extern int res; + +void +foo (bar_p bar, struct ucontext *oucp) +{ + res = bar (oucp); +} diff --git a/gcc/testsuite/gcc.target/i386/pr86560-3.c b/gcc/testsuite/gcc.target/i386/pr86560-3.c new file mode 100644 index 0000000..05328e2 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr86560-3.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcf-protection" } */ +/* { dg-final { scan-assembler-times {\mendbr} 2 } } */ + +struct ucontext; + +extern int (*bar) (struct ucontext *); + +extern int res; + +void +foo (struct ucontext *oucp) +{ + int (*f) (struct ucontext *) __attribute__((__indirect_return__)) + = bar; + res = f (oucp); +} |