summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2022-06-14 08:20:16 -0700
committerH.J. Lu <hjl.tools@gmail.com>2022-06-21 10:44:22 -0700
commit2474c8e09a93027cde39ecb6a53742142c8496ed (patch)
tree7e8416f1d0ea5379c0f6bcb87baae0a4f829993d
parentDaily bump. (diff)
downloadgcc-2474c8e09a93027cde39ecb6a53742142c8496ed.tar.gz
gcc-2474c8e09a93027cde39ecb6a53742142c8496ed.tar.bz2
gcc-2474c8e09a93027cde39ecb6a53742142c8496ed.tar.xz
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 fe9765c0b97e6b4ce2cd226631d329fc05ba2aa5)
-rw-r--r--gcc/config/i386/i386.cc9
-rw-r--r--gcc/testsuite/gcc.target/i386/pr105960.c19
2 files changed, 28 insertions, 0 deletions
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 83995a8cc6b..9dd9fa68722 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)
1015 } 1015 }
1016 } 1016 }
1017 1017
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
1018 /* Otherwise okay. That also includes certain types of indirect calls. */ 1027 /* Otherwise okay. That also includes certain types of indirect calls. */
1019 return true; 1028 return true;
1020} 1029}
diff --git a/gcc/testsuite/gcc.target/i386/pr105960.c b/gcc/testsuite/gcc.target/i386/pr105960.c
new file mode 100644
index 00000000000..db137a1642d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr105960.c
@@ -0,0 +1,19 @@
1/* { dg-do compile } */
2/* { dg-require-ifunc "" } */
3/* { dg-options "-O2 -fpic" } */
4
5__attribute__((target_clones("default","fma")))
6static inline double
7expfull_ref(double x)
8{
9 return __builtin_pow(x, 0.1234);
10}
11
12double
13exp_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 } } } */