From f1ed9790a36ceff598fc2ad873a0bb7778c9fa6e Mon Sep 17 00:00:00 2001 From: Alexander Monakov Date: Mon, 11 May 2015 19:10:24 +0300 Subject: [PATCH] re PR target/65753 ([i386] Incorrect tail call inhibition logic on i386 (32-bit)) 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. From-SVN: r223005 --- gcc/ChangeLog | 6 ++++++ gcc/config/i386/i386.c | 6 +++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/i386/pr65753.c | 8 ++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr65753.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 38f929bd19d..7640c5b50aa 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-05-11 Alexander Monakov + + PR target/65753 + * config/i386/i386.c (ix86_function_ok_for_sibcall): Allow PIC sibcalls + via function pointers. + 2015-05-11 Alexander Monakov * calls.c (prepare_call_address): Transform PLT call to GOT lookup and diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 7bd9ff307b6..fb7977f4d65 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -5473,12 +5473,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/ChangeLog b/gcc/testsuite/ChangeLog index 3b327b75b7f..e5fda8b9f3d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-05-11 Alexander Monakov + + PR target/65753 + * gcc.target/i386/pr65753.c: New test. + 2015-05-11 Richard Sandiford PR rtl-optimization/66076 diff --git a/gcc/testsuite/gcc.target/i386/pr65753.c b/gcc/testsuite/gcc.target/i386/pr65753.c new file mode 100644 index 00000000000..70061e2effb --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr65753.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-fPIC -O" } */ +/* { dg-final { scan-assembler-not "call" } } */ + +void foo(void (*bar)(void)) +{ + bar(); +}