Skip to content

Commit fe9765c

Browse files
committed
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.
1 parent 1b23812 commit fe9765c

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

gcc/config/i386/i386.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,15 @@ ix86_function_ok_for_sibcall (tree decl, tree exp)
10151015
}
10161016
}
10171017

1018+
if (decl && ix86_use_pseudo_pic_reg ())
1019+
{
1020+
/* When PIC register is used, it must be restored after ifunc
1021+
function returns. */
1022+
cgraph_node *node = cgraph_node::get (decl);
1023+
if (node && node->ifunc_resolver)
1024+
return false;
1025+
}
1026+
10181027
/* Otherwise okay. That also includes certain types of indirect calls. */
10191028
return true;
10201029
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* { dg-do compile } */
2+
/* { dg-require-ifunc "" } */
3+
/* { dg-options "-O2 -fpic" } */
4+
5+
__attribute__((target_clones("default","fma")))
6+
static inline double
7+
expfull_ref(double x)
8+
{
9+
return __builtin_pow(x, 0.1234);
10+
}
11+
12+
double
13+
exp_ref(double x)
14+
{
15+
return expfull_ref(x);
16+
}
17+
18+
/* { dg-final { scan-assembler "jmp\[ \t\]*expfull_ref@PLT" { target { ! ia32 } } } } */
19+
/* { dg-final { scan-assembler "call\[ \t\]*expfull_ref@PLT" { target ia32 } } } */

0 commit comments

Comments
 (0)