summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoramonakov <amonakov@138bc75d-0d04-0410-961f-82ee72b054a4>2015-05-11 16:10:24 +0000
committerH.J. Lu <hjl.tools@gmail.com>2015-08-18 04:49:33 -0700
commitb95473cfb6b843125a64415ea006d96c54bab51a (patch)
tree0d8f2b17999c507e2abc215b4f2a4c04fc44a104
parent045ed2eca0004a9e622ce426eb5c487507304441 (diff)
downloadgcc-b95473cfb6b843125a64415ea006d96c54bab51a.tar.gz
Fix PR target/65753
* gcc.target/i386/pr65753.c: Use -O2 instead of -O. PR target/65753 * config/i386/i386.c (ix86_function_ok_for_sibcall): Allow PIC sibcalls via function pointers. testsuite: * gcc.target/i386/pr65753.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223005 138bc75d-0d04-0410-961f-82ee72b054a4 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223055 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/config/i386/i386.c6
-rw-r--r--gcc/testsuite/gcc.target/i386/pr65753.c8
2 files changed, 11 insertions, 3 deletions
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 873de32f040..005e1e46e4d 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -5465,12 +5465,12 @@ ix86_function_ok_for_sibcall (tree decl, tree exp)
rtx a, b;
/* If we are generating position-independent code, we cannot sibcall
- optimize any indirect call, or a direct call to a global function,
- as the PLT requires %ebx be live. (Darwin does not have a PLT.) */
+ optimize direct calls to global functions, as the PLT requires
+ %ebx be live. (Darwin does not have a PLT.) */
if (!TARGET_MACHO
&& !TARGET_64BIT
&& flag_pic
- && (!decl || !targetm.binds_local_p (decl)))
+ && decl && !targetm.binds_local_p (decl))
return false;
/* If we need to align the outgoing stack, then sibcalling would
diff --git a/gcc/testsuite/gcc.target/i386/pr65753.c b/gcc/testsuite/gcc.target/i386/pr65753.c
new file mode 100644
index 00000000000..562f54bff6b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr65753.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-fPIC -O2" } */
+/* { dg-final { scan-assembler-not "call" } } */
+
+void foo(void (*bar)(void))
+{
+ bar();
+}