diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2022-06-14 08:20:16 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2022-06-20 08:26:47 -0700 |
commit | fe9765c0b97e6b4ce2cd226631d329fc05ba2aa5 (patch) | |
tree | 0aa82431aa82b11596e02944610305db29075662 /gcc | |
parent | 1b238124840a323e70771d88a5b8fae48f26c69b (diff) | |
download | gcc-fe9765c0b97e6b4ce2cd226631d329fc05ba2aa5.zip gcc-fe9765c0b97e6b4ce2cd226631d329fc05ba2aa5.tar.gz gcc-fe9765c0b97e6b4ce2cd226631d329fc05ba2aa5.tar.bz2 |
i386: Disallow sibcall for calling ifunc functions with PIC register
Disallow siball when calling ifunc functions with PIC register so that
PIC register can be restored.
gcc/
PR target/105960
* config/i386/i386.cc (ix86_function_ok_for_sibcall): Return
false if PIC register is used when calling ifunc functions.
gcc/testsuite/
PR target/105960
* gcc.target/i386/pr105960.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/config/i386/i386.cc | 9 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr105960.c | 19 |
2 files changed, 28 insertions, 0 deletions
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index f158cc3..b15b489 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -1015,6 +1015,15 @@ ix86_function_ok_for_sibcall (tree decl, tree exp) } } + if (decl && ix86_use_pseudo_pic_reg ()) + { + /* When PIC register is used, it must be restored after ifunc + function returns. */ + cgraph_node *node = cgraph_node::get (decl); + if (node && node->ifunc_resolver) + return false; + } + /* Otherwise okay. That also includes certain types of indirect calls. */ return true; } diff --git a/gcc/testsuite/gcc.target/i386/pr105960.c b/gcc/testsuite/gcc.target/i386/pr105960.c new file mode 100644 index 0000000..db137a1 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr105960.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-ifunc "" } */ +/* { dg-options "-O2 -fpic" } */ + +__attribute__((target_clones("default","fma"))) +static inline double +expfull_ref(double x) +{ + return __builtin_pow(x, 0.1234); +} + +double +exp_ref(double x) +{ + return expfull_ref(x); +} + +/* { dg-final { scan-assembler "jmp\[ \t\]*expfull_ref@PLT" { target { ! ia32 } } } } */ +/* { dg-final { scan-assembler "call\[ \t\]*expfull_ref@PLT" { target ia32 } } } */ |