Re: [PATCH 16/56] gcc: Re-add TYPE_METHODS.

2022-11-25 Thread Xi Ruoyao via Gcc-patches
On Sat, 2022-11-26 at 18:30 +1100, Zopolis0 via Gcc-patches wrote:
> > Re-adding a field to all types is a no-go
> 
> To be entirely honest, my current priority is simply to get this
> merged so I can spend less time keeping up with upstream changes
> breaking everything and spend more time actually improving things. The
> additional labour cost for the maintainer who is making the change and
> understands it deeply is much less than what it takes for me to bisect
> the issue, find the commit, understand it and fix the issue.

No.  Java was removed to reduce the maintenance burden, you can't just
reintroduce the burden and say "hey, I don't want to pay for the burden
so you please do it".

And we are in stage 3 now so it's not possible to merge 50+ patches
(completely not reviewed in stage 1) until GCC 14 stage 1 opens.

-- 
Xi Ruoyao 
School of Aerospace Science and Technology, Xidian University


Re: [PATCH 19/56] Revert "Move void_list_node init to common code". (8ff2a92a0450243e52d3299a13b30f208bafa7e0)

2022-11-25 Thread Andrew Pinski via Gcc-patches
On Fri, Nov 25, 2022 at 11:37 PM Zopolis0 via Gcc-patches
 wrote:
>
> > How does the Java FE initialize void_list_node?
> https://github.com/Zopolis4/gcj/blob/master/gcc/java/builtins.cc#L503
> ```
> void_list_node = end_params_node;
> ```
>
> end_params_node is defined a couple times around the Java frontend,
> not sure which definition it is using.

What happens if you remove end_params_node from the Java front-end and
replace it with void_list_node?

Thanks,
Andrew


Re: [PATCH 19/56] Revert "Move void_list_node init to common code". (8ff2a92a0450243e52d3299a13b30f208bafa7e0)

2022-11-25 Thread Zopolis0 via Gcc-patches
> How does the Java FE initialize void_list_node?
https://github.com/Zopolis4/gcj/blob/master/gcc/java/builtins.cc#L503
```
void_list_node = end_params_node;
```

end_params_node is defined a couple times around the Java frontend,
not sure which definition it is using.


Re: [PATCH 16/56] gcc: Re-add TYPE_METHODS.

2022-11-25 Thread Zopolis0 via Gcc-patches
> TYPE_METHODS uses the field used by TYPE_BINFO so the patches are related.

As the person who wrote the patches, I can confirm that they are not
in fact related. Or, at least, they fix different issues and have no
reliance upon each other. If you mean related as in they both contain
RECORD_OR_UNION_CHECK, sure, but even then they are two very different
patches, with one being a temporary stopgap and the other being a
thought-through change that solves a large issue with minimal addition
and leaves existing functionality intact.

> Re-adding a field to all types is a no-go

To be entirely honest, my current priority is simply to get this
merged so I can spend less time keeping up with upstream changes
breaking everything and spend more time actually improving things. The
additional labour cost for the maintainer who is making the change and
understands it deeply is much less than what it takes for me to bisect
the issue, find the commit, understand it and fix the issue.

>From my point of view, temporarily re-adding a grand total of two
lines is worth that goal.
If you consider this a large enough issue that you won't accept that,
then let me know so we don't dance around the issue and I can get on
with solving the issue.


Re: [PATCH 16/56] gcc: Re-add TYPE_METHODS.

2022-11-25 Thread Richard Biener via Gcc-patches



> Am 26.11.2022 um 02:55 schrieb Zopolis0 :
> 
> Oh wait wrong patch. You talking about binfo confused me.
> 
> Anyways, I re-added this because replacing Java's usage of
> TYPE_METHODS with TYPE_FIELDS even when I properly checked for
> different types of functions still broke things, so I added this as a
> stopgap.
> 
> No idea what you are talking about with binfo though, I added binfo
> for the reasons you can see in the email above, nothing to do with
> TYPE_METHODS.

TYPE_METHODS uses the field used by TYPE_BINFO so the patches are related.
I fear you have to understand what the java
Frontend does to fix your problem, I certainly don’t know what it does wrong 
here.  Re-adding a field to all types is a no-go

Richard 

> 
>> On Sat, Nov 26, 2022 at 11:16 AM Zopolis0  wrote:
>> 
>> Because the frontend uses TYPE_BINFO specifically. It expects a TYPE_BINFO 
>> that writes to this value, and will break with replacements. I have tried a 
>> number of alternatives, and this is what works.
>> 
>> I can't use lang_1 because other frontends use it in ways that java doesn't 
>> expect and I can't create a replacement for TYPE_BINFO because then it won't 
>> have the regular checks that TYPE_BINFO has.
>> 
>> I couldn't find a better solution because I'm not particularly versed with 
>> the internal workings of gcc, if you can think of a better idea feel free to 
>> let me know.
>> 
>>> On Sat, 26 Nov 2022 at 07:20, Richard Biener  
>>> wrote:
>>> 
>>> On Fri, Nov 25, 2022 at 9:55 AM Zopolis0 via Gcc-patches
>>>  wrote:
 
>>> 
>>> Why add this when nothing uses it and you need to re-add binfo because
>>> of this?  If the frontend uses
>>> it then add it to lang_type.


Re: [PATCH 19/56] Revert "Move void_list_node init to common code". (8ff2a92a0450243e52d3299a13b30f208bafa7e0)

2022-11-25 Thread Richard Biener via Gcc-patches



> Am 26.11.2022 um 02:40 schrieb Zopolis0 :
> 
> Because if I don't, all java files break:
> 
> /bin/bash ./libtool  --tag=GCJ   --mode=compile
> /home/zopolis4/trustme/./gcc/gcj
> -B/home/zopolis4/trustme/x86_64-pc-linux-gnu/libjava/
> -B/home/zopolis4/trustme/./gcc/ -B/usr/local/x86_64-pc-linux-gnu/bin/
> -B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem
> /usr/local/x86_64-pc-linux-gnu/include -isystem
> /usr/local/x86_64-pc-linux-gnu/sys-include-fomit-frame-pointer
> -Usun -fclasspath=
> -fbootclasspath=/home/zopolis4/trustme/../gcj/libjava/classpath/lib
> --encoding=UTF-8 -Wno-deprecated -fbootstrap-classes -g -O2 -c -o
> java/lang/Object.lo
> -fsource-filename=/home/zopolis4/trustme/../gcj/libjava/java/lang/Object.java
> /home/zopolis4/trustme/../gcj/libjava/classpath/lib/java/lang/Object.class
> libtool: compile:  /home/zopolis4/trustme/./gcc/gcj
> -B/home/zopolis4/trustme/x86_64-pc-linux-gnu/libjava/
> -B/home/zopolis4/trustme/./gcc/ -B/usr/local/x86_64-pc-linux-gnu/bin/
> -B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem
> /usr/local/x86_64-pc-linux-gnu/include -isystem
> /usr/local/x86_64-pc-linux-gnu/sys-include -fomit-frame-pointer -Usun
> -fclasspath= 
> -fbootclasspath=/home/zopolis4/trustme/../gcj/libjava/classpath/lib
> --encoding=UTF-8 -Wno-deprecated -fbootstrap-classes -g -O2 -c
> -fsource-filename=/home/zopolis4/trustme/../gcj/libjava/java/lang/Object.java
> /home/zopolis4/trustme/../gcj/libjava/classpath/lib/java/lang/Object.class
> -fPIC -o java/lang/.libs/Object.o
> /home/zopolis4/trustme/../gcj/libjava/java/lang/Object.java: In class
> 'java.lang.Object':
> /home/zopolis4/trustme/../gcj/libjava/java/lang/Object.java: In method
> 'java.lang.Object.finalize(void)':
> In file included from :63:
> /home/zopolis4/trustme/../gcj/libjava/java/lang/Object.java:119:
> internal compiler error: in start_java_method, at java/decl.cc:1779
>  119 |   }
>  |
> 0x662bca start_java_method(tree_node*)
>/home/zopolis4/trustme/../gcj/gcc/java/decl.cc:1779
> 0x862829 parse_class_file
>/home/zopolis4/trustme/../gcj/gcc/java/jcf-parse.cc:1634
> 0x8630ed java_parse_file()
>/home/zopolis4/trustme/../gcj/gcc/java/jcf-parse.cc:1970
> Please submit a full bug report, with preprocessed source (by using
> -freport-bug).
> Please include the complete backtrace with any bug report.
> See  for instructions.
> make[3]: *** [Makefile:10643: java/lang/Object.lo] Error 1
> make[3]: Leaving directory 
> '/home/zopolis4/trustme/x86_64-pc-linux-gnu/libjava'
> make[2]: *** [Makefile:10265: all-recursive] Error 1
> make[2]: Leaving directory 
> '/home/zopolis4/trustme/x86_64-pc-linux-gnu/libjava'
> make[1]: *** [Makefile:15471: all-target-libjava] Error 2
> make[1]: Leaving directory '/home/zopolis4/trustme'
> make: *** [Makefile:1016: all] Error 2

Please debug the above and see why it ICEs.  How does the Java FE initialize 
void_list_node?

> I asked about this in
> https://gcc.gnu.org/pipermail/gcc-help/2022-November/141981.html, but
> got no response, so I reverted the commit.
> 
>> On Sat, Nov 26, 2022 at 7:17 AM Richard Biener
>>  wrote:
>> 
>>> On Fri, Nov 25, 2022 at 9:46 AM Zopolis0 via Gcc-patches
>>>  wrote:
>>> 
>> 
>> Why?!


Re: [PATCH 16/56] gcc: Re-add TYPE_METHODS.

2022-11-25 Thread Zopolis0 via Gcc-patches
Oh wait wrong patch. You talking about binfo confused me.

Anyways, I re-added this because replacing Java's usage of
TYPE_METHODS with TYPE_FIELDS even when I properly checked for
different types of functions still broke things, so I added this as a
stopgap.

No idea what you are talking about with binfo though, I added binfo
for the reasons you can see in the email above, nothing to do with
TYPE_METHODS.

On Sat, Nov 26, 2022 at 11:16 AM Zopolis0  wrote:
>
> Because the frontend uses TYPE_BINFO specifically. It expects a TYPE_BINFO 
> that writes to this value, and will break with replacements. I have tried a 
> number of alternatives, and this is what works.
>
> I can't use lang_1 because other frontends use it in ways that java doesn't 
> expect and I can't create a replacement for TYPE_BINFO because then it won't 
> have the regular checks that TYPE_BINFO has.
>
> I couldn't find a better solution because I'm not particularly versed with 
> the internal workings of gcc, if you can think of a better idea feel free to 
> let me know.
>
> On Sat, 26 Nov 2022 at 07:20, Richard Biener  
> wrote:
>>
>> On Fri, Nov 25, 2022 at 9:55 AM Zopolis0 via Gcc-patches
>>  wrote:
>> >
>>
>> Why add this when nothing uses it and you need to re-add binfo because
>> of this?  If the frontend uses
>> it then add it to lang_type.


Re: [PATCH 19/56] Revert "Move void_list_node init to common code". (8ff2a92a0450243e52d3299a13b30f208bafa7e0)

2022-11-25 Thread Zopolis0 via Gcc-patches
Because if I don't, all java files break:

/bin/bash ./libtool  --tag=GCJ   --mode=compile
/home/zopolis4/trustme/./gcc/gcj
-B/home/zopolis4/trustme/x86_64-pc-linux-gnu/libjava/
-B/home/zopolis4/trustme/./gcc/ -B/usr/local/x86_64-pc-linux-gnu/bin/
-B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem
/usr/local/x86_64-pc-linux-gnu/include -isystem
/usr/local/x86_64-pc-linux-gnu/sys-include-fomit-frame-pointer
-Usun -fclasspath=
-fbootclasspath=/home/zopolis4/trustme/../gcj/libjava/classpath/lib
--encoding=UTF-8 -Wno-deprecated -fbootstrap-classes -g -O2 -c -o
java/lang/Object.lo
-fsource-filename=/home/zopolis4/trustme/../gcj/libjava/java/lang/Object.java
/home/zopolis4/trustme/../gcj/libjava/classpath/lib/java/lang/Object.class
libtool: compile:  /home/zopolis4/trustme/./gcc/gcj
-B/home/zopolis4/trustme/x86_64-pc-linux-gnu/libjava/
-B/home/zopolis4/trustme/./gcc/ -B/usr/local/x86_64-pc-linux-gnu/bin/
-B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem
/usr/local/x86_64-pc-linux-gnu/include -isystem
/usr/local/x86_64-pc-linux-gnu/sys-include -fomit-frame-pointer -Usun
-fclasspath= -fbootclasspath=/home/zopolis4/trustme/../gcj/libjava/classpath/lib
--encoding=UTF-8 -Wno-deprecated -fbootstrap-classes -g -O2 -c
-fsource-filename=/home/zopolis4/trustme/../gcj/libjava/java/lang/Object.java
/home/zopolis4/trustme/../gcj/libjava/classpath/lib/java/lang/Object.class
 -fPIC -o java/lang/.libs/Object.o
/home/zopolis4/trustme/../gcj/libjava/java/lang/Object.java: In class
'java.lang.Object':
/home/zopolis4/trustme/../gcj/libjava/java/lang/Object.java: In method
'java.lang.Object.finalize(void)':
In file included from :63:
/home/zopolis4/trustme/../gcj/libjava/java/lang/Object.java:119:
internal compiler error: in start_java_method, at java/decl.cc:1779
  119 |   }
  |
0x662bca start_java_method(tree_node*)
/home/zopolis4/trustme/../gcj/gcc/java/decl.cc:1779
0x862829 parse_class_file
/home/zopolis4/trustme/../gcj/gcc/java/jcf-parse.cc:1634
0x8630ed java_parse_file()
/home/zopolis4/trustme/../gcj/gcc/java/jcf-parse.cc:1970
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
make[3]: *** [Makefile:10643: java/lang/Object.lo] Error 1
make[3]: Leaving directory '/home/zopolis4/trustme/x86_64-pc-linux-gnu/libjava'
make[2]: *** [Makefile:10265: all-recursive] Error 1
make[2]: Leaving directory '/home/zopolis4/trustme/x86_64-pc-linux-gnu/libjava'
make[1]: *** [Makefile:15471: all-target-libjava] Error 2
make[1]: Leaving directory '/home/zopolis4/trustme'
make: *** [Makefile:1016: all] Error 2

I asked about this in
https://gcc.gnu.org/pipermail/gcc-help/2022-November/141981.html, but
got no response, so I reverted the commit.

On Sat, Nov 26, 2022 at 7:17 AM Richard Biener
 wrote:
>
> On Fri, Nov 25, 2022 at 9:46 AM Zopolis0 via Gcc-patches
>  wrote:
> >
>
> Why?!


Re: [PATCH 14/56] middle-end: Set TREE_ADDRESSABLE in folding debug stmts.

2022-11-25 Thread Zopolis0 via Gcc-patches
I was reverting a076632e274abe344ca7648b7c7f299273d4cbe0 as it removed code
for Java, but I may have misunderstood the change and made the incorrect
edits.

On Sat, 26 Nov 2022 at 07:16, Richard Biener 
wrote:

> On Fri, Nov 25, 2022 at 9:43 AM Zopolis0 via Gcc-patches
>  wrote:
> >
>
> That's wrong and the comment you remove explains why.
>


Re: [PATCH 16/56] gcc: Re-add TYPE_METHODS.

2022-11-25 Thread Zopolis0 via Gcc-patches
Because the frontend uses TYPE_BINFO specifically. It expects a TYPE_BINFO
that writes to this value, and will break with replacements. I have tried a
number of alternatives, and this is what works.

I can't use lang_1 because other frontends use it in ways that java doesn't
expect and I can't create a replacement for TYPE_BINFO because then it
won't have the regular checks that TYPE_BINFO has.

I couldn't find a better solution because I'm not particularly versed with
the internal workings of gcc, if you can think of a better idea feel free
to let me know.

On Sat, 26 Nov 2022 at 07:20, Richard Biener 
wrote:

> On Fri, Nov 25, 2022 at 9:55 AM Zopolis0 via Gcc-patches
>  wrote:
> >
>
> Why add this when nothing uses it and you need to re-add binfo because
> of this?  If the frontend uses
> it then add it to lang_type.
>


Re: [PATCH] tree-optimization/106912 - IPA profile and pure/const

2022-11-25 Thread Richard Biener via Gcc-patches




On Fri, 25 Nov 2022, Jan Hubicka wrote:


On Fri, 25 Nov 2022, Jan Hubicka wrote:





Am 25.11.2022 um 11:05 schrieb Jan Hubicka via Gcc-patches 
:




IPA profile instrumentation tries to clear the pure and const
flags of functions but that's quite hopeless in particular for
const since that attribute prevails on the type and thus on each
call to the function leading to inconsistencies in the IL and
eventual checking ICEs.  There's no good reason to do this and
it wouldn't fixup any indirect calls so just don't.  No other
instrumentation GCC does bothers about this.


This was mostly meant to deadl with situation where we auto-detect
function to be const and then partially inline it to a loop.
Then both caller and callee accesses same counters in the memory and if
you move load/stores out of the loop in caller you lose counters and get
inconsistencies at profile read-in time.


Don?t we Instrument after partial inlining now?  As said, since we have the 
fntype on the call this doesn?t work anymore for const functions via attributes.


Full inlining can cause problem already.  So for code like

do
{
  if (__builtin_expect (test,1))
a+=foo (a);
  else
a+=foo (b);
} while ();
we may end up inlining one of the two invocation. Then caller and callee
will modify the same counter.  If we handle the remaining call as const,
we can hoist the counter modifications out of the loop and mix them up.

I remember I run into an actual example of this problem during GCC
bootstrap. There the function was auto-detected to be const by
early pure-const pass so type was not an problem. You are right we ought
to do something about types since the scenario above can happen with foo
being declared with an attribute as well.


Or by doing the first call as

volatile int __attribute__((const)) (*foop)(int) = foo;

  a += (*foop) (a);

you'd need to get all calls that might possibly call an instrumented
function adjusted.

I think if we're taking this issue serious we'd have to simply
ignore const/pure attributes at parsing time and refrain from
auto-detecting as well, at least for address-taken functions?


I think that is also not a good idea, since we would have to do that
with -fprofile-use, too (so the CFG at the instrumentation time
matches) and it would lead to poor perofrmance with FDO.


Hmm, possibly, yes.


The idea was to honor pure/const during early opt and undo the
attributes when profiling is inserted.
We have fixup_cfg to compensate for attribute changes.


Which works for pure (it's not an attribute on types) but fails for
const (which is).  That's a bug btw.


We could
probably keep tract if any instrumented code was ever inlined into a
given function and perhaps just start ignoring attributes set on types?


But ignoring attributes on types makes all indirect calls not
const/pure annotatable (OK, they are not pure annotatable because of
the above bug).  I really don't see how to conservatively solve this
issue?  Maybe we can ignore all pure/const when the cgraph state is
in profile-instrumented state?  Of course we have multiple "APIs"
to query that.

Richard.


Honza


That said, this adjustment in the "wrong" direction causes problems
downstream, which is what the fixed PR is about (simd cloning picks
up the wrong things, or rather possibly fails to clone the attributes?).

Richard.


Honza


Richard

Honza


Bootstrap and regtest pending on x86_64-unknown-linux-gnu, OK?

Thanks,
Richard.

   PR tree-optimization/106912
   * tree-profile.cc (tree_profiling): Do not clear pure/const
   flags.

   * gcc.dg/pr106912.c: New testcase.
---
gcc/testsuite/gcc.dg/pr106912.c | 16 
gcc/tree-profile.cc |  3 ---
2 files changed, 16 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/pr106912.c

diff --git a/gcc/testsuite/gcc.dg/pr106912.c b/gcc/testsuite/gcc.dg/pr106912.c
new file mode 100644
index 000..8faa877d8b3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr106912.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fPIC -ftree-vectorize -fprofile-generate" } */
+
+__attribute__ ((__simd__))
+__attribute__ ((__nothrow__ , __leaf__ , __const__))
+double foo (double x);
+void bar(double *f, int n)
+{
+  int i;
+  for (i = 0; i < n; i++)
+f[i] = foo(f[i]);
+}
+double foo(double x)
+{
+  return x * x / 3.0;
+}
diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc
index 2beb49241f2..5491b398870 100644
--- a/gcc/tree-profile.cc
+++ b/gcc/tree-profile.cc
@@ -814,9 +814,6 @@ tree_profiling (void)
   /* Don't profile functions produced for builtin stuff.  */
   if (DECL_SOURCE_LOCATION (node->decl) == BUILTINS_LOCATION)
 continue;
-
-node->set_const_flag (false, false);
-node->set_pure_flag (false, false);
  }

  /* Update call statements and rebuild the cgraph.  */
--
2.35.3




--
Richard Biener 
SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg,
Germany; GF: Ivo Totev, Andrew Myers, Andrew 

Re: [PATCH 16/56] gcc: Re-add TYPE_METHODS.

2022-11-25 Thread Richard Biener via Gcc-patches
On Fri, Nov 25, 2022 at 9:55 AM Zopolis0 via Gcc-patches
 wrote:
>

Why add this when nothing uses it and you need to re-add binfo because
of this?  If the frontend uses
it then add it to lang_type.


Re: [PATCH 19/56] Revert "Move void_list_node init to common code". (8ff2a92a0450243e52d3299a13b30f208bafa7e0)

2022-11-25 Thread Richard Biener via Gcc-patches
On Fri, Nov 25, 2022 at 9:46 AM Zopolis0 via Gcc-patches
 wrote:
>

Why?!


Re: [PATCH 14/56] middle-end: Set TREE_ADDRESSABLE in folding debug stmts.

2022-11-25 Thread Richard Biener via Gcc-patches
On Fri, Nov 25, 2022 at 9:43 AM Zopolis0 via Gcc-patches
 wrote:
>

That's wrong and the comment you remove explains why.


Re: [PATCH] tree-optimization/107672 - avoid vector mode type_for_mode call

2022-11-25 Thread Richard Biener via Gcc-patches




On Fri, 25 Nov 2022, Vaseeharan Vinayagamoorthy wrote:


Hi,

I am seeing an internal compiler error, related to this patch:


Can you please open a bugzilla for this and attach preprocessed
source so I can reproduce the ICE with a cc1 cross compiler?

Thanks,
Richard.



during GIMPLE pass: slp

options-save.cc: In function 'void cl_optimization_restore(gcc_options*,
gcc_options*, cl_optimization*)':

