libsoup3: update to 3.6.0; fix GTK2/3 app startup
[oi-userland.git] / components / developer / gcc-12 / patches / 0005-Implement-fstrict-calling-conventions.patch
blobcdd9f8ab2753ac2570cb36284ff1b6d32808d287
1 From 0c9aef2bfddbd3fc5e856baa4dc2967c5a0c5af3 Mon Sep 17 00:00:00 2001
2 From: Richard Lowe <richlowe@richlowe.net>
3 Date: Sat, 27 Oct 2012 02:44:09 +0100
4 Subject: Implement -fstrict-calling-conventions
6 Stock GCC is overly willing to violate the ABI when calling local functions,
7 such that it passes arguments in registers on i386. This hampers debugging
8 with anything other than a fully-aware DWARF debugger, and is generally not
9 something we desire.
11 Implement a flag which disables this behaviour, enabled by default. The flag is
12 global, though only effective on i386, to more easily allow its globalization
13 later which, given the odds, is likely to be necessary.
14 ---
15 gcc/common.opt | 4 ++++
16 gcc/config/i386/i386.cc | 2 ++
17 gcc/doc/invoke.texi | 6 ++++++
18 gcc/testsuite/gcc.target/i386/local.c | 3 ++-
19 gcc/testsuite/gcc.target/i386/strict-cc.c | 24 +++++++++++++++++++++++
20 5 files changed, 38 insertions(+), 1 deletion(-)
21 create mode 100644 gcc/testsuite/gcc.target/i386/strict-cc.c
23 diff --git a/gcc/common.opt b/gcc/common.opt
24 index 8a0dafc522d..314c1c6a478 100644
25 --- a/gcc/common.opt
26 +++ b/gcc/common.opt
27 @@ -2745,6 +2745,10 @@ fstrict-aliasing
28 Common Var(flag_strict_aliasing) Optimization
29 Assume strict aliasing rules apply.
31 +fstrict-calling-conventions
32 +Common Var(flag_strict_calling_conventions) Init(1)
33 +Use strict ABI calling conventions even for static functions
35 fstrict-overflow
36 Common
37 Treat signed overflow as undefined. Negated as -fwrapv -fwrapv-pointer.
38 diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
39 index 9a9ff3b34b8..ce156c3be3a 100644
40 --- a/gcc/config/i386/i386.cc
41 +++ b/gcc/config/i386/i386.cc
42 @@ -1147,6 +1147,7 @@ ix86_function_regparm (const_tree type, const_tree decl)
43 and callee not, or vice versa. Instead look at whether the callee
44 is optimized or not. */
45 if (target && opt_for_fn (target->decl, optimize)
46 + && !flag_strict_calling_conventions
47 && !(profile_flag && !flag_fentry))
49 if (target->local && target->can_change_signature)
50 @@ -1243,6 +1244,7 @@ ix86_function_sseregparm (const_tree type, const_tree decl, bool warn)
51 /* TARGET_SSE_MATH */
52 && (target_opts_for_fn (target->decl)->x_ix86_fpmath & FPMATH_SSE)
53 && opt_for_fn (target->decl, optimize)
54 + && !flag_strict_calling_conventions
55 && !(profile_flag && !flag_fentry))
57 if (target->local && target->can_change_signature)
58 diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
59 index cb83dd8a1cc..348df5caf1d 100644
60 --- a/gcc/doc/invoke.texi
61 +++ b/gcc/doc/invoke.texi
62 @@ -7296,6 +7296,12 @@ with multiple statement cases using flow-sensitive points-to information.
63 Only warns when the converted pointer is dereferenced.
64 Does not warn about incomplete types.
66 +@item -fstrict-calling-conventions
67 +@opindex fstrict-calling-conventions
68 +Use strict ABI calling conventions even with local functions.
69 +This disable certain optimizations that may cause GCC to call local
70 +functions in a manner other than that described by the ABI.
72 @item -Wstrict-overflow
73 @itemx -Wstrict-overflow=@var{n}
74 @opindex Wstrict-overflow
75 diff --git a/gcc/testsuite/gcc.target/i386/local.c b/gcc/testsuite/gcc.target/i386/local.c
76 index f4444951e12..3a487583d81 100644
77 --- a/gcc/testsuite/gcc.target/i386/local.c
78 +++ b/gcc/testsuite/gcc.target/i386/local.c
79 @@ -1,5 +1,6 @@
80 /* { dg-do compile } */
81 -/* { dg-options "-O2 -funit-at-a-time" } */
82 +/* { dg-options "-O2 -funit-at-a-time -fno-strict-calling-conventions" { target ia32 } } */
83 +/* { dg-options "-O2 -funit-at-a-time" { target lp64 } } */
84 /* { dg-final { scan-assembler "magic\[^\\n\]*eax" { target ia32 } } } */
85 /* { dg-final { scan-assembler "magic\[^\\n\]*(edi|ecx)" { target { ! ia32 } } } } */
87 diff --git a/gcc/testsuite/gcc.target/i386/strict-cc.c b/gcc/testsuite/gcc.target/i386/strict-cc.c
88 new file mode 100644
89 index 00000000000..fa0543e52ff
90 --- /dev/null
91 +++ b/gcc/testsuite/gcc.target/i386/strict-cc.c
92 @@ -0,0 +1,24 @@
93 +/* { dg-do compile { target { ilp32 } } } */
94 +/* { dg-options "-O2 -funit-at-a-time -fstrict-calling-conventions" } */
95 +/* { dg-final { scan-assembler "pushl.*\\\$1" } } */
96 +/* { dg-final { scan-assembler "pushl.*\\\$2" } } */
97 +/* { dg-final { scan-assembler "pushl.*\\\$3" } } */
98 +/* { dg-final { scan-assembler "pushl.*\\\$4" } } */
99 +/* { dg-final { scan-assembler "pushl.*\\\$5" } } */
101 +#include <stdio.h>
103 +/* Verify that local calling convention is not used if strict conventions. */
104 +static int t(int, int, int, int, int) __attribute__ ((noinline));
106 +int
107 +m()
109 + t(1, 2, 3, 4, 5);
112 +static int
113 +t(int a, int b, int c, int d, int e)
115 + printf("%d\n", a, b, c, d, e);