* [PATCH] Fix stack pointer handling in ms_hook_prologue functions for i386 target.
@ 2020-02-10 16:22 Paul Gofman
2020-02-21 9:11 ` Paul Gofman
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Paul Gofman @ 2020-02-10 16:22 UTC (permalink / raw)
To: gcc-patches; +Cc: Paul Gofman
ChangeLog:
PR target/91489
* config/i386/i386.md (simple_return): Also check
for ms_hook_prologue function attribute.
* config/i386/i386.c (ix86_can_use_return_insn_p):
Also check for ms_hook_prologue function attribute.
testsuite/ChangeLog:
PR target/91489
* gcc.target/i386/ms_hook_prologue.c: Expand testcase
to reproduce PR target/91489 issue.
Signed-off-by: Paul Gofman <gofmanp@gmail.com>
---
gcc/config/i386/i386-protos.h | 1 +
gcc/config/i386/i386.c | 3 +++
gcc/config/i386/i386.md | 5 ++++-
gcc/testsuite/gcc.target/i386/ms_hook_prologue.c | 13 ++++++++++++-
4 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
index 266381ca5a6..966ce426a18 100644
--- a/gcc/config/i386/i386-protos.h
+++ b/gcc/config/i386/i386-protos.h
@@ -26,6 +26,7 @@ extern bool ix86_handle_option (struct gcc_options *opts,
/* Functions in i386.c */
extern bool ix86_target_stack_probe (void);
extern bool ix86_can_use_return_insn_p (void);
+extern bool ix86_function_ms_hook_prologue (const_tree fn);
extern void ix86_setup_frame_addresses (void);
extern bool ix86_rip_relative_addr_p (struct ix86_address *parts);
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 44bc0e0176a..68e2a7519f4 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -4954,6 +4954,9 @@ symbolic_reference_mentioned_p (rtx op)
bool
ix86_can_use_return_insn_p (void)
{
+ if (ix86_function_ms_hook_prologue (current_function_decl))
+ return false;
+
if (ix86_function_naked (current_function_decl))
return false;
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index f14683cd14f..a7302b886c6 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -13445,10 +13445,13 @@
;; static chain pointer - the first instruction has to be pushl %esi
;; and it can't be moved around, as we use alternate entry points
;; in that case.
+;; Also disallow for ms_hook_prologue functions which have frame
+;; pointer set up in function label which is correctly handled in
+;; ix86_expand_{prologue|epligoue}() only.
(define_expand "simple_return"
[(simple_return)]
- "!TARGET_SEH && !ix86_static_chain_on_stack"
+ "!TARGET_SEH && !ix86_static_chain_on_stack && !ix86_function_ms_hook_prologue (cfun->decl)"
{
if (crtl->args.pops_args)
{
diff --git a/gcc/testsuite/gcc.target/i386/ms_hook_prologue.c b/gcc/testsuite/gcc.target/i386/ms_hook_prologue.c
index e11bcc049cb..12e54c0e4ad 100644
--- a/gcc/testsuite/gcc.target/i386/ms_hook_prologue.c
+++ b/gcc/testsuite/gcc.target/i386/ms_hook_prologue.c
@@ -4,6 +4,8 @@
/* { dg-require-effective-target ms_hook_prologue } */
/* { dg-options "-O2 -fomit-frame-pointer" } */
+#include <stdio.h>
+
int __attribute__ ((__ms_hook_prologue__)) foo ()
{
unsigned char *ptr = (unsigned char *) foo;
@@ -32,7 +34,16 @@ int __attribute__ ((__ms_hook_prologue__)) foo ()
return 0;
}
+unsigned int __attribute__ ((noinline, __ms_hook_prologue__)) test_func()
+{
+ static int value;
+
+ if (value++) puts("");
+
+ return 0;
+}
+
int main ()
{
- return foo();
+ return foo() || test_func();
}
--
2.24.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix stack pointer handling in ms_hook_prologue functions for i386 target.
2020-02-10 16:22 [PATCH] Fix stack pointer handling in ms_hook_prologue functions for i386 target Paul Gofman
@ 2020-02-21 9:11 ` Paul Gofman
2020-03-25 14:17 ` Paul Gofman
2020-03-25 22:49 ` Jeff Law
2020-11-06 22:40 ` Jeff Law
2 siblings, 1 reply; 6+ messages in thread
From: Paul Gofman @ 2020-02-21 9:11 UTC (permalink / raw)
To: gcc-patches
Hello,
   ping for patch https://gcc.gnu.org/ml/gcc-patches/2020-02/msg00554.html.
Thanks,
   Paul.
On 2/10/20 19:22, Paul Gofman wrote:
> ChangeLog:
> PR target/91489
> * config/i386/i386.md (simple_return): Also check
> for ms_hook_prologue function attribute.
> * config/i386/i386.c (ix86_can_use_return_insn_p):
> Also check for ms_hook_prologue function attribute.
>
> testsuite/ChangeLog:
> PR target/91489
> * gcc.target/i386/ms_hook_prologue.c: Expand testcase
> to reproduce PR target/91489 issue.
>
> Signed-off-by: Paul Gofman <gofmanp@gmail.com>
> ---
> gcc/config/i386/i386-protos.h | 1 +
> gcc/config/i386/i386.c | 3 +++
> gcc/config/i386/i386.md | 5 ++++-
> gcc/testsuite/gcc.target/i386/ms_hook_prologue.c | 13 ++++++++++++-
> 4 files changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
> index 266381ca5a6..966ce426a18 100644
> --- a/gcc/config/i386/i386-protos.h
> +++ b/gcc/config/i386/i386-protos.h
> @@ -26,6 +26,7 @@ extern bool ix86_handle_option (struct gcc_options *opts,
> /* Functions in i386.c */
> extern bool ix86_target_stack_probe (void);
> extern bool ix86_can_use_return_insn_p (void);
> +extern bool ix86_function_ms_hook_prologue (const_tree fn);
> extern void ix86_setup_frame_addresses (void);
> extern bool ix86_rip_relative_addr_p (struct ix86_address *parts);
>
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index 44bc0e0176a..68e2a7519f4 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -4954,6 +4954,9 @@ symbolic_reference_mentioned_p (rtx op)
> bool
> ix86_can_use_return_insn_p (void)
> {
> + if (ix86_function_ms_hook_prologue (current_function_decl))
> + return false;
> +
> if (ix86_function_naked (current_function_decl))
> return false;
>
> diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
> index f14683cd14f..a7302b886c6 100644
> --- a/gcc/config/i386/i386.md
> +++ b/gcc/config/i386/i386.md
> @@ -13445,10 +13445,13 @@
> ;; static chain pointer - the first instruction has to be pushl %esi
> ;; and it can't be moved around, as we use alternate entry points
> ;; in that case.
> +;; Also disallow for ms_hook_prologue functions which have frame
> +;; pointer set up in function label which is correctly handled in
> +;; ix86_expand_{prologue|epligoue}() only.
>
> (define_expand "simple_return"
> [(simple_return)]
> - "!TARGET_SEH && !ix86_static_chain_on_stack"
> + "!TARGET_SEH && !ix86_static_chain_on_stack && !ix86_function_ms_hook_prologue (cfun->decl)"
> {
> if (crtl->args.pops_args)
> {
> diff --git a/gcc/testsuite/gcc.target/i386/ms_hook_prologue.c b/gcc/testsuite/gcc.target/i386/ms_hook_prologue.c
> index e11bcc049cb..12e54c0e4ad 100644
> --- a/gcc/testsuite/gcc.target/i386/ms_hook_prologue.c
> +++ b/gcc/testsuite/gcc.target/i386/ms_hook_prologue.c
> @@ -4,6 +4,8 @@
> /* { dg-require-effective-target ms_hook_prologue } */
> /* { dg-options "-O2 -fomit-frame-pointer" } */
>
> +#include <stdio.h>
> +
> int __attribute__ ((__ms_hook_prologue__)) foo ()
> {
> unsigned char *ptr = (unsigned char *) foo;
> @@ -32,7 +34,16 @@ int __attribute__ ((__ms_hook_prologue__)) foo ()
> return 0;
> }
>
> +unsigned int __attribute__ ((noinline, __ms_hook_prologue__)) test_func()
> +{
> + static int value;
> +
> + if (value++) puts("");
> +
> + return 0;
> +}
> +
> int main ()
> {
> - return foo();
> + return foo() || test_func();
> }
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix stack pointer handling in ms_hook_prologue functions for i386 target.
2020-02-21 9:11 ` Paul Gofman
@ 2020-03-25 14:17 ` Paul Gofman
0 siblings, 0 replies; 6+ messages in thread
From: Paul Gofman @ 2020-03-25 14:17 UTC (permalink / raw)
To: gcc-patches
Hello,
ping for patch https://gcc.gnu.org/ml/gcc-patches/2020-02/msg00554.html
Regards,
Paul.
On 2/21/20 12:10, Paul Gofman wrote:
> Hello,
>
> ping for patch https://gcc.gnu.org/ml/gcc-patches/2020-02/msg00554.html.
>
> Thanks,
> Paul.
>
> On 2/10/20 19:22, Paul Gofman wrote:
>> ChangeLog:
>> PR target/91489
>> * config/i386/i386.md (simple_return): Also check
>> for ms_hook_prologue function attribute.
>> * config/i386/i386.c (ix86_can_use_return_insn_p):
>> Also check for ms_hook_prologue function attribute.
>>
>> testsuite/ChangeLog:
>> PR target/91489
>> * gcc.target/i386/ms_hook_prologue.c: Expand testcase
>> to reproduce PR target/91489 issue.
>>
>> Signed-off-by: Paul Gofman <gofmanp@gmail.com>
>> ---
>> gcc/config/i386/i386-protos.h | 1 +
>> gcc/config/i386/i386.c | 3 +++
>> gcc/config/i386/i386.md | 5 ++++-
>> gcc/testsuite/gcc.target/i386/ms_hook_prologue.c | 13 ++++++++++++-
>> 4 files changed, 20 insertions(+), 2 deletions(-)
>>
>> diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
>> index 266381ca5a6..966ce426a18 100644
>> --- a/gcc/config/i386/i386-protos.h
>> +++ b/gcc/config/i386/i386-protos.h
>> @@ -26,6 +26,7 @@ extern bool ix86_handle_option (struct gcc_options *opts,
>> /* Functions in i386.c */
>> extern bool ix86_target_stack_probe (void);
>> extern bool ix86_can_use_return_insn_p (void);
>> +extern bool ix86_function_ms_hook_prologue (const_tree fn);
>> extern void ix86_setup_frame_addresses (void);
>> extern bool ix86_rip_relative_addr_p (struct ix86_address *parts);
>>
>> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
>> index 44bc0e0176a..68e2a7519f4 100644
>> --- a/gcc/config/i386/i386.c
>> +++ b/gcc/config/i386/i386.c
>> @@ -4954,6 +4954,9 @@ symbolic_reference_mentioned_p (rtx op)
>> bool
>> ix86_can_use_return_insn_p (void)
>> {
>> + if (ix86_function_ms_hook_prologue (current_function_decl))
>> + return false;
>> +
>> if (ix86_function_naked (current_function_decl))
>> return false;
>>
>> diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
>> index f14683cd14f..a7302b886c6 100644
>> --- a/gcc/config/i386/i386.md
>> +++ b/gcc/config/i386/i386.md
>> @@ -13445,10 +13445,13 @@
>> ;; static chain pointer - the first instruction has to be pushl %esi
>> ;; and it can't be moved around, as we use alternate entry points
>> ;; in that case.
>> +;; Also disallow for ms_hook_prologue functions which have frame
>> +;; pointer set up in function label which is correctly handled in
>> +;; ix86_expand_{prologue|epligoue}() only.
>>
>> (define_expand "simple_return"
>> [(simple_return)]
>> - "!TARGET_SEH && !ix86_static_chain_on_stack"
>> + "!TARGET_SEH && !ix86_static_chain_on_stack && !ix86_function_ms_hook_prologue (cfun->decl)"
>> {
>> if (crtl->args.pops_args)
>> {
>> diff --git a/gcc/testsuite/gcc.target/i386/ms_hook_prologue.c b/gcc/testsuite/gcc.target/i386/ms_hook_prologue.c
>> index e11bcc049cb..12e54c0e4ad 100644
>> --- a/gcc/testsuite/gcc.target/i386/ms_hook_prologue.c
>> +++ b/gcc/testsuite/gcc.target/i386/ms_hook_prologue.c
>> @@ -4,6 +4,8 @@
>> /* { dg-require-effective-target ms_hook_prologue } */
>> /* { dg-options "-O2 -fomit-frame-pointer" } */
>>
>> +#include <stdio.h>
>> +
>> int __attribute__ ((__ms_hook_prologue__)) foo ()
>> {
>> unsigned char *ptr = (unsigned char *) foo;
>> @@ -32,7 +34,16 @@ int __attribute__ ((__ms_hook_prologue__)) foo ()
>> return 0;
>> }
>>
>> +unsigned int __attribute__ ((noinline, __ms_hook_prologue__)) test_func()
>> +{
>> + static int value;
>> +
>> + if (value++) puts("");
>> +
>> + return 0;
>> +}
>> +
>> int main ()
>> {
>> - return foo();
>> + return foo() || test_func();
>> }
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix stack pointer handling in ms_hook_prologue functions for i386 target.
2020-02-10 16:22 [PATCH] Fix stack pointer handling in ms_hook_prologue functions for i386 target Paul Gofman
2020-02-21 9:11 ` Paul Gofman
@ 2020-03-25 22:49 ` Jeff Law
2020-06-18 17:42 ` Paul Gofman
2020-11-06 22:40 ` Jeff Law
2 siblings, 1 reply; 6+ messages in thread
From: Jeff Law @ 2020-03-25 22:49 UTC (permalink / raw)
To: Paul Gofman, gcc-patches
On Mon, 2020-02-10 at 19:22 +0300, Paul Gofman wrote:
> ChangeLog:
> PR target/91489
> * config/i386/i386.md (simple_return): Also check
> for ms_hook_prologue function attribute.
> * config/i386/i386.c (ix86_can_use_return_insn_p):
> Also check for ms_hook_prologue function attribute.
>
> testsuite/ChangeLog:
> PR target/91489
> * gcc.target/i386/ms_hook_prologue.c: Expand testcase
> to reproduce PR target/91489 issue.
I'm going to queue this for gcc-11. While I realize this is a codegen issue, I'm
not familiar enough with the stdcall conventions to give this the review it would
need at this stage in gcc-10 development.
jeff
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix stack pointer handling in ms_hook_prologue functions for i386 target.
2020-03-25 22:49 ` Jeff Law
@ 2020-06-18 17:42 ` Paul Gofman
0 siblings, 0 replies; 6+ messages in thread
From: Paul Gofman @ 2020-06-18 17:42 UTC (permalink / raw)
To: law, gcc-patches
Hello Jeff,
pinging the patch.
Regards,
Paul.
On 3/26/20 01:49, Jeff Law wrote:
> On Mon, 2020-02-10 at 19:22 +0300, Paul Gofman wrote:
>> ChangeLog:
>> PR target/91489
>> * config/i386/i386.md (simple_return): Also check
>> for ms_hook_prologue function attribute.
>> * config/i386/i386.c (ix86_can_use_return_insn_p):
>> Also check for ms_hook_prologue function attribute.
>>
>> testsuite/ChangeLog:
>> PR target/91489
>> * gcc.target/i386/ms_hook_prologue.c: Expand testcase
>> to reproduce PR target/91489 issue.
> I'm going to queue this for gcc-11. While I realize this is a codegen issue, I'm
> not familiar enough with the stdcall conventions to give this the review it would
> need at this stage in gcc-10 development.
>
> jeff
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix stack pointer handling in ms_hook_prologue functions for i386 target.
2020-02-10 16:22 [PATCH] Fix stack pointer handling in ms_hook_prologue functions for i386 target Paul Gofman
2020-02-21 9:11 ` Paul Gofman
2020-03-25 22:49 ` Jeff Law
@ 2020-11-06 22:40 ` Jeff Law
2 siblings, 0 replies; 6+ messages in thread
From: Jeff Law @ 2020-11-06 22:40 UTC (permalink / raw)
To: Paul Gofman, gcc-patches
On 2/10/20 9:22 AM, Paul Gofman wrote:
> ChangeLog:
> PR target/91489
> * config/i386/i386.md (simple_return): Also check
> for ms_hook_prologue function attribute.
> * config/i386/i386.c (ix86_can_use_return_insn_p):
> Also check for ms_hook_prologue function attribute.
>
> testsuite/ChangeLog:
> PR target/91489
> * gcc.target/i386/ms_hook_prologue.c: Expand testcase
> to reproduce PR target/91489 issue.
Thanks. I'm sorry it took so long, but this has been committed to the
trunk.
jeff
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-11-06 22:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-10 16:22 [PATCH] Fix stack pointer handling in ms_hook_prologue functions for i386 target Paul Gofman
2020-02-21 9:11 ` Paul Gofman
2020-03-25 14:17 ` Paul Gofman
2020-03-25 22:49 ` Jeff Law
2020-06-18 17:42 ` Paul Gofman
2020-11-06 22:40 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).