options-save.cc:1292:1: internal compiler error: in
supportable_widening_operation, at tree-vect-stmts.cc:12199

 

 1292 | cl_optimization_restore (struct gcc_options *opts, struct
gcc_options *opts_set,

 | ^~~

/…/src/gcc/gcc/profile-count.cc: In member function 'int
profile_count::to_cgraph_frequency(profile_count) const':

/…/src/gcc/gcc/profile-count.cc:308:1: note: parameter passing for argument
of type 'profile_count' changed in GCC 9.1

 308 | profile_count::to_cgraph_frequency (profile_count entry_bb_count)
const

 | ^

/…/src/gcc/gcc/profile-count.cc: In member function 'sreal
profile_count::to_sreal_scale(profile_count, bool*) const':

/…/src/gcc/gcc/profile-count.cc:326:1: note: parameter passing for argument
of type 'profile_count' changed in GCC 9.1

 326 | profile_count::to_sreal_scale (profile_count in, bool *known) const

 | ^

0x2195bdd supportable_widening_operation(vec_info*, tree_code,
_stmt_vec_info*, tree_node*, tree_node*, tree_code*, tree_code*, int*,
vec*)

 /…/src/gcc/gcc/tree-vect-stmts.cc:12199

0x2180493 vectorizable_conversion

 /…/src/gcc/gcc/tree-vect-stmts.cc:5064

0x2192fdd vect_analyze_stmt(vec_info*, _stmt_vec_info*, bool*, _slp_tree*,
_slp_instance*, vec*)

 /…/src/gcc/gcc/tree-vect-stmts.cc:11256

 

/…/src/gcc/gcc/profile-count.cc: In member function 'profile_count
profile_count::combine_with_ipa_count(profile_count)':

/…/src/gcc/gcc/profile-count.cc:398:1: note: parameter passing for argument
of type 'profile_count' changed in GCC 9.1

 398 | profile_count::combine_with_ipa_count (profile_count ipa)

 | ^

0x14f95d1 vect_slp_analyze_node_operations_1

 /…/src/gcc/gcc/tree-vect-slp.cc:5958

0x14f9c19 vect_slp_analyze_node_operations

 /…/src/gcc/gcc/tree-vect-slp.cc:6147

0x14f9b4d vect_slp_analyze_node_operations

 /…/src/gcc/gcc/tree-vect-slp.cc:6126

0x14fa439 vect_slp_analyze_operations(vec_info*)

 /…/src/gcc/gcc/tree-vect-slp.cc:6387

0x14fd423 vect_slp_analyze_bb_1

 /…/src/gcc/gcc/tree-vect-slp.cc:7372

0x14fd599 vect_slp_region

 /…/src/gcc/gcc/tree-vect-slp.cc:7419

0x14fe0d1 vect_slp_bbs

 /…/src/gcc/gcc/tree-vect-slp.cc:7610

0x14fe46f vect_slp_function(function*)

 /…/src/gcc/gcc/tree-vect-slp.cc:7698

0x151a109 execute

 /…/src/gcc/gcc/tree-vectorizer.cc:1532

Please submit a full bug report, with preprocessed source (by using
-freport-bug).

Please include the complete backtrace with any bug report.

See  for instructions.

Makefile:1146: recipe for target 'options-save.o' failed

make[3]: *** [options-save.o] Error 1



That happens when building the arm-none-linux-gnueabihf toolchain natively
with glibc bootstrap:
Build:arm-none-linux-gnueabihf
Host:arm-none-linux-gnueabihf
Target: arm-none-linux-gnueabihf

The compiler being used to build the toolchain is gcc 7.5.0.


Kind regards
Vasee


From: Gcc-patches  on
behalf of Richard Biener via Gcc-patches 
Sent: 22 November 2022 08:48
To: gcc-patches@gcc.gnu.org 
Subject: [PATCH] tree-optimization/107672 - avoid vector mode type_for_mode
call  
The following avoids using type_for_mode on vector modes which might
not work for all frontends.  Instead we look for the inner mode
type and use build_vector_type_for_mode instead.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

    PR tree-optimization/107672
    * tree-vect-stmts.cc (supportable_widening_operation): Avoid
    type_for_mode on vector modes.
---
 gcc/tree-vect-stmts.cc | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index bc0ef136f19..b35b986889d 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -12195,9 +12195,15 @@ supportable_widening_operation (vec_info *vinfo,
 intermediate_type
   = vect_halve_mask_nunits (prev_type, intermediate_mode);
   else
-   intermediate_type
- = lang_hooks.types.type_for_mode (intermediate_mode,
-   TYPE_UNSIGNED (prev_type));
+   {
+ gcc_assert (VECTOR_MODE_P (intermediate_mode));
+ tree intermediate_element_type
+   = lang_hooks.types.type_for_mode (GET_MODE_INNER
(intermediate_mode),
+ TYPE_UNSIGNED (prev_type));
+ intermediate_type
+   = build_vector_type_for_mode (intermediate_element_type,
+ intermediate_mode);
+   }
 
   

PING [PATCH v3] c++: Allow module name to be a single letter on Windows

2022-11-25 Thread Torbjorn SVENSSON via Gcc-patches

Hi,

Ping, https://gcc.gnu.org/pipermail/gcc-patches/2022-November/606528.html

Kind regards,
Torbjörn

On 2022-11-17 14:20, Torbjörn SVENSSON wrote:

v1 -> v2:
Paths without "C:" part can still be absolute if they start with / or
\ on Windows.

v2 -> v3:
Use alternative approach by having platform specific code in module.cc.

Truth table for the new expression:
c:\foo -> true
c:/foo -> true
/foo   -> true
\foo   -> true
c:foo  -> false
foo-> false
./foo  -> true
.\foo  -> true


Ok for trunk?

---

On Windows, the ':' character is special and when the module name is
a single character, like 'A', then the flatname would be (for
example) 'A:Foo'. On Windows, 'A:Foo' is treated as an absolute
path by the module loader and is likely not found.

Without this patch, the test case pr98944_c.C fails with:

In module imported at /src/gcc/testsuite/g++.dg/modules/pr98944_b.C:7:1,
of module A:Foo, imported at /src/gcc/testsuite/g++.dg/modules/pr98944_c.C:7:
A:Internals: error: header module expected, module 'A:Internals' found
A:Internals: error: failed to read compiled module: Bad file data
A:Internals: note: compiled module file is 'gcm.cache/A-Internals.gcm'
In module imported at /src/gcc/testsuite/g++.dg/modules/pr98944_c.C:7:8:
A:Foo: error: failed to read compiled module: Bad import dependency
A:Foo: note: compiled module file is 'gcm.cache/A-Foo.gcm'
A:Foo: fatal error: returning to the gate for a mechanical issue
compilation terminated.

gcc/cp/ChangeLog:

* module.cc: On Windows, 'A:Foo' is supposed to be a module
and not a path.

Tested on Windows with arm-none-eabi for Cortex-M3 in gcc-11 tree.

Co-Authored-By: Yvan ROUX 
Signed-off-by: Torbjörn SVENSSON 
---
  gcc/cp/module.cc | 10 +-
  1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 0e9af318ba4..fa41a86213f 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -13960,7 +13960,15 @@ get_module (tree name, module_state *parent, bool 
partition)
  static module_state *
  get_module (const char *ptr)
  {
-  if (ptr[0] == '.' ? IS_DIR_SEPARATOR (ptr[1]) : IS_ABSOLUTE_PATH (ptr))
+  /* On DOS based file systems, there is an ambiguity with A:B which can be
+ interpreted as a module Module:Partition or Drive:PATH.  Interpret strings
+ which clearly starts as pathnames as header-names and everything else is
+ treated as a (possibly malformed) named moduled.  */
+  if (IS_DIR_SEPARATOR (ptr[ptr[0] == '.']) // ./FOO or /FOO
+#if HAVE_DOS_BASED_FILE_SYSTEM
+  || (HAS_DRIVE_SPEC (ptr) && IS_DIR_SEPARATOR (ptr[2])) // A:/FOO
+#endif
+  || false)
  /* A header name.  */
  return get_module (build_string (strlen (ptr), ptr));
  


Re: [PATCH v2 16/19] modula2 front end: bootstrap and documentation tools

2022-11-25 Thread David Malcolm via Gcc-patches
On Thu, 2022-11-24 at 14:30 +, Gaius Mulley via Gcc-patches wrote:
> Martin Liška  writes:
> 
> > On 11/8/22 14:22, Gaius Mulley wrote:
> > > Martin Liška  writes:
> > > 
> > > should be good - I'll complete the rst output in the scripts,
> > 
> > Hi.
> > 
> 
> Hi Martin,
> 
> > As you probably noticed, the Sphinx migration didn't go well.
> 
> Yes, sorry to see this didn't happen.  Thank you for your hard work
> and
> I hope it can occur in the future.

Likewise, thanks for all your work on this.

> 
> > However, it's still up to you if you want to use it or not for
> > Modula
> > 2.
> 
> Once modula-2 is in master I'd like to revisit rst in devel/modula-2
> along with analyzer patches and m2 generics.  If successful then
> submit
> patches in early stage 1.

Am I right in thinking the analyzer stuff would be an updated version
of the work you posted here:
 https://gcc.gnu.org/pipermail/gcc-patches/2021-April/567953.html
?

Thanks
Dave



Re: [PATCH v2 16/19] modula2 front end: bootstrap and documentation tools

2022-11-25 Thread Martin Liška
On 11/24/22 15:30, Gaius Mulley wrote:
> Martin Liška  writes:
> 
>> On 11/8/22 14:22, Gaius Mulley wrote:
>>> Martin Liška  writes:
>>>
>>> should be good - I'll complete the rst output in the scripts,
>>
>> Hi.
>>
> 
> Hi Martin,
> 
>> As you probably noticed, the Sphinx migration didn't go well.
> 
> Yes, sorry to see this didn't happen.  Thank you for your hard work and
> I hope it can occur in the future.

Hi.

We'll see, it's not in my plans for near future.

> 
>> However, it's still up to you if you want to use it or not for Modula
>> 2.
> 
> Once modula-2 is in master I'd like to revisit rst in devel/modula-2
> along with analyzer patches and m2 generics.  If successful then submit
> patches in early stage 1.

Sounds good.

> 
>> We have manuals like libgccjit, or Ada manuals
>> that use RST natively and provide exported .texi files.
> 
> Ok thanks for the pointers, I will experiment with these build rhunes.
> 
>> Cheers and sorry for the troubles I caused.
> 
> No problem at all - the modula-2 scripts are now improved and cleaner
> due to the port.  Hopefully rst will happen sometime in the future,

Regards,
Martin

> 
> regards,
> Gaius



Re: [PATCH][PING][sanitizer/106558] asan: fix unsafe optimization of Asan checks.

2022-11-25 Thread Martin Liška
On 11/21/22 11:02, Jakub Jelinek wrote:
> Otherwise LGTM.  Thanks and sorry for the review delay.

Yuri, do you want to commit the patch soon?

If not, I can help if you want?

Cheers,
Martin


[PATCH] RISC-V: Add duplicate vector support.

2022-11-25 Thread juzhe . zhong
From: Ju-Zhe Zhong 

gcc/ChangeLog:

* config/riscv/constraints.md (Wdm): New constraint.
* config/riscv/predicates.md (direct_broadcast_operand): New predicate.
* config/riscv/riscv-protos.h (RVV_VLMAX): New macro.
(emit_pred_op): Refine function.
* config/riscv/riscv-selftests.cc (run_const_vector_selftests): New 
function.
(run_broadcast_selftests): Ditto.
(BROADCAST_TEST): New tests.
(riscv_run_selftests): More tests. 
* config/riscv/riscv-v.cc (emit_pred_move): Refine function.
(emit_vlmax_vsetvl): Ditto.
(emit_pred_op): Ditto.
(expand_const_vector): New function.
(legitimize_move): Add constant vector support.
* config/riscv/riscv.cc (riscv_print_operand): New asm print rule for 
const vector.
* config/riscv/riscv.h (X0_REGNUM): New macro.
* config/riscv/vector-iterators.md: New attribute.
* config/riscv/vector.md (vec_duplicate): New pattern.
(@pred_broadcast): New pattern.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/dup-1.c: New test.
* gcc.target/riscv/rvv/base/dup-2.c: New test.

---
 gcc/config/riscv/constraints.md   |   5 +
 gcc/config/riscv/predicates.md|   5 +
 gcc/config/riscv/riscv-protos.h   |   2 +
 gcc/config/riscv/riscv-selftests.cc   | 127 +
 gcc/config/riscv/riscv-v.cc   |  86 ++-
 gcc/config/riscv/riscv.cc |  13 +
 gcc/config/riscv/riscv.h  |   3 +
 gcc/config/riscv/vector-iterators.md  |   9 +
 gcc/config/riscv/vector.md|  53 +-
 .../gcc.target/riscv/rvv/base/dup-1.c | 521 ++
 .../gcc.target/riscv/rvv/base/dup-2.c |  75 +++
 11 files changed, 881 insertions(+), 18 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/dup-1.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/dup-2.c

diff --git a/gcc/config/riscv/constraints.md b/gcc/config/riscv/constraints.md
index 4088c48150a..51cffb2bcb6 100644
--- a/gcc/config/riscv/constraints.md
+++ b/gcc/config/riscv/constraints.md
@@ -151,3 +151,8 @@
  A constraint that matches a vector of immediate all ones."
  (and (match_code "const_vector")
   (match_test "op == CONSTM1_RTX (GET_MODE (op))")))
+
+(define_constraint "Wdm"
+  "Vector duplicate memory operand"
+  (and (match_operand 0 "memory_operand")
+   (match_code "reg" "0")))
diff --git a/gcc/config/riscv/predicates.md b/gcc/config/riscv/predicates.md
index dfd98761b8b..5a5a49bf7c0 100644
--- a/gcc/config/riscv/predicates.md
+++ b/gcc/config/riscv/predicates.md
@@ -286,6 +286,11 @@
(match_test "GET_CODE (op) == UNSPEC
 && (XINT (op, 1) == UNSPEC_VUNDEF)"
 
+;; The scalar operand can be directly broadcast by RVV instructions.
+(define_predicate "direct_broadcast_operand"
+  (ior (match_operand 0 "register_operand")
+   (match_test "satisfies_constraint_Wdm (op)")))
+
 ;; A CONST_INT operand that has exactly two bits cleared.
 (define_predicate "const_nottwobits_operand"
   (and (match_code "const_int")
diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h
index 2ec3af05aa4..27692ffb210 100644
--- a/gcc/config/riscv/riscv-protos.h
+++ b/gcc/config/riscv/riscv-protos.h
@@ -119,6 +119,7 @@ extern void riscv_run_selftests (void);
 #endif
 
 namespace riscv_vector {
+#define RVV_VLMAX gen_rtx_REG (Pmode, X0_REGNUM)
 /* Routines implemented in riscv-vector-builtins.cc.  */
 extern void init_builtins (void);
 extern const char *mangle_builtin_type (const_tree);
@@ -130,6 +131,7 @@ extern tree builtin_decl (unsigned, bool);
 extern rtx expand_builtin (unsigned int, tree, rtx);
 extern bool const_vec_all_same_in_range_p (rtx, HOST_WIDE_INT, HOST_WIDE_INT);
 extern bool legitimize_move (rtx, rtx, machine_mode);
+extern void emit_pred_op (unsigned, rtx, rtx, machine_mode);
 enum tail_policy
 {
   TAIL_UNDISTURBED = 0,
diff --git a/gcc/config/riscv/riscv-selftests.cc 
b/gcc/config/riscv/riscv-selftests.cc
index 636874ebc0f..1bf1a648fa1 100644
--- a/gcc/config/riscv/riscv-selftests.cc
+++ b/gcc/config/riscv/riscv-selftests.cc
@@ -33,6 +33,9 @@ along with GCC; see the file COPYING3.  If not see
 #include "expr.h"
 #include "selftest.h"
 #include "selftest-rtl.h"
+#include "insn-attr.h"
+#include "target.h"
+#include "optabs.h"
 
 #if CHECKING_P
 using namespace selftest;
@@ -230,12 +233,136 @@ run_poly_int_selftests (void)
   run_poly_int_selftest ("rv32imafd_zve32x1p0", ABI_ILP32D, POLY_TEST_DIMODE,
 worklist);
 }
+
+static void
+run_const_vector_selftests (void)
+{
+  /* We dont't need to do the redundant tests in different march && mabi.
+ Just pick up the march && mabi which fully support all RVV modes.  */
+  riscv_selftest_arch_abi_setter rv ("rv64imafdcv", ABI_LP64D);
+  rtl_dump_test t (SELFTEST_LOCATION, locate_file 

Re: [PATCH] sync libsframe toplevel from binutils-gdb

2022-11-25 Thread Richard Sandiford via Gcc-patches
Richard Earnshaw via Gcc-patches  writes:
> This pulls in the toplevel portion of this binutils-gdb commit:
>19e559f1c91bfaedbd2f91d85ee161f3f03fda3c libsframe: add the SFrame library
>
> ChangeLog:
>   * Makefile.def: Add libsframe as new module with its dependencies.
>   * Makefile.in: Regenerated.
>   * configure.ac: Add libsframe to host_libs.
>   * configure: Regenerated.

OK, thanks.

Richard

> ---
>  Makefile.def |2 +
>  Makefile.in  | 1288 +-
>  configure|2 +-
>  configure.ac |2 +-
>  4 files changed, 1287 insertions(+), 7 deletions(-)
>
> diff --git a/Makefile.def b/Makefile.def
> index 02e63c57177..83ae77586ad 100644
> --- a/Makefile.def
> +++ b/Makefile.def
> @@ -145,6 +145,7 @@ host_modules= { module= lto-plugin; bootstrap=true;
>  host_modules= { module= libcc1; extra_configure_flags=--enable-shared; };
>  host_modules= { module= gotools; };
>  host_modules= { module= libctf; bootstrap=true; };
> +host_modules= { module= libsframe; bootstrap=true; };
>  
>  target_modules = { module= libstdc++-v3;
>  bootstrap=true;
> @@ -470,6 +471,7 @@ dependencies = { module=all-binutils; on=all-intl; };
>  dependencies = { module=all-binutils; on=all-gas; };
>  dependencies = { module=all-binutils; on=all-libctf; };
>  dependencies = { module=all-ld; on=all-libctf; };
> +dependencies = { module=all-binutils; on=all-libsframe; };
>  
>  // We put install-opcodes before install-binutils because the installed
>  // binutils might be on PATH, and they might need the shared opcodes
> diff --git a/Makefile.in b/Makefile.in
> index 6ffa9660c25..e5bed1bea3a 100644
> --- a/Makefile.in
> +++ b/Makefile.in
> @@ -1097,7 +1097,8 @@ configure-host:  \
>  maybe-configure-lto-plugin \
>  maybe-configure-libcc1 \
>  maybe-configure-gotools \
> -maybe-configure-libctf
> +maybe-configure-libctf \
> +maybe-configure-libsframe
>  .PHONY: configure-target
>  configure-target:  \
>  maybe-configure-target-libstdc++-v3 \
> @@ -1273,6 +1274,9 @@ all-host: maybe-all-gotools
>  @if libctf-no-bootstrap
>  all-host: maybe-all-libctf
>  @endif libctf-no-bootstrap
> +@if libsframe-no-bootstrap
> +all-host: maybe-all-libsframe
> +@endif libsframe-no-bootstrap
>  
>  .PHONY: all-target
>  
> @@ -1384,6 +1388,7 @@ info-host: maybe-info-lto-plugin
>  info-host: maybe-info-libcc1
>  info-host: maybe-info-gotools
>  info-host: maybe-info-libctf
> +info-host: maybe-info-libsframe
>  
>  .PHONY: info-target
>  
> @@ -1472,6 +1477,7 @@ dvi-host: maybe-dvi-lto-plugin
>  dvi-host: maybe-dvi-libcc1
>  dvi-host: maybe-dvi-gotools
>  dvi-host: maybe-dvi-libctf
> +dvi-host: maybe-dvi-libsframe
>  
>  .PHONY: dvi-target
>  
> @@ -1560,6 +1566,7 @@ pdf-host: maybe-pdf-lto-plugin
>  pdf-host: maybe-pdf-libcc1
>  pdf-host: maybe-pdf-gotools
>  pdf-host: maybe-pdf-libctf
> +pdf-host: maybe-pdf-libsframe
>  
>  .PHONY: pdf-target
>  
> @@ -1648,6 +1655,7 @@ html-host: maybe-html-lto-plugin
>  html-host: maybe-html-libcc1
>  html-host: maybe-html-gotools
>  html-host: maybe-html-libctf
> +html-host: maybe-html-libsframe
>  
>  .PHONY: html-target
>  
> @@ -1736,6 +1744,7 @@ TAGS-host: maybe-TAGS-lto-plugin
>  TAGS-host: maybe-TAGS-libcc1
>  TAGS-host: maybe-TAGS-gotools
>  TAGS-host: maybe-TAGS-libctf
> +TAGS-host: maybe-TAGS-libsframe
>  
>  .PHONY: TAGS-target
>  
> @@ -1824,6 +1833,7 @@ install-info-host: maybe-install-info-lto-plugin
>  install-info-host: maybe-install-info-libcc1
>  install-info-host: maybe-install-info-gotools
>  install-info-host: maybe-install-info-libctf
> +install-info-host: maybe-install-info-libsframe
>  
>  .PHONY: install-info-target
>  
> @@ -1912,6 +1922,7 @@ install-dvi-host: maybe-install-dvi-lto-plugin
>  install-dvi-host: maybe-install-dvi-libcc1
>  install-dvi-host: maybe-install-dvi-gotools
>  install-dvi-host: maybe-install-dvi-libctf
> +install-dvi-host: maybe-install-dvi-libsframe
>  
>  .PHONY: install-dvi-target
>  
> @@ -2000,6 +2011,7 @@ install-pdf-host: maybe-install-pdf-lto-plugin
>  install-pdf-host: maybe-install-pdf-libcc1
>  install-pdf-host: maybe-install-pdf-gotools
>  install-pdf-host: maybe-install-pdf-libctf
> +install-pdf-host: maybe-install-pdf-libsframe
>  
>  .PHONY: install-pdf-target
>  
> @@ -2088,6 +2100,7 @@ install-html-host: maybe-install-html-lto-plugin
>  install-html-host: maybe-install-html-libcc1
>  install-html-host: maybe-install-html-gotools
>  install-html-host: maybe-install-html-libctf
> +install-html-host: maybe-install-html-libsframe
>  
>  .PHONY: install-html-target
>  
> @@ -2176,6 +2189,7 @@ installcheck-host: maybe-installcheck-lto-plugin
>  installcheck-host: maybe-installcheck-libcc1
>  installcheck-host: maybe-installcheck-gotools
>  installcheck-host: maybe-installcheck-libctf
> +installcheck-host: maybe-installcheck-libsframe
>  
>  .PHONY: installcheck-target
>  
> @@ -2264,6 +2278,7 @@ mostlyclean-host: maybe-mostlyclean-lto-plugin
>  

Re: [PATCH]rs6000: Load high and low part of 64bit constant independently

2022-11-25 Thread Segher Boessenkool
Hi!

On Fri, Nov 25, 2022 at 09:21:21PM +0800, Jiufu Guo wrote:
> "Kewen.Lin"  writes:
> > on 2022/9/15 16:30, Jiufu Guo wrote:
> >> For a complicate 64bit constant, blow is one instruction-sequence to
> >> build:
> >>lis 9,0x800a
> >>ori 9,9,0xabcd
> >>sldi 9,9,32
> >>oris 9,9,0xc167
> >>ori 9,9,0xfa16
> >> 
> >> while we can also use below sequence to build:
> >>lis 9,0xc167
> >>lis 10,0x800a
> >>ori 9,9,0xfa16
> >>ori 10,10,0xabcd
> >>rldimi 9,10,32,0
> >> This sequence is using 2 registers to build high and low part firstly,
> >> and then merge them.
> >> In parallel aspect, this sequence would be faster. (Ofcause, using 1 more
> >> register with potential register pressure).

And crucially this patch only uses two registers if can_create_pseudo_p.
Please mention that.

> >>* config/rs6000/rs6000.cc (rs6000_emit_set_long_const): Update 64bit
> >>constant build.

If you don't give details of what this does, just say "Update." please.
But update to what?

"Generate more parallel code if can_create_pseudo_p." maybe?

> >> +rtx H = gen_reg_rtx (DImode);
> >> +rtx L = gen_reg_rtx (DImode);

Please don't use all-uppercase variable names, those are for macros.  In
fact, don't use uppercase in variable (and function etc.) names at all,
unless there is a really good reason to.

Just call it "high" and "low", or "hi" and "lo", or something?

> >> --- /dev/null
> >> +++ b/gcc/testsuite/gcc.target/powerpc/parall_5insn_const.c
> >> @@ -0,0 +1,27 @@
> >> +/* { dg-do run } */
> >> +/* { dg-options "-O2 -mdejagnu-cpu=power7  -save-temps" } */
> >
> > Why do we need power7 here?
> power8/9 are also ok for this case.  Actually, O just want to
> avoid to use new p10 instruction, like "pli", and then selected
> an old arch option.

Why does it need _at least_ p7, is the question (as I understand it).

To prohibit pli etc. you can do -mno-prefixed (which works on all older
CPUs just as well), or skip the test if prefixed insns are enabled, or
scan for the then generated code as well.  The first option is by far
the simplest.

> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/parall_5insn_const.c
> @@ -0,1 +1,27 @@
> +/* { dg-do run } */
> +/* { dg-options "-O2 -mdejagnu-cpu=power8  -save-temps" } */
> +/* { dg-require-effective-target has_arch_ppc64 } */

p8 here makes no sense, we also want good and correct code generated for
older CPUs, so we should not preevent testing on those.  For that reason
you shouldn't use -mcpu= when not needed.  Like here :-)



[committed] libstdc++: Fix orphaned/nested output of configure checks

2022-11-25 Thread Jonathan Wakely via Gcc-patches
Tested x86_64-linux. Pushed to trunk.

-- >8 --

This moves two AC_MSG_RESULT lines for  features so that they
are only printed when the corresponding AC_MSG_CHECKING actually
happened. This fixes configure output like:

checking for uchar.h... no
no
checking for int64_t... yes

Also move the AC_MSG_CHECKING for libbacktrace support so it doesn't
come after AC_CHECK_HEADERS output. This fixes:

checking whether to build libbacktrace support... checking for sys/mman.h... 
(cached) yes
yes

libstdc++-v3/ChangeLog:

* acinclude.m4 (GLIBCXX_CHECK_UCHAR_H): Don't use AC_MSG_RESULT
unless the AC_MSG_CHECKING happened.
* configure: Regenerate.
---
 libstdc++-v3/acinclude.m4 |  6 +++---
 libstdc++-v3/configure| 12 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index baf01913a90..b957c728ba1 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -2060,10 +2060,10 @@ AC_DEFUN([GLIBCXX_CHECK_UCHAR_H], [
   ],
   [], [ac_uchar_c8rtomb_mbrtoc8_fchar8_t=yes],
   [ac_uchar_c8rtomb_mbrtoc8_fchar8_t=no])
+AC_MSG_RESULT($ac_uchar_c8rtomb_mbrtoc8_fchar8_t)
   else
 ac_uchar_c8rtomb_mbrtoc8_fchar8_t=no
   fi
-  AC_MSG_RESULT($ac_uchar_c8rtomb_mbrtoc8_fchar8_t)
   if test x"$ac_uchar_c8rtomb_mbrtoc8_fchar8_t" = x"yes"; then
 AC_DEFINE(_GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_FCHAR8_T, 1,
  [Define if c8rtomb and mbrtoc8 functions in  should be
@@ -2082,10 +2082,10 @@ AC_DEFUN([GLIBCXX_CHECK_UCHAR_H], [
   ],
   [], [ac_uchar_c8rtomb_mbrtoc8_cxx20=yes],
   [ac_uchar_c8rtomb_mbrtoc8_cxx20=no])
+AC_MSG_RESULT($ac_uchar_c8rtomb_mbrtoc8_cxx20)
   else
 ac_uchar_c8rtomb_mbrtoc8_cxx20=no
   fi
-  AC_MSG_RESULT($ac_uchar_c8rtomb_mbrtoc8_cxx20)
   if test x"$ac_uchar_c8rtomb_mbrtoc8_cxx20" = x"yes"; then
 AC_DEFINE(_GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_CXX20, 1,
  [Define if c8rtomb and mbrtoc8 functions in  should be
@@ -5045,6 +5045,7 @@ BACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS 
-DBACKTRACE_ELF_SIZE=$elfsize"
   if test "$enable_libstdcxx_backtrace" = "auto"; then
 enable_libstdcxx_backtrace=no
   fi
+  AC_MSG_RESULT($enable_libstdcxx_backtrace)
   if test "$enable_libstdcxx_backtrace" = "yes"; then
 BACKTRACE_SUPPORTED=1
 
@@ -5091,7 +5092,6 @@ BACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS 
-DBACKTRACE_ELF_SIZE=$elfsize"
 BACKTRACE_USES_MALLOC=0
 BACKTRACE_SUPPORTS_THREADS=0
   fi
-  AC_MSG_RESULT($enable_libstdcxx_backtrace)
   GLIBCXX_CONDITIONAL(ENABLE_BACKTRACE, [test "$enable_libstdcxx_backtrace" = 
yes])
 ])
 
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 31ccff5da0d..1f7017c08a4 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -19215,11 +19215,11 @@ else
   ac_uchar_c8rtomb_mbrtoc8_fchar8_t=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: 
$ac_uchar_c8rtomb_mbrtoc8_fchar8_t" >&5
+$as_echo "$ac_uchar_c8rtomb_mbrtoc8_fchar8_t" >&6; }
   else
 ac_uchar_c8rtomb_mbrtoc8_fchar8_t=no
   fi
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: 
$ac_uchar_c8rtomb_mbrtoc8_fchar8_t" >&5
-$as_echo "$ac_uchar_c8rtomb_mbrtoc8_fchar8_t" >&6; }
   if test x"$ac_uchar_c8rtomb_mbrtoc8_fchar8_t" = x"yes"; then
 
 $as_echo "#define _GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_FCHAR8_T 1" >>confdefs.h
@@ -19253,11 +19253,11 @@ else
   ac_uchar_c8rtomb_mbrtoc8_cxx20=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: 
$ac_uchar_c8rtomb_mbrtoc8_cxx20" >&5
+$as_echo "$ac_uchar_c8rtomb_mbrtoc8_cxx20" >&6; }
   else
 ac_uchar_c8rtomb_mbrtoc8_cxx20=no
   fi
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: 
$ac_uchar_c8rtomb_mbrtoc8_cxx20" >&5
-$as_echo "$ac_uchar_c8rtomb_mbrtoc8_cxx20" >&6; }
   if test x"$ac_uchar_c8rtomb_mbrtoc8_cxx20" = x"yes"; then
 
 $as_echo "#define _GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_CXX20 1" >>confdefs.h
@@ -71212,6 +71212,8 @@ $as_echo_n "checking whether to build libbacktrace 
support... " >&6; }
   if test "$enable_libstdcxx_backtrace" = "auto"; then
 enable_libstdcxx_backtrace=no
   fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: 
$enable_libstdcxx_backtrace" >&5
+$as_echo "$enable_libstdcxx_backtrace" >&6; }
   if test "$enable_libstdcxx_backtrace" = "yes"; then
 BACKTRACE_SUPPORTED=1
 
@@ -71280,8 +71282,6 @@ $as_echo "#define HAVE_STACKTRACE 1" >>confdefs.h
 BACKTRACE_USES_MALLOC=0
 BACKTRACE_SUPPORTS_THREADS=0
   fi
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: 
$enable_libstdcxx_backtrace" >&5
-$as_echo "$enable_libstdcxx_backtrace" >&6; }
 
 
 
-- 
2.38.1



[committed] libstdc++: Call predicate with non-const values in std::erase_if [PR107850]

2022-11-25 Thread Jonathan Wakely via Gcc-patches
Tested x86_64-linux. Pushed to trunk. Backport to gcc-12 needed too.

-- >8 --

As specified in the standard, the predicate for std::erase_if has to be
invocable as non-const with a non-const lvalues argument. Restore
support for predicates that only accept non-const arguments.

It's not strictly nevessary to change it for the set and unordered_set
overloads, because they only give const access to the elements anyway.
I've done it for them too just to keep them all consistent.

libstdc++-v3/ChangeLog:

PR libstdc++/107850
* include/bits/erase_if.h (__erase_nodes_if): Use non-const
reference to the container.
* include/experimental/map (erase_if): Likewise.
* include/experimental/set (erase_if): Likewise.
* include/experimental/unordered_map (erase_if): Likewise.
* include/experimental/unordered_set (erase_if): Likewise.
* include/std/map (erase_if): Likewise.
* include/std/set (erase_if): Likewise.
* include/std/unordered_map (erase_if): Likewise.
* include/std/unordered_set (erase_if): Likewise.
* testsuite/23_containers/map/erasure.cc: Check with
const-incorrect predicate.
* testsuite/23_containers/set/erasure.cc: Likewise.
* testsuite/23_containers/unordered_map/erasure.cc: Likewise.
* testsuite/23_containers/unordered_set/erasure.cc: Likewise.
* testsuite/experimental/map/erasure.cc: Likewise.
* testsuite/experimental/set/erasure.cc: Likewise.
* testsuite/experimental/unordered_map/erasure.cc: Likewise.
* testsuite/experimental/unordered_set/erasure.cc: Likewise.
---
 libstdc++-v3/include/bits/erase_if.h|  2 +-
 libstdc++-v3/include/experimental/map   |  6 ++
 libstdc++-v3/include/experimental/set   |  4 ++--
 libstdc++-v3/include/experimental/unordered_map |  4 ++--
 libstdc++-v3/include/experimental/unordered_set |  4 ++--
 libstdc++-v3/include/std/map|  6 ++
 libstdc++-v3/include/std/set|  4 ++--
 libstdc++-v3/include/std/unordered_map  |  4 ++--
 libstdc++-v3/include/std/unordered_set  |  4 ++--
 libstdc++-v3/testsuite/23_containers/map/erasure.cc | 13 +
 libstdc++-v3/testsuite/23_containers/set/erasure.cc | 13 +
 .../23_containers/unordered_map/erasure.cc  | 13 +
 .../23_containers/unordered_set/erasure.cc  | 13 +
 libstdc++-v3/testsuite/experimental/map/erasure.cc  | 13 +
 libstdc++-v3/testsuite/experimental/set/erasure.cc  | 13 +
 .../testsuite/experimental/unordered_map/erasure.cc | 13 +
 .../testsuite/experimental/unordered_set/erasure.cc | 13 +
 17 files changed, 121 insertions(+), 21 deletions(-)

diff --git a/libstdc++-v3/include/bits/erase_if.h 
b/libstdc++-v3/include/bits/erase_if.h
index 397207f4b56..b336e263d2d 100644
--- a/libstdc++-v3/include/bits/erase_if.h
+++ b/libstdc++-v3/include/bits/erase_if.h
@@ -49,7 +49,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 template
   typename _Container::size_type
-  __erase_nodes_if(_Container& __cont, const _UnsafeContainer& __ucont,
+  __erase_nodes_if(_Container& __cont, _UnsafeContainer& __ucont,
   _Predicate __pred)
   {
typename _Container::size_type __num = 0;
diff --git a/libstdc++-v3/include/experimental/map 
b/libstdc++-v3/include/experimental/map
index 525252b83c1..9557a2aec1c 100644
--- a/libstdc++-v3/include/experimental/map
+++ b/libstdc++-v3/include/experimental/map
@@ -53,8 +53,7 @@ inline namespace fundamentals_v2
 inline void
 erase_if(map<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred)
 {
-  const _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Alloc>&
-   __ucont = __cont;
+  _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Alloc>& __ucont = __cont;
   std::__detail::__erase_nodes_if(__cont, __ucont, __pred);
 }
 
@@ -63,8 +62,7 @@ inline namespace fundamentals_v2
 inline void
 erase_if(multimap<_Key, _Tp, _Compare, _Alloc>& __cont, _Predicate __pred)
 {
-  const _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Alloc>&
-   __ucont = __cont;
+  _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Alloc>& __ucont = __cont;
   std::__detail::__erase_nodes_if(__cont, __ucont, __pred);
 }
 
diff --git a/libstdc++-v3/include/experimental/set 
b/libstdc++-v3/include/experimental/set
index b42a3cdcf1a..7d142e081d9 100644
--- a/libstdc++-v3/include/experimental/set
+++ b/libstdc++-v3/include/experimental/set
@@ -53,7 +53,7 @@ inline namespace fundamentals_v2
 inline void
 erase_if(set<_Key, _Compare, _Alloc>& __cont, _Predicate __pred)
 {
-  const _GLIBCXX_STD_C::set<_Key, _Compare, _Alloc>& __ucont = __cont;
+  _GLIBCXX_STD_C::set<_Key, _Compare, _Alloc>& __ucont = __cont;
   std::__detail::__erase_nodes_if(__cont, __ucont, 

[committed] libstdc++: Do not define operator!= in for C++20

2022-11-25 Thread Jonathan Wakely via Gcc-patches
Tested x86_64-linux. Pushed to trunk.

-- >8 --

These overloads are not needed in C++20 as they can be synthesized by
the compiler. Removing them means less code to compile when including
these headers.

libstdc++-v3/ChangeLog:

* include/bits/random.h [three_way_comparison] (operator!=):
Do not define inequality operators when C++20 three way
comparisons are supported.
* include/ext/random [three_way_comparison] (operator!=):
Likewise.
---
 libstdc++-v3/include/bits/random.h | 106 -
 libstdc++-v3/include/ext/random|  72 
 2 files changed, 148 insertions(+), 30 deletions(-)

diff --git a/libstdc++-v3/include/bits/random.h 
b/libstdc++-v3/include/bits/random.h
index 28b37a9e5a5..3b4e7d42bb5 100644
--- a/libstdc++-v3/include/bits/random.h
+++ b/libstdc++-v3/include/bits/random.h
@@ -423,6 +423,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   _UIntType _M_x;
 };
 
+#if __cpp_impl_three_way_comparison < 201907L
   /**
* @brief Compares two linear congruential random number generator
* objects of the same type for inequality.
@@ -441,7 +442,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   const std::linear_congruential_engine<_UIntType, __a,
   __c, __m>& __rhs)
 { return !(__lhs == __rhs); }
-
+#endif
 
   /**
* A generalized feedback shift register discrete random number generator.
@@ -656,6 +657,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   size_t_M_p;
 };
 
+#if __cpp_impl_three_way_comparison < 201907L
   /**
* @brief Compares two % mersenne_twister_engine random number generator
*objects of the same type for inequality.
@@ -679,7 +681,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   const std::mersenne_twister_engine<_UIntType, __w, __n, __m,
   __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __rhs)
 { return !(__lhs == __rhs); }
-
+#endif
 
   /**
* @brief The Marsaglia-Zaman generator.
@@ -862,6 +864,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   size_t _M_p; ///< Current index of x(i - r).
 };
 
+#if __cpp_impl_three_way_comparison < 201907L
   /**
* @brief Compares two % subtract_with_carry_engine random number
*generator objects of the same type for inequality.
@@ -881,7 +884,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   const std::subtract_with_carry_engine<_UIntType, __w,
   __s, __r>& __rhs)
 { return !(__lhs == __rhs); }
-
+#endif
 
   /**
* Produces random numbers from some base engine by discarding blocks of
@@ -1087,6 +1090,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   size_t _M_n;
 };
 
+#if __cpp_impl_three_way_comparison < 201907L
   /**
* @brief Compares two %discard_block_engine random number generator
*objects of the same type for inequality.
@@ -1105,7 +1109,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   const std::discard_block_engine<_RandomNumberEngine, __p,
   __r>& __rhs)
 { return !(__lhs == __rhs); }
-
+#endif
 
   /**
* Produces random numbers by combining random numbers from some base
@@ -1284,6 +1288,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   _RandomNumberEngine _M_b;
 };
 
+#if __cpp_impl_three_way_comparison < 201907L
   /**
* @brief Compares two %independent_bits_engine random number generator
* objects of the same type for inequality.
@@ -1303,6 +1308,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   const std::independent_bits_engine<_RandomNumberEngine, __w,
   _UIntType>& __rhs)
 { return !(__lhs == __rhs); }
+#endif
 
   /**
* @brief Inserts the current state of a %independent_bits_engine random
@@ -1541,6 +1547,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   result_type _M_y;
 };
 
+#if __cpp_impl_three_way_comparison < 201907L
   /**
* Compares two %shuffle_order_engine random number generator objects
* of the same type for inequality.
@@ -1559,7 +1566,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   const std::shuffle_order_engine<_RandomNumberEngine,
   __k>& __rhs)
 { return !(__lhs == __rhs); }
-
+#endif
 
   /**
* The classic Minimum Standard rand0 of Lewis, Goodman, and Miller.
@@ -1703,6 +1710,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   // std::uniform_int_distribution is defined in 
 
+#if __cpp_impl_three_way_comparison < 201907L
   /**
* @brief Return true if two uniform integer distributions have
*different parameters.
@@ -1712,6 +1720,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 operator!=(const std::uniform_int_distribution<_IntType>& __d1,
   const std::uniform_int_distribution<_IntType>& __d2)
 { return !(__d1 == __d2); }
+#endif
 
   /**
* @brief Inserts a %uniform_int_distribution random number
@@ -1786,9 +1795,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator==(const param_type& __p1, const param_type& __p2)
{ return __p1._M_a == __p2._M_a && __p1._M_b 

[committed] libstdc++: Add always_inline to trivial iterator operations

2022-11-25 Thread Jonathan Wakely via Gcc-patches
Tested x86_64-linux. Pushed to trunk.

-- >8 --

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator_base_funcs.h (__distance):
Add always_inline attribute to overload for random
access iterators.
(advance, distance, next, prev): Add always_inline attribute to
inline functions that just forward to another function.
---
 libstdc++-v3/include/bits/stl_iterator_base_funcs.h | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/include/bits/stl_iterator_base_funcs.h 
b/libstdc++-v3/include/bits/stl_iterator_base_funcs.h
index 1551b226ff4..25dddb3e7e8 100644
--- a/libstdc++-v3/include/bits/stl_iterator_base_funcs.h
+++ b/libstdc++-v3/include/bits/stl_iterator_base_funcs.h
@@ -94,6 +94,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
 }
 
   template
+__attribute__((__always_inline__))
 inline _GLIBCXX14_CONSTEXPR
 typename iterator_traits<_RandomAccessIterator>::difference_type
 __distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
@@ -141,7 +142,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
*  and are constant time.  For other %iterator classes they are linear time.
   */
   template
-_GLIBCXX_NODISCARD
+_GLIBCXX_NODISCARD __attribute__((__always_inline__))
 inline _GLIBCXX17_CONSTEXPR
 typename iterator_traits<_InputIterator>::difference_type
 distance(_InputIterator __first, _InputIterator __last)
@@ -214,6 +215,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
*  and are constant time.  For other %iterator classes they are linear time.
   */
   template
+__attribute__((__always_inline__))
 inline _GLIBCXX17_CONSTEXPR void
 advance(_InputIterator& __i, _Distance __n)
 {
@@ -225,7 +227,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
 #if __cplusplus >= 201103L
 
   template
-_GLIBCXX_NODISCARD
+_GLIBCXX_NODISCARD [[__gnu__::__always_inline__]]
 inline _GLIBCXX17_CONSTEXPR _InputIterator
 next(_InputIterator __x, typename
 iterator_traits<_InputIterator>::difference_type __n = 1)
@@ -237,7 +239,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
 }
 
   template
-_GLIBCXX_NODISCARD
+_GLIBCXX_NODISCARD [[__gnu__::__always_inline__]]
 inline _GLIBCXX17_CONSTEXPR _BidirectionalIterator
 prev(_BidirectionalIterator __x, typename
 iterator_traits<_BidirectionalIterator>::difference_type __n = 1) 
-- 
2.38.1



Re: [PATCH V2] rs6000: Support to build constants by li/lis+oris/xoris

2022-11-25 Thread Segher Boessenkool
Hi guys,

On Fri, Nov 25, 2022 at 04:11:49PM +0800, Kewen.Lin wrote:
> on 2022/10/26 19:40, Jiufu Guo wrote:
> for "li/lis + oris/xoris", I interpreted it into four combinations:
> 
>li + oris, lis + oris, li + xoris, lis + xoris.
> 
> not sure just me interpreting like that, but the actual combinations
> which this patch adopts are:
> 
>li + oris, li + xoris, lis + xoris.
> 
> It's a bit off, but not a big deal, up to you to reword it or not.  :)

The first two are obvious, but the last one is almost never a good idea,
there usually are better ways to do the same.  I cannot even think of
any case where this is best?  A lis;rl* is always prefered (it can
optimise better, be combined with other insns).

> > +  HOST_WIDE_INT orig_c = c;

If you ever feel you need a variable to hold an "orig" value, that is a
good hint that you should restructure the code a bit, perhaps even
factor it.  That often is overdue (like here), not caused by you, but
you could help solve it ;-)

(This is what made this patch hard to review, btw).

> > gen_rtx_IOR (DImode, copy_rtx (temp),
> >  GEN_INT (ud1)));
> >  }
> > +  else if ((ud4 == 0x && ud3 == 0x)
> > +  && ((ud1 & 0x8000) || (ud1 == 0 && !(ud2 & 0x8000
> > +{
> > +  temp = !can_create_pseudo_p () ? dest : gen_reg_rtx (DImode);
> > +
> > +  HOST_WIDE_INT imm = (ud1 & 0x8000) ? ((ud1 ^ 0x8000) - 0x8000)
> > +: ((ud2 << 16) - 0x8000);

We really should have some "hwi::sign_extend (ud1, 16)" helper function,
heh.  Maybe there already is?  Ah, "sext_hwi".  Fixing that up
everywhere in this function is preapproved.

> > +  else
> > +   {
> > + emit_move_insn (temp,
> > + GEN_INT (((ud2 << 16) ^ 0x8000) - 0x8000));
> > + if (ud1 != 0)
> > +   emit_move_insn (temp, gen_rtx_IOR (DImode, temp, GEN_INT (ud1)));
> > + emit_move_insn (dest,
> > + gen_rtx_ZERO_EXTEND (DImode,
> > +  gen_lowpart (SImode, temp)));
> > +   }

Why this?  Please just write it in DImode, do not go via SImode?

> > --- /dev/null
> > +++ b/gcc/testsuite/gcc.target/powerpc/pr106708.h
> > @@ -0,0 +1,9 @@
> > +/* Test constants which can be built by li/lis + oris/xoris */
> > +void  __attribute__ ((__noinline__, __noclone__)) foo (long long *arg)
> > +{
> > +  *arg++ = 0x98765432ULL;
> > +  *arg++ = 0x7cdeab55ULL;
> > +  *arg++ = 0x6543ULL;
> > +}

Use noipa please (it is shorter, simpler, and covers more :-) )

Could you comment what exact instructions are expected?
li;xoris and li;xoris and lis;xoris I guess?  It helps if you just tell
the reader here.

The li;oris and li;xoris parts look good.


Segher


[PATCH] sync libsframe toplevel from binutils-gdb

2022-11-25 Thread Richard Earnshaw via Gcc-patches

This pulls in the toplevel portion of this binutils-gdb commit:
   19e559f1c91bfaedbd2f91d85ee161f3f03fda3c libsframe: add the SFrame library

ChangeLog:
* Makefile.def: Add libsframe as new module with its dependencies.
* Makefile.in: Regenerated.
* configure.ac: Add libsframe to host_libs.
* configure: Regenerated.
---
 Makefile.def |2 +
 Makefile.in  | 1288 +-
 configure|2 +-
 configure.ac |2 +-
 4 files changed, 1287 insertions(+), 7 deletions(-)

diff --git a/Makefile.def b/Makefile.def
index 02e63c57177..83ae77586ad 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -145,6 +145,7 @@ host_modules= { module= lto-plugin; bootstrap=true;
 host_modules= { module= libcc1; extra_configure_flags=--enable-shared; };
 host_modules= { module= gotools; };
 host_modules= { module= libctf; bootstrap=true; };
+host_modules= { module= libsframe; bootstrap=true; };
 
 target_modules = { module= libstdc++-v3;
 		   bootstrap=true;
@@ -470,6 +471,7 @@ dependencies = { module=all-binutils; on=all-intl; };
 dependencies = { module=all-binutils; on=all-gas; };
 dependencies = { module=all-binutils; on=all-libctf; };
 dependencies = { module=all-ld; on=all-libctf; };
+dependencies = { module=all-binutils; on=all-libsframe; };
 
 // We put install-opcodes before install-binutils because the installed
 // binutils might be on PATH, and they might need the shared opcodes
diff --git a/Makefile.in b/Makefile.in
index 6ffa9660c25..e5bed1bea3a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1097,7 +1097,8 @@ configure-host:  \
 maybe-configure-lto-plugin \
 maybe-configure-libcc1 \
 maybe-configure-gotools \
-maybe-configure-libctf
+maybe-configure-libctf \
+maybe-configure-libsframe
 .PHONY: configure-target
 configure-target:  \
 maybe-configure-target-libstdc++-v3 \
@@ -1273,6 +1274,9 @@ all-host: maybe-all-gotools
 @if libctf-no-bootstrap
 all-host: maybe-all-libctf
 @endif libctf-no-bootstrap
+@if libsframe-no-bootstrap
+all-host: maybe-all-libsframe
+@endif libsframe-no-bootstrap
 
 .PHONY: all-target
 
@@ -1384,6 +1388,7 @@ info-host: maybe-info-lto-plugin
 info-host: maybe-info-libcc1
 info-host: maybe-info-gotools
 info-host: maybe-info-libctf
+info-host: maybe-info-libsframe
 
 .PHONY: info-target
 
@@ -1472,6 +1477,7 @@ dvi-host: maybe-dvi-lto-plugin
 dvi-host: maybe-dvi-libcc1
 dvi-host: maybe-dvi-gotools
 dvi-host: maybe-dvi-libctf
+dvi-host: maybe-dvi-libsframe
 
 .PHONY: dvi-target
 
@@ -1560,6 +1566,7 @@ pdf-host: maybe-pdf-lto-plugin
 pdf-host: maybe-pdf-libcc1
 pdf-host: maybe-pdf-gotools
 pdf-host: maybe-pdf-libctf
+pdf-host: maybe-pdf-libsframe
 
 .PHONY: pdf-target
 
@@ -1648,6 +1655,7 @@ html-host: maybe-html-lto-plugin
 html-host: maybe-html-libcc1
 html-host: maybe-html-gotools
 html-host: maybe-html-libctf
+html-host: maybe-html-libsframe
 
 .PHONY: html-target
 
@@ -1736,6 +1744,7 @@ TAGS-host: maybe-TAGS-lto-plugin
 TAGS-host: maybe-TAGS-libcc1
 TAGS-host: maybe-TAGS-gotools
 TAGS-host: maybe-TAGS-libctf
+TAGS-host: maybe-TAGS-libsframe
 
 .PHONY: TAGS-target
 
@@ -1824,6 +1833,7 @@ install-info-host: maybe-install-info-lto-plugin
 install-info-host: maybe-install-info-libcc1
 install-info-host: maybe-install-info-gotools
 install-info-host: maybe-install-info-libctf
+install-info-host: maybe-install-info-libsframe
 
 .PHONY: install-info-target
 
@@ -1912,6 +1922,7 @@ install-dvi-host: maybe-install-dvi-lto-plugin
 install-dvi-host: maybe-install-dvi-libcc1
 install-dvi-host: maybe-install-dvi-gotools
 install-dvi-host: maybe-install-dvi-libctf
+install-dvi-host: maybe-install-dvi-libsframe
 
 .PHONY: install-dvi-target
 
@@ -2000,6 +2011,7 @@ install-pdf-host: maybe-install-pdf-lto-plugin
 install-pdf-host: maybe-install-pdf-libcc1
 install-pdf-host: maybe-install-pdf-gotools
 install-pdf-host: maybe-install-pdf-libctf
+install-pdf-host: maybe-install-pdf-libsframe
 
 .PHONY: install-pdf-target
 
@@ -2088,6 +2100,7 @@ install-html-host: maybe-install-html-lto-plugin
 install-html-host: maybe-install-html-libcc1
 install-html-host: maybe-install-html-gotools
 install-html-host: maybe-install-html-libctf
+install-html-host: maybe-install-html-libsframe
 
 .PHONY: install-html-target
 
@@ -2176,6 +2189,7 @@ installcheck-host: maybe-installcheck-lto-plugin
 installcheck-host: maybe-installcheck-libcc1
 installcheck-host: maybe-installcheck-gotools
 installcheck-host: maybe-installcheck-libctf
+installcheck-host: maybe-installcheck-libsframe
 
 .PHONY: installcheck-target
 
@@ -2264,6 +2278,7 @@ mostlyclean-host: maybe-mostlyclean-lto-plugin
 mostlyclean-host: maybe-mostlyclean-libcc1
 mostlyclean-host: maybe-mostlyclean-gotools
 mostlyclean-host: maybe-mostlyclean-libctf
+mostlyclean-host: maybe-mostlyclean-libsframe
 
 .PHONY: mostlyclean-target
 
@@ -2352,6 +2367,7 @@ clean-host: maybe-clean-lto-plugin
 clean-host: maybe-clean-libcc1
 clean-host: maybe-clean-gotools
 clean-host: 

Fix resolution streaming with incremental linking

2022-11-25 Thread Jan Hubicka via Gcc-patches
Hi,
this patch fixes streaming of resolution info when flag_incremental_link
== INCREMENTAL_LINK_NOLTO.  Here we want to stream the info from WPA to
ltrans as usual.

Bootstrapped/regtested x86_64-linux, tested with kernel LTO builds.
Plan to commit it later today.

Honza

* gcc/lto-cgraph.cc (lto_output_node): Only drop resolution info when
flag_incremental_link === INCREMENTAL_LINK_LTO.
diff --git a/gcc/lto-cgraph.cc b/gcc/lto-cgraph.cc
index 350195d86db..ff7669d0c4b 100644
--- a/gcc/lto-cgraph.cc
+++ b/gcc/lto-cgraph.cc
@@ -563,7 +563,7 @@ lto_output_node (struct lto_simple_output_block *ob, struct 
cgraph_node *node,
LDPR_NUM_KNOWN,
/* When doing incremental link, we will get new resolution
   info next time we process the file.  */
-   flag_incremental_link ? LDPR_UNKNOWN : node->resolution);
+   flag_incremental_link == INCREMENTAL_LINK_LTO ? LDPR_UNKNOWN : 
node->resolution);
   bp_pack_value (, node->split_part, 1);
   streamer_write_bitpack ();
   streamer_write_data_stream (ob->main_stream, section, strlen (section) + 1);


[PING][PATCH] RISC-V: Avoid redundant sign-extension for SImode SGE, SGEU, SLE, SLEU

2022-11-25 Thread Maciej W. Rozycki
Hi Kito,

On Fri, 12 Aug 2022, Maciej W. Rozycki wrote:

> > LGTM, but with a nit, I don't get set.w but get an andi like below, so
> > maybe we should also scan-assembler-not andi? feel free to commit that
> > directly with that fix
> > 
> > ```asm
> > sleu:
> >sgtua0,a0,a1# 9 [c=4 l=4]  *sgtu_disi
> >xoria0,a0,1 # 10[c=4 l=4]  *xorsi3_internal/1
> >andia0,a0,1 # 16[c=4 l=4]  anddi3/1
> >ret # 25[c=0 l=4]  simple_return
> > ```
> 
>  Interesting.  I can do that, but can you please share the compilation 
> options, given or defaulted (from `--with...' configuration options), this 
> happens with?

 I have noticed it went nowhere.  Can you please check what compilation 
options lead to this discrepancy so that we can have the fix included in 
GCC 13?  I'd like to understand what's going on here.

  Maciej


Re: [PATCH]rs6000: Load high and low part of 64bit constant independently

2022-11-25 Thread Jiufu Guo via Gcc-patches
Jiufu Guo via Gcc-patches  writes:

> Hi Kewen,
>
> Thanks for your review on this patch!
>
> "Kewen.Lin"  writes:
>
>> Hi Jeff,
>>
>> Sorry for the late review.
>>
>> on 2022/9/15 16:30, Jiufu Guo wrote:
>>> Hi,
>>> 
>>> For a complicate 64bit constant, blow is one instruction-sequence to
>>> build:
>>> lis 9,0x800a
>>> ori 9,9,0xabcd
>>> sldi 9,9,32
>>> oris 9,9,0xc167
>>> ori 9,9,0xfa16
>>> 
>>> while we can also use below sequence to build:
>>> lis 9,0xc167
>>> lis 10,0x800a
>>> ori 9,9,0xfa16
>>> ori 10,10,0xabcd
>>> rldimi 9,10,32,0
>>> This sequence is using 2 registers to build high and low part firstly,
>>> and then merge them.
>>> In parallel aspect, this sequence would be faster. (Ofcause, using 1 more
>>> register with potential register pressure).
>>> 
>>> Bootstrap and regtest pass on ppc64le.
>>> Is this ok for trunk?
>>> 
>>> 
>>> BR,
>>> Jeff(Jiufu)
>>> 
>>> 
>>> gcc/ChangeLog:
>>> 
>>> * config/rs6000/rs6000.cc (rs6000_emit_set_long_const): Update 64bit
>>> constant build.
>>> 
>>> gcc/testsuite/ChangeLog:
>>> 
>>> * gcc.target/powerpc/parall_5insn_const.c: New test.
>>> 
>>> ---
cut...
> @@ -0,1 +1,27 @@
> +/* { dg-do run } */
> +/* { dg-options "-O2 -mdejagnu-cpu=power8  -save-temps" } */
maybe, I could use power7.  Any comments?
> +/* { dg-require-effective-target has_arch_ppc64 } */
> +
> +/* { dg-final { scan-assembler-times {\mlis\M} 4 } } */
> +/* { dg-final { scan-assembler-times {\mori\M} 4 } } */
> +/* { dg-final { scan-assembler-times {\mrldimi\M} 2 } } */
> +
> +void __attribute__ ((noinline)) foo (unsigned long long *a)
> +{
> +  /* 2 lis + 2 ori + 1 rldimi for each constant.  */
> +  *a++ = 0x800aabcdc167fa16ULL;
> +  *a++ = 0x7543a876867f616ULL;
> +}
> +
> +long long A[] = {0x800aabcdc167fa16ULL, 0x7543a876867f616ULL};
> +int
> +main ()
> +{
> +  long long res[2];
> +
> +  foo (res);
> +  if (__builtin_memcmp (res, A, sizeof (res)) != 0)
> +__builtin_abort ();
> +
> +  return 0;
> +}


Re: [PATCH] tree-optimization/107672 - avoid vector mode type_for_mode call

2022-11-25 Thread Vaseeharan Vinayagamoorthy via Gcc-patches
Hi,


I am seeing an internal compiler error, related to this patch:



during GIMPLE pass: slp

options-save.cc: In function 'void cl_optimization_restore(gcc_options*, 
gcc_options*, cl_optimization*)':

options-save.cc:1292:1: internal compiler error: in 
supportable_widening_operation, at tree-vect-stmts.cc:12199


 1292 | cl_optimization_restore (struct gcc_options *opts, struct gcc_options 
*opts_set,

 | ^~~

/…/src/gcc/gcc/profile-count.cc: In member function 'int 
profile_count::to_cgraph_frequency(profile_count) const':

/…/src/gcc/gcc/profile-count.cc:308:1: note: parameter passing for argument of 
type 'profile_count' changed in GCC 9.1

 308 | profile_count::to_cgraph_frequency (profile_count entry_bb_count) const

 | ^

/…/src/gcc/gcc/profile-count.cc: In member function 'sreal 
profile_count::to_sreal_scale(profile_count, bool*) const':

/…/src/gcc/gcc/profile-count.cc:326:1: note: parameter passing for argument of 
type 'profile_count' changed in GCC 9.1

 326 | profile_count::to_sreal_scale (profile_count in, bool *known) const

 | ^

0x2195bdd supportable_widening_operation(vec_info*, tree_code, _stmt_vec_info*, 
tree_node*, tree_node*, tree_code*, tree_code*, int*, vec*)

 /…/src/gcc/gcc/tree-vect-stmts.cc:12199

0x2180493 vectorizable_conversion

 /…/src/gcc/gcc/tree-vect-stmts.cc:5064

0x2192fdd vect_analyze_stmt(vec_info*, _stmt_vec_info*, bool*, _slp_tree*, 
_slp_instance*, vec*)

 /…/src/gcc/gcc/tree-vect-stmts.cc:11256


/…/src/gcc/gcc/profile-count.cc: In member function 'profile_count 
profile_count::combine_with_ipa_count(profile_count)':

/…/src/gcc/gcc/profile-count.cc:398:1: note: parameter passing for argument of 
type 'profile_count' changed in GCC 9.1

 398 | profile_count::combine_with_ipa_count (profile_count ipa)

 | ^

0x14f95d1 vect_slp_analyze_node_operations_1

 /…/src/gcc/gcc/tree-vect-slp.cc:5958

0x14f9c19 vect_slp_analyze_node_operations

 /…/src/gcc/gcc/tree-vect-slp.cc:6147

0x14f9b4d vect_slp_analyze_node_operations

 /…/src/gcc/gcc/tree-vect-slp.cc:6126

0x14fa439 vect_slp_analyze_operations(vec_info*)

 /…/src/gcc/gcc/tree-vect-slp.cc:6387

0x14fd423 vect_slp_analyze_bb_1

 /…/src/gcc/gcc/tree-vect-slp.cc:7372

0x14fd599 vect_slp_region

 /…/src/gcc/gcc/tree-vect-slp.cc:7419

0x14fe0d1 vect_slp_bbs

 /…/src/gcc/gcc/tree-vect-slp.cc:7610

0x14fe46f vect_slp_function(function*)

 /…/src/gcc/gcc/tree-vect-slp.cc:7698

0x151a109 execute

 /…/src/gcc/gcc/tree-vectorizer.cc:1532

Please submit a full bug report, with preprocessed source (by using 
-freport-bug).

Please include the complete backtrace with any bug report.

See  for instructions.

Makefile:1146: recipe for target 'options-save.o' failed

make[3]: *** [options-save.o] Error 1


That happens when building the arm-none-linux-gnueabihf toolchain natively with 
glibc bootstrap:
Build:arm-none-linux-gnueabihf
Host:arm-none-linux-gnueabihf
Target: arm-none-linux-gnueabihf

The compiler being used to build the toolchain is gcc 7.5.0.


Kind regards
Vasee

From: Gcc-patches  on behalf 
of Richard Biener via Gcc-patches 
Sent: 22 November 2022 08:48
To: gcc-patches@gcc.gnu.org 
Subject: [PATCH] tree-optimization/107672 - avoid vector mode type_for_mode call

The following avoids using type_for_mode on vector modes which might
not work for all frontends.  Instead we look for the inner mode
type and use build_vector_type_for_mode instead.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

PR tree-optimization/107672
* tree-vect-stmts.cc (supportable_widening_operation): Avoid
type_for_mode on vector modes.
---
 gcc/tree-vect-stmts.cc | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index bc0ef136f19..b35b986889d 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -12195,9 +12195,15 @@ supportable_widening_operation (vec_info *vinfo,
 intermediate_type
   = vect_halve_mask_nunits (prev_type, intermediate_mode);
   else
-   intermediate_type
- = lang_hooks.types.type_for_mode (intermediate_mode,
-   TYPE_UNSIGNED (prev_type));
+   {
+ gcc_assert (VECTOR_MODE_P (intermediate_mode));
+ tree intermediate_element_type
+   = lang_hooks.types.type_for_mode (GET_MODE_INNER 
(intermediate_mode),
+ TYPE_UNSIGNED (prev_type));
+ intermediate_type
+   = build_vector_type_for_mode (intermediate_element_type,
+ intermediate_mode);
+   }

   if (VECTOR_BOOLEAN_TYPE_P (intermediate_type)
   && VECTOR_BOOLEAN_TYPE_P (prev_type)
--
2.35.3


Re: [PATCH v2 06/11] OpenMP: lvalue parsing for map clauses (C++)

2022-11-25 Thread Jakub Jelinek via Gcc-patches
On Tue, Nov 08, 2022 at 02:36:17PM +, Julian Brown wrote:
> @@ -3258,6 +3273,7 @@ c_omp_address_inspector::get_origin (tree t)
>  || TREE_CODE (t) == SAVE_EXPR)
>   t = TREE_OPERAND (t, 0);
>else if (TREE_CODE (t) == INDIRECT_REF
> +&& TREE_TYPE (TREE_OPERAND (t, 0))
>  && TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) == REFERENCE_TYPE)
>   t = TREE_OPERAND (t, 0);
>else
> @@ -3274,7 +3290,9 @@ c_omp_address_inspector::get_origin (tree t)
>  tree
>  c_omp_address_inspector::maybe_unconvert_ref (tree t)
>  {
> +  /* The TREE_TYPE can be null if we had an earlier error.  */
>if (TREE_CODE (t) == INDIRECT_REF
> +  && TREE_TYPE (TREE_OPERAND (t, 0))
>&& TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) == REFERENCE_TYPE)
>  return TREE_OPERAND (t, 0);
>  

I'd prefer avoiding changes like the above.
If we had an earlier error, it should be error_mark_node or have
error_mark_node type, not NULL.
NULL type means something different in the C++ FE, in particular that
something is type dependent and the type will be only figured out after
instantiation.

Other than that LGTM.

Jakub



Re: [PATCH]rs6000: Load high and low part of 64bit constant independently

2022-11-25 Thread Jiufu Guo via Gcc-patches
Hi Kewen,

Thanks for your review on this patch!

"Kewen.Lin"  writes:

> Hi Jeff,
>
> Sorry for the late review.
>
> on 2022/9/15 16:30, Jiufu Guo wrote:
>> Hi,
>> 
>> For a complicate 64bit constant, blow is one instruction-sequence to
>> build:
>>  lis 9,0x800a
>>  ori 9,9,0xabcd
>>  sldi 9,9,32
>>  oris 9,9,0xc167
>>  ori 9,9,0xfa16
>> 
>> while we can also use below sequence to build:
>>  lis 9,0xc167
>>  lis 10,0x800a
>>  ori 9,9,0xfa16
>>  ori 10,10,0xabcd
>>  rldimi 9,10,32,0
>> This sequence is using 2 registers to build high and low part firstly,
>> and then merge them.
>> In parallel aspect, this sequence would be faster. (Ofcause, using 1 more
>> register with potential register pressure).
>> 
>> Bootstrap and regtest pass on ppc64le.
>> Is this ok for trunk?
>> 
>> 
>> BR,
>> Jeff(Jiufu)
>> 
>> 
>> gcc/ChangeLog:
>> 
>>  * config/rs6000/rs6000.cc (rs6000_emit_set_long_const): Update 64bit
>>  constant build.
>> 
>> gcc/testsuite/ChangeLog:
>> 
>>  * gcc.target/powerpc/parall_5insn_const.c: New test.
>> 
>> ---
>>  gcc/config/rs6000/rs6000.cc   | 45 +++
>>  .../gcc.target/powerpc/parall_5insn_const.c   | 27 +++
>>  2 files changed, 53 insertions(+), 19 deletions(-)
>>  create mode 100644 gcc/testsuite/gcc.target/powerpc/parall_5insn_const.c
>> 
>> diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
>> index a656cb32a47..759c6309677 100644
>> --- a/gcc/config/rs6000/rs6000.cc
>> +++ b/gcc/config/rs6000/rs6000.cc
>> @@ -10180,26 +10180,33 @@ rs6000_emit_set_long_const (rtx dest, 
>> HOST_WIDE_INT c)
>>  }
>>else
>>  {
>> -  temp = !can_create_pseudo_p () ? dest : gen_reg_rtx (DImode);
>> -
>> -  emit_move_insn (copy_rtx (temp),
>> -  GEN_INT (((ud4 << 16) ^ 0x8000) - 0x8000));
>> -  if (ud3 != 0)
>> -emit_move_insn (copy_rtx (temp),
>> -gen_rtx_IOR (DImode, copy_rtx (temp),
>> - GEN_INT (ud3)));
>> +  if (can_create_pseudo_p ())
>> +{
>> +  /* lis A,U4; ori A,U3; lis B,U2; ori B,U1; rldimi A,B,32,0.  */
>
> Nit: A, B are supposed to be H, L?
Yes, thanks for this catch! It should be
/* lis H,U4; ori H,U3; lis L,U2; ori L,U1; rldimi L,H,32,0.  */
>
>> +  rtx H = gen_reg_rtx (DImode);
>> +  rtx L = gen_reg_rtx (DImode);
>> +  HOST_WIDE_INT num = (ud2 << 16) | ud1;
>> +  rs6000_emit_set_long_const (L, (num ^ 0x8000) - 0x8000);
>> +  num = (ud4 << 16) | ud3;
>> +  rs6000_emit_set_long_const (H, (num ^ 0x8000) - 0x8000);
>> +  emit_insn (gen_rotldi3_insert_3 (dest, H, GEN_INT (32), L,
>> +   GEN_INT (0x)));
>> +}
>> +  else
>> +{
>> +  /* lis A, U4; ori A,U3; rotl A,32; oris A,U2; ori A,U1.  */
>~~~ unexpected space?
Thanks for the catch!
>
>> +  emit_move_insn (dest,
>> +  GEN_INT (((ud4 << 16) ^ 0x8000) - 0x8000));
>> +  if (ud3 != 0)
>> +emit_move_insn (dest, gen_rtx_IOR (DImode, dest, GEN_INT (ud3)));
>> 
>> -  emit_move_insn (ud2 != 0 || ud1 != 0 ? copy_rtx (temp) : dest,
>> -  gen_rtx_ASHIFT (DImode, copy_rtx (temp),
>> -  GEN_INT (32)));
>> -  if (ud2 != 0)
>> -emit_move_insn (ud1 != 0 ? copy_rtx (temp) : dest,
>> -gen_rtx_IOR (DImode, copy_rtx (temp),
>> - GEN_INT (ud2 << 16)));
>> -  if (ud1 != 0)
>> -emit_move_insn (dest,
>> -gen_rtx_IOR (DImode, copy_rtx (temp),
>> - GEN_INT (ud1)));
>> +  emit_move_insn (dest, gen_rtx_ASHIFT (DImode, dest, GEN_INT (32)));
>> +  if (ud2 != 0)
>> +emit_move_insn (dest,
>> +gen_rtx_IOR (DImode, dest, GEN_INT (ud2 << 16)));
>> +  if (ud1 != 0)
>> +emit_move_insn (dest, gen_rtx_IOR (DImode, dest, GEN_INT (ud1)));
>> +}
>>  }
>>  }
>> 
>> diff --git a/gcc/testsuite/gcc.target/powerpc/parall_5insn_const.c 
>> b/gcc/testsuite/gcc.target/powerpc/parall_5insn_const.c
>> new file mode 100644
>> index 000..ed8ccc73378
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.target/powerpc/parall_5insn_const.c
>> @@ -0,0 +1,27 @@
>> +/* { dg-do run } */
>> +/* { dg-options "-O2 -mdejagnu-cpu=power7  -save-temps" } */
>
> Why do we need power7 here?
power8/9 are also ok for this case.  Actually, O just want to
avoid to use new p10 instruction, like "pli", and then selected
an old arch option.

>
>> +/* { dg-require-effective-target has_arch_ppc64 } */
>> +
>> +/* { dg-final { scan-assembler-times {\mlis\M} 4 } } */
>> +/* { dg-final { scan-assembler-times {\mori\M} 4 } } */
>> +/* { dg-final { scan-assembler-times {\mrldimi\M} 2 } } */
>> +
>> +void __attribute__ ((noinline)) foo (unsigned long long *a)
>> +{
>> +  /* 2lis+2ori+1rldimi for each constant.  */
>

Re: [PATCH] tree-optimization/106912 - IPA profile and pure/const

2022-11-25 Thread Jan Hubicka via Gcc-patches
> On Fri, 25 Nov 2022, Jan Hubicka wrote:
> 
> > > 
> > > 
> > > > Am 25.11.2022 um 11:05 schrieb Jan Hubicka via Gcc-patches 
> > > > :
> > > > 
> > > > 
> > > >> 
> > > >> IPA profile instrumentation tries to clear the pure and const
> > > >> flags of functions but that's quite hopeless in particular for
> > > >> const since that attribute prevails on the type and thus on each
> > > >> call to the function leading to inconsistencies in the IL and
> > > >> eventual checking ICEs.  There's no good reason to do this and
> > > >> it wouldn't fixup any indirect calls so just don't.  No other
> > > >> instrumentation GCC does bothers about this.
> > > > 
> > > > This was mostly meant to deadl with situation where we auto-detect
> > > > function to be const and then partially inline it to a loop.
> > > > Then both caller and callee accesses same counters in the memory and if
> > > > you move load/stores out of the loop in caller you lose counters and get
> > > > inconsistencies at profile read-in time.
> > > 
> > > Don?t we Instrument after partial inlining now?  As said, since we have 
> > > the fntype on the call this doesn?t work anymore for const functions via 
> > > attributes.
> > 
> > Full inlining can cause problem already.  So for code like
> > 
> > do
> > {
> >   if (__builtin_expect (test,1))
> > a+=foo (a);
> >   else
> > a+=foo (b);
> > } while ();
> > we may end up inlining one of the two invocation. Then caller and callee
> > will modify the same counter.  If we handle the remaining call as const,
> > we can hoist the counter modifications out of the loop and mix them up.
> >
> > I remember I run into an actual example of this problem during GCC
> > bootstrap. There the function was auto-detected to be const by
> > early pure-const pass so type was not an problem. You are right we ought
> > to do something about types since the scenario above can happen with foo
> > being declared with an attribute as well.
> 
> Or by doing the first call as
> 
> volatile int __attribute__((const)) (*foop)(int) = foo;
> 
>   a += (*foop) (a);
> 
> you'd need to get all calls that might possibly call an instrumented
> function adjusted.
> 
> I think if we're taking this issue serious we'd have to simply
> ignore const/pure attributes at parsing time and refrain from
> auto-detecting as well, at least for address-taken functions?

I think that is also not a good idea, since we would have to do that
with -fprofile-use, too (so the CFG at the instrumentation time
matches) and it would lead to poor perofrmance with FDO.
The idea was to honor pure/const during early opt and undo the
attributes when profiling is inserted.
We have fixup_cfg to compensate for attribute changes.  We could
probably keep tract if any instrumented code was ever inlined into a
given function and perhaps just start ignoring attributes set on types?

Honza
> 
> That said, this adjustment in the "wrong" direction causes problems
> downstream, which is what the fixed PR is about (simd cloning picks
> up the wrong things, or rather possibly fails to clone the attributes?).
> 
> Richard.
> 
> > Honza
> > > 
> > > Richard 
> > > > Honza
> > > >> 
> > > >> Bootstrap and regtest pending on x86_64-unknown-linux-gnu, OK?
> > > >> 
> > > >> Thanks,
> > > >> Richard.
> > > >> 
> > > >>PR tree-optimization/106912
> > > >>* tree-profile.cc (tree_profiling): Do not clear pure/const
> > > >>flags.
> > > >> 
> > > >>* gcc.dg/pr106912.c: New testcase.
> > > >> ---
> > > >> gcc/testsuite/gcc.dg/pr106912.c | 16 
> > > >> gcc/tree-profile.cc |  3 ---
> > > >> 2 files changed, 16 insertions(+), 3 deletions(-)
> > > >> create mode 100644 gcc/testsuite/gcc.dg/pr106912.c
> > > >> 
> > > >> diff --git a/gcc/testsuite/gcc.dg/pr106912.c 
> > > >> b/gcc/testsuite/gcc.dg/pr106912.c
> > > >> new file mode 100644
> > > >> index 000..8faa877d8b3
> > > >> --- /dev/null
> > > >> +++ b/gcc/testsuite/gcc.dg/pr106912.c
> > > >> @@ -0,0 +1,16 @@
> > > >> +/* { dg-do compile } */
> > > >> +/* { dg-options "-O2 -fPIC -ftree-vectorize -fprofile-generate" } */
> > > >> +
> > > >> +__attribute__ ((__simd__))
> > > >> +__attribute__ ((__nothrow__ , __leaf__ , __const__))
> > > >> +double foo (double x);
> > > >> +void bar(double *f, int n)
> > > >> +{
> > > >> +  int i;
> > > >> +  for (i = 0; i < n; i++)
> > > >> +f[i] = foo(f[i]);
> > > >> +}
> > > >> +double foo(double x)
> > > >> +{
> > > >> +  return x * x / 3.0;
> > > >> +}
> > > >> diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc
> > > >> index 2beb49241f2..5491b398870 100644
> > > >> --- a/gcc/tree-profile.cc
> > > >> +++ b/gcc/tree-profile.cc
> > > >> @@ -814,9 +814,6 @@ tree_profiling (void)
> > > >>/* Don't profile functions produced for builtin stuff.  */
> > > >>if (DECL_SOURCE_LOCATION (node->decl) == BUILTINS_LOCATION)
> > > >>  continue;
> > > >> -
> > > >> -node->set_const_flag (false, false);
> > > >> -node->set_pure_flag 

Re: [PATCH] tree-optimization/106912 - IPA profile and pure/const

2022-11-25 Thread Richard Biener via Gcc-patches
On Fri, 25 Nov 2022, Jan Hubicka wrote:

> > 
> > 
> > > Am 25.11.2022 um 11:05 schrieb Jan Hubicka via Gcc-patches 
> > > :
> > > 
> > > 
> > >> 
> > >> IPA profile instrumentation tries to clear the pure and const
> > >> flags of functions but that's quite hopeless in particular for
> > >> const since that attribute prevails on the type and thus on each
> > >> call to the function leading to inconsistencies in the IL and
> > >> eventual checking ICEs.  There's no good reason to do this and
> > >> it wouldn't fixup any indirect calls so just don't.  No other
> > >> instrumentation GCC does bothers about this.
> > > 
> > > This was mostly meant to deadl with situation where we auto-detect
> > > function to be const and then partially inline it to a loop.
> > > Then both caller and callee accesses same counters in the memory and if
> > > you move load/stores out of the loop in caller you lose counters and get
> > > inconsistencies at profile read-in time.
> > 
> > Don?t we Instrument after partial inlining now?  As said, since we have the 
> > fntype on the call this doesn?t work anymore for const functions via 
> > attributes.
> 
> Full inlining can cause problem already.  So for code like
> 
> do
> {
>   if (__builtin_expect (test,1))
> a+=foo (a);
>   else
> a+=foo (b);
> } while ();
> we may end up inlining one of the two invocation. Then caller and callee
> will modify the same counter.  If we handle the remaining call as const,
> we can hoist the counter modifications out of the loop and mix them up.
>
> I remember I run into an actual example of this problem during GCC
> bootstrap. There the function was auto-detected to be const by
> early pure-const pass so type was not an problem. You are right we ought
> to do something about types since the scenario above can happen with foo
> being declared with an attribute as well.

Or by doing the first call as

volatile int __attribute__((const)) (*foop)(int) = foo;

  a += (*foop) (a);

you'd need to get all calls that might possibly call an instrumented
function adjusted.

I think if we're taking this issue serious we'd have to simply
ignore const/pure attributes at parsing time and refrain from
auto-detecting as well, at least for address-taken functions?

That said, this adjustment in the "wrong" direction causes problems
downstream, which is what the fixed PR is about (simd cloning picks
up the wrong things, or rather possibly fails to clone the attributes?).

Richard.

> Honza
> > 
> > Richard 
> > > Honza
> > >> 
> > >> Bootstrap and regtest pending on x86_64-unknown-linux-gnu, OK?
> > >> 
> > >> Thanks,
> > >> Richard.
> > >> 
> > >>PR tree-optimization/106912
> > >>* tree-profile.cc (tree_profiling): Do not clear pure/const
> > >>flags.
> > >> 
> > >>* gcc.dg/pr106912.c: New testcase.
> > >> ---
> > >> gcc/testsuite/gcc.dg/pr106912.c | 16 
> > >> gcc/tree-profile.cc |  3 ---
> > >> 2 files changed, 16 insertions(+), 3 deletions(-)
> > >> create mode 100644 gcc/testsuite/gcc.dg/pr106912.c
> > >> 
> > >> diff --git a/gcc/testsuite/gcc.dg/pr106912.c 
> > >> b/gcc/testsuite/gcc.dg/pr106912.c
> > >> new file mode 100644
> > >> index 000..8faa877d8b3
> > >> --- /dev/null
> > >> +++ b/gcc/testsuite/gcc.dg/pr106912.c
> > >> @@ -0,0 +1,16 @@
> > >> +/* { dg-do compile } */
> > >> +/* { dg-options "-O2 -fPIC -ftree-vectorize -fprofile-generate" } */
> > >> +
> > >> +__attribute__ ((__simd__))
> > >> +__attribute__ ((__nothrow__ , __leaf__ , __const__))
> > >> +double foo (double x);
> > >> +void bar(double *f, int n)
> > >> +{
> > >> +  int i;
> > >> +  for (i = 0; i < n; i++)
> > >> +f[i] = foo(f[i]);
> > >> +}
> > >> +double foo(double x)
> > >> +{
> > >> +  return x * x / 3.0;
> > >> +}
> > >> diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc
> > >> index 2beb49241f2..5491b398870 100644
> > >> --- a/gcc/tree-profile.cc
> > >> +++ b/gcc/tree-profile.cc
> > >> @@ -814,9 +814,6 @@ tree_profiling (void)
> > >>/* Don't profile functions produced for builtin stuff.  */
> > >>if (DECL_SOURCE_LOCATION (node->decl) == BUILTINS_LOCATION)
> > >>  continue;
> > >> -
> > >> -node->set_const_flag (false, false);
> > >> -node->set_pure_flag (false, false);
> > >>   }
> > >> 
> > >>   /* Update call statements and rebuild the cgraph.  */
> > >> -- 
> > >> 2.35.3
> 

-- 
Richard Biener 
SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg,
Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman;
HRB 36809 (AG Nuernberg)


[PATCH] i386: fix assert (__builtin_cpu_supports ("x86-64") >= 0)

2022-11-25 Thread Martin Liška
Similar story as PR103661, we again return a negative number
for __builtin_cpu_supports:

Documentation says:

int __builtin_cpu_supports(const char *feature)
This function returns a positive integer if the run-time CPU supports feature 
and returns 0 otherwise.
while we return -2147483648.

Moreover, I noticed "x86-64" is not a valid option for __builtin_cpu_is,
but for __builtin_cpu_supports.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

PR target/107551

gcc/ChangeLog:

* config/i386/i386-builtins.cc (fold_builtin_cpu): Use same path
as for PR103661.
* doc/extend.texi: Fix "x86-64" use.

gcc/testsuite/ChangeLog:

* gcc.target/i386/builtin_target.c: Add more checks.
---
 gcc/config/i386/i386-builtins.cc  | 25 ---
 gcc/doc/extend.texi   | 22 
 .../gcc.target/i386/builtin_target.c  |  5 
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/gcc/config/i386/i386-builtins.cc b/gcc/config/i386/i386-builtins.cc
index eacdf072244..c57c1380298 100644
--- a/gcc/config/i386/i386-builtins.cc
+++ b/gcc/config/i386/i386-builtins.cc
@@ -2181,18 +2181,14 @@ fold_builtin_cpu (tree fndecl, tree *args)
  varpool_node::add (ix86_cpu_features2_var);
}
 
+ /* Skip __cpu_features[0].  */
  feature -= INT_TYPE_SIZE;
- field_val = 1U << (feature % INT_TYPE_SIZE);
  tree index = size_int (feature / INT_TYPE_SIZE);
+ feature = feature % INT_TYPE_SIZE;
  array_elt = build4 (ARRAY_REF, unsigned_type_node,
  ix86_cpu_features2_var,
  index, NULL_TREE, NULL_TREE);
  /* Return __cpu_features2[index] & field_val  */
- final = build2 (BIT_AND_EXPR, unsigned_type_node,
- array_elt,
- build_int_cstu (unsigned_type_node,
- field_val));
- return build1 (NOP_EXPR, integer_type_node, final);
}
   else
{
@@ -2209,16 +2205,17 @@ fold_builtin_cpu (tree fndecl, tree *args)
  array_elt = build4 (ARRAY_REF, unsigned_type_node, ref,
  integer_zero_node, NULL_TREE, NULL_TREE);
 
- field_val = (1U << feature);
  /* Return __cpu_model.__cpu_features[0] & field_val  */
- final = build2 (BIT_AND_EXPR, unsigned_type_node, array_elt,
- build_int_cstu (unsigned_type_node, field_val));
- if (feature == (INT_TYPE_SIZE - 1))
-   return build2 (NE_EXPR, integer_type_node, final,
-  build_int_cst (unsigned_type_node, 0));
- else
-   return build1 (NOP_EXPR, integer_type_node, final);
}
+
+  field_val = (1U << feature);
+  final = build2 (BIT_AND_EXPR, unsigned_type_node, array_elt,
+ build_int_cstu (unsigned_type_node, field_val));
+  if (feature == (INT_TYPE_SIZE - 1))
+   return build2 (NE_EXPR, integer_type_node, final,
+  build_int_cst (unsigned_type_node, 0));
+  else
+   return build1 (NOP_EXPR, integer_type_node, final);
 }
   gcc_unreachable ();
 }
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index b1dd39e64b8..d3812fa55b0 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -21897,18 +21897,6 @@ AMD Family 19h Zen version 3.
 
 @item znver4
 AMD Family 19h Zen version 4.
-
-@item x86-64
-Baseline x86-64 microarchitecture level (as defined in x86-64 psABI).
-
-@item x86-64-v2
-x86-64-v2 microarchitecture level.
-
-@item x86-64-v3
-x86-64-v3 microarchitecture level.
-
-@item x86-64-v4
-x86-64-v4 microarchitecture level.
 @end table
 
 Here is an example:
@@ -22002,6 +21990,16 @@ VPCLMULQDQ instructions.
 AVX512VNNI instructions.
 @item avx512bitalg
 AVX512BITALG instructions.
+@item x86-64
+Baseline x86-64 microarchitecture level (as defined in x86-64 psABI).
+@item x86-64-v2
+x86-64-v2 microarchitecture level.
+@item x86-64-v3
+x86-64-v3 microarchitecture level.
+@item x86-64-v4
+x86-64-v4 microarchitecture level.
+
+
 @end table
 
 Here is an example:
diff --git a/gcc/testsuite/gcc.target/i386/builtin_target.c 
b/gcc/testsuite/gcc.target/i386/builtin_target.c
index 3e7505a8c3a..fff643c13b0 100644
--- a/gcc/testsuite/gcc.target/i386/builtin_target.c
+++ b/gcc/testsuite/gcc.target/i386/builtin_target.c
@@ -95,6 +95,11 @@ quick_check ()
 
   assert (__builtin_cpu_supports ("avx512vpopcntdq") >= 0);
 
+  assert (__builtin_cpu_supports ("x86-64") >= 0);
+  assert (__builtin_cpu_supports ("x86-64-v2") >= 0);
+  assert (__builtin_cpu_supports ("x86-64-v3") >= 0);
+  assert (__builtin_cpu_supports ("x86-64-v4") >= 0);
+
   /* Check CPU type.  */
   assert (__builtin_cpu_is ("amd") >= 0);
 
-- 
2.38.1



Re: [PATCH V2] rs6000: Support to build constants by li/lis+oris/xoris

2022-11-25 Thread Jiufu Guo via Gcc-patches


Hi Kewen,

Thanks a lot for your insight comments!

"Kewen.Lin"  writes:

> Hi Jeff,
>
> Sorry for the late reply.
>
> on 2022/10/26 19:40, Jiufu Guo wrote:
>> Hi,
>> 
>> PR106708 constaint some constants which can be support by li/lis + 
>> oris/xoris.
> typo?
Oh, typo!
>
> for "li/lis + oris/xoris", I interpreted it into four combinations:
>
>li + oris, lis + oris, li + xoris, lis + xoris.
>
> not sure just me interpreting like that, but the actual combinations
> which this patch adopts are:
>
>li + oris, li + xoris, lis + xoris.
>
> It's a bit off, but not a big deal, up to you to reword it or not.  :)
Oh, thanks! I will update to use "li/lis + xoris" or "li + oris" to
avoid confuse.
>
>> 
>> For constant C:
>> if '(c & 0x80008000ULL) == 0x8000ULL' or say:
>> 32(0) || 1(1) || 15(x) || 1(0) || 15(x), we could use li+oris to
>> build constant 'C'.
>> Here N(M) means N continuous bit M, x for M means it is ok for either
>> 1 or 0; '||' means concatenation.
>> 
>> if '(c & 0x8000ULL) == 0x8000ULL' or say:
>> 32(1) || 16(x) || 1(1) || 15(x), using li+xoris would be ok.
>> 
>> if '(c & 0xULL) == 0x' or say:
>> 32(1) || 1(0) || 15(x) || 16(0), using lis+xoris would be ok.
>> 
>> This patch update rs6000_emit_set_long_const to support these forms.
>> Bootstrap and regtest pass on ppc64 and ppc64le.
>> 
>> Is this ok for trunk?
>
> This updated version looks good to me, but I'd leave it to Segher for the
> final say.  Thanks!

Thanks!

BR,
Jeff (Jiufu)
>
> BR,
> Kewen
>
>> 
>> BR,
>> Jeff(Jiufu)
>> 
>> 
>>  PR target/106708
>> 
>> gcc/ChangeLog:
>> 
>>  * config/rs6000/rs6000.cc (rs6000_emit_set_long_const): Support
>>  constants which can be built with li + oris or li/lis + xoris.
>> 
>> gcc/testsuite/ChangeLog:
>> 
>>  * gcc.target/powerpc/pr106708-run.c: New test.
>>  * gcc.target/powerpc/pr106708.c: New test.
>>  * gcc.target/powerpc/pr106708.h: New file.
>> 
>> ---
>>  gcc/config/rs6000/rs6000.cc   | 41 ++-
>>  .../gcc.target/powerpc/pr106708-run.c | 17 
>>  gcc/testsuite/gcc.target/powerpc/pr106708.c   | 12 ++
>>  gcc/testsuite/gcc.target/powerpc/pr106708.h   |  9 
>>  4 files changed, 69 insertions(+), 10 deletions(-)
>>  create mode 100644 gcc/testsuite/gcc.target/powerpc/pr106708-run.c
>>  create mode 100644 gcc/testsuite/gcc.target/powerpc/pr106708.c
>>  create mode 100644 gcc/testsuite/gcc.target/powerpc/pr106708.h
>> 
>> diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
>> index d2743f7bce6..9b7a51f052d 100644
>> --- a/gcc/config/rs6000/rs6000.cc
>> +++ b/gcc/config/rs6000/rs6000.cc
>> @@ -10228,6 +10228,7 @@ rs6000_emit_set_long_const (rtx dest, HOST_WIDE_INT 
>> c)
>>  {
>>rtx temp;
>>HOST_WIDE_INT ud1, ud2, ud3, ud4;
>> +  HOST_WIDE_INT orig_c = c;
>> 
>>ud1 = c & 0x;
>>c = c >> 16;
>> @@ -10253,21 +10254,41 @@ rs6000_emit_set_long_const (rtx dest, 
>> HOST_WIDE_INT c)
>>  gen_rtx_IOR (DImode, copy_rtx (temp),
>>   GEN_INT (ud1)));
>>  }
>> +  else if ((ud4 == 0x && ud3 == 0x)
>> +   && ((ud1 & 0x8000) || (ud1 == 0 && !(ud2 & 0x8000
>> +{
>> +  temp = !can_create_pseudo_p () ? dest : gen_reg_rtx (DImode);
>> +
>> +  HOST_WIDE_INT imm = (ud1 & 0x8000) ? ((ud1 ^ 0x8000) - 0x8000)
>> + : ((ud2 << 16) - 0x8000);
>> +  /* li/lis + xoris */
>> +  emit_move_insn (temp, GEN_INT (imm));
>> +  emit_move_insn (dest, gen_rtx_XOR (DImode, temp,
>> + GEN_INT (orig_c ^ imm)));
>> +}
>>else if (ud3 == 0 && ud4 == 0)
>>  {
>>temp = !can_create_pseudo_p () ? dest : gen_reg_rtx (DImode);
>> 
>>gcc_assert (ud2 & 0x8000);
>> -  emit_move_insn (copy_rtx (temp),
>> -  GEN_INT (((ud2 << 16) ^ 0x8000) - 0x8000));
>> -  if (ud1 != 0)
>> -emit_move_insn (copy_rtx (temp),
>> -gen_rtx_IOR (DImode, copy_rtx (temp),
>> - GEN_INT (ud1)));
>> -  emit_move_insn (dest,
>> -  gen_rtx_ZERO_EXTEND (DImode,
>> -   gen_lowpart (SImode,
>> -copy_rtx (temp;
>> +
>> +  if (!(ud1 & 0x8000))
>> +{
>> +  /* li+oris */
>> +  emit_move_insn (temp, GEN_INT (ud1));
>> +  emit_move_insn (dest,
>> +  gen_rtx_IOR (DImode, temp, GEN_INT (ud2 << 16)));
>> +}
>> +  else
>> +{
>> +  emit_move_insn (temp,
>> +  GEN_INT (((ud2 << 16) ^ 0x8000) - 0x8000));
>> +  if (ud1 != 0)
>> +emit_move_insn (temp, gen_rtx_IOR (DImode, temp, GEN_INT (ud1)));
>> +  emit_move_insn (dest,
>> +  gen_rtx_ZERO_EXTEND (DImode,
>> + 

Re: [PATCH V2] Use subscalar mode to move struct block for parameter

2022-11-25 Thread Jiufu Guo via Gcc-patches
Jiufu Guo via Gcc-patches  writes:

> Hi Richard,
>
> Thanks a lot for your comments!
>
> Richard Biener  writes:
>
>> On Wed, 23 Nov 2022, Jiufu Guo wrote:
>>
>>> Hi Jeff,
>>> 
>>> Thanks a lot for your comments!
>>
>> Sorry for the late response ...
>>
>>> Jeff Law  writes:
>>> 
>>> > On 11/20/22 20:07, Jiufu Guo wrote:
>>> >> Jiufu Guo  writes:
>>> >>
>>> >>> Hi,
>>> >>>
>>> >>> As mentioned in the previous version patch:
>>> >>> https://gcc.gnu.org/pipermail/gcc-patches/2022-October/604646.html
>>> >>> The suboptimal code is generated for "assigning from parameter" or
>>> >>> "assigning to return value".
>>> >>> This patch enhances the assignment from parameters like the below
>>> >>> cases:
>>> >>> /case1.c
cut...
>>> >> +  FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR_FOR_FN (cfun)->preds)
>>> >> +if (greturn *ret = safe_dyn_cast (last_stmt 
>>> >> (e->src)))
>>> >> +  {
>>> >> +tree val = gimple_return_retval (ret);
>>> >> +if (val && VAR_P (val))
>>> >> +  DECL_USEDBY_RETURN_P (val) = 1;
>>
>> you probably want to check && auto_var_in_fn (val, ...) since val
>> might be global?
> Since we are collecting the return vals, it would be built in function
> gimplify_return_expr.  In this function, create_tmp_reg is used and
> a local temp.  So it would not be a global var here.
>
> code piece in gimplify_return_expr:
>   if (!result_decl)
> result = NULL_TREE;
>   else if (aggregate_value_p (result_decl, TREE_TYPE (current_function_decl)))
> {
> 
>   result = result_decl;
> }
>   else if (gimplify_ctxp->return_temp)
> result = gimplify_ctxp->return_temp;
>   else
> {
>   result = create_tmp_reg (TREE_TYPE (result_decl));
>
> Here, for "typedef struct SA {double a[3];}", aggregate_value_p returns
> false for target like ppc64le, because result of "hard_function_value"
> is a "rtx with PARALLELL code".
> And then a DECL_VAR is built via "create_tmp_reg" (actually it is not a
> reg here. it built a DECL_VAR with RECORD type and BLK mode).
>
> I also tried the way to use RESULT_DECL for this kind of type, or
> let aggregate_value_p accept this kind of type.  But it seems not easy,
> because " (RESULT_DECL with PARALLEL)" is not ok for address
> operations.
>
>
>>
>>> >> +  }
>>> >> +}
>>> >> +
>>> >> /* Set TREE_USED on all variables in the local_decls.  */
>>> >> FOR_EACH_LOCAL_DECL (cfun, i, var)
>>> >>   TREE_USED (var) = 1;
>>> >> diff --git a/gcc/expr.cc b/gcc/expr.cc
>>> >> index d9407432ea5..20973649963 100644
>>> >> --- a/gcc/expr.cc
>>> >> +++ b/gcc/expr.cc
>>> >> @@ -6045,6 +6045,52 @@ expand_assignment (tree to, tree from, bool 
>>> >> nontemporal)
>>> >> return;
>>> >>   }
>>
>> I miss an explanatory comment here on that the following is heuristics
>> and its reasoning.
>>
>>> >>   +  if ((TREE_CODE (from) == PARM_DECL && DECL_INCOMING_RTL (from)
>>> >> +   && TYPE_MODE (TREE_TYPE (from)) == BLKmode
>>
>> Why check TYPE_MODE here?  Do you want AGGREGATE_TYPE_P on the type
>> instead?
> Checking BLK, because I want make sure the param should occur on
> register and stack (saved from register).
> Actualy, my intention is checking:
> GET_MODE (DECL_INCOMING_RTL (from)) == BLKmode
>
> For code:
> GET_MODE (DECL_INCOMING_RTL (from)) == BLKmode
> && (GET_CODE (DECL_INCOMING_RTL (from)) == PARALLEL
> || REG_P (DECL_INCOMING_RTL (from)))
> This checking indicates if the param may be passing via 2 or more
> registers.
>
> Using "AGGREGATE_TYPE_P && (PARALLEL || REG_P)" may be ok and more
> readable. I would have a test.
Oh, AGGREGATE_TYPE_P seems not the intention of this patch, since if
struct size can be represented by an INT size, the mode would be that
INT mode, and no need to use block move for the assignment.

BR,
Jeff (Jiufu)
>
>>
>>> >> +   && (GET_CODE (DECL_INCOMING_RTL (from)) == PARALLEL
>>> >> +   || REG_P (DECL_INCOMING_RTL (from
>>> >> +  || (VAR_P (to) && DECL_USEDBY_RETURN_P (to)
>>> >> +  && TYPE_MODE (TREE_TYPE (to)) == BLKmode
>>
>> Likewise.
>>
>>> >> +  && GET_CODE (DECL_RTL (DECL_RESULT (current_function_decl)))
>>> >> +   == PARALLEL))
>>
>> Not REG_P here?
> REG_P with BLK on return would means return in memory, instead return
> through registers, so, REG_P was not added here, and let it use
> orignal behavior.
>>
>>> >> +{
>>> >> +  push_temp_slots ();
>>> >> +  rtx par_ret;
>>> >> +  machine_mode mode;
>>> >> +  par_ret = TREE_CODE (from) == PARM_DECL
>>> >> +  ? DECL_INCOMING_RTL (from)
>>> >> +  : DECL_RTL (DECL_RESULT (current_function_decl));
>>> >> +  mode = GET_CODE (par_ret) == PARALLEL
>>> >> +   ? GET_MODE (XEXP (XVECEXP (par_ret, 0, 0), 0))
>>> >> +   : word_mode;
>>> >> +  int mode_size = GET_MODE_SIZE (mode).to_constant ();
>>> >> +  int size = INTVAL (expr_size (from));
>>> >> +
>>> >> +  /* If/How 

Re: [PATCH] tree-optimization/106912 - IPA profile and pure/const

2022-11-25 Thread Jan Hubicka via Gcc-patches
> 
> 
> > Am 25.11.2022 um 11:05 schrieb Jan Hubicka via Gcc-patches 
> > :
> > 
> > 
> >> 
> >> IPA profile instrumentation tries to clear the pure and const
> >> flags of functions but that's quite hopeless in particular for
> >> const since that attribute prevails on the type and thus on each
> >> call to the function leading to inconsistencies in the IL and
> >> eventual checking ICEs.  There's no good reason to do this and
> >> it wouldn't fixup any indirect calls so just don't.  No other
> >> instrumentation GCC does bothers about this.
> > 
> > This was mostly meant to deadl with situation where we auto-detect
> > function to be const and then partially inline it to a loop.
> > Then both caller and callee accesses same counters in the memory and if
> > you move load/stores out of the loop in caller you lose counters and get
> > inconsistencies at profile read-in time.
> 
> Don’t we Instrument after partial inlining now?  As said, since we have the 
> fntype on the call this doesn’t work anymore for const functions via 
> attributes.

Full inlining can cause problem already.  So for code like

do
{
  if (__builtin_expect (test,1))
a+=foo (a);
  else
a+=foo (b);
} while ();
we may end up inlining one of the two invocation. Then caller and callee
will modify the same counter.  If we handle the remaining call as const,
we can hoist the counter modifications out of the loop and mix them up.

I remember I run into an actual example of this problem during GCC
bootstrap. There the function was auto-detected to be const by
early pure-const pass so type was not an problem. You are right we ought
to do something about types since the scenario above can happen with foo
being declared with an attribute as well.

Honza
> 
> Richard 
> > Honza
> >> 
> >> Bootstrap and regtest pending on x86_64-unknown-linux-gnu, OK?
> >> 
> >> Thanks,
> >> Richard.
> >> 
> >>PR tree-optimization/106912
> >>* tree-profile.cc (tree_profiling): Do not clear pure/const
> >>flags.
> >> 
> >>* gcc.dg/pr106912.c: New testcase.
> >> ---
> >> gcc/testsuite/gcc.dg/pr106912.c | 16 
> >> gcc/tree-profile.cc |  3 ---
> >> 2 files changed, 16 insertions(+), 3 deletions(-)
> >> create mode 100644 gcc/testsuite/gcc.dg/pr106912.c
> >> 
> >> diff --git a/gcc/testsuite/gcc.dg/pr106912.c 
> >> b/gcc/testsuite/gcc.dg/pr106912.c
> >> new file mode 100644
> >> index 000..8faa877d8b3
> >> --- /dev/null
> >> +++ b/gcc/testsuite/gcc.dg/pr106912.c
> >> @@ -0,0 +1,16 @@
> >> +/* { dg-do compile } */
> >> +/* { dg-options "-O2 -fPIC -ftree-vectorize -fprofile-generate" } */
> >> +
> >> +__attribute__ ((__simd__))
> >> +__attribute__ ((__nothrow__ , __leaf__ , __const__))
> >> +double foo (double x);
> >> +void bar(double *f, int n)
> >> +{
> >> +  int i;
> >> +  for (i = 0; i < n; i++)
> >> +f[i] = foo(f[i]);
> >> +}
> >> +double foo(double x)
> >> +{
> >> +  return x * x / 3.0;
> >> +}
> >> diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc
> >> index 2beb49241f2..5491b398870 100644
> >> --- a/gcc/tree-profile.cc
> >> +++ b/gcc/tree-profile.cc
> >> @@ -814,9 +814,6 @@ tree_profiling (void)
> >>/* Don't profile functions produced for builtin stuff.  */
> >>if (DECL_SOURCE_LOCATION (node->decl) == BUILTINS_LOCATION)
> >>  continue;
> >> -
> >> -node->set_const_flag (false, false);
> >> -node->set_pure_flag (false, false);
> >>   }
> >> 
> >>   /* Update call statements and rebuild the cgraph.  */
> >> -- 
> >> 2.35.3


Re: [PATCH] tree-optimization/106912 - IPA profile and pure/const

2022-11-25 Thread Richard Biener via Gcc-patches



> Am 25.11.2022 um 11:05 schrieb Jan Hubicka via Gcc-patches 
> :
> 
> 
>> 
>> IPA profile instrumentation tries to clear the pure and const
>> flags of functions but that's quite hopeless in particular for
>> const since that attribute prevails on the type and thus on each
>> call to the function leading to inconsistencies in the IL and
>> eventual checking ICEs.  There's no good reason to do this and
>> it wouldn't fixup any indirect calls so just don't.  No other
>> instrumentation GCC does bothers about this.
> 
> This was mostly meant to deadl with situation where we auto-detect
> function to be const and then partially inline it to a loop.
> Then both caller and callee accesses same counters in the memory and if
> you move load/stores out of the loop in caller you lose counters and get
> inconsistencies at profile read-in time.

Don’t we Instrument after partial inlining now?  As said, since we have the 
fntype on the call this doesn’t work anymore for const functions via attributes.

Richard 
> Honza
>> 
>> Bootstrap and regtest pending on x86_64-unknown-linux-gnu, OK?
>> 
>> Thanks,
>> Richard.
>> 
>>PR tree-optimization/106912
>>* tree-profile.cc (tree_profiling): Do not clear pure/const
>>flags.
>> 
>>* gcc.dg/pr106912.c: New testcase.
>> ---
>> gcc/testsuite/gcc.dg/pr106912.c | 16 
>> gcc/tree-profile.cc |  3 ---
>> 2 files changed, 16 insertions(+), 3 deletions(-)
>> create mode 100644 gcc/testsuite/gcc.dg/pr106912.c
>> 
>> diff --git a/gcc/testsuite/gcc.dg/pr106912.c 
>> b/gcc/testsuite/gcc.dg/pr106912.c
>> new file mode 100644
>> index 000..8faa877d8b3
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.dg/pr106912.c
>> @@ -0,0 +1,16 @@
>> +/* { dg-do compile } */
>> +/* { dg-options "-O2 -fPIC -ftree-vectorize -fprofile-generate" } */
>> +
>> +__attribute__ ((__simd__))
>> +__attribute__ ((__nothrow__ , __leaf__ , __const__))
>> +double foo (double x);
>> +void bar(double *f, int n)
>> +{
>> +  int i;
>> +  for (i = 0; i < n; i++)
>> +f[i] = foo(f[i]);
>> +}
>> +double foo(double x)
>> +{
>> +  return x * x / 3.0;
>> +}
>> diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc
>> index 2beb49241f2..5491b398870 100644
>> --- a/gcc/tree-profile.cc
>> +++ b/gcc/tree-profile.cc
>> @@ -814,9 +814,6 @@ tree_profiling (void)
>>/* Don't profile functions produced for builtin stuff.  */
>>if (DECL_SOURCE_LOCATION (node->decl) == BUILTINS_LOCATION)
>>  continue;
>> -
>> -node->set_const_flag (false, false);
>> -node->set_pure_flag (false, false);
>>   }
>> 
>>   /* Update call statements and rebuild the cgraph.  */
>> -- 
>> 2.35.3


Re: [PATCH v4] OpenMP: Generate SIMD clones for functions with "declare target"

2022-11-25 Thread Jakub Jelinek via Gcc-patches
On Mon, Nov 14, 2022 at 09:46:15PM -0700, Sandra Loosemore wrote:
> --- a/gcc/omp-simd-clone.cc
> +++ b/gcc/omp-simd-clone.cc
> @@ -51,6 +51,210 @@ along with GCC; see the file COPYING3.  If not see
>  #include "stringpool.h"
>  #include "attribs.h"
>  #include "omp-simd-clone.h"
> +#include "omp-low.h"
> +#include "omp-general.h"
> +
> +/* Print debug info for ok_for_auto_simd_clone to the dump file, logging
> +   failure reason EXCUSE for function DECL.  Always returns false.  */
> +static bool
> +auto_simd_fail (tree decl, const char *excuse)
> +{
> +  if (dump_file && (dump_flags & TDF_DETAILS))
> +fprintf (dump_file, "\nNot auto-cloning %s because %s\n",
> +  IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
> +  excuse);
> +  return false;
> +}
> +
> +/* Helper function for ok_for_auto_simd_clone; return false if the statement
> +   violates restrictions for an "omp declare simd" function.  Specifically,
> +   the function must not
> +   - throw or call setjmp/longjmp
> +   - write memory that could alias parallel calls
> +   - read volatile memory
> +   - include openmp directives or calls
> +   - call functions that might do those things */
> +
> +static bool
> +auto_simd_check_stmt (gimple *stmt, tree outer)
> +{
> +  tree decl;
> +
> +  switch (gimple_code (stmt))
> +{
> +case GIMPLE_CALL:
> +
> +  /* Calls to functions that are CONST or PURE are ok, even if they
> +  are internal functions without a decl.  Reject other internal
> +  functions.  */
> +  if (gimple_call_flags (stmt) & (ECF_CONST | ECF_PURE))
> + break;
> +  if (gimple_call_internal_p (stmt))
> + return auto_simd_fail (outer,
> +"body contains internal function call");

Just a note, this kind of building sentences from separate parts is
not ok for translations, but in the fprintf case the string isn't translated
anyway, so it is ok in this case.  But if we wanted to emit a
warning/inform, it wouldn't be.

The patch LGTM, thanks.

Jakub



Re: [Patch] libgomp: Add no-target-region rev offload test + fix plugin-nvptx

2022-11-25 Thread Jakub Jelinek via Gcc-patches
On Thu, Nov 24, 2022 at 06:48:01PM +0100, Tobias Burnus wrote:
> libgomp: Add no-target-region rev offload test + fix plugin-nvptx
> 
> OpenMP permits that a 'target device(ancestor:1)' is called without being
> enclosed in a target region - using the current device (i.e. the host) in
> that case.  This commit adds a testcase for this.
> 
> In case of nvptx, the missing on-device 'GOMP_target_ext' call causes that
> it and also the associated on-device GOMP_REV_OFFLOAD_VAR variable are not
> linked in from nvptx's libgomp.a. Thus, handle the failing cuModuleGetGlobal
> gracefully by disabling reverse offload and assuming that the failure is fine.
> 
> libgomp/ChangeLog:
> 
>   * plugin/plugin-nvptx.c (GOMP_OFFLOAD_load_image): Use unsigned int
>   for 'i' to match 'fn_entries'; regard absent GOMP_REV_OFFLOAD_VAR
>   as valid and the code having no reverse-offload code.
>   * testsuite/libgomp.c-c++-common/reverse-offload-2.c: New test.

Ok, thanks.

Jakub



[PING] nvptx: stack size limits are relevant for execution only (was: [PATCH, testsuite] Add effective target stack_size)

2022-11-25 Thread Thomas Schwinge
Hi!

Ping.


Grüße
 Thomas


On 2022-11-08T21:29:49+0100, I wrote:
> Hi!
>
> On 2017-06-09T16:24:30+0200, Tom de Vries  wrote:
>> The patch defines an effective target stack_size, which is used in
>> individual test-cases to add -DSTACK_SIZE= [...]
>
>> gccint.info (edited for long lines):
>> ...
>> 7.2.3.12 Other attributes
>> .
>>
>> 'stack_size'
>>   Target has limited stack size.  [...]
>
> On top of that, OK to push the attached
> "nvptx: stack size limits are relevant for execution only"?
>
>
> Grüße
>  Thomas


-
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 
München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas 
Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht 
München, HRB 106955
>From 158a077129cb1579b93ddf440a5bb60b457e4b7c Mon Sep 17 00:00:00 2001
From: Thomas Schwinge 
Date: Tue, 8 Nov 2022 12:10:03 +0100
Subject: [PATCH] nvptx: stack size limits are relevant for execution only

For non-'dg-do run' test cases, that means: big 'dg-require-stack-size' need
not be UNSUPPORTED (and indeed now do all PASS), 'dg-add-options stack_size'
need not define (and thus limit) 'STACK_SIZE' (and still do all PASS).

Re "Find 'dg-do-what' in an outer frame", currently (sources not completely
clean, though), we've got:

$ git grep -F 'check_effective_target_stack_size: found dg-do-what at level ' -- build-gcc/\*.log | sort | uniq -c
  6 build-gcc/gcc/testsuite/gcc/gcc.log:check_effective_target_stack_size: found dg-do-what at level 2
267 build-gcc/gcc/testsuite/gcc/gcc.log:check_effective_target_stack_size: found dg-do-what at level 3
239 build-gcc/gcc/testsuite/gcc/gcc.log:check_effective_target_stack_size: found dg-do-what at level 4

	gcc/testsuite/
	* lib/target-supports.exp (check_effective_target_stack_size): For
	nvptx target, stack size limits are relevant for execution only.
	gcc/
	* doc/sourcebuild.texi (stack_size): Update.
---
 gcc/doc/sourcebuild.texi  |  4 
 gcc/testsuite/lib/target-supports.exp | 16 
 2 files changed, 20 insertions(+)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 137f00aadc1f..5bbf6fc55909 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2848,6 +2848,10 @@ Target has limited stack size.  The stack size limit can be obtained using the
 STACK_SIZE macro defined by @ref{stack_size_ao,,@code{dg-add-options} feature
 @code{stack_size}}.
 
+Note that for certain targets, stack size limits are relevant for
+execution only, and therefore considered only if @code{dg-do run} is
+in effect, otherwise unlimited.
+
 @item static
 Target supports @option{-static}.
 
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 750897d08548..39ed1723b03a 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -625,6 +625,22 @@ proc check_effective_target_trampolines { } {
 # Return 1 if target has limited stack size.
 
 proc check_effective_target_stack_size { } {
+# For nvptx target, stack size limits are relevant for execution only.
+if { [istarget nvptx-*-*] } {
+	# Find 'dg-do-what' in an outer frame.
+	set level 1
+	while true {
+	upvar $level dg-do-what dg-do-what
+	if [info exists dg-do-what] then break
+	incr level
+	}
+	verbose "check_effective_target_stack_size: found dg-do-what at level $level" 2
+
+	if { ![string equal [lindex ${dg-do-what} 0] run] } {
+	return 0
+	}
+}
+
 if [target_info exists gcc,stack_size] {
 	return 1
 }
-- 
2.35.1



Re: [Patch] libgomp.texi: OpenMP Impl Status 5.1 additions + TR11

2022-11-25 Thread Tobias Burnus

On 25.11.22 11:38, Jakub Jelinek wrote:

On Fri, Nov 25, 2022 at 11:34:35AM +0100, Tobias Burnus wrote:

It also adds TR11. I don't think we will work any time soon
on TR11 – possibly except for clarifications.

OK for mainline?

Ok (but I hope that once 6.0 is out, we just keep OpenMP 6.0 entries
and don't mention any TRs).


Yes, that was the idea to update it to/for TR12 next year and to/for 6.0
in two years. That also matches the spec itself, which gets replaced by
newer TR and then by the final spec, keeping the old TR only in some
more hidden links on the spec page.

Pushed as
https://gcc.gnu.org/r13-4301-gc16e85d726a7793c05209af031dac0bebf035ab9

Tobias

-
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 
München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas 
Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht 
München, HRB 106955


Re: [Patch] libgomp.texi: OpenMP Impl Status 5.1 additions + TR11

2022-11-25 Thread Jakub Jelinek via Gcc-patches
On Fri, Nov 25, 2022 at 11:34:35AM +0100, Tobias Burnus wrote:
> Update libgomp.texi's OpenMP implementation status.
> The 5.1 changes are taken from Jakub's comment at
> https://gcc.gnu.org/pipermail/gcc-patches/2022-September/602639.html
> (sorry for taking that long to incorporate those).
> 
> It also adds TR11. I don't think we will work any time soon
> on TR11 – possibly except for clarifications.
> 
> OK for mainline?

Ok (but I hope that once 6.0 is out, we just keep OpenMP 6.0 entries
and don't mention any TRs).

Jakub



[Patch] libgomp.texi: OpenMP Impl Status 5.1 additions + TR11

2022-11-25 Thread Tobias Burnus

Update libgomp.texi's OpenMP implementation status.
The 5.1 changes are taken from Jakub's comment at
https://gcc.gnu.org/pipermail/gcc-patches/2022-September/602639.html
(sorry for taking that long to incorporate those).

It also adds TR11. I don't think we will work any time soon
on TR11 – possibly except for clarifications.

OK for mainline?

Tobias

PS: Albeit sometimes there is a fine border between clarification and
larger new feature. For instance,
* implicitly declared reduction identifiers for arbitrary C++ classes - or
* how to handle implicit 'declare target' with declare variant and (no)host
  selectors.
(The TR11 wording implies that the former is an old feature, while the latter
is implied by the OpenMP 5.2 examples document, albeit an issue to clarify
this in TR12 exists. For the latter: https://gcc.gnu.org/PR106316 + OpenMP Spec 
Issue 3416.)
-
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 
München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas 
Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht 
München, HRB 106955
libgomp.texi: OpenMP Impl Status 5.1 additions + TR11

libgomp/ChangeLog:

	* libgomp.texi (OpenMP Implementation Status): Add three 5.1 items
	and status for Technical Report (TR) 11.

 libgomp/libgomp.texi | 68 
 1 file changed, 68 insertions(+)

diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi
index 10fefa97922..584af45bd67 100644
--- a/libgomp/libgomp.texi
+++ b/libgomp/libgomp.texi
@@ -162,6 +162,7 @@ See also @ref{OpenMP Implementation Status}.
 * OpenMP 5.0:: Feature completion status to 5.0 specification
 * OpenMP 5.1:: Feature completion status to 5.1 specification
 * OpenMP 5.2:: Feature completion status to 5.2 specification
+* OpenMP Technical Report 11:: Feature completion status to first 6.0 preview
 @end menu
 
 The @code{_OPENMP} preprocessor macro and Fortran's @code{openmp_version}
@@ -350,6 +351,9 @@ The OpenMP 4.5 specification is fully supported.
 to address of matching mapped list item per 5.1, Sect. 2.21.7.2 @tab N @tab
 @item For Fortran, diagnose placing declarative before/between @code{USE},
   @code{IMPORT}, and @code{IMPLICIT} as invalid @tab N @tab
+@item Optional comma beween directive and clause in the @code{#pragma} form @tab Y @tab
+@item @code{indirect} clause in @code{declare target} @tab N @tab
+@item @code{device_type(nohost)}/@code{device_type(host)} for variables @tab N @tab
 @end multitable
 
 
@@ -425,6 +429,70 @@ to address of matching mapped list item per 5.1, Sect. 2.21.7.2 @tab N @tab
 @end multitable
 
 
+@node OpenMP Technical Report 11
+@section OpenMP Technical Report 11
+
+Technical Report (TR) 11 is the first preview for OpenMP 6.0.
+
+@unnumberedsubsec New features listed in Appendix B of the OpenMP specification
+@multitable @columnfractions .60 .10 .25
+@item Features deprecated in versions 5.2, 5.1 and 5.0 were removed
+  @tab N/A @tab Backward compatibility
+@item The @code{decl} attribute was added to the C++ attribute syntax
+  @tab N @tab
+@item @code{_ALL} suffix to the device-scope environment variables
+  @tab P @tab Host device number wrongly accepted
+@item For Fortran, @emph{locator list} can be also function reference with
+  data pointer result @tab N @tab
+@item Ref-count change for @code{use_device_ptr}/@code{use_device_addr}
+  @tab N @tab
+@item Implicit reduction identifiers of C++ classes
+  @tab N @tab
+@item Change of the @emph{map-type} property from @emph{ultimate} to
+  @emph{default} @tab N @tab
+@item Concept of @emph{assumed-size arrays} in C and C++
+  @tab N @tab
+@item Mapping of @emph{assumed-size arrays} in C, C++ and Fortran
+  @tab N @tab
+@item @code{groupprivate} directive @tab N @tab
+@item @code{local} clause to declare target directive @tab N @tab
+@item @code{part_size} allocator trait @tab N @tab
+@item @code{pin_device}, @code{preferred_device} and @code{target_access}
+  allocator traits
+  @tab N @tab
+@item @code{access} allocator trait changes @tab N @tab
+@item Extension of @code{interop} operation of @code{append_args}, allowing all
+  modifiers of the @code{init} clause
+@item @code{interop} clause to @code{dispatch} @tab N @tab
+@item @code{apply} code to loop-transforming constructs @tab N @tab
+@item @code{omp_curr_progress_width} identifier @tab N @tab
+@item @code{safesync} clause to the @code{parallel} construct @tab N @tab
+@item @code{omp_get_max_progress_width} runtime routine @tab N @tab
+@item @code{strict} modifier keyword to @code{num_threads}, @code{num_tasks}
+  and @code{grainsize} @tab N @tab
+@item @code{memscope} clause to @code{atomic} and @code{flush} @tab N @tab
+@item Routines for obtaining memory spaces/allocators for shared/device memory
+  @tab N @tab
+@item @code{omp_get_memspace_num_resources} routine @tab N @tab
+@item @code{omp_get_submemspace} 

Re: [PATCH] tree-optimization/106912 - IPA profile and pure/const

2022-11-25 Thread Jan Hubicka via Gcc-patches
> IPA profile instrumentation tries to clear the pure and const
> flags of functions but that's quite hopeless in particular for
> const since that attribute prevails on the type and thus on each
> call to the function leading to inconsistencies in the IL and
> eventual checking ICEs.  There's no good reason to do this and
> it wouldn't fixup any indirect calls so just don't.  No other
> instrumentation GCC does bothers about this.

This was mostly meant to deadl with situation where we auto-detect
function to be const and then partially inline it to a loop.
Then both caller and callee accesses same counters in the memory and if
you move load/stores out of the loop in caller you lose counters and get
inconsistencies at profile read-in time.

Honza
> 
> Bootstrap and regtest pending on x86_64-unknown-linux-gnu, OK?
> 
> Thanks,
> Richard.
> 
>   PR tree-optimization/106912
>   * tree-profile.cc (tree_profiling): Do not clear pure/const
>   flags.
> 
>   * gcc.dg/pr106912.c: New testcase.
> ---
>  gcc/testsuite/gcc.dg/pr106912.c | 16 
>  gcc/tree-profile.cc |  3 ---
>  2 files changed, 16 insertions(+), 3 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.dg/pr106912.c
> 
> diff --git a/gcc/testsuite/gcc.dg/pr106912.c b/gcc/testsuite/gcc.dg/pr106912.c
> new file mode 100644
> index 000..8faa877d8b3
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/pr106912.c
> @@ -0,0 +1,16 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fPIC -ftree-vectorize -fprofile-generate" } */
> +
> +__attribute__ ((__simd__))
> +__attribute__ ((__nothrow__ , __leaf__ , __const__))
> +double foo (double x);
> +void bar(double *f, int n)
> +{
> +  int i;
> +  for (i = 0; i < n; i++)
> +f[i] = foo(f[i]);
> +}
> +double foo(double x)
> +{
> +  return x * x / 3.0;
> +}
> diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc
> index 2beb49241f2..5491b398870 100644
> --- a/gcc/tree-profile.cc
> +++ b/gcc/tree-profile.cc
> @@ -814,9 +814,6 @@ tree_profiling (void)
>   /* Don't profile functions produced for builtin stuff.  */
>   if (DECL_SOURCE_LOCATION (node->decl) == BUILTINS_LOCATION)
> continue;
> -
> - node->set_const_flag (false, false);
> - node->set_pure_flag (false, false);
>}
>  
>/* Update call statements and rebuild the cgraph.  */
> -- 
> 2.35.3


Re: [PATCH] lto: fix usage of timer in materialize_cgraph

2022-11-25 Thread Martin Liška
On 11/23/22 10:40, Martin Liška wrote:
> Pretty obvious change.
> 
> Ready to be installed?

Pushed as obvious.

Martin

> Thanks,
> Martin
> 
>   PR lto/107829
> 
> gcc/lto/ChangeLog:
> 
>   * lto.cc (materialize_cgraph): Call timevar_push before
>   materialization starts.
> ---
>  gcc/lto/lto.cc | 14 ++
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/gcc/lto/lto.cc b/gcc/lto/lto.cc
> index 3a9147b01b5..3265a1d07bc 100644
> --- a/gcc/lto/lto.cc
> +++ b/gcc/lto/lto.cc
> @@ -137,6 +137,12 @@ materialize_cgraph (void)
>  fprintf (stderr,
>flag_wpa ? "Materializing decls:" : "Reading function bodies:");
>  
> +  /* Start the appropriate timer depending on the mode that we are
> + operating in.  */
> +  lto_timer = (flag_wpa) ? TV_WHOPR_WPA
> +   : (flag_ltrans) ? TV_WHOPR_LTRANS
> +   : TV_LTO;
> +  timevar_push (lto_timer);
>  
>FOR_EACH_FUNCTION (node)
>  {
> @@ -147,14 +153,6 @@ materialize_cgraph (void)
>   }
>  }
>  
> -
> -  /* Start the appropriate timer depending on the mode that we are
> - operating in.  */
> -  lto_timer = (flag_wpa) ? TV_WHOPR_WPA
> -   : (flag_ltrans) ? TV_WHOPR_LTRANS
> -   : TV_LTO;
> -  timevar_push (lto_timer);
> -
>current_function_decl = NULL;
>set_cfun (NULL);
>  



Re: [PATCH] Fix thinko in operator_bitwise_xor::op1_range

2022-11-25 Thread Richard Biener via Gcc-patches
On Fri, Nov 25, 2022 at 10:22 AM Eric Botcazou via Gcc-patches
 wrote:
>
> Hi,
>
> there is a thinko in the op1_range method of ranger's operator_bitwise_xor
> class in a boolean context: if the result is known to be true, it may infer
> than a specific operand is false without any basis.
>
> Tested on x86-64/Linux, OK for mainline, 12 and 11 branches?

OK.

Thanks,
Richard.

>
> 2022-11-25  Eric Botcazou  
>
> * range-op.cc (operator_bitwise_xor::op1_range): Fix thinko.
>
>
> 2022-11-25  Eric Botcazou  
>
> * gnat.dg/opt100.adb: New test.
> * gnat.dg/opt100_pkg.adb, gnat.dg/opt100_pkg.ads: New helper.
>
> --
> Eric Botcazou


[PATCH] Fix thinko in operator_bitwise_xor::op1_range

2022-11-25 Thread Eric Botcazou via Gcc-patches
Hi,

there is a thinko in the op1_range method of ranger's operator_bitwise_xor 
class in a boolean context: if the result is known to be true, it may infer 
than a specific operand is false without any basis.

Tested on x86-64/Linux, OK for mainline, 12 and 11 branches?


2022-11-25  Eric Botcazou  

* range-op.cc (operator_bitwise_xor::op1_range): Fix thinko.


2022-11-25  Eric Botcazou  

* gnat.dg/opt100.adb: New test.
* gnat.dg/opt100_pkg.adb, gnat.dg/opt100_pkg.ads: New helper.

-- 
Eric Botcazoudiff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 6fa3b151596..daea084ce18 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -3501,6 +3501,9 @@ operator_bitwise_xor::op1_range (irange , tree type,
 	r.set_varying (type);
 	  else if (op2.zero_p ())
 	r = range_true (type);
+	  // See get_bool_state for the rationale
+	  else if (op2.contains_p (build_zero_cst (op2.type (
+	r = range_true_and_false (type);
 	  else
 	r = range_false (type);
 	  break;
-- { dg-do run }
-- { dg-options "-O2 -gnatp" }

with Opt100_Pkg; use Opt100_Pkg;

procedure Opt100 is
  R : constant Rec := (K => B, N => 1);

begin
  if Func (R) /= 1 then
 raise Program_Error;
  end if;
end;
package body Opt100_Pkg is

   function Func (R : Rec) return Integer is
   begin
  if R in Small_Rec then
 case R.K is
when A => return 0;
when B => return 1;
when C => return 2;
when others => raise Program_Error;
 end case;
  else
 return -1;
  end if;
   end;

end Opt100_Pkg;
with Interfaces; use Interfaces;

package Opt100_Pkg is

  A : constant Unsigned_8 := 0;
  B : constant Unsigned_8 := 1;
  C : constant Unsigned_8 := 2;

  subtype Small_Unsigned_8 is Unsigned_8 range A .. C;

  type Rec is record
K : Unsigned_8;
N : Natural;
  end record;

  subtype Small_Rec is Rec
with Dynamic_Predicate =>
  Small_Rec.K in Small_Unsigned_8 and
((Small_Rec.N in Positive) = (Small_Rec.K in B | C));

   function Func (R : Rec) return Integer;

end Opt100_Pkg;


Re: [PATCH V3] [x86] Fix incorrect _mm_cvtsbh_ss.

2022-11-25 Thread Jakub Jelinek via Gcc-patches
On Fri, Nov 25, 2022 at 01:39:04PM +0800, liuhongt wrote:
> Update in V3:
> Remove !flag_signaling_nans since there's already HONOR_NANS (BFmode).
> 
> Here's the patch:
> 
> After supporting real __bf16, the implementation of _mm_cvtsbh_ss went
> wrong.
> 
> The patch add a builtin to generate pslld for the intrinsic, also
> extendbfsf2 is supported with pslld when !HONOR_NANS (BFmode).
> 
> truncsfbf2 is supported with vcvtneps2bf16 when
> !HONOR_NANS (BFmode) && flag_unsafe_math_optimizations.
> 
> gcc/ChangeLog:
> 
>   PR target/107748
>   * config/i386/avx512bf16intrin.h (_mm_cvtsbh_ss): Refined.
>   * config/i386/i386-builtin-types.def (FLOAT_FTYPE_BFLOAT16):
>   New function type.
>   * config/i386/i386-builtin.def (BDESC): New builtin.
>   * config/i386/i386-expand.cc (ix86_expand_args_builtin):
>   Handle the builtin.
>   * config/i386/i386.md (extendbfsf2): New expander.
>   (extendbfsf2_1): New define_insn.
>   (truncsfbf2): Ditto.
> 
> gcc/testsuite/ChangeLog:
> 
>   * gcc.target/i386/avx512bf16-cvtsbh2ss-1.c: Scan pslld.
>   * gcc.target/i386/extendbfsf.c: New test.

LGTM.

Jakub



Re: [PATCH]rs6000: Load high and low part of 64bit constant independently

2022-11-25 Thread Kewen.Lin via Gcc-patches
Hi Jeff,

Sorry for the late review.

on 2022/9/15 16:30, Jiufu Guo wrote:
> Hi,
> 
> For a complicate 64bit constant, blow is one instruction-sequence to
> build:
>   lis 9,0x800a
>   ori 9,9,0xabcd
>   sldi 9,9,32
>   oris 9,9,0xc167
>   ori 9,9,0xfa16
> 
> while we can also use below sequence to build:
>   lis 9,0xc167
>   lis 10,0x800a
>   ori 9,9,0xfa16
>   ori 10,10,0xabcd
>   rldimi 9,10,32,0
> This sequence is using 2 registers to build high and low part firstly,
> and then merge them.
> In parallel aspect, this sequence would be faster. (Ofcause, using 1 more
> register with potential register pressure).
> 
> Bootstrap and regtest pass on ppc64le.
> Is this ok for trunk?
> 
> 
> BR,
> Jeff(Jiufu)
> 
> 
> gcc/ChangeLog:
> 
>   * config/rs6000/rs6000.cc (rs6000_emit_set_long_const): Update 64bit
>   constant build.
> 
> gcc/testsuite/ChangeLog:
> 
>   * gcc.target/powerpc/parall_5insn_const.c: New test.
> 
> ---
>  gcc/config/rs6000/rs6000.cc   | 45 +++
>  .../gcc.target/powerpc/parall_5insn_const.c   | 27 +++
>  2 files changed, 53 insertions(+), 19 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/powerpc/parall_5insn_const.c
> 
> diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
> index a656cb32a47..759c6309677 100644
> --- a/gcc/config/rs6000/rs6000.cc
> +++ b/gcc/config/rs6000/rs6000.cc
> @@ -10180,26 +10180,33 @@ rs6000_emit_set_long_const (rtx dest, HOST_WIDE_INT 
> c)
>  }
>else
>  {
> -  temp = !can_create_pseudo_p () ? dest : gen_reg_rtx (DImode);
> -
> -  emit_move_insn (copy_rtx (temp),
> -   GEN_INT (((ud4 << 16) ^ 0x8000) - 0x8000));
> -  if (ud3 != 0)
> - emit_move_insn (copy_rtx (temp),
> - gen_rtx_IOR (DImode, copy_rtx (temp),
> -  GEN_INT (ud3)));
> +  if (can_create_pseudo_p ())
> + {
> +   /* lis A,U4; ori A,U3; lis B,U2; ori B,U1; rldimi A,B,32,0.  */

Nit: A, B are supposed to be H, L?

> +   rtx H = gen_reg_rtx (DImode);
> +   rtx L = gen_reg_rtx (DImode);
> +   HOST_WIDE_INT num = (ud2 << 16) | ud1;
> +   rs6000_emit_set_long_const (L, (num ^ 0x8000) - 0x8000);
> +   num = (ud4 << 16) | ud3;
> +   rs6000_emit_set_long_const (H, (num ^ 0x8000) - 0x8000);
> +   emit_insn (gen_rotldi3_insert_3 (dest, H, GEN_INT (32), L,
> +GEN_INT (0x)));
> + }
> +  else
> + {
> +   /* lis A, U4; ori A,U3; rotl A,32; oris A,U2; ori A,U1.  */
   ~~~ unexpected space?

> +   emit_move_insn (dest,
> +   GEN_INT (((ud4 << 16) ^ 0x8000) - 0x8000));
> +   if (ud3 != 0)
> + emit_move_insn (dest, gen_rtx_IOR (DImode, dest, GEN_INT (ud3)));
> 
> -  emit_move_insn (ud2 != 0 || ud1 != 0 ? copy_rtx (temp) : dest,
> -   gen_rtx_ASHIFT (DImode, copy_rtx (temp),
> -   GEN_INT (32)));
> -  if (ud2 != 0)
> - emit_move_insn (ud1 != 0 ? copy_rtx (temp) : dest,
> - gen_rtx_IOR (DImode, copy_rtx (temp),
> -  GEN_INT (ud2 << 16)));
> -  if (ud1 != 0)
> - emit_move_insn (dest,
> - gen_rtx_IOR (DImode, copy_rtx (temp),
> -  GEN_INT (ud1)));
> +   emit_move_insn (dest, gen_rtx_ASHIFT (DImode, dest, GEN_INT (32)));
> +   if (ud2 != 0)
> + emit_move_insn (dest,
> + gen_rtx_IOR (DImode, dest, GEN_INT (ud2 << 16)));
> +   if (ud1 != 0)
> + emit_move_insn (dest, gen_rtx_IOR (DImode, dest, GEN_INT (ud1)));
> + }
>  }
>  }
> 
> diff --git a/gcc/testsuite/gcc.target/powerpc/parall_5insn_const.c 
> b/gcc/testsuite/gcc.target/powerpc/parall_5insn_const.c
> new file mode 100644
> index 000..ed8ccc73378
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/parall_5insn_const.c
> @@ -0,0 +1,27 @@
> +/* { dg-do run } */
> +/* { dg-options "-O2 -mdejagnu-cpu=power7  -save-temps" } */

Why do we need power7 here?

> +/* { dg-require-effective-target has_arch_ppc64 } */
> +
> +/* { dg-final { scan-assembler-times {\mlis\M} 4 } } */
> +/* { dg-final { scan-assembler-times {\mori\M} 4 } } */
> +/* { dg-final { scan-assembler-times {\mrldimi\M} 2 } } */
> +
> +void __attribute__ ((noinline)) foo (unsigned long long *a)
> +{
> +  /* 2lis+2ori+1rldimi for each constant.  */

Nit: seems better to read with "/* 2 lis + 2 ori + 1 rldimi for ..."

BR,
Kewen


[PATCH 56/56] java, libjava: Upgrade from in-tree boehm-gc to external boehm-gc 8.3.0.

2022-11-25 Thread Zopolis0 via Gcc-patches

From a267b06e1e2ef0cd7da0b8d418c348c51b4904e7 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 25 Nov 2022 17:05:30 +1100
Subject: [PATCH 56/56] java, libjava: Upgrade from in-tree boehm-gc to
 external boehm-gc 8.3.0.

gcc/java/ChangeLog:

	* boehm.cc (get_boehm_type_descriptor): Remove check for flag_use_boehm_gc.
	(uses_jv_markobj_p): Remove flag_use_boehm_gc assert.
	* jvspec.cc: Remove fuse-boehm-gc.
	* lang.opt: Likewise.

libjava/ChangeLog:

	* boehm.cc (GC_REDIRECT_TO_LOCAL): Include gc/gc.h instead of gc_local_alloc.h.
	(_Jv_SetGCFreeSpaceDivisor): Use GC_get_free_space_divisor to get old_div (before GC_set_free_space_divisor call).
	(_Jv_InitGC): Use GC_set variants of functions.
	(_Jv_GCInitializeFinalizers): Likewise.
	* configure.ac: Replace in-tree check with external checks from libobjc, check that found version is modern enough.
	* gnu/gcj/util/natGCInfo.cc (PACKAGE_NAME): Remove.
	(PACKAGE_STRING): Likewise.
	(PACKAGE_TARNAME): Likewise.
	(PACKAGE_VERSION): Likewise.
	(TRUE): Likewise.
	(FALSE): Likewise.
	(GC_print_debug_callback): Replace GC_n_set_marks with public functions.
	(struct print_hblkfl_s): Add.
	(UNIQUE_THRESHOLD): Remove.
	(HUGE_THRESHOLD): Likewise.
	(FL_COMPRESSION): Likewise.
	(N_HBLK_FLS): Likewise.
	(print_hblkfl_file_item): Add.
	(IS_MAPPED): Remove.
	(GC_print_hblkfreelist_file): Handle lack of HDR macro.
	(GC_print_debug_info_file): Use GC_word instead of word, handle lack of struct hblkhdr.
	(GC_enumerator::enumerate): Use GC_word instead of word.
	(GC_enumerator::enumerate_callback_adaptor): Use GC_word instead of word, handle lack of struct hblkhdr.
	(GC_enumerator::enumerate_callback): Handle lack of HDR macro.
	* include/boehm-gc.h: Include gc/gc.h instead of gc_ext_config.h, adjust comment accordingly.
	* libgcj.spec.in: Remove GCSPEC and JC1GCSPEC.
	* Makefile.in: Reconfigure.
	* configure: Likewise.
	* gcj/Makefile.in: Likewise.
	* include/Makefile.in: Likewise.
	* include/config.h.in: Likewise.
	* testsuite/Makefile.in: Likewise.

Co-authored-by: Ivan Maidanski 
---
 gcc/java/boehm.cc |   6 -
 gcc/java/jvspec.cc|   2 +-
 gcc/java/lang.opt |   4 -
 libjava/Makefile.in   |   4 -
 libjava/boehm.cc  |  24 +--
 libjava/configure | 309 +-
 libjava/configure.ac  | 202 +++
 libjava/gcj/Makefile.in   |   4 -
 libjava/gnu/gcj/util/natGCInfo.cc | 171 +
 libjava/include/Makefile.in   |   4 -
 libjava/include/boehm-gc.h|   5 +-
 libjava/include/config.h.in   |   3 +
 libjava/libgcj.spec.in|   4 +-
 libjava/testsuite/Makefile.in |   4 -
 14 files changed, 501 insertions(+), 245 deletions(-)

diff --git a/gcc/java/boehm.cc b/gcc/java/boehm.cc
index 38a2131e6f8..5859f038998 100644
--- a/gcc/java/boehm.cc
+++ b/gcc/java/boehm.cc
@@ -136,10 +136,6 @@ get_boehm_type_descriptor (tree type)
   int pointer_after_end = 0;
   tree field, value, value_type;
 
-  /* If the GC wasn't requested, just use a null pointer.  */
-  if (! flag_use_boehm_gc)
-return null_pointer_node;
-
   value_type = java_type_for_mode (ptr_mode, 1);
   wide_int mask = wi::zero (TYPE_PRECISION (value_type));
 
@@ -223,8 +219,6 @@ bool
 uses_jv_markobj_p (tree dtable)
 {
   tree v;
-  /* FIXME: what do we return if !flag_use_boehm_gc ? */
-  gcc_assert (flag_use_boehm_gc);
   /* FIXME: this is wrong if TARGET_VTABLE_USES_DESCRIPTORS.  However,
  this function is only used with flag_reduced_reflection.  No
  point in asserting unless we hit the bad case.  */
diff --git a/gcc/java/jvspec.cc b/gcc/java/jvspec.cc
index 58142368621..3786926e8d9 100644
--- a/gcc/java/jvspec.cc
+++ b/gcc/java/jvspec.cc
@@ -66,7 +66,7 @@ static const char jvgenmain_spec[] =
 		   %
-
 // Set GC_DEBUG before including gc.h!
 #ifdef LIBGCJ_GC_DEBUG
 # define GC_DEBUG
 #endif
 
-#include 
-#include 
-#include   // GC_finalize_all declaration.  
+#include 
+#include 
+#include   // GC_finalize_all declaration.
 
 #ifdef THREAD_LOCAL_ALLOC
 # define GC_REDIRECT_TO_LOCAL
-# include 
+# include 
 #endif
 
   // From boehm's misc.c 
@@ -468,7 +466,9 @@ _Jv_GCSetMaximumHeapSize (size_t size)
 int
 _Jv_SetGCFreeSpaceDivisor (int div)
 {
-  return (int)GC_set_free_space_divisor ((GC_word)div);
+  int old_div = (int)GC_get_free_space_divisor ();
+  GC_set_free_space_divisor ((GC_word)div);
+  return old_div;
 }
 
 void
@@ -523,7 +523,7 @@ _Jv_InitGC (void)
   gc_initialized = 1;
 
   // Ignore pointers that do not point to the start of an object.
-  GC_all_interior_pointers = 0;
+  GC_set_all_interior_pointers(0);
 
 #if defined (HAVE_DLFCN_H) && defined (HAVE_DLADDR)
   // Tell the collector to ask us before scanning DSOs.
@@ -538,9 +538,9 @@ _Jv_InitGC (void)
 
   // Cause an out of memory error to be thrown from the allocators,
   // instead of returning 0.  This is cheaper than checking on allocation.
-  

[PATCH 53/56] classpath: Use modern autotools mkdir -p handling.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 6cddfc752e14a4e8084e62dc03872411ee7493df Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 25 Nov 2022 16:35:31 +1100
Subject: [PATCH 53/56] classpath: Use modern autotools mkdir -p handling.

libjava/classpath/ChangeLog:

	* configure.ac: Add AC_PROG_MKDIR_P call, replace @mkdir_p@ with $(MKDIR_P).
	* configure: Reconfigure.
	* lib/Makefile.am: Replace @mkdir_p@ with $(MKDIR_P).
	* lib/Makefile.in: Reconfigure.
	* lib/copy-vmresources.sh.in: Replace @mkdir_p@ with $(MKDIR_P).
---
 libjava/classpath/configure  | 10 ++
 libjava/classpath/configure.ac   |  2 ++
 libjava/classpath/lib/Makefile.am| 10 +-
 libjava/classpath/lib/Makefile.in| 10 +-
 libjava/classpath/lib/copy-vmresources.sh.in |  4 ++--
 5 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/libjava/classpath/configure b/libjava/classpath/configure
index 8214e1ba7cd..dbde6463c94 100755
--- a/libjava/classpath/configure
+++ b/libjava/classpath/configure
@@ -24338,6 +24338,8 @@ fi
 
 
 
+
+
 # Extract the first word of "find", so it can be a program name with args.
 set dummy find; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -25559,7 +25561,7 @@ else
 JAVA_TEST=Object.java
 CLASS_TEST=Object.class
 cat << \EOF > $JAVA_TEST
-/* #line 25562 "configure" */
+/* #line 25564 "configure" */
 package java.lang;
 
 public class Object
@@ -25652,7 +25654,7 @@ EOF
 if uudecode$EXEEXT Test.uue; then
 ac_cv_prog_uudecode_base64=yes
 else
-echo "configure: 25655: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
+echo "configure: 25657: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
 echo "configure: failed file was:" >&5
 cat Test.uue >&5
 ac_cv_prog_uudecode_base64=no
@@ -25680,7 +25682,7 @@ JAVA_TEST=Test.java
 CLASS_TEST=Test.class
 TEST=Test
 cat << \EOF > $JAVA_TEST
-/* [#]line 25683 "configure" */
+/* [#]line 25685 "configure" */
 public class Test {
 public static void main (String args[]) {
 System.exit (0);
@@ -25888,7 +25890,7 @@ if test "x${use_glibj_zip}" = xfalse || \
   JAVA_TEST=Test.java
   CLASS_TEST=Test.class
   cat << \EOF > $JAVA_TEST
-  /* #line 25891 "configure" */
+  /* #line 25893 "configure" */
   public class Test
   {
 public static void main(String args)
diff --git a/libjava/classpath/configure.ac b/libjava/classpath/configure.ac
index 2079fd2121b..40439f594dc 100644
--- a/libjava/classpath/configure.ac
+++ b/libjava/classpath/configure.ac
@@ -1008,6 +1008,8 @@ AC_PATH_PROG(MKDIR, mkdir)
 AC_PATH_PROG(CP, cp)
 AC_PATH_PROG(DATE, date)
 
+AC_PROG_MKDIR_P
+
 dnl ---
 dnl According to the GNU coding guide, we shouldn't require find, 
 dnl and zip, however GNU provides both so it should be okay 
diff --git a/libjava/classpath/lib/Makefile.am b/libjava/classpath/lib/Makefile.am
index 2d47009f459..2f9e32ae98c 100644
--- a/libjava/classpath/lib/Makefile.am
+++ b/libjava/classpath/lib/Makefile.am
@@ -86,18 +86,18 @@ endif # USE_PREBUILT_GLIBJ_ZIP
 resources: copy-vmresources.sh
 	@list=`cd $(top_srcdir)/resource && $(FIND) gnu java javax org -name \*\.properties -print -o -name \*\.css -print`; for p in $$list; do \
   dirname=`dirname $$p`; \
-  if ! test -d "$$dirname"; then @mkdir_p@ "$$dirname"; fi; \
+  if ! test -d "$$dirname"; then $(MKDIR_P) "$$dirname"; fi; \
 	  cp $(top_srcdir)/resource/$$p $$p; \
 	done
 	@list=`cd $(top_srcdir)/resource && $(FIND) META-INF -name CVS -prune -o -name .svn -prune -o -name \*\.in -prune -o -type f -print`; for p in $$list; do \
   dirname=`dirname $$p`; \
-  if ! test -d "$$dirname"; then @mkdir_p@ "$$dirname"; fi; \
+  if ! test -d "$$dirname"; then $(MKDIR_P) "$$dirname"; fi; \
 	  cp $(top_srcdir)/resource/$$p $$p; \
 	done
 	@$(SHELL) ./copy-vmresources.sh
 	@list=`cd $(top_srcdir) && $(FIND) gnu/javax/swing/plaf/gtk/icons -name *.png -type f -print`; for p in $$list; do \
   dirname=`dirname $$p`; \
-  if ! test -d "$$dirname"; then @mkdir_p@ "$$dirname"; fi; \
+  if ! test -d "$$dirname"; then $(MKDIR_P) "$$dirname"; fi; \
 	  cp $(top_srcdir)/$$p $$p; \
 	done
 	touch resources
@@ -105,7 +105,7 @@ resources: copy-vmresources.sh
 classes: genclasses
 
 $(top_builddir)/gnu/java/locale/LocaleData.java: $(top_srcdir)/scripts/generate-locale-list.sh 
-	@mkdir_p@ $(top_builddir)/gnu/java/locale
+	$(MKDIR_P) $(top_builddir)/gnu/java/locale
 	$(top_srcdir)/scripts/generate-locale-list.sh > $(top_builddir)/gnu/java/locale/LocaleData.java
 
 genclasses: gen-classlist.sh standard.omit $(top_builddir)/gnu/java/locale/LocaleData.java gen-xpath-parser
@@ -165,7 +165,7 @@ clean-local:
 	-rm -rf lists
 
 dist-hook:
-	@mkdir_p@ $(distdir)
+	$(MKDIR_P) $(distdir)
 	cp -pdfR $(top_srcdir)/gnu $(top_srcdir)/java $(top_srcdir)/javax $(top_srcdir)/org 

[PATCH 50/56] libjava: Replace AC_LANG_PROGRAM with AC_LANG_SOURCE.

2022-11-25 Thread Zopolis0 via Gcc-patches

From a1a703a9e118ed76cace8165d8ed3e5ec88c6477 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:37:56 +1100
Subject: [PATCH 50/56] libjava: Replace AC_LANG_PROGRAM with AC_LANG_SOURCE.

libjava/classpath/ChangeLog:

	* configure.ac: Replace AC_LANG_PROGRAM with AC_LANG_SOURCE.
	* configure: Regenerate.

libjava/ChangeLog:

	* configure.ac: Replace AC_LANG_PROGRAM with AC_LANG_SOURCE, add additional AC_LANG_SOURCE call.
	* configure: Regenerate.
---
 libjava/classpath/configure|  57 ++---
 libjava/classpath/configure.ac |  14 ++---
 libjava/configure  | 109 +
 libjava/configure.ac   |  34 +-
 4 files changed, 46 insertions(+), 168 deletions(-)

diff --git a/libjava/classpath/configure b/libjava/classpath/configure
index 091d96058f8..12ef419fa6b 100755
--- a/libjava/classpath/configure
+++ b/libjava/classpath/configure
@@ -17613,13 +17613,6 @@ $as_echo_n "checking whether struct sockaddr_in6 is in netinet/in.h... " >&6; }
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include 
-int
-main ()
-{
-struct sockaddr_in6 addr6;
-  ;
-  return 0;
-}
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
 
@@ -17779,13 +17772,6 @@ $as_echo_n "checking for tm_gmtoff in struct tm... " >&6; }
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include 
-int
-main ()
-{
-struct tm tim; tim.tm_gmtoff = 0;
-  ;
-  return 0;
-}
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
 
@@ -17801,13 +17787,6 @@ $as_echo_n "checking for global timezone variable... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include 
-int
-main ()
-{
-void i(){long z2 = 2*timezone;}
-  ;
-  return 0;
-}
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
 
@@ -17823,13 +17802,6 @@ $as_echo_n "checking for global _timezone variable... " >&6; }
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include 
-int
-main ()
-{
-long z2 = _timezone;
-  ;
-  return 0;
-}
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
 
@@ -22205,13 +22177,6 @@ $as_echo_n "checking for MSG_NOSIGNAL... " >&6; }
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include 
-int
-main ()
-{
- int f = MSG_NOSIGNAL;
-  ;
-  return 0;
-}
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
@@ -22230,13 +22195,6 @@ $as_echo_n "checking for SO_NOSIGPIPE ... " >&6; }
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include 
-int
-main ()
-{
- int f = SO_NOSIGPIPE;
-  ;
-  return 0;
-}
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
@@ -22255,13 +22213,6 @@ $as_echo_n "checking for MSG_WAITALL... " >&6; }
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include 
-int
-main ()
-{
- int f = MSG_WAITALL;
-  ;
-  return 0;
-}
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
@@ -25591,7 +25542,7 @@ else
 JAVA_TEST=Object.java
 CLASS_TEST=Object.class
 cat << \EOF > $JAVA_TEST
-/* #line 25594 "configure" */
+/* #line 25545 "configure" */
 package java.lang;
 
 public class Object
@@ -25684,7 +25635,7 @@ EOF
 if uudecode$EXEEXT Test.uue; then
 ac_cv_prog_uudecode_base64=yes
 else
-echo "configure: 25687: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
+echo "configure: 25638: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
 echo "configure: failed file was:" >&5
 cat Test.uue >&5
 ac_cv_prog_uudecode_base64=no
@@ -25712,7 +25663,7 @@ JAVA_TEST=Test.java
 CLASS_TEST=Test.class
 TEST=Test
 cat << \EOF > $JAVA_TEST
-/* [#]line 25715 "configure" */
+/* [#]line 25666 "configure" */
 public class Test {
 public static void main (String args[]) {
 System.exit (0);
@@ -25920,7 +25871,7 @@ if test "x${use_glibj_zip}" = xfalse || \
   JAVA_TEST=Test.java
   CLASS_TEST=Test.class
   cat << \EOF > $JAVA_TEST
-  /* #line 25923 "configure" */
+  /* #line 25874 "configure" */
   public class Test
   {
 public static void main(String args)
diff --git a/libjava/classpath/configure.ac b/libjava/classpath/configure.ac
index 95c7b599297..77ed70300e9 100644
--- a/libjava/classpath/configure.ac
+++ b/libjava/classpath/configure.ac
@@ -532,7 +532,7 @@ if test "x${COMPILE_JNI}" = xyes; then
   AC_SUBST(LIBMAGIC)
 
   AC_MSG_CHECKING([whether struct sockaddr_in6 is in netinet/in.h])
-  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[struct sockaddr_in6 addr6;]])],
+  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include ]], [[struct sockaddr_in6 addr6;]])],
 [AC_DEFINE(HAVE_INET6, 1,
  [Define if inet6 structures are defined in netinet/in.h.])
  AC_MSG_RESULT(yes)],
@@ -543,7 +543,7 @@ if test 

[PATCH 48/56] classpath: Rename documentation files from .texinfo to .texi.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 971906a595876549c0a2e3ecefa38aac6efaf487 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:09:27 +1100
Subject: [PATCH 48/56] classpath: Rename documentation files from .texinfo to
 .texi.

libjava/classpath/ChangeLog:

	* doc/Makefile.am: Rename documentation files from .texinfo to .texi.
	* doc/cp-hacking.texinfo: Moved to...
	* doc/cp-hacking.texi: ...here.
	* doc/cp-tools.texinfo: Moved to...
	* doc/cp-tools.texi: ...here.
	* doc/cp-vmintegration.texinfo: Moved to...
	* doc/cp-vmintegration.texi: ...here.
---
 libjava/classpath/doc/Makefile.am | 32 +--
 .../{cp-hacking.texinfo => cp-hacking.texi}   |  0
 .../doc/{cp-tools.texinfo => cp-tools.texi}   |  0
 ...egration.texinfo => cp-vmintegration.texi} |  0
 4 files changed, 16 insertions(+), 16 deletions(-)
 rename libjava/classpath/doc/{cp-hacking.texinfo => cp-hacking.texi} (100%)
 rename libjava/classpath/doc/{cp-tools.texinfo => cp-tools.texi} (100%)
 rename libjava/classpath/doc/{cp-vmintegration.texinfo => cp-vmintegration.texi} (100%)

diff --git a/libjava/classpath/doc/Makefile.am b/libjava/classpath/doc/Makefile.am
index 27a378d07be..27ea7c00a95 100644
--- a/libjava/classpath/doc/Makefile.am
+++ b/libjava/classpath/doc/Makefile.am
@@ -3,12 +3,12 @@ SUBDIRS = api
 EXTRA_DIST = README.jaxp texi2pod.pl $(man_MANS)
 
 ## GCJ LOCAL: we don't want to install all of Classpath's info files.
-## info_TEXINFOS = cp-hacking.texinfo cp-vmintegration.texinfo cp-tools.texinfo
+## info_TEXINFOS = cp-hacking.texi cp-vmintegration.texi cp-tools.texi
 TEXINFO_TEX = ../../gcc/doc/include/texinfo.tex
-info_TEXINFOS = cp-tools.texinfo
+info_TEXINFOS = cp-tools.texi
 
 # POSIX locale necessary to make grep work; see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=586134
-.texinfo.dvi:
+.texi.dvi:
 	LC_ALL=POSIX texi2dvi --build-dir=$(builddir) -o $@ $<
 
 .dvi.ps:
@@ -46,47 +46,47 @@ STAMP = echo timestamp >
 	gkeytool.pod gnative2ascii.pod gorbd.pod grmid.pod grmiregistry.pod \
 	gserialver.pod gtnameserv.pod gcjh.pod gjdoc.pod
 
-gappletviewer.pod: $(srcdir)/cp-tools.texinfo
+gappletviewer.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gappletviewer < $< > $@
 
-gjarsigner.pod: $(srcdir)/cp-tools.texinfo
+gjarsigner.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gjarsigner < $< > $@
 
-gjar.pod: $(srcdir)/cp-tools.texinfo
+gjar.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gjar < $< > $@
 
-gcjh.pod: $(srcdir)/cp-tools.texinfo
+gcjh.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gcjh < $< > $@
 
-gjavah.pod: $(srcdir)/cp-tools.texinfo
+gjavah.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gjavah < $< > $@
 
 # hack around the cross references and the enumeration
-gkeytool.pod: $(srcdir)/cp-tools.texinfo
+gkeytool.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gkeytool < $< \
 	  | sed -e 's/^For more details.*/See I for more details./' \
 	-e 's/1\.<\([^>]*\)>/- \1/' \
 		> $@
 
-gnative2ascii.pod: $(srcdir)/cp-tools.texinfo
+gnative2ascii.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gnative2ascii < $< > $@
 
-gorbd.pod: $(srcdir)/cp-tools.texinfo
+gorbd.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gorbd < $< > $@
 
-grmid.pod: $(srcdir)/cp-tools.texinfo
+grmid.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D grmid < $< > $@
 
-grmiregistry.pod: $(srcdir)/cp-tools.texinfo
+grmiregistry.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D grmiregistry < $< > $@
 
-gserialver.pod: $(srcdir)/cp-tools.texinfo
+gserialver.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gserialver < $< > $@
 
-gtnameserv.pod: $(srcdir)/cp-tools.texinfo
+gtnameserv.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gtnameserv < $< > $@
 
-gjdoc.pod: $(srcdir)/cp-tools.texinfo
+gjdoc.pod: $(srcdir)/cp-tools.texi
 	-$(TEXI2POD) -D gjdoc < $< > $@
 
 # GCJ LOCAL CHANGE
diff --git a/libjava/classpath/doc/cp-hacking.texinfo b/libjava/classpath/doc/cp-hacking.texi
similarity index 100%
rename from libjava/classpath/doc/cp-hacking.texinfo
rename to libjava/classpath/doc/cp-hacking.texi
diff --git a/libjava/classpath/doc/cp-tools.texinfo b/libjava/classpath/doc/cp-tools.texi
similarity index 100%
rename from libjava/classpath/doc/cp-tools.texinfo
rename to libjava/classpath/doc/cp-tools.texi
diff --git a/libjava/classpath/doc/cp-vmintegration.texinfo b/libjava/classpath/doc/cp-vmintegration.texi
similarity index 100%
rename from libjava/classpath/doc/cp-vmintegration.texinfo
rename to libjava/classpath/doc/cp-vmintegration.texi
-- 
2.38.1



[PATCH 49/56] libjava: Move to autoconf 2.69, automake 1.15.

2022-11-25 Thread Zopolis0 via Gcc-patches
libjava/classpath/ChangeLog:

* configure.ac: Remove autoconf2.64 prerequisite.
* Makefile.in: Regenerate.
* aclocal.m4: Likewise.
* configure: Likewise.
* doc/Makefile.in: Likewise.
* doc/api/Makefile.in: Likewise.
* examples/Makefile.in: Likewise.
* external/Makefile.in: Likewise.
* external/jsr166/Makefile.in: Likewise.
* external/relaxngDatatype/Makefile.in: Likewise.
* external/sax/Makefile.in: Likewise.
* external/w3c_dom/Makefile.in: Likewise.
* include/Makefile.in: Likewise.
* include/config.h.in: Likewise.
* lib/Makefile.in: Likewise.
* native/Makefile.in: Likewise.
* native/fdlibm/Makefile.in: Likewise.
* native/jawt/Makefile.in: Likewise.
* native/jni/Makefile.in: Likewise.
* native/jni/Makefile.in: Likewise.
* native/jni/gconf-peer/Makefile.in: Likewise.
* native/jni/gstreamer-peer/Makefile.in: Likewise.
* native/jni/gtk-peer/Makefile.in: Likewise.
* native/jni/java-io/Makefile.in: Likewise.
* native/jni/java-lang/Makefile.in: Likewise.
* native/jni/java-math/Makefile.in: Likewise.
* native/jni/java-net/Makefile.in: Likewise.
* native/jni/java-nio/Makefile.in: Likewise.
* native/jni/java-util/Makefile.in: Likewise.
* native/jni/midi-alsa/Makefile.in: Likewise.
* native/jni/midi-dssi/Makefile.in: Likewise.
* native/jni/native-lib/Makefile.in: Likewise.
* native/jni/qt-peer/Makefile.in: Likewise.
* native/jni/xmlj/Makefile.in: Likewise.
* native/plugin/Makefile.in: Likewise.
* resource/Makefile.in: Likewise.
* scripts/Makefile.in: Likewise.
* tools/Makefile.in: Likewise.

libjava/ChangeLog:

* configure.ac: Remove autoconf2.64 prerequisite, relocate
AM_INIT_AUTOMAKE call, use modern multilib configuration, use autoconf
builtins for noncanonical build and target macros.
* Makefile.in: Regenerate.
* aclocal.m4: Likewise.
* configure: Likewise.
* gcj/Makefile.in: Likewise.
* include/Makefile.in: Likewise.
* include/config.h.in: Likewise.
* testsuite/Makefile.in: Likewise.

libjava/libltdl/ChangeLog:

* configure.ac: Set AC_CONFIG_AUX_DIR to root of gcc tree.
* Makefile.in: Regenerate.
* aclocal.m4: Likewise.
* configure: Likewise.


0049-libjava-Move-to-autoconf-2.69-automake-1.15.patch.bz3
Description: Binary data


[PATCH 46/56] libjava: Remove unnecessary parentheses.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 9727bbe203cb3e32bd4f70c3e6c1e7a5f08ecc6c Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:07:31 +1100
Subject: [PATCH 46/56] libjava: Remove unnecessary parentheses.

libjava/ChangeLog:

	* gnu/gcj/jvmti/Breakpoint.h (_Jv_RewriteBreakpointInsn): Remove unnecessary parentheses.
---
 libjava/gnu/gcj/jvmti/Breakpoint.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libjava/gnu/gcj/jvmti/Breakpoint.h b/libjava/gnu/gcj/jvmti/Breakpoint.h
index f614df9e5e1..107e13cbc4d 100644
--- a/libjava/gnu/gcj/jvmti/Breakpoint.h
+++ b/libjava/gnu/gcj/jvmti/Breakpoint.h
@@ -30,7 +30,7 @@ class gnu::gcj::jvmti::Breakpoint : public ::java::lang::Object
 {
 
 #ifdef DIRECT_THREADED
-friend void (::_Jv_RewriteBreakpointInsn (jmethodID, jlocation, pc_t));
+friend void ::_Jv_RewriteBreakpointInsn (jmethodID, jlocation, pc_t);
 #endif
 
 public:
-- 
2.38.1



[PATCH 47/56] libjava: Use ucontext_t instead of struct ucontext.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 0a48a9b40e58611602df083296fb9e272ec47214 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:08:08 +1100
Subject: [PATCH 47/56] libjava: Use ucontext_t instead of struct ucontext.

libjava/ChangeLog:

	* include/i386-signal.h: Use ucontext_t instead of struct ucontext.
	* include/s390-signal.h: Likewise.
	* include/x86_64-signal.h: Likewise.
---
 libjava/include/i386-signal.h   | 2 +-
 libjava/include/s390-signal.h   | 2 +-
 libjava/include/x86_64-signal.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libjava/include/i386-signal.h b/libjava/include/i386-signal.h
index c2409b0e301..3a15415510d 100644
--- a/libjava/include/i386-signal.h
+++ b/libjava/include/i386-signal.h
@@ -29,7 +29,7 @@ static void _Jv_##_name (int, siginfo_t *,			\
 #define HANDLE_DIVIDE_OVERFLOW		\
 do	\
 {	\
-  struct ucontext *_uc = (struct ucontext *)_p;\
+  ucontext_t *_uc = (ucontext_t *)_p;\
   gregset_t &_gregs = _uc->uc_mcontext.gregs;\
   unsigned char *_eip = (unsigned char *)_gregs[REG_EIP];		\
 	\
diff --git a/libjava/include/s390-signal.h b/libjava/include/s390-signal.h
index 4ca4c108864..9261b52be6e 100644
--- a/libjava/include/s390-signal.h
+++ b/libjava/include/s390-signal.h
@@ -51,7 +51,7 @@ do	\
   struct\
   { \
 unsigned long int uc_flags; \
-struct ucontext *uc_link;   \
+ucontext_t *uc_link;\
 stack_t uc_stack;   \
 mcontext_t uc_mcontext; \
 unsigned long sigmask[2];   \
diff --git a/libjava/include/x86_64-signal.h b/libjava/include/x86_64-signal.h
index 12383b5485a..a463ee3b980 100644
--- a/libjava/include/x86_64-signal.h
+++ b/libjava/include/x86_64-signal.h
@@ -28,7 +28,7 @@ static void _Jv_##_name (int, siginfo_t *,			\
 #define HANDLE_DIVIDE_OVERFLOW		\
 do	\
 {	\
-  struct ucontext *_uc = (struct ucontext *)_p;\
+  ucontext_t *_uc = (ucontext_t *)_p;\
   gregset_t &_gregs = _uc->uc_mcontext.gregs;\
   unsigned char *_rip = (unsigned char *)_gregs[REG_RIP];		\
 	\
-- 
2.38.1



[PATCH 55/56] classpath: Mark generate-locale-list.sh as executable.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 6812eff2161bb08560549fe7b8c309d83af47142 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 25 Nov 2022 16:41:21 +1100
Subject: [PATCH 55/56] classpath: Mark generate-locale-list.sh as executable.

libjava/classpath/ChangeLog:

	* scripts/generate-locale-list.sh: Mark as executable.
---
 libjava/classpath/scripts/generate-locale-list.sh | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 libjava/classpath/scripts/generate-locale-list.sh

diff --git a/libjava/classpath/scripts/generate-locale-list.sh b/libjava/classpath/scripts/generate-locale-list.sh
old mode 100644
new mode 100755
-- 
2.38.1



[PATCH 41/56] java: Replace struct deps with struct mkdeps and set phoniness of dependencies via bool argument to deps_write.

2022-11-25 Thread Zopolis0 via Gcc-patches

From ddb4f48708722a2343e104cc27d094ce70235362 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:03:06 +1100
Subject: [PATCH 41/56] java: Replace struct deps with struct mkdeps and set
 phoniness of dependencies via bool argument to deps_write.

gcc/java/ChangeLog:

	* jcf-depend.cc (struct deps): Rename to ...
	(struct mkdeps): ... this.
	(jcf_dependency_write): Set phoniness of dependencies via bool argument to deps_write.
---
 gcc/java/jcf-depend.cc | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gcc/java/jcf-depend.cc b/gcc/java/jcf-depend.cc
index b5e850dfecc..f46189233d3 100644
--- a/gcc/java/jcf-depend.cc
+++ b/gcc/java/jcf-depend.cc
@@ -34,7 +34,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 
 
 /* The dependency structure used for this invocation.  */
-struct deps *dependencies;
+struct mkdeps *dependencies;
 
 /* The output file, or NULL if we aren't doing dependency tracking.  */
 static FILE *dep_out = NULL;
@@ -133,8 +133,10 @@ jcf_dependency_write (void)
 
   gcc_assert (dependencies);
 
-  deps_write (dependencies, dep_out, 72);
   if (print_dummies)
-deps_phony_targets (dependencies, dep_out);
+deps_write (dependencies, dep_out, 1, 72);
+  else
+deps_write (dependencies, dep_out, 0, 72);
+
   fflush (dep_out);
 }
-- 
2.38.1



[PATCH 44/56] java: Add FUNCTION_DECL_CHECK in METHOD_DUMMY.

2022-11-25 Thread Zopolis0 via Gcc-patches

From f833395379572ae8d153edab0d9e14bb8182e3dc Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:06:32 +1100
Subject: [PATCH 44/56] java: Add FUNCTION_DECL_CHECK in METHOD_DUMMY.

gcc/java/ChangeLog:

	* java-tree.h (METHOD_DUMMY): Check for FUNCTION_DECL.
---
 gcc/java/java-tree.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h
index 813bc3237e1..d2e08f294f2 100644
--- a/gcc/java/java-tree.h
+++ b/gcc/java/java-tree.h
@@ -1197,7 +1197,7 @@ int cxx_keyword_p (const char *name, int length);
 
 /* Access flags etc for a method (a FUNCTION_DECL): */
 
-#define METHOD_DUMMY(DECL) (DECL_LANG_SPECIFIC (DECL)->u.f.dummy)
+#define METHOD_DUMMY(DECL) (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (DECL))->u.f.dummy)
 
 #define METHOD_PUBLIC(DECL) DECL_LANG_FLAG_1 (FUNCTION_DECL_CHECK (DECL))
 #define METHOD_PRIVATE(DECL) TREE_PRIVATE (FUNCTION_DECL_CHECK (DECL))
-- 
2.38.1



[PATCH 54/56] classpath: Use info-in-builddir.

2022-11-25 Thread Zopolis0 via Gcc-patches

From f212f36a69de5a84b2f66951c97ad454e03fb646 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 25 Nov 2022 16:40:15 +1100
Subject: [PATCH 54/56] classpath: Use info-in-builddir.

libjava/classpath/ChangeLog:

	* doc/Makefile.am: Add info-in-builddir.
	* doc/Makefile.in: Reconfigure.
---
 libjava/classpath/doc/Makefile.am | 2 ++
 libjava/classpath/doc/Makefile.in | 1 +
 2 files changed, 3 insertions(+)

diff --git a/libjava/classpath/doc/Makefile.am b/libjava/classpath/doc/Makefile.am
index 27ea7c00a95..9f532890df0 100644
--- a/libjava/classpath/doc/Makefile.am
+++ b/libjava/classpath/doc/Makefile.am
@@ -1,3 +1,5 @@
+AUTOMAKE_OPTIONS = info-in-builddir
+
 SUBDIRS = api
 
 EXTRA_DIST = README.jaxp texi2pod.pl $(man_MANS)
diff --git a/libjava/classpath/doc/Makefile.in b/libjava/classpath/doc/Makefile.in
index ea6681f8cf3..66bdc594a09 100644
--- a/libjava/classpath/doc/Makefile.in
+++ b/libjava/classpath/doc/Makefile.in
@@ -459,6 +459,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 uudecode = @uudecode@
 vm_classes = @vm_classes@
+AUTOMAKE_OPTIONS = info-in-builddir
 SUBDIRS = api
 EXTRA_DIST = README.jaxp texi2pod.pl $(man_MANS)
 TEXINFO_TEX = ../../gcc/doc/include/texinfo.tex
-- 
2.38.1



[PATCH 37/56] java: Build SWITCH_EXPR using build2 instead of build3.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 94f41c513be007f380e2c18771ab9d8fd33ecd76 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 18:58:44 +1100
Subject: [PATCH 37/56] java: Build SWITCH_EXPR using build2 instead of build3.

gcc/java/ChangeLog:

	* expr.cc (expand_java_switch): Build SWITCH_EXPR using build2 instead of build3.
---
 gcc/java/expr.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/java/expr.cc b/gcc/java/expr.cc
index 80bff58d727..4e212e7ed21 100644
--- a/gcc/java/expr.cc
+++ b/gcc/java/expr.cc
@@ -1887,8 +1887,8 @@ expand_java_switch (tree selector, int default_pc)
   tree switch_expr, x;
 
   flush_quick_stack ();
-  switch_expr = build3 (SWITCH_EXPR, TREE_TYPE (selector), selector,
-			NULL_TREE, NULL_TREE);
+  switch_expr = build2 (SWITCH_EXPR, TREE_TYPE (selector), selector,
+			NULL_TREE);
   java_add_stmt (switch_expr);
 
   x = build_case_label (NULL_TREE, NULL_TREE,
-- 
2.38.1



[PATCH 42/56] java: Include memmodel.h in builtins.cc.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 455027503890dabd31947f45ca8ac6c78a1360e5 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:04:36 +1100
Subject: [PATCH 42/56] java: Include memmodel.h in builtins.cc.

gcc/java/ChangeLog:

	* builtins.cc: Include memmodel.h.
---
 gcc/java/builtins.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/java/builtins.cc b/gcc/java/builtins.cc
index 45d736a0d7b..0482bbd830d 100644
--- a/gcc/java/builtins.cc
+++ b/gcc/java/builtins.cc
@@ -34,6 +34,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 #include "tree.h"
 #include "stringpool.h"
 #include "expmed.h"
+#include "memmodel.h"
 #include "optabs.h"
 #include "fold-const.h"
 #include "stor-layout.h"
-- 
2.38.1



[PATCH 28/56] java: Replace TYPE_MINVAL with TYPE_MIN_VALUE_RAW.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 47048f95e0fd265badb53dc373e6bdc91f7ac39c Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:31:50 +1100
Subject: [PATCH 28/56] java: Replace TYPE_MINVAL with TYPE_MIN_VALUE_RAW.

gcc/java/ChangeLog:

	* java-tree.h (TYPE_ARGUMENT_SIGNATURE): Replace TYPE_MINVAL with TYPE_MIN_VALUE_RAW.
---
 gcc/java/java-tree.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h
index 6f286ecf666..813bc3237e1 100644
--- a/gcc/java/java-tree.h
+++ b/gcc/java/java-tree.h
@@ -1339,7 +1339,7 @@ extern tree *type_map;
 
 /* If FUNCTION_TYPE or METHOD_TYPE: cache for build_java_argument_signature. */
 #define TYPE_ARGUMENT_SIGNATURE(TYPE) \
-  (TYPE_MINVAL (TREE_CHECK2 (TYPE, FUNCTION_TYPE, METHOD_TYPE)))
+  (TYPE_MIN_VALUE_RAW (TREE_CHECK2 (TYPE, FUNCTION_TYPE, METHOD_TYPE)))
 
 /* Given an array type, give the type of the elements. */
 /* FIXME this use of TREE_TYPE conflicts with something or other. */
-- 
2.38.1



[PATCH 51/56] libjava: Check for libz_convenience.la instead of libzgcj_convenience.la.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 64685f25317b541ff9a677e34a2df01d136665e4 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:43:14 +1100
Subject: [PATCH 51/56] libjava: Check for libz_convenience.la instead of
 libzgcj_convenience.la.

libjava/ChangeLog:

	* configure.ac: Check for libz_convenience.la instead of libzgcj_convenience.la.
	* configure: Regenerate.
---
 libjava/configure| 2 +-
 libjava/configure.ac | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libjava/configure b/libjava/configure
index 1ae56784d5f..ce96a9a8911 100755
--- a/libjava/configure
+++ b/libjava/configure
@@ -24077,7 +24077,7 @@ ZINCS=
 if test -z "$ZLIBSPEC"; then
# Use zlib from the GCC tree.
ZINCS='-I$(top_srcdir)/../zlib'
-   ZLIBS=../zlib/libzgcj_convenience.la
+   ZLIBS=../zlib/libz_convenience.la
 else
# System's zlib.
SYS_ZLIBS="$ZLIBSPEC"
diff --git a/libjava/configure.ac b/libjava/configure.ac
index 8fb16765e05..b3d667a7da3 100644
--- a/libjava/configure.ac
+++ b/libjava/configure.ac
@@ -1490,7 +1490,7 @@ ZINCS=
 if test -z "$ZLIBSPEC"; then
# Use zlib from the GCC tree.
ZINCS='-I$(top_srcdir)/../zlib'
-   ZLIBS=../zlib/libzgcj_convenience.la
+   ZLIBS=../zlib/libz_convenience.la
 else
# System's zlib.
SYS_ZLIBS="$ZLIBSPEC"
-- 
2.38.1



[PATCH 36/56] java: Don't check the value of dump_switch_p.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 93865231f5e5b2217ac9709b95a3eff2b068a6c4 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 18:55:56 +1100
Subject: [PATCH 36/56] java: Don't check the value of dump_switch_p.

gcc/java/ChangeLog:

	* lang.cc (java_handle_option): Don't check the value of dump_switch_p.
---
 gcc/java/lang.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/java/lang.cc b/gcc/java/lang.cc
index f79c89ab418..8a5bff8d7c8 100644
--- a/gcc/java/lang.cc
+++ b/gcc/java/lang.cc
@@ -262,8 +262,7 @@ java_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
   break;
 
 case OPT_fdump_:
-  if (!g->get_dumps ()->dump_switch_p (arg))
-	return false;
+  g->get_dumps ()->dump_switch_p (arg);
   break;
 
 case OPT_fencoding_:
-- 
2.38.1



[PATCH 39/56] java: Check that type is array or integer before checking string flag.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 03914cb1b32656b3d54a7c838666d32c8d2c1c4e Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:00:01 +1100
Subject: [PATCH 39/56] java: Check that type is array or integer before
 checking string flag.

gcc/java/ChangeLog:

	* decl.cc (push_promoted_type): Check that type is array or integer before checking string flag.
---
 gcc/java/decl.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/java/decl.cc b/gcc/java/decl.cc
index 6319d1ce18a..6d7a4ae37bf 100644
--- a/gcc/java/decl.cc
+++ b/gcc/java/decl.cc
@@ -481,7 +481,8 @@ push_promoted_type (const char *name, tree actual_type)
   TYPE_MAX_VALUE (type) = copy_node (in_max);
   TREE_TYPE (TYPE_MAX_VALUE (type)) = type;
   TYPE_PRECISION (type) = TYPE_PRECISION (int_type_node);
-  TYPE_STRING_FLAG (type) = TYPE_STRING_FLAG (actual_type);
+  if (TREE_CODE (type) == ARRAY_TYPE || TREE_CODE (type) == INTEGER_TYPE)
+TYPE_STRING_FLAG (type) = TYPE_STRING_FLAG (actual_type);
   layout_type (type);
   pushdecl (build_decl (input_location,
 			TYPE_DECL, get_identifier (name), type));
-- 
2.38.1



[PATCH 23/56] java: Don't build by default.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 9cc1761bef480ab6833b499a4293d4f60b6ac756 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:27:17 +1100
Subject: [PATCH 23/56] java: Don't build by default.

gcc/java/ChangeLog:

	* config-lang.in: Don't build Java by default.
---
 gcc/java/config-lang.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/java/config-lang.in b/gcc/java/config-lang.in
index 2cec3736655..cf46ce0a250 100644
--- a/gcc/java/config-lang.in
+++ b/gcc/java/config-lang.in
@@ -36,5 +36,5 @@ gtfiles="\$(srcdir)/java/java-tree.h \$(srcdir)/java/jcf.h \$(srcdir)/java/parse
 
 target_libs="target-libjava target-libffi target-zlib"
 lang_dirs="fastjar"
-#build_by_default=no
+build_by_default=no
 lang_requires=c++
-- 
2.38.1



[PATCH 45/56] libjava: Remove unnecessary register keyword.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 6f8caea61b454cfa8fd55ad2ae17cd613f39e77e Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:07:03 +1100
Subject: [PATCH 45/56] libjava: Remove unnecessary register keyword.

libjava/ChangeLog:

	* java/lang/natString.cc (_Jv_FormatInt): Remove unnecessary register keyword.
---
 libjava/java/lang/natString.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libjava/java/lang/natString.cc b/libjava/java/lang/natString.cc
index 75006a7c9a7..dc32757541a 100644
--- a/libjava/java/lang/natString.cc
+++ b/libjava/java/lang/natString.cc
@@ -368,7 +368,7 @@ _Jv_GetStringUTFRegion (jstring str, jsize start, jsize len, char *buf)
 jint
 _Jv_FormatInt (jchar* bufend, jint num)
 {
-  register jchar* ptr = bufend;
+  jchar* ptr = bufend;
   jboolean isNeg;
   if (num < 0)
 {
-- 
2.38.1



[PATCH 35/56] java: Use checking forms of DECL_FUNCTION_CODE.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 9b2de9f1573a12674ab30e4dc7b5ccbf5b5d5921 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 18:54:38 +1100
Subject: [PATCH 35/56] java: Use checking forms of DECL_FUNCTION_CODE.

gcc/java/ChangeLog:

	* builtins.cc (define_builtin): Use set_decl_built_in_function.
---
 gcc/java/builtins.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/java/builtins.cc b/gcc/java/builtins.cc
index 09f6c159aa5..45d736a0d7b 100644
--- a/gcc/java/builtins.cc
+++ b/gcc/java/builtins.cc
@@ -472,8 +472,7 @@ define_builtin (enum built_in_function val,
   TREE_PUBLIC (decl) = 1;
   SET_DECL_ASSEMBLER_NAME (decl, get_identifier (libname));
   pushdecl (decl);
-  DECL_BUILT_IN_CLASS (decl) = BUILT_IN_NORMAL;
-  DECL_FUNCTION_CODE (decl) = val;
+  set_decl_built_in_function (decl, BUILT_IN_NORMAL, val);
   set_call_expr_flags (decl, flags);
 
   set_builtin_decl (val, decl, true);
-- 
2.38.1



[PATCH 38/56] java: Use dump_flags_t.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 06d15f71846a82e92ac842d5df30f6cac6fed523 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 18:59:38 +1100
Subject: [PATCH 38/56] java: Use dump_flags_t.

gcc/java/ChangeLog:

	* java-gimplify.cc (dump_java_tree): Use dump_flags_t.
---
 gcc/java/java-gimplify.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/java/java-gimplify.cc b/gcc/java/java-gimplify.cc
index c723cb665ce..8c490ab832e 100644
--- a/gcc/java/java-gimplify.cc
+++ b/gcc/java/java-gimplify.cc
@@ -160,7 +160,7 @@ static void
 dump_java_tree (enum tree_dump_index phase, tree t)
 {
   FILE *stream;
-  int flags;
+  dump_flags_t flags;
 
   stream = dump_begin (phase, );
   flags |= TDF_SLIM;
-- 
2.38.1



[PATCH 21/56] Rename gcc/java/*.c to *.cc.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 03f1795edba9ec9c8cb64031ddfe61a67e6167ff Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:53:31 +1100
Subject: [PATCH 21/56] Rename gcc/java/*.c to *.cc.

gcc/java/ChangeLog:

	* Make-lang.in: Rename .c names to .cc.
	* boehm.c: Moved to...
	* boehm.cc: ...here.
	* builtins.c: Moved to...
	* builtins.cc: ...here.
	* class.c: Moved to...
	* class.cc: ...here.
	* config-lang.in:
	* constants.c: Moved to...
	* constants.cc: ...here.
	* decl.c: Moved to...
	* decl.cc: ...here.
	* except.c: Moved to...
	* except.cc: ...here.
	* expr.c: Moved to...
	* expr.cc: ...here.
	* java-gimplify.c: Moved to...
	* java-gimplify.cc: ...here.
	* jcf-depend.c: Moved to...
	* jcf-depend.cc: ...here.
	* jcf-dump.c: Moved to...
	* jcf-dump.cc: ...here.
	* jcf-io.c: Moved to...
	* jcf-io.cc: ...here.
	* jcf-parse.c: Moved to...
	* jcf-parse.cc: ...here.
	* jcf-path.c: Moved to...
	* jcf-path.cc: ...here.
	* jcf-reader.c: Moved to...
	* jcf-reader.cc: ...here.
	* jvgenmain.c: Moved to...
	* jvgenmain.cc: ...here.
	* jvspec.c: Moved to...
	* jvspec.cc: ...here.
	* lang.c: Moved to...
	* lang.cc: ...here.
	* mangle.c: Moved to...
	* mangle.cc: ...here.
	* mangle_name.c: Moved to...
	* mangle_name.cc: ...here.
	* resource.c: Moved to...
	* resource.cc: ...here.
	* typeck.c: Moved to...
	* typeck.cc: ...here.
	* verify-glue.c: Moved to...
	* verify-glue.cc: ...here.
	* verify-impl.c: Moved to...
	* verify-impl.cc: ...here.
	* win32-host.c: Moved to...
	* win32-host.cc: ...here.
	* zextract.c: Moved to...
	* zextract.cc: ...here.
---
 gcc/java/Make-lang.in  | 2 +-
 gcc/java/{boehm.c => boehm.cc} | 0
 gcc/java/{builtins.c => builtins.cc}   | 0
 gcc/java/{class.c => class.cc} | 0
 gcc/java/config-lang.in| 2 +-
 gcc/java/{constants.c => constants.cc} | 0
 gcc/java/{decl.c => decl.cc}   | 0
 gcc/java/{except.c => except.cc}   | 0
 gcc/java/{expr.c => expr.cc}   | 0
 gcc/java/{java-gimplify.c => java-gimplify.cc} | 0
 gcc/java/{jcf-depend.c => jcf-depend.cc}   | 0
 gcc/java/{jcf-dump.c => jcf-dump.cc}   | 2 +-
 gcc/java/{jcf-io.c => jcf-io.cc}   | 0
 gcc/java/{jcf-parse.c => jcf-parse.cc} | 2 +-
 gcc/java/{jcf-path.c => jcf-path.cc}   | 0
 gcc/java/{jcf-reader.c => jcf-reader.cc}   | 0
 gcc/java/{jvgenmain.c => jvgenmain.cc} | 0
 gcc/java/{jvspec.c => jvspec.cc}   | 0
 gcc/java/{lang.c => lang.cc}   | 0
 gcc/java/{mangle.c => mangle.cc}   | 0
 gcc/java/{mangle_name.c => mangle_name.cc} | 0
 gcc/java/{resource.c => resource.cc}   | 0
 gcc/java/{typeck.c => typeck.cc}   | 0
 gcc/java/{verify-glue.c => verify-glue.cc} | 0
 gcc/java/{verify-impl.c => verify-impl.cc} | 0
 gcc/java/{win32-host.c => win32-host.cc}   | 0
 gcc/java/{zextract.c => zextract.cc}   | 0
 27 files changed, 4 insertions(+), 4 deletions(-)
 rename gcc/java/{boehm.c => boehm.cc} (100%)
 rename gcc/java/{builtins.c => builtins.cc} (100%)
 rename gcc/java/{class.c => class.cc} (100%)
 rename gcc/java/{constants.c => constants.cc} (100%)
 rename gcc/java/{decl.c => decl.cc} (100%)
 rename gcc/java/{except.c => except.cc} (100%)
 rename gcc/java/{expr.c => expr.cc} (100%)
 rename gcc/java/{java-gimplify.c => java-gimplify.cc} (100%)
 rename gcc/java/{jcf-depend.c => jcf-depend.cc} (100%)
 rename gcc/java/{jcf-dump.c => jcf-dump.cc} (99%)
 rename gcc/java/{jcf-io.c => jcf-io.cc} (100%)
 rename gcc/java/{jcf-parse.c => jcf-parse.cc} (99%)
 rename gcc/java/{jcf-path.c => jcf-path.cc} (100%)
 rename gcc/java/{jcf-reader.c => jcf-reader.cc} (100%)
 rename gcc/java/{jvgenmain.c => jvgenmain.cc} (100%)
 rename gcc/java/{jvspec.c => jvspec.cc} (100%)
 rename gcc/java/{lang.c => lang.cc} (100%)
 rename gcc/java/{mangle.c => mangle.cc} (100%)
 rename gcc/java/{mangle_name.c => mangle_name.cc} (100%)
 rename gcc/java/{resource.c => resource.cc} (100%)
 rename gcc/java/{typeck.c => typeck.cc} (100%)
 rename gcc/java/{verify-glue.c => verify-glue.cc} (100%)
 rename gcc/java/{verify-impl.c => verify-impl.cc} (100%)
 rename gcc/java/{win32-host.c => win32-host.cc} (100%)
 rename gcc/java/{zextract.c => zextract.cc} (100%)

diff --git a/gcc/java/Make-lang.in b/gcc/java/Make-lang.in
index cbfd479a3dd..80e221b30a7 100644
--- a/gcc/java/Make-lang.in
+++ b/gcc/java/Make-lang.in
@@ -117,7 +117,7 @@ java.rest.encap:
 
 
 java.tags: force
-	cd $(srcdir)/java; etags -o TAGS.sub *.c *.h --language=none \
+	cd $(srcdir)/java; etags -o TAGS.sub *.cc *.h --language=none \
 	  --regex='/DEFTREECODE [(]\([A-Z_]+\)/\1/' java-tree.def; \
 	etags --include TAGS.sub --include ../TAGS.sub
 
diff --git a/gcc/java/boehm.c b/gcc/java/boehm.cc
similarity index 100%
rename from gcc/java/boehm.c
rename to gcc/java/boehm.cc
diff --git a/gcc/java/builtins.c b/gcc/java/builtins.cc
similarity index 100%
rename 

[PATCH 43/56] java: Include opt-suggestions.h in jvspec.cc.

2022-11-25 Thread Zopolis0 via Gcc-patches

From cdeae5ba5f541b14ad50efc16f4d17f24998e115 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:05:03 +1100
Subject: [PATCH 43/56] java: Include opt-suggestions.h in jvspec.cc.

gcc/java/ChangeLog:

	* jvspec.cc: Include opt-suggestions.h.
---
 gcc/java/jvspec.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/java/jvspec.cc b/gcc/java/jvspec.cc
index a2010db4c97..58142368621 100644
--- a/gcc/java/jvspec.cc
+++ b/gcc/java/jvspec.cc
@@ -26,6 +26,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
+#include "opt-suggestions.h"
 #include "gcc.h"
 #include "jcf.h"
 #include "opts.h"
-- 
2.38.1



[PATCH 34/56] java: Replace flag_excess_precision_cmdline with flag_excess_precision.

2022-11-25 Thread Zopolis0 via Gcc-patches

From a6dd3bf6fbd57289dee1a73bc8b24b3de33374b6 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:38:01 +1100
Subject: [PATCH 34/56] java: Replace flag_excess_precision_cmdline with
 flag_excess_precision.

gcc/java/ChangeLog:

	* lang.cc (java_post_options): Replace flag_excess_precision_cmdline with flag_excess_precision.
---
 gcc/java/lang.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/java/lang.cc b/gcc/java/lang.cc
index 742a772bae1..f79c89ab418 100644
--- a/gcc/java/lang.cc
+++ b/gcc/java/lang.cc
@@ -570,9 +570,9 @@ java_post_options (const char **pfilename)
 
   /* Excess precision other than "fast" requires front-end
  support.  */
-  if (flag_excess_precision_cmdline == EXCESS_PRECISION_STANDARD)
+  if (flag_excess_precision == EXCESS_PRECISION_STANDARD)
 sorry ("%<-fexcess-precision=standard%> for Java");
-  flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
+  flag_excess_precision = EXCESS_PRECISION_FAST;
 
   /* An absolute requirement: if we're not using indirect dispatch, we
  must always verify everything.  */
-- 
2.38.1



[PATCH 17/56] gcc: Add binfo value to tree_type_non_common and make TYPE_BINFO use it.

2022-11-25 Thread Zopolis0 via Gcc-patches

From eb12f8c4c87314779ae35842f7a833eb4ad89b62 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:22:36 +1100
Subject: [PATCH 17/56] gcc: Add binfo value to tree_type_non_common and make
 TYPE_BINFO use it.

gcc/ChangeLog:

	* tree-core.h (struct tree_type_non_common): Re-add binfo.
	* tree.h (TYPE_BINFO): Use type_non_common.binfo.
---
 gcc/tree-core.h | 1 +
 gcc/tree.h  | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-core.h b/gcc/tree-core.h
index e146b133dbd..90b0cac7f90 100644
--- a/gcc/tree-core.h
+++ b/gcc/tree-core.h
@@ -1745,6 +1745,7 @@ struct GTY(()) tree_type_non_common {
   tree values;
   tree minval;
   tree maxval;
+  tree binfo;
   tree lang_1;
 };
 
diff --git a/gcc/tree.h b/gcc/tree.h
index 56409bfad13..9ad86307a72 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -2468,7 +2468,7 @@ extern tree vector_element_bits_tree (const_tree);
 #define TYPE_MAX_VALUE_RAW(NODE) (TYPE_CHECK (NODE)->type_non_common.maxval)
 /* For record and union types, information about this type, as a base type
for itself.  */
-#define TYPE_BINFO(NODE) (RECORD_OR_UNION_CHECK (NODE)->type_non_common.maxval)
+#define TYPE_BINFO(NODE) (RECORD_OR_UNION_CHECK (NODE)->type_non_common.binfo)
 
 /* For types, used in a language-dependent way.  */
 #define TYPE_LANG_SLOT_1(NODE) \
-- 
2.38.1



[PATCH 31/56] java: Use HOST_WIDE_INT.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 3fdb672e06dc91ec22bfb56ec3b441fdbc343fdd Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:34:07 +1100
Subject: [PATCH 31/56] java: Use HOST_WIDE_INT.

gcc/java/ChangeLog:

	* lang.cc (java_handle_option): Replace 'int value' with 'HOST_WIDE_INT value'.
---
 gcc/java/lang.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/java/lang.cc b/gcc/java/lang.cc
index 0353f6f3b95..ab204f9531f 100644
--- a/gcc/java/lang.cc
+++ b/gcc/java/lang.cc
@@ -44,7 +44,7 @@ static void java_init_options_struct (struct gcc_options *);
 static void java_init_options (unsigned int, struct cl_decoded_option *);
 static bool java_post_options (const char **);
 
-static bool java_handle_option (size_t, const char *, int, int, location_t,
+static bool java_handle_option (size_t, const char *, HOST_WIDE_INT, int, location_t,
 const struct cl_option_handlers *);
 static void put_decl_string (const char *, int);
 static void put_decl_node (tree, int);
@@ -171,7 +171,7 @@ struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
  * return false, but do not complain if the option is not recognized.
  */
 static bool
-java_handle_option (size_t scode, const char *arg, int value,
+java_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
 		int kind ATTRIBUTE_UNUSED, location_t loc ATTRIBUTE_UNUSED,
 		const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
 {
-- 
2.38.1



[PATCH 40/56] java: Fix Wstringop-* warnings.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 704b4df7d1965090d27e76eba9257e2a29b34595 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 19:01:56 +1100
Subject: [PATCH 40/56] java: Fix Wstringop-* warnings.

gcc/java/ChangeLog:

	* jcf-parse.cc (compute_class_name): Fix Wstringop-* warnings.

Co-authored-by: 277r 
---
 gcc/java/jcf-parse.cc | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/gcc/java/jcf-parse.cc b/gcc/java/jcf-parse.cc
index 683f7211085..a4ee9af51d2 100644
--- a/gcc/java/jcf-parse.cc
+++ b/gcc/java/jcf-parse.cc
@@ -1992,8 +1992,8 @@ compute_class_name (struct ZipDirectory *zdir)
 {
   char *class_name_in_zip_dir = ZIPDIR_FILENAME (zdir);
   char *class_name;
-  int i;
-  int filename_length = zdir->filename_length;
+  size_t i;
+  size_t filename_length = zdir->filename_length;
 
   while (filename_length > 2 && strncmp (class_name_in_zip_dir, "./", 2) == 0)
 {
@@ -2002,15 +2002,20 @@ compute_class_name (struct ZipDirectory *zdir)
 }
 
   filename_length -= strlen (".class");
-  class_name = XNEWVEC (char, filename_length + 1);
-  memcpy (class_name, class_name_in_zip_dir, filename_length);
-  class_name [filename_length] = '\0';
+  if (filename_length > 0)
+  {
+class_name = XNEWVEC (char, size_t(filename_length + 1));
+memcpy (class_name, class_name_in_zip_dir, filename_length);
+class_name [filename_length] = '\0';
 
-  for (i = 0; i < filename_length; i++)
-if (class_name[i] == '/')
-  class_name[i] = '.';
+for (i = 0; i < filename_length; i++)
+  if (class_name[i] == '/')
+class_name[i] = '.';
 
-  return class_name;
+return class_name;
+  }
+
+  return 0;
 }
 
 /* Return 0 if we should skip this entry, 1 if it is a .class file, 2
-- 
2.38.1



[PATCH 33/56] java: Fix -Wformat-diag warnings.

2022-11-25 Thread Zopolis0 via Gcc-patches

From d240e44f078badbaff23b7dc73c17f82c3b791d0 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:36:52 +1100
Subject: [PATCH 33/56] java: Fix -Wformat-diag warnings.

gcc/java/ChangeLog:

	* decl.cc (force_poplevels): Fix -Wformat-diag warning.
	* except.cc (doing_eh): Likewise.
	* jcf-parse.cc (handle_constant): Likewise.
	(jcf_parse): Likewise.
	(java_parse_file): Likewise.
	* jvspec.cc (lang_specific_driver): Likewise.
	* lang.cc (java_post_options): Likewise.
	* verify-glue.cc (verify_jvm_instructions_new): Likewise.
---
 gcc/java/decl.cc|  2 +-
 gcc/java/except.cc  |  2 +-
 gcc/java/jcf-parse.cc   | 14 +++---
 gcc/java/jvspec.cc  |  8 
 gcc/java/lang.cc| 10 +-
 gcc/java/verify-glue.cc |  2 +-
 6 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/gcc/java/decl.cc b/gcc/java/decl.cc
index 4fdfaaaf8c1..6319d1ce18a 100644
--- a/gcc/java/decl.cc
+++ b/gcc/java/decl.cc
@@ -1617,7 +1617,7 @@ force_poplevels (int start_pc)
   while (current_binding_level->start_pc > start_pc)
 {
   if (pedantic && current_binding_level->start_pc > start_pc)
-	warning (0, "In %+D: overlapped variable and exception ranges at %d",
+	warning (0, "In %<%+D:%> overlapped variable and exception ranges at %d",
  current_function_decl,
 		 current_binding_level->start_pc);
   poplevel (1, 0, 0);
diff --git a/gcc/java/except.cc b/gcc/java/except.cc
index c5e2326..7d936d379bd 100644
--- a/gcc/java/except.cc
+++ b/gcc/java/except.cc
@@ -577,7 +577,7 @@ doing_eh (void)
   static int warned = 0;
   if (! warned)
 	{
-	  error ("exception handling disabled, use -fexceptions to enable");
+	  error ("exception handling disabled, use %<-fexceptions%> to enable");
 	  warned = 1;
 	}
   return 0;
diff --git a/gcc/java/jcf-parse.cc b/gcc/java/jcf-parse.cc
index b5e39fd5a5c..683f7211085 100644
--- a/gcc/java/jcf-parse.cc
+++ b/gcc/java/jcf-parse.cc
@@ -499,7 +499,7 @@ handle_constant (JCF *jcf, int index, enum cpool_tag purpose)
 return 0;
 
   if (! CPOOL_INDEX_IN_RANGE (>cpool, index))
-error ("", index);
+error ("constant pool index %d not in range", index);
   
   kind = JPOOL_TAG (jcf, index);
 
@@ -509,7 +509,7 @@ handle_constant (JCF *jcf, int index, enum cpool_tag purpose)
 	  && kind == CONSTANT_Utf8)
 	;
   else
-	error (" file");
   code = jcf_parse_constant_pool (jcf);
   if (code != 0)
 fatal_error (input_location, "error while parsing constant pool");
   code = verify_constant_pool (jcf);
   if (code > 0)
-fatal_error (input_location, "error in constant pool entry #%d\n", code);
+fatal_error (input_location, "error in constant pool entry %d", code);
 
   jcf_parse_class (jcf);
   if (main_class == NULL_TREE)
@@ -1749,7 +1749,7 @@ java_parse_file (void)
   finput = fopen (main_input_filename, "r");
   if (finput == NULL)
 	fatal_error (input_location,
-		 "can%'t open %s: %m", LOCATION_FILE (input_location));
+		 "cannot open %s: %m", LOCATION_FILE (input_location));
   list = XNEWVEC (char, avail);
   next = list;
   for (;;)
@@ -1884,11 +1884,11 @@ java_parse_file (void)
   /* Close previous descriptor, if any */
   if (finput && fclose (finput))
 	fatal_error (input_location,
-		 "can%'t close input file %s: %m", main_input_filename);
+		 "cannot close input file %s: %m", main_input_filename);
   
   finput = fopen (filename, "rb");
   if (finput == NULL)
-	fatal_error (input_location, "can%'t open %s: %m", filename);
+	fatal_error (input_location, "cannot open %s: %m", filename);
 
 #ifdef IO_BUFFER_SIZE
   setvbuf (finput, xmalloc (IO_BUFFER_SIZE),
diff --git a/gcc/java/jvspec.cc b/gcc/java/jvspec.cc
index 73985751c86..a2010db4c97 100644
--- a/gcc/java/jvspec.cc
+++ b/gcc/java/jvspec.cc
@@ -392,7 +392,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
 }
 
   if (saw_D && ! main_class_name)
-fatal_error (input_location, "can%'t specify %<-D%> without %<--main%>");
+fatal_error (input_location, "cannot specify %<-D%> without %<--main%>");
 
   if (main_class_name && ! verify_class_name (main_class_name))
 fatal_error (input_location,
@@ -402,21 +402,21 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
   if (saw_resource)
 {
   if (! saw_o)
-	fatal_error (input_location, "--resource requires -o");
+	fatal_error (input_location, "%<--resource%> requires %<-o%>");
 }
   if (saw_C)
 {
   num_args += 3;
   if (class_files_count + zip_files_count > 0)
 	{
-	  warning (0, "already-compiled .class files ignored with -C"); 
+	  warning (0, "already-compiled %<.class%> files ignored with %<-C%>"); 
 	  num_args -= class_files_count + zip_files_count;
 	  class_files_count = 0;
 	  zip_files_count = 0;
 	}
   num_args += 2;  /* For -o NONE. */
   if (saw_o)
-	fatal_error (input_location, "cannot specify both -C and -o");
+	

[PATCH 30/56] java: Add handle_nonnull_attribute function.

2022-11-25 Thread Zopolis0 via Gcc-patches

From d512d93b50ce31537b2d05615b5c553c07a6ebdb Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:33:35 +1100
Subject: [PATCH 30/56] java: Add handle_nonnull_attribute function.

gcc/java/ChangeLog:

	* lang.cc (handle_nonnull_attribute): Add.
	(java_eh_personality): Adjust.
---
 gcc/java/lang.cc | 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/gcc/java/lang.cc b/gcc/java/lang.cc
index 65025eeeb72..0353f6f3b95 100644
--- a/gcc/java/lang.cc
+++ b/gcc/java/lang.cc
@@ -57,6 +57,7 @@ static bool java_decl_ok_for_sibcall (const_tree);
 static enum classify_record java_classify_record (tree type);
 
 static tree java_eh_personality (void);
+static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *);
 
 #ifndef TARGET_OBJECT_SUFFIX
 # define TARGET_OBJECT_SUFFIX ".o"
@@ -65,9 +66,9 @@ static tree java_eh_personality (void);
 /* Table of machine-independent attributes.  */
 const struct attribute_spec java_attribute_table[] =
 {
- { "nonnull",0, -1, false, true, true,
-			  NULL, false },
-  { NULL, 0, 0, false, false, false, NULL, false }
+ { "nonnull",0, -1, false, true, true, false,
+			  handle_nonnull_attribute, NULL },
+  { NULL, 0, 0, false, false, false, false, NULL, NULL }
 };
 
 /* Used to avoid printing error messages with bogus function
@@ -909,4 +910,15 @@ java_eh_personality (void)
   return java_eh_personality_decl;
 }
 
+/* Handle the "nonnull" attribute.
+   FIXME: Implement an actual function here. */
+
+static tree
+handle_nonnull_attribute
+  (tree ARG_UNUSED (*node), tree ARG_UNUSED (name), tree ARG_UNUSED (args),
+  int ARG_UNUSED (flags), bool ARG_UNUSED (*no_add_attrs))
+{
+  return NULL_TREE;
+}
+
 #include "gt-java-lang.h"
-- 
2.38.1



[PATCH 16/56] gcc: Re-add TYPE_METHODS.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 19c63dd04c55e0954e181b8b6cd06e435024df70 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:21:50 +1100
Subject: [PATCH 16/56] gcc: Re-add TYPE_METHODS.

gcc/ChangeLog:

	* tree.h (TYPE_METHODS): Re-add.
---
 gcc/tree.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/tree.h b/gcc/tree.h
index a863d2e50e5..56409bfad13 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -2454,6 +2454,8 @@ extern tree vector_element_bits_tree (const_tree);
 
 #define TYPE_MAX_VALUE(NODE) \
   (NUMERICAL_TYPE_CHECK (NODE)->type_non_common.maxval)
+#define TYPE_METHODS(NODE)\
+  (RECORD_OR_UNION_CHECK (NODE)->type_non_common.maxval)
 #define TYPE_METHOD_BASETYPE(NODE)			\
   (FUNC_OR_METHOD_CHECK (NODE)->type_non_common.maxval)
 #define TYPE_OFFSET_BASETYPE(NODE)			\
-- 
2.38.1



[PATCH 32/56] java: Replace pfatal_with_name with fatal_error.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 757dda1de05e322415f3cf26078527626a1c7da5 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:35:41 +1100
Subject: [PATCH 32/56] java: Replace pfatal_with_name with fatal_error.

gcc/java/ChangeLog:

	* jvspec.cc (lang_specific_driver): Replace pfatal_with_name with fatal_error.
---
 gcc/java/jvspec.cc | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/java/jvspec.cc b/gcc/java/jvspec.cc
index 6b138d4cce8..73985751c86 100644
--- a/gcc/java/jvspec.cc
+++ b/gcc/java/jvspec.cc
@@ -432,7 +432,8 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
   record_temp_file (filelist_filename, ! saw_save_temps, 0);
   filelist_file = fopen (filelist_filename, "w");
   if (filelist_file == NULL)
-	pfatal_with_name (filelist_filename);
+	fatal_error (input_location, "cannot read spec file %qs: %m", 
+ filelist_filename);
   num_args -= java_files_count + class_files_count + zip_files_count;
   num_args += 3;  /* for the combined arg "-xjava", and "-xnone" */
 }
@@ -577,7 +578,8 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
   if (combine_inputs)
 {
   if (fclose (filelist_file))
-	pfatal_with_name (filelist_filename);
+	fatal_error (input_location, "cannot read spec file %qs: %m", 
+ filelist_filename);
 }
 
   /* If we saw no -O or -g option, default to -g1, for javac compatibility. */
-- 
2.38.1



[PATCH 29/56] java: Properly handle GET_MODE_SIZE as a poly_uint16.

2022-11-25 Thread Zopolis0 via Gcc-patches

From be336e025f92b7ce30143380f8d1d50a7f02d282 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:32:58 +1100
Subject: [PATCH 29/56] java: Properly handle GET_MODE_SIZE as a poly_uint16.

gcc/java/ChangeLog:

	* builtins.cc (compareAndSwapLong_builtin): Treat GET_MODE_SIZE as polynomial.
	* expr.cc (expand_java_return): Likewise.
---
 gcc/java/builtins.cc | 2 +-
 gcc/java/expr.cc | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/java/builtins.cc b/gcc/java/builtins.cc
index f27831d51c2..09f6c159aa5 100644
--- a/gcc/java/builtins.cc
+++ b/gcc/java/builtins.cc
@@ -348,7 +348,7 @@ compareAndSwapLong_builtin (tree method_return_type ATTRIBUTE_UNUSED,
  versions.  */
   if (can_compare_and_swap_p (mode,
 			  (flag_use_atomic_builtins
-			   && GET_MODE_SIZE (mode) <= UNITS_PER_WORD)))
+			   && known_le (GET_MODE_SIZE (mode), UNITS_PER_WORD
 {
   tree addr, stmt;
   enum built_in_function fncode = BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_8;
diff --git a/gcc/java/expr.cc b/gcc/java/expr.cc
index 8d897550a59..80bff58d727 100644
--- a/gcc/java/expr.cc
+++ b/gcc/java/expr.cc
@@ -1299,8 +1299,8 @@ expand_java_return (tree type)
 	 The whole if expression just goes away if INT_TYPE_SIZE < 32
 	 is false. */
   if (INT_TYPE_SIZE < 32
-	  && (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (res)))
-	  < GET_MODE_SIZE (TYPE_MODE (type
+	  && known_lt (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (res))),
+	   GET_MODE_SIZE (TYPE_MODE (type
 	retval = build1 (NOP_EXPR, TREE_TYPE (res), retval);
   
   TREE_SIDE_EFFECTS (retval) = 1;
-- 
2.38.1



[PATCH 27/56] java: Replace source_location with location_t.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 3642e1652800078ab126a6d1575a370076d476e0 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:31:22 +1100
Subject: [PATCH 27/56] java: Replace source_location with location_t.

gcc/java/ChangeLog:

	* decl.cc (java_replace_references): Replace source_location with location_t.
	(struct GTY): Likewise.
	* java-tree.h (struct lang_decl_func): Likewise.
---
 gcc/java/decl.cc | 4 ++--
 gcc/java/java-tree.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/java/decl.cc b/gcc/java/decl.cc
index 70eac315113..4fdfaaaf8c1 100644
--- a/gcc/java/decl.cc
+++ b/gcc/java/decl.cc
@@ -341,7 +341,7 @@ java_replace_references (tree *tp, int *walk_subtrees,
 {
   if (TREE_CODE (*tp) == MODIFY_EXPR)
 {
-  source_location loc = EXPR_LOCATION (*tp);
+  location_t loc = EXPR_LOCATION (*tp);
   tree lhs = TREE_OPERAND (*tp, 0);
   /* This is specific to the bytecode compiler.  If a variable has
 	 LOCAL_SLOT_P set, replace an assignment to it with an assignment
@@ -416,7 +416,7 @@ struct GTY(())
 unsigned binding_depth;
 
 /* The location at which this level began.  */
-source_location loc;
+location_t loc;
   };
 
 #define NULL_BINDING_LEVEL (struct binding_level *) NULL
diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h
index d7ccbbe8768..6f286ecf666 100644
--- a/gcc/java/java-tree.h
+++ b/gcc/java/java-tree.h
@@ -739,7 +739,7 @@ struct GTY(()) lang_decl_func {
   int max_locals;
   int max_stack;
   int arg_slot_count;
-  source_location last_line;	/* End line number for a function decl */
+  location_t last_line;	/* End line number for a function decl */
   vec *throws_list;	/* Exception specified by `throws' */
   tree exc_obj;			/* Decl holding the exception object.  */
 
-- 
2.38.1



[PATCH 15/56] libcpp: Change deps_write and make_write to take class mkdeps instead of const cpp_reader and to learn about the the dependency phoniness via a bool argument.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 4ad8c0daab866f3d811006846a8040c9f05c0384 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:19:34 +1100
Subject: [PATCH 15/56] libcpp: Change deps_write and make_write to take class
 mkdeps instead of const cpp_reader and to learn about the the dependency
 phoniness via a bool argument.

libcpp/ChangeLog:

	* include/mkdeps.h (deps_write): Adjust first parm type, re-add phony argument.
	* init.cc (cpp_finish): Adjust accordingly.
	* mkdeps.cc (make_write): Adjust first parm type, re-add phony argument.
	(deps_write): Likewise.
---
 libcpp/include/mkdeps.h |  2 +-
 libcpp/init.cc  |  2 +-
 libcpp/mkdeps.cc| 15 +--
 3 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/libcpp/include/mkdeps.h b/libcpp/include/mkdeps.h
index 96d64641b1a..1eb96d3e8af 100644
--- a/libcpp/include/mkdeps.h
+++ b/libcpp/include/mkdeps.h
@@ -66,7 +66,7 @@ extern void deps_add_dep (class mkdeps *, const char *);
 
 /* Write out a deps buffer to a specified file.  The last argument
is the number of columns to word-wrap at (0 means don't wrap).  */
-extern void deps_write (const cpp_reader *, FILE *, unsigned int);
+extern void deps_write (class mkdeps *, FILE *, bool, unsigned int);
 
 /* Write out a deps buffer to a file, in a form that can be read back
with deps_restore.  Returns nonzero on error, in which case the
diff --git a/libcpp/init.cc b/libcpp/init.cc
index 5f34e3515d2..fb379dcc0cd 100644
--- a/libcpp/init.cc
+++ b/libcpp/init.cc
@@ -870,7 +870,7 @@ cpp_finish (cpp_reader *pfile, FILE *deps_stream)
 _cpp_pop_buffer (pfile);
 
   if (deps_stream)
-deps_write (pfile, deps_stream, 72);
+deps_write (pfile->deps, deps_stream, CPP_OPTION (pfile, deps.phony_targets), 72);
 
   /* Report on headers that could use multiple include guards.  */
   if (CPP_OPTION (pfile, print_include_names))
diff --git a/libcpp/mkdeps.cc b/libcpp/mkdeps.cc
index 30e87d8b4d7..1921017622f 100644
--- a/libcpp/mkdeps.cc
+++ b/libcpp/mkdeps.cc
@@ -387,10 +387,8 @@ make_write_vec (const mkdeps::vec , FILE *fp,
.PHONY targets for all the dependencies too.  */
 
 static void
-make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax)
+make_write (class mkdeps *d, FILE *fp, bool phony, unsigned int colmax)
 {
-  const mkdeps *d = pfile->deps;
-
   unsigned column = 0;
   if (colmax && colmax < 34)
 colmax = 34;
@@ -398,20 +396,17 @@ make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax)
   if (d->deps.size ())
 {
   column = make_write_vec (d->targets, fp, 0, colmax, d->quote_lwm);
-  if (CPP_OPTION (pfile, deps.modules) && d->cmi_name)
+  if ((d->module_name) && (d->cmi_name))
 	column = make_write_name (d->cmi_name, fp, column, colmax);
   fputs (":", fp);
   column++;
   make_write_vec (d->deps, fp, column, colmax);
   fputs ("\n", fp);
-  if (CPP_OPTION (pfile, deps.phony_targets))
+  if (phony)
 	for (unsigned i = 1; i < d->deps.size (); i++)
 	  fprintf (fp, "%s:\n", munge (d->deps[i]));
 }
 
-  if (!CPP_OPTION (pfile, deps.modules))
-return;
-
   if (d->modules.size ())
 {
   column = make_write_vec (d->targets, fp, 0, colmax, d->quote_lwm);
@@ -468,9 +463,9 @@ make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax)
 /* Really we should be opening fp here.  */
 
 void
-deps_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax)
+deps_write (class mkdeps *d, FILE *fp, bool phony, unsigned int colmax)
 {
-  make_write (pfile, fp, colmax);
+  make_write (d, fp, phony, colmax);
 }
 
 /* Write out a deps buffer to a file, in a form that can be read back
-- 
2.38.1



[PATCH 18/56] Fix regression around friend declarations in local classes [PR69410].

2022-11-25 Thread Zopolis0 via Gcc-patches

From 56b722459a756a283e97c8508c8e187a1c81 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:23:33 +1100
Subject: [PATCH 18/56] Fix regression around friend declarations in local
 classes [PR69410].

gcc/cp/ChangeLog:

	* name-lookup.cc (pop_local_binding): Remove checking assert.
	(pushdecl): Remove overzealous check for friend declarations finding a matching declaration in a nearby scope.
---
 gcc/cp/name-lookup.cc | 20 +---
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index dfa6fb40675..b5f6e84cad9 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -2481,7 +2481,6 @@ pop_local_binding (tree id, tree decl)
 binding->value = NULL_TREE;
   else
 {
-  gcc_checking_assert (binding->type == decl);
   binding->type = NULL_TREE;
 }
 
@@ -3746,24 +3745,7 @@ pushdecl (tree decl, bool hiding)
   check_template_shadow (decl);
 
   if (DECL_DECLARES_FUNCTION_P (decl))
-	{
-	  check_default_args (decl);
-
-	  if (hiding)
-	{
-	  if (level->kind != sk_namespace)
-		{
-		  /* In a local class, a friend function declaration must
-		 find a matching decl in the innermost non-class scope.
-		 [class.friend/11] */
-		  error_at (DECL_SOURCE_LOCATION (decl),
-			"friend declaration %qD in local class without "
-			"prior local declaration", decl);
-		  /* Don't attempt to push it.  */
-		  return error_mark_node;
-		}
-	}
-	}
+	check_default_args (decl);
 
   if (level->kind != sk_namespace)
 	{
-- 
2.38.1



[PATCH 25/56] java: Replace PTR with 'void *'.

2022-11-25 Thread Zopolis0 via Gcc-patches

From c4e928a8f9d194a45ac4fd1b638c9978da790dea Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:29:21 +1100
Subject: [PATCH 25/56] java: Replace PTR with 'void *'.

gcc/java/ChangeLog:

	* expr.cc (pop_arguments): Use void * instead of PTR.
	* jcf.h (GTY): Likewise.
---
 gcc/java/expr.cc | 2 +-
 gcc/java/jcf.h   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/java/expr.cc b/gcc/java/expr.cc
index ba798ca3165..8d897550a59 100644
--- a/gcc/java/expr.cc
+++ b/gcc/java/expr.cc
@@ -1956,7 +1956,7 @@ pop_arguments (tree method_type)
   return args;
 }
 
-/* Attach to PTR (a block) the declaration found in ENTRY. */
+/* Attach to void * (a block) the declaration found in ENTRY. */
 
 int
 attach_init_test_initialization_flags (treetreehash_entry **slot, tree block)
diff --git a/gcc/java/jcf.h b/gcc/java/jcf.h
index f14b2388db0..87531edc13c 100644
--- a/gcc/java/jcf.h
+++ b/gcc/java/jcf.h
@@ -110,7 +110,7 @@ typedef struct GTY(()) JCF {
   unsigned int right_zip : 1;
   unsigned int finished : 1;
   jcf_filbuf_t filbuf;
-  PTR GTY ((skip)) read_state;
+  void * GTY ((skip)) read_state;
   const char *filename;
   const char *classname;
   /* Directory entry where it was found.  */
-- 
2.38.1



[PATCH 26/56] java: Remove 'FREE' macro.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 186b17cf869fa906761987e2d34ecbc4c8adb514 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:30:19 +1100
Subject: [PATCH 26/56] java: Remove 'FREE' macro.

gcc/java/ChangeLog:

	* jcf-parse.cc (parse_zip_file_entries): Use free instead of FREE.
	* jcf.h (FREE): Remove.
---
 gcc/java/jcf-parse.cc | 2 +-
 gcc/java/jcf.h| 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/gcc/java/jcf-parse.cc b/gcc/java/jcf-parse.cc
index 7fb734215c2..b5e39fd5a5c 100644
--- a/gcc/java/jcf-parse.cc
+++ b/gcc/java/jcf-parse.cc
@@ -2060,7 +2060,7 @@ parse_zip_file_entries (void)
 	char *class_name = compute_class_name (zdir);
 	int previous_alias_set = -1;
 	klass = lookup_class (get_identifier (class_name));
-	FREE (class_name);
+	free (class_name);
 	current_jcf = TYPE_JCF (klass);
 	output_class = current_class = klass;
 
diff --git a/gcc/java/jcf.h b/gcc/java/jcf.h
index 87531edc13c..5ad906d9e81 100644
--- a/gcc/java/jcf.h
+++ b/gcc/java/jcf.h
@@ -36,9 +36,6 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 
 #define ALLOC xmalloc
 #define REALLOC xrealloc
-#ifndef FREE
-#define FREE(PTR) free(PTR)
-#endif
 
 #ifdef JCF_word
 #define JCF_word JCF_u4
-- 
2.38.1



[PATCH 13/56] Re-add flag_evaluation_order, reorder_operands_p, and add reorder bool argument to tree_swap_operands_p.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 4a60186570defebed7d811b37c46092267407a96 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:05:50 +1100
Subject: [PATCH 13/56] Re-add flag_evaluation_order, reorder_operands_p, and
 add reorder bool argument to tree_swap_operands_p.

gcc/ChangeLog:

	* common.opt (flag_evaluation_order): Re-add.
	* expr.cc (expand_operands): Re-add code guarded by flag_evaluation_order.
	* fold-const.cc (reorder_operands_p): Re-add.
	(negate_expr_p): Handle reorder_operands_p.
	(fold_negate_expr_1): Likewise.
	(tree_swap_operands_p): Re-add reorder argument.
	(fold_binary_loc): Likewise.
	(fold_ternary_loc): Likewise
	* fold-const.h (tree_swap_operands_p): Likewise.
	* genmatch.cc (dt_operand::gen_gimple_expr): Likewise.
	* gimple-fold.cc (fold_stmt_1): Likewise.
	* gimple-match-head.cc (gimple_resimplify2): Likewise.
	(gimple_resimplify3): Likewise.
	(gimple_resimplify4): Likewise.
	(gimple_resimplify5): Likewise.
	(gimple_simplify): Likewise.
	* match.pd: Likewise.
	* tree-ssa-dom.cc (record_equality): Likewise.
	* tree-ssa-reassoc.cc (optimize_range_tests_var_bound): Likewise.
	* tree-ssa-sccvn.cc (vn_nary_op_compute_hash): Likewise.
	* tree-ssa-threadedge.cc: Likewise.
---
 gcc/common.opt |  4 +++
 gcc/expr.cc|  4 +++
 gcc/fold-const.cc  | 51 ++
 gcc/fold-const.h   |  2 +-
 gcc/genmatch.cc|  2 +-
 gcc/gimple-fold.cc |  8 +++---
 gcc/gimple-match-head.cc   | 20 +--
 gcc/match.pd   |  2 +-
 gcc/tree-ssa-dom.cc|  2 +-
 gcc/tree-ssa-reassoc.cc|  2 +-
 gcc/tree-ssa-sccvn.cc  |  4 +--
 gcc/tree-ssa-threadedge.cc |  2 +-
 12 files changed, 74 insertions(+), 29 deletions(-)

diff --git a/gcc/common.opt b/gcc/common.opt
index 26e9d1cc4e7..318eafc2e8c 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -62,6 +62,10 @@ int flag_complex_method = 1
 Variable
 int flag_default_complex_method = 1
 
+; Nonzero if subexpressions must be evaluated from left-to-right.
+Variable
+int flag_evaluation_order = 0
+
 ; Language specific warning pass for unused results.
 Variable
 bool flag_warn_unused_result = false
diff --git a/gcc/expr.cc b/gcc/expr.cc
index d9407432ea5..2e770ab090d 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -8576,6 +8576,10 @@ expand_operands (tree exp0, tree exp1, rtx target, rtx *op0, rtx *op1,
 }
   else
 {
+  /* If we need to preserve evaluation order, copy exp0 into its own
+	 temporary variable so that it can't be clobbered by exp1.  */
+  if (flag_evaluation_order && TREE_SIDE_EFFECTS (exp1))
+	exp0 = save_expr (exp0);
   *op0 = expand_expr (exp0, target, VOIDmode, modifier);
   *op1 = expand_expr (exp1, NULL_RTX, VOIDmode, modifier);
 }
diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index b89cac91cae..374878b31a4 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -139,6 +139,7 @@ static tree fold_cond_expr_with_comparison (location_t, tree, enum tree_code,
 static tree unextend (tree, int, int, tree);
 static tree extract_muldiv (tree, tree, enum tree_code, tree, bool *);
 static tree extract_muldiv_1 (tree, tree, enum tree_code, tree, bool *);
+static bool reorder_operands_p (const_tree, const_tree);
 static tree fold_binary_op_with_conditional_arg (location_t,
 		 enum tree_code, tree,
 		 tree, tree,
@@ -472,7 +473,9 @@ negate_expr_p (tree t)
 	  && ! TYPE_OVERFLOW_WRAPS (type)))
 	return false;
   /* -(A + B) -> (-B) - A.  */
-  if (negate_expr_p (TREE_OPERAND (t, 1)))
+  if (negate_expr_p (TREE_OPERAND (t, 1))
+	  && reorder_operands_p (TREE_OPERAND (t, 0),
+ TREE_OPERAND (t, 1)))
 	return true;
   /* -(A + B) -> (-A) - B.  */
   return negate_expr_p (TREE_OPERAND (t, 0));
@@ -482,7 +485,9 @@ negate_expr_p (tree t)
   return !HONOR_SIGN_DEPENDENT_ROUNDING (type)
 	 && !HONOR_SIGNED_ZEROS (type)
 	 && (! ANY_INTEGRAL_TYPE_P (type)
-		 || TYPE_OVERFLOW_WRAPS (type));
+		 || TYPE_OVERFLOW_WRAPS (type))
+	 && reorder_operands_p (TREE_OPERAND (t, 0),
+TREE_OPERAND (t, 1));
 
 case MULT_EXPR:
   if (TYPE_UNSIGNED (type))
@@ -643,7 +648,9 @@ fold_negate_expr_1 (location_t loc, tree t)
 	  && !HONOR_SIGNED_ZEROS (type))
 	{
 	  /* -(A + B) -> (-B) - A.  */
-	  if (negate_expr_p (TREE_OPERAND (t, 1)))
+	  if (negate_expr_p (TREE_OPERAND (t, 1))
+	  && reorder_operands_p (TREE_OPERAND (t, 0),
+ TREE_OPERAND (t, 1)))
 	{
 	  tem = negate_expr (TREE_OPERAND (t, 1));
 	  return fold_build2_loc (loc, MINUS_EXPR, type,
@@ -663,7 +670,8 @@ fold_negate_expr_1 (location_t loc, tree t)
 case MINUS_EXPR:
   /* - (A - B) -> B - A  */
   if (!HONOR_SIGN_DEPENDENT_ROUNDING (type)
-	  && !HONOR_SIGNED_ZEROS (type))
+	  && !HONOR_SIGNED_ZEROS (element_mode (type))
+	  && reorder_operands_p (TREE_OPERAND (t, 0), TREE_OPERAND (t, 1)))
 	return fold_build2_loc (loc, MINUS_EXPR, type,
 TREE_OPERAND (t, 1), 

[PATCH 12/56] Re-add Java (to) comments.

2022-11-25 Thread Zopolis0 via Gcc-patches

From d686e07a2900e8fe2c13b58b0a00021ce932e507 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:03:34 +1100
Subject: [PATCH 12/56] Re-add Java (to) comments.

gcc/ChangeLog:

	* cfgexpand.cc (expand_gimple_basic_block): Re-add Java comment.
	* gimplify.cc (gimplify_save_expr): Re-add Java to comment.
	* ipa-utils.h (polymorphic_type_binfo_p): Re-add Java comment.
	* langhooks.h (struct lang_hooks): Re-add Java to comment.
	* tree-cfg.cc (verify_gimple_call): Re-add Java comment.
	* tree-eh.cc (lower_try_finally_switch): Likewise.
	(lower_resx): Re-add Java to comment.
	* tree.cc (build_common_builtin_nodes): Likewise.
	* varasm.cc (assemble_external): Likewise.
---
 gcc/cfgexpand.cc | 2 ++
 gcc/gimplify.cc  | 3 ++-
 gcc/ipa-utils.h  | 3 +++
 gcc/langhooks.h  | 2 +-
 gcc/tree-cfg.cc  | 2 ++
 gcc/tree-eh.cc   | 8 +++-
 gcc/tree.cc  | 2 +-
 gcc/varasm.cc| 2 +-
 8 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc
index dd29c03..b85934c511a 100644
--- a/gcc/cfgexpand.cc
+++ b/gcc/cfgexpand.cc
@@ -5824,6 +5824,8 @@ expand_gimple_basic_block (basic_block bb, bool disable_tail_calls)
   if (elt)
 	emit_label (*elt);
 
+  /* Java emits line number notes in the top of labels.
+	 ??? Make this go away once line number notes are obsoleted.  */
   BB_HEAD (bb) = NEXT_INSN (last);
   if (NOTE_P (BB_HEAD (bb)))
 	BB_HEAD (bb) = NEXT_INSN (BB_HEAD (bb));
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 02415cb1b5c..eb562c3a313 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -6447,7 +6447,8 @@ gimplify_save_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
   /* If the SAVE_EXPR has not been resolved, then evaluate it once.  */
   if (!SAVE_EXPR_RESOLVED_P (*expr_p))
 {
-  /* The operand may be a void-valued expression.  It is
+  /* The operand may be a void-valued expression such as SAVE_EXPRs
+	 generated by the Java frontend for class initialization.  It is
 	 being executed only for its side-effects.  */
   if (TREE_TYPE (val) == void_type_node)
 	{
diff --git a/gcc/ipa-utils.h b/gcc/ipa-utils.h
index 3ca058c0b56..89245263141 100644
--- a/gcc/ipa-utils.h
+++ b/gcc/ipa-utils.h
@@ -186,6 +186,9 @@ possible_polymorphic_call_target_p (struct cgraph_edge *e,
 inline bool
 polymorphic_type_binfo_p (const_tree binfo)
 {
+  /* See if BINFO's type has an virtual table associtated with it.
+ Check is defensive because of Java FE produces BINFOs
+ without BINFO_TYPE set.   */
   return (BINFO_TYPE (binfo) && TYPE_BINFO (BINFO_TYPE (binfo))
 	  && BINFO_VTABLE (TYPE_BINFO (BINFO_TYPE (binfo;
 }
diff --git a/gcc/langhooks.h b/gcc/langhooks.h
index b1b2b0e10f0..c8f5136d840 100644
--- a/gcc/langhooks.h
+++ b/gcc/langhooks.h
@@ -359,7 +359,7 @@ struct lang_hooks_for_lto
 struct lang_hooks
 {
   /* String identifying the front end and optionally language standard
- version, e.g. "GNU C++98".  */
+ version, e.g. "GNU C++98" or "GNU Java".  */
   const char *name;
 
   /* sizeof (struct lang_identifier), so make_node () creates
diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index d982988048f..aa0cd454aa3 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -3470,6 +3470,8 @@ verify_gimple_call (gcall *stmt)
   && !useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (fntype))
   /* ???  At least C++ misses conversions at assignments from
 	 void * call results.
+	 ???  Java is completely off.  Especially with functions
+	 returning java.lang.Object.
 	 For now simply allow arbitrary pointer type conversions.  */
   && !(POINTER_TYPE_P (TREE_TYPE (lhs))
 	   && POINTER_TYPE_P (TREE_TYPE (fntype
diff --git a/gcc/tree-eh.cc b/gcc/tree-eh.cc
index ae8fa21d9a3..fd768913e76 100644
--- a/gcc/tree-eh.cc
+++ b/gcc/tree-eh.cc
@@ -1564,6 +1564,12 @@ lower_try_finally_switch (struct leh_state *state, struct leh_tf_state *tf)
 /* Decide whether or not we are going to duplicate the finally block.
There are several considerations.
 
+   First, if this is Java, then the finally block contains code
+   written by the user.  It has line numbers associated with it,
+   so duplicating the block means it's difficult to set a breakpoint.
+   Since controlling code generation via -g is verboten, we simply
+   never duplicate code without optimization.
+
Second, we'd like to prevent egregious code growth.  One way to
do this is to estimate the size of the finally block, multiply
that by the number of copies we'd need to make, and compare against
@@ -3433,7 +3439,7 @@ lower_resx (basic_block bb, gresx *stmt,
 	 _Unwind_Resume library function.  */
 
   /* The ARM EABI redefines _Unwind_Resume as __cxa_end_cleanup
-	 with no arguments for C++.  Check for that.  */
+	 with no arguments for C++ and Java.  Check for that.  */
   if (src_r->use_cxa_end_cleanup)
 	{
 	  fn = builtin_decl_implicit (BUILT_IN_CXA_END_CLEANUP);
diff --git a/gcc/tree.cc 

[PATCH 24/56] java: Add empty selftest hook.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 3972b6e455e33a9a03dbddfe05f4fb2110b47492 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 14:28:04 +1100
Subject: [PATCH 24/56] java: Add empty selftest hook.

gcc/java/ChangeLog:

	* Make-lang.in: Add empty selftest hook.
---
 gcc/java/Make-lang.in | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/java/Make-lang.in b/gcc/java/Make-lang.in
index 80e221b30a7..6e28ea3c9ad 100644
--- a/gcc/java/Make-lang.in
+++ b/gcc/java/Make-lang.in
@@ -150,6 +150,9 @@ java.srcman: $(JAVA_MANFILES)
 check-java :
 check-java-subtargets :
 
+# No Java-specific selftests.
+selftest-java:
+
 # Install hooks:
 # jc1, gcj, and jvgenmain are installed elsewhere as part
 # of $(COMPILERS).
-- 
2.38.1



[PATCH 20/56] Re-add Java handling to gcc and gcc/cp.

2022-11-25 Thread Zopolis0 via Gcc-patches

From a7801c18fac9b20ee47d09ed15380a83fabeeec9 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:34:30 +1100
Subject: [PATCH 20/56] Re-add Java handling to gcc and gcc/cp.

gcc/cp/ChangeLog:

	* call.cc (build_java_interface_fn_ref): Re-add.
	(build_over_call): Handle TYPE_JAVA_INTERFACE.
	(java_iface_lookup_fn): Re-add.
	* class.cc (add_method): Handle TYPE_FOR_JAVA.
	(add_implicitly_declared_members): Likewise.
	(determine_key_method): Likewise.
	(finish_struct_1): Likewise.
	(push_lang_context): Handle lang_name_java.
	* cp-lang.cc (cp_eh_personality): Handle pragma_java_exceptions.
	* cp-tree.h (enum cp_tree_index): Re-add CPTI_JAVA_*, CPTI_LANG_NAME_JAVA and CPTI_JCLASS.
	(java_byte_type_node): Re-add.
	(java_short_type_node): Likewise.
	(java_int_type_node): Likewise.
	(java_long_type_node): Likewise.
	(java_float_type_node): Likewise.
	(java_double_type_node): Likewise.
	(java_char_type_node): Likewise.
	(java_boolean_type_node): Likewise.
	(lang_name_java): Likewise.
	(jclass_node): Likewise.
	(cp_global_trees): Re-add TYPE_FOR_JAVA.
	(enum languages): Re-add lang_java.
	(TYPE_FOR_JAVA): Re-add.
	(struct lang_type): Re-add java_interface.
	(TYPE_JAVA_INTERFACE): Re-add.
	(struct lang_decl_base): Increase language by 1.
	(check_java_method): Re-add.
	(build_java_class_ref): Likewise.
	(pragma_java_exceptions): Likewise.
	* decl.cc (record_builtin_java_type): Re-add.
	(initialize_predefined_identifiers): Re-add Java.
	(cxx_init_decl_processing): Re-add java_*_type_node.
	(cp_finish_decl): Handle TYPE_FOR_JAVA.
	(grokfndecl): Likewise.
	(check_special_function_return_type): Likewise.
	(grokdeclarator): Set TYPE_FOR_JAVA.
	(grokparms): Handle TYPE_FOR_JAVA.
	(xref_basetypes): Likewise.
	(check_function_type): Likewise.
	(maybe_return_this): Likewise.
	* decl2.cc (acceptable_java_type): Re-add.
	(check_java_method): Likewise.
	(import_export_decl): Handle TYPE_FOR_JAVA.
	(build_java_method_aliases): Re-add.
	(c_parse_final_cleanups): Call build_java_method_aliases.
	(possibly_inlined_p): Test pragma_java_exceptions.
	* error.cc (language_to_string): Handle lang_java.
	* except.cc (decl_is_java_type): Re-add.
	(eh_type_info): Re-add java type handling.
	(choose_personality_routine): Re-add.
	(initialize_handler_parm): Call choose_personality_routine.
	(expand_start_catch_block): Handle java types.
	(build_throw): Likewise.
	* init.cc (build_new_1): Handle TYPE_FOR_JAVA.
	(build_java_class_ref): Likewise.
	* lex.cc (handle_pragma_java_exceptions): Re-add.
	(init_cp_pragma): Register GCC java_exceptions pragma.
	(set_decl_linkage): Handle lang_name_java.
	* mangle.cc (write_java_integer_type_codes): Re-add.
	(write_builtin_type): Handle TYPE_FOR_JAVA.
	(write_bare_function_type): Handle java_*_type_node.
	* method.cc (implicitly_declare_fn): Handle TYPE_FOR_JAVA.
	* name-lookup.cc (pushtag): Set TYPE_FOR_JAVA.
	* pt.cc (maybe_new_partial_specialization): Copy TYPE_FOR_JAVA.
	(lookup_template_class): Likewise.
	(instantiate_class_template): Likewise.
	* tree.cc (handle_java_interface_attribute): Re-add.
	* typeck.cc (structural_comptypes): Compare TYPE_FOR_JAVA.

gcc/ChangeLog:

	* dwarf2out.cc (is_java): Re-add.
	(output_pubname): Handle is_java.
	(lower_bound_default): Handle DW_LANG_Java.
	(gen_compile_unit_die): Likewise.
	* gimplify.cc (mostly_copy_tree_r): Re-add Java-special part.
	* ipa-free-lang-data.cc (free_lang_data_in_type): Handle Java's usage of TYPE_MIN_VALUE.
	(find_decls_types_r): Handle Java's usage of TYPE_BINFO.
	* tree.cc (verify_type): Handle Java's usage of TYPE_MIN_VALUE, TYPE_BINFO, and TYPE_STRING_FLAG.
---
 gcc/cp/call.cc|  66 -
 gcc/cp/class.cc   |  50 -
 gcc/cp/cp-lang.cc |   5 +-
 gcc/cp/cp-tree.h  |  45 ++-
 gcc/cp/decl.cc| 124 +--
 gcc/cp/decl2.cc   | 122 +-
 gcc/cp/error.cc   |   3 +
 gcc/cp/except.cc  | 152 +-
 gcc/cp/init.cc| 128 +---
 gcc/cp/lex.cc |  18 +
 gcc/cp/mangle.cc  |  62 +++-
 gcc/cp/method.cc  |   2 +-
 gcc/cp/name-lookup.cc |   3 +
 gcc/cp/pt.cc  |   3 +
 gcc/cp/tree.cc|  28 +++
 gcc/cp/typeck.cc  |   2 +
 gcc/dwarf2out.cc  |  17 -
 gcc/gimplify.cc   |   7 +-
 gcc/ipa-free-lang-data.cc |  16 +++-
 gcc/tree.cc   |  30 +++-
 20 files changed, 839 insertions(+), 44 deletions(-)

diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index 459e86b5f09..32ead577737 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -167,6 +167,7 @@ static int compare_ics (conversion *, conversion *);
 static void maybe_warn_class_memaccess (location_t, tree,
 	const vec *);
 static tree build_over_call (struct z_candidate *, int, tsubst_flags_t);
+static tree build_java_interface_fn_ref (tree, tree);

[PATCH 11/56] Re-add handling of Java file extensions (.java, .class, .zip, .jar).

2022-11-25 Thread Zopolis0 via Gcc-patches

From 72b2446899b30213647de3d504f3f9058f49b027 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 17 Nov 2022 14:16:08 +1100
Subject: [PATCH 11/56] Re-add handling of Java file extensions (.java, .class,
 .zip, .jar).

gcc/ChangeLog:

	* gcc.cc: Re-add compiler defaults for .java and .zip files.
	* gimple-expr.cc (remove_suffix): Change as there is now a longer extension than 4 letters.
	* opts.cc (strip_off_ending): Change as there is now a longer extension than 4 letters.
---
 gcc/gcc.cc | 2 ++
 gcc/gimple-expr.cc | 4 ++--
 gcc/opts.cc| 4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index ca1c9e27a94..4f596c63773 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -1421,6 +1421,8 @@ static const struct compiler default_compilers[] =
   {".f03", "#Fortran", 0, 0, 0}, {".F03", "#Fortran", 0, 0, 0},
   {".f08", "#Fortran", 0, 0, 0}, {".F08", "#Fortran", 0, 0, 0},
   {".r", "#Ratfor", 0, 0, 0},
+  {".java", "#Java", 0, 0, 0}, {".class", "#Java", 0, 0, 0},
+  {".zip", "#Java", 0, 0, 0}, {".jar", "#Java", 0, 0, 0},
   {".go", "#Go", 0, 1, 0},
   {".d", "#D", 0, 1, 0}, {".dd", "#D", 0, 1, 0}, {".di", "#D", 0, 1, 0},
   /* Next come the entries for C.  */
diff --git a/gcc/gimple-expr.cc b/gcc/gimple-expr.cc
index 4fbce9369c7..c25d8ee4750 100644
--- a/gcc/gimple-expr.cc
+++ b/gcc/gimple-expr.cc
@@ -393,14 +393,14 @@ copy_var_decl (tree var, tree name, tree type)
 /* Strip off a legitimate source ending from the input string NAME of
length LEN.  Rather than having to know the names used by all of
our front ends, we strip off an ending of a period followed by
-   up to four characters.  (like ".cpp".)  */
+   up to five characters.  (Java uses ".class".)  */
 
 static inline void
 remove_suffix (char *name, int len)
 {
   int i;
 
-  for (i = 2;  i < 7 && len > i;  i++)
+  for (i = 2;  i < 8 && len > i;  i++)
 {
   if (name[len - i] == '.')
 	{
diff --git a/gcc/opts.cc b/gcc/opts.cc
index 3797784c865..5df153cc2cb 100644
--- a/gcc/opts.cc
+++ b/gcc/opts.cc
@@ -275,13 +275,13 @@ set_struct_debug_option (struct gcc_options *opts, location_t loc,
 /* Strip off a legitimate source ending from the input string NAME of
length LEN.  Rather than having to know the names used by all of
our front ends, we strip off an ending of a period followed by
-   up to fource characters.  (C++ uses ".cpp".)  */
+   up to five characters.  (Java uses ".class".)  */
 
 void
 strip_off_ending (char *name, int len)
 {
   int i;
-  for (i = 2; i < 5 && len > i; i++)
+  for (i = 2; i < 6 && len > i; i++)
 {
   if (name[len - i] == '.')
 	{
-- 
2.38.1



[PATCH 10/56] Re-add JCR_SECTION_NAME, TARGET_USE_JCR_SECTION, __LIBGCC_JCR_SECTION_NAME__, _Jv_RegisterClasses, __JCR_LIST__, __JCR_END__.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 82fa9c7851beeb448fc6977f92297fb123c9f1de Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 18:44:19 +1100
Subject: [PATCH 10/56] Re-add JCR_SECTION_NAME, TARGET_USE_JCR_SECTION,
 __LIBGCC_JCR_SECTION_NAME__, _Jv_RegisterClasses, __JCR_LIST__, __JCR_END__.

gcc/c-family/ChangeLog:

	* c-cppbuiltin.cc (c_cpp_builtins): Define __LIBGCC_JCR_SECTION_NAME__.

gcc/ChangeLog:

	* config/darwin.h (JCR_SECTION_NAME): Define.
	* config/i386/cygming.h (TARGET_USE_JCR_SECTION): Likewise.
	* config/i386/mingw32.h (TARGET_USE_JCR_SECTION): Undefine.
	* config/pa/pa64-hpux.h (JCR_SECTION_NAME): Re-add.
	* config/rs6000/aix71.h (TARGET_USE_JCR_SECTION): Define.
	* defaults.h (JCR_SECTION_NAME): Define.
	(TARGET_USE_JCR_SECTION): Define.
	* doc/tm.texi.in (TARGET_USE_JCR_SECTION): Document.
	* doc/tm.texi: Regenerate.
	* system.h (fancy_abort): Do not poison TARGET_USE_JCR_SECTION nor JCR_SECTION_NAME.

libgcc/ChangeLog:

	* config/i386/cygming-crtbegin.c (_Jv_RegisterClasses): Re-add.
	(__JCR_LIST__): Likewise.
	(__gcc_register_frame): Attempt to _Jv_RegisterClasses.
	* config/i386/cygming-crtend.c (__JCR_END__): Re-add.
	* config/ia64/crtbegin.S (__JCR_LIST__): Likewise.
	* config/ia64/crtend.S (__JCR_END__): Likewise.
	* config/pa/pa64-hpux-lib.h (defined):
	* crtstuff.c: Re-add __LIBGCC_JCR_SECTION_NAME__ to preprocessor conditionals.
	(__JCR_LIST__, __JCR_END__): Re-add.
	(frame_dummy): Attempt to _Jv_RegisterClasses.
	(__do_global_ctors_1): Likewise.
---
 gcc/c-family/c-cppbuiltin.cc  |  4 ++
 gcc/config/darwin.h   |  3 ++
 gcc/config/i386/cygming.h |  5 +++
 gcc/config/i386/mingw32.h |  3 ++
 gcc/config/pa/pa64-hpux.h |  2 +
 gcc/config/rs6000/aix71.h |  2 +
 gcc/defaults.h| 21 ++
 gcc/doc/tm.texi   |  6 +++
 gcc/doc/tm.texi.in|  6 +++
 gcc/system.h  |  3 +-
 libgcc/config/i386/cygming-crtbegin.c | 12 ++
 libgcc/config/i386/cygming-crtend.c   |  8 
 libgcc/config/ia64/crtbegin.S |  4 ++
 libgcc/config/ia64/crtend.S   |  5 +++
 libgcc/config/pa/pa64-hpux-lib.h  |  4 +-
 libgcc/crtstuff.c | 57 ---
 16 files changed, 136 insertions(+), 9 deletions(-)

diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc
index 333f3e138d6..bdc834afbb8 100644
--- a/gcc/c-family/c-cppbuiltin.cc
+++ b/gcc/c-family/c-cppbuiltin.cc
@@ -1480,6 +1480,10 @@ c_cpp_builtins (cpp_reader *pfile)
   builtin_define_with_value ("__LIBGCC_EH_FRAME_SECTION_NAME__",
  EH_FRAME_SECTION_NAME, 1);
 #endif
+#ifdef JCR_SECTION_NAME
+  builtin_define_with_value ("__LIBGCC_JCR_SECTION_NAME__",
+ JCR_SECTION_NAME, 1);
+#endif
 #ifdef CTORS_SECTION_ASM_OP
   builtin_define_with_value ("__LIBGCC_CTORS_SECTION_ASM_OP__",
  CTORS_SECTION_ASM_OP, 1);
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index d1b4f277c2e..3cea1f7a36e 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -1067,6 +1067,9 @@ enum machopic_addr_class {
 #define EH_FRAME_SECTION_NAME   "__TEXT"
 #define EH_FRAME_SECTION_ATTR ",coalesced,no_toc+strip_static_syms+live_support"
 
+/* Java runtime class list.  */
+#define JCR_SECTION_NAME "__DATA,jcr,regular,no_dead_strip"
+
 #undef ASM_PREFERRED_EH_DATA_FORMAT
 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL)  \
   (((CODE) == 2 && (GLOBAL) == 1) \
diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h
index 867ac5bf181..921279b9837 100644
--- a/gcc/config/i386/cygming.h
+++ b/gcc/config/i386/cygming.h
@@ -444,6 +444,11 @@ do {		\
 
 #endif /* HAVE_GAS_WEAK */
 
+/* FIXME: SUPPORTS_WEAK && TARGET_HAVE_NAMED_SECTIONS is true,
+   but for .jcr section to work we also need crtbegin and crtend
+   objects.  */
+#define TARGET_USE_JCR_SECTION 1
+
 /* Decide whether it is safe to use a local alias for a virtual function
when constructing thunks.  */
 #undef TARGET_USE_LOCAL_THUNK_ALIAS_P
diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h
index c1ab489c377..d3a1dd3292e 100644
--- a/gcc/config/i386/mingw32.h
+++ b/gcc/config/i386/mingw32.h
@@ -281,6 +281,9 @@ do {		 \
 #undef TARGET_N_FORMAT_TYPES
 #define TARGET_N_FORMAT_TYPES 3
 
+/* Let defaults.h definition of TARGET_USE_JCR_SECTION apply. */
+#undef TARGET_USE_JCR_SECTION
+
 #define HAVE_ENABLE_EXECUTE_STACK
 #undef  CHECK_EXECUTE_STACK_ENABLED
 #define CHECK_EXECUTE_STACK_ENABLED flag_setstackexecutable
diff --git a/gcc/config/pa/pa64-hpux.h b/gcc/config/pa/pa64-hpux.h
index a35f428bb44..8cb9bef520f 100644
--- a/gcc/config/pa/pa64-hpux.h
+++ b/gcc/config/pa/pa64-hpux.h
@@ -164,6 +164,8 @@ along with GCC; see the file COPYING3.  If not see
 #define DATA_SECTION_ASM_OP	"\t.data"
 #define BSS_SECTION_ASM_OP	"\t.section\t.bss"
 
+#define JCR_SECTION_NAME ".jcr"
+
 #define HP_INIT_ARRAY_SECTION_ASM_OP	"\t.section\t.init"
 

[PATCH 22/56] java: Comment out -fassert documentation.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 802da4df1d0fba08ab3e14529f10942ed87d4eef Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:54:55 +1100
Subject: [PATCH 22/56] java: Comment out -fassert documentation.

gcc/java/ChangeLog:

	* lang.opt: Comment out -fassert documentation.
---
 gcc/java/lang.opt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/java/lang.opt b/gcc/java/lang.opt
index c077b6a97f8..a6596d55a9c 100644
--- a/gcc/java/lang.opt
+++ b/gcc/java/lang.opt
@@ -154,7 +154,7 @@ Java Separate RejectNegative Undocumented
 
 fassert
 Java Var(flag_assert) Init(1)
-Permit the use of the assert keyword.
+; Permit the use of the assert keyword.
 
 fassume-compiled
 Java
-- 
2.38.1



[PATCH 09/56] Re-add LIBGCJ_SONAME.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 724c8fd361781a31f2899876e28ccd783805b599 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 24 Nov 2022 18:48:12 +1100
Subject: [PATCH 09/56] Re-add LIBGCJ_SONAME.

gcc/ChangeLog:

	* config/i386/cygwin.h (LIBGCJ_SONAME): Define.
	* config/i386/mingw32.h (LIBGCJ_SONAME): Likewise.

libgcc/ChangeLog:

	* config/i386/cygming-crtbegin.c (LIBGCJ_SONAME): Define.
---
 gcc/config/i386/cygwin.h  | 3 +++
 gcc/config/i386/mingw32.h | 2 ++
 libgcc/config/i386/cygming-crtbegin.c | 4 
 3 files changed, 9 insertions(+)

diff --git a/gcc/config/i386/cygwin.h b/gcc/config/i386/cygwin.h
index 0a604d65b32..4544b738df1 100644
--- a/gcc/config/i386/cygwin.h
+++ b/gcc/config/i386/cygwin.h
@@ -153,6 +153,9 @@ along with GCC; see the file COPYING3.  If not see
 #endif
 #define LIBGCC_SONAME "cyggcc_s" LIBGCC_EH_EXTN "-1.dll"
 
+/* We should find a way to not have to update this manually.  */
+#define LIBGCJ_SONAME "cyggcj" /*LIBGCC_EH_EXTN*/ "-16.dll"
+
 /* Make stack executable to avoid DEP problems with trampolines.  */
 #define HAVE_ENABLE_EXECUTE_STACK
 #undef  CHECK_EXECUTE_STACK_ENABLED
diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h
index 19a98c3d995..c1ab489c377 100644
--- a/gcc/config/i386/mingw32.h
+++ b/gcc/config/i386/mingw32.h
@@ -294,3 +294,5 @@ do {		 \
 #endif
 #define LIBGCC_SONAME "libgcc_s" LIBGCC_EH_EXTN "-1.dll"
 
+/* We should find a way to not have to update this manually.  */
+#define LIBGCJ_SONAME "cyggcj" /*LIBGCC_EH_EXTN*/ "-16.dll"
diff --git a/libgcc/config/i386/cygming-crtbegin.c b/libgcc/config/i386/cygming-crtbegin.c
index ed97b073819..43096c7813f 100644
--- a/libgcc/config/i386/cygming-crtbegin.c
+++ b/libgcc/config/i386/cygming-crtbegin.c
@@ -42,6 +42,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #define LIBGCC_SONAME "libgcc_s.dll"
 #endif
 
+#ifndef LIBGCJ_SONAME
+#define LIBGCJ_SONAME "libgcj_s.dll"
+#endif
+
 #if DWARF2_UNWIND_INFO
 /* Make the declarations weak.  This is critical for
_Jv_RegisterClasses because it lives in libgcj.a  */
-- 
2.38.1



[PATCH 19/56] Revert "Move void_list_node init to common code". (8ff2a92a0450243e52d3299a13b30f208bafa7e0)

2022-11-25 Thread Zopolis0 via Gcc-patches

From c173c5771008522c13792bf89a27f6c95989dce5 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Fri, 18 Nov 2022 09:26:42 +1100
Subject: [PATCH 19/56] Revert "Move void_list_node init to common code".
 (8ff2a92a0450243e52d3299a13b30f208bafa7e0)

gcc/ada/ChangeLog:

	* gcc-interface/trans.cc (gigi): Initialize void_list_node.

gcc/c-family/ChangeLog:

	* c-common.cc (c_common_nodes_and_builtins): Initialize void_list_node.
	* c-common.h (build_void_list_node): Re-add.

gcc/c/ChangeLog:

	* c-decl.cc (build_void_list_node): Re-add.

gcc/cp/ChangeLog:

	* decl.cc (cxx_init_decl_processing): No longer inline last build_void_list_node call.
	(build_void_list_node): Re-add.

gcc/d/ChangeLog:

	* d-builtins.cc (d_build_c_type_nodes): Initialize void_list_node.

gcc/fortran/ChangeLog:

	* f95-lang.cc (gfc_init_decl_processing): Initialize void_list_node.

gcc/go/ChangeLog:

	* go-lang.cc (go_langhook_init): Initialize void_list_node.

gcc/jit/ChangeLog:

	* dummy-frontend.cc (jit_langhook_init): Initialize void_list_node.

gcc/lto/ChangeLog:

	* lto-lang.cc (lto_build_c_type_nodes): Initialize void_list_node.

gcc/ChangeLog:

	* tree.cc (build_common_tree_nodes): Do not initialize void_list_node here.
---
 gcc/ada/gcc-interface/trans.cc |  1 +
 gcc/c-family/c-common.cc   |  2 ++
 gcc/c-family/c-common.h|  1 +
 gcc/c/c-decl.cc|  8 
 gcc/cp/decl.cc | 10 +-
 gcc/d/d-builtins.cc|  1 +
 gcc/fortran/f95-lang.cc|  2 ++
 gcc/go/go-lang.cc  |  3 +++
 gcc/jit/dummy-frontend.cc  |  3 +++
 gcc/lto/lto-lang.cc|  1 +
 gcc/tree.cc|  2 --
 11 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index 1cd621a9377..da18a4dd49b 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -413,6 +413,7 @@ gigi (Node_Id gnat_root,
   save_gnu_tree (gnat_literal, t, false);
 
   /* Declare the building blocks of function nodes.  */
+  void_list_node = build_tree_list (NULL_TREE, void_type_node);
   void_ftype = build_function_type_list (void_type_node, NULL_TREE);
   ptr_void_ftype = build_pointer_type (void_ftype);
 
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index 6f1f21bc4c1..fe7bbcbc13b 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -4490,6 +4490,8 @@ c_common_nodes_and_builtins (void)
 TYPE_NAME (void_type_node) = void_name;
   }
 
+  void_list_node = build_void_list_node ();
+
   /* Make a type to be the domain of a few array types
  whose domains don't really matter.
  200 is small enough that it always fits in size_t
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index f9d0d2945a5..52962c0f19f 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -840,6 +840,7 @@ extern tree identifier_global_tag (tree);
 extern bool names_builtin_p (const char *);
 extern tree c_linkage_bindings (tree);
 extern void record_builtin_type (enum rid, const char *, tree);
+extern tree build_void_list_node (void);
 extern void start_fname_decls (void);
 extern void finish_fname_decls (void);
 extern const char *fname_as_string (int);
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index 098e475f65d..6d81c37ca38 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -11236,6 +11236,14 @@ record_builtin_type (enum rid rid_index, const char *name, tree type)
 debug_hooks->type_decl (decl, false);
 }
 
+/* Build the void_list_node (void_type_node having been created).  */
+tree
+build_void_list_node (void)
+{
+  tree t = build_tree_list (NULL_TREE, void_type_node);
+  return t;
+}
+
 /* Return a c_parm structure with the given SPECS, ATTRS and DECLARATOR.  */
 
 struct c_parm *
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 544efdc9914..06740d420d9 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -4750,7 +4750,7 @@ cxx_init_decl_processing (void)
   record_unknown_type (init_list_type_node, "init list");
 
   /* Used when parsing to distinguish parameter-lists () and (void).  */
-  explicit_void_list_node = build_tree_list (NULL_TREE, void_type_node);
+  explicit_void_list_node = build_void_list_node ();
 
   {
 /* Make sure we get a unique function type, so we can give
@@ -18659,6 +18659,14 @@ cp_tree_node_structure (union lang_tree_node * t)
 }
 }
 
+/* Build the void_list_node (void_type_node having been created).  */
+tree
+build_void_list_node (void)
+{
+  tree t = build_tree_list (NULL_TREE, void_type_node);
+  return t;
+}
+
 bool
 cp_missing_noreturn_ok_p (tree decl)
 {
diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc
index 51e562a96c1..6533c7e205f 100644
--- a/gcc/d/d-builtins.cc
+++ b/gcc/d/d-builtins.cc
@@ -892,6 +892,7 @@ static GTY(()) tree signed_size_type_node;
 static void
 d_build_c_type_nodes (void)
 {
+  void_list_node = build_tree_list (NULL_TREE, void_type_node);
   string_type_node = 

[PATCH 08/56] Re-add MODIFY_JNI_METHOD_CALL.

2022-11-25 Thread Zopolis0 via Gcc-patches

From 558ba6feeeb75bafdbcadd05a8e708b567b3bfc0 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss 
Date: Thu, 17 Nov 2022 14:08:04 +1100
Subject: [PATCH 08/56] Re-add MODIFY_JNI_METHOD_CALL.

gcc/ChangeLog:

	* config/i386/cygming.h (MODIFY_JNI_METHOD_CALL): Define.
	* doc/tm.texi: Rebuild.
	* doc/tm.texi.in (Misc): Document MODIFY_JNI_METHOD_CALL.
---
 gcc/config/i386/cygming.h |  8 
 gcc/doc/tm.texi   | 16 
 gcc/doc/tm.texi.in| 16 
 3 files changed, 40 insertions(+)

diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h
index 4007fd96eac..867ac5bf181 100644
--- a/gcc/config/i386/cygming.h
+++ b/gcc/config/i386/cygming.h
@@ -376,6 +376,14 @@ do {		\
 	const0_rtx));			\
 }
 
+/* Java Native Interface (JNI) methods on Win32 are invoked using the
+   stdcall calling convention.  */
+#undef MODIFY_JNI_METHOD_CALL
+#define MODIFY_JNI_METHOD_CALL(MDECL)	  \
+  build_type_attribute_variant ((MDECL),  \
+			   build_tree_list (get_identifier ("stdcall"),   \
+		NULL))
+
 /* For Win32 ABI compatibility */
 #undef DEFAULT_PCC_STRUCT_RETURN
 #define DEFAULT_PCC_STRUCT_RETURN 0
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index af77d16030c..c370c34b584 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -11954,6 +11954,22 @@ object files that are not referenced from @code{main} and uses export
 lists.
 @end defmac
 
+@defmac MODIFY_JNI_METHOD_CALL (@var{mdecl})
+Define this macro to a C expression representing a variant of the
+method call @var{mdecl}, if Java Native Interface (JNI) methods
+must be invoked differently from other methods on your target.
+For example, on 32-bit Microsoft Windows, JNI methods must be invoked using
+the @code{stdcall} calling convention and this macro is then
+defined as this expression:
+
+@smallexample
+build_type_attribute_variant (@var{mdecl},
+  build_tree_list
+  (get_identifier ("stdcall"),
+   NULL))
+@end smallexample
+@end defmac
+
 @deftypefn {Target Hook} bool TARGET_CANNOT_MODIFY_JUMPS_P (void)
 This target hook returns @code{true} past the point in which new jump
 instructions could be created.  On machines that require a register for
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 62c49ac46de..1ec14c27b40 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -,6 +,22 @@ object files that are not referenced from @code{main} and uses export
 lists.
 @end defmac
 
+@defmac MODIFY_JNI_METHOD_CALL (@var{mdecl})
+Define this macro to a C expression representing a variant of the
+method call @var{mdecl}, if Java Native Interface (JNI) methods
+must be invoked differently from other methods on your target.
+For example, on 32-bit Microsoft Windows, JNI methods must be invoked using
+the @code{stdcall} calling convention and this macro is then
+defined as this expression:
+
+@smallexample
+build_type_attribute_variant (@var{mdecl},
+  build_tree_list
+  (get_identifier ("stdcall"),
+   NULL))
+@end smallexample
+@end defmac
+
 @hook TARGET_CANNOT_MODIFY_JUMPS_P
 
 @hook TARGET_HAVE_CONDITIONAL_EXECUTION
-- 
2.38.1



  1   2   >