mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-18 08:23:50 +08:00
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.
(cherry picked from commit fe9765c0b9
)
This commit is contained in:
parent
00b26ae2d1
commit
2474c8e09a
@ -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;
|
||||
}
|
||||
|
19
gcc/testsuite/gcc.target/i386/pr105960.c
Normal file
19
gcc/testsuite/gcc.target/i386/pr105960.c
Normal file
@ -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 } } } */
|
Loading…
Reference in New Issue
Block a user