Patrick Palka [Thu, 6 May 2021 13:11:44 +0000 (09:11 -0400)]
libstdc++: Implement LWG 3533 changes to foo_view::iterator::base()
libstdc++-v3/ChangeLog:
* include/std/ranges (filter_view::_Iterator::base): Make the
const& overload unconstrained and return a const reference as
per LWG 3533. Make unconditionally noexcept.
(transform_view::_Iterator::base): Likewise.
(elements_view::_Iterator::base): Likewise.
Patrick Palka [Thu, 6 May 2021 13:11:42 +0000 (09:11 -0400)]
libstdc++: Implement LWG 3391 changes to move/counted_iterator::base()
libstdc++-v3/ChangeLog:
* include/bits/stl_iterator.h (move_iterator::base): Make the
const& overload unconstrained and return a const reference as
per LWG 3391. Make unconditionally noexcept.
(counted_iterator::base): Likewise.
* testsuite/24_iterators/move_iterator/lwg3391.cc: New test.
* testsuite/24_iterators/move_iterator/move_only.cc: Adjust
has_member_base concept to decay-copy the result of base().
Richard Biener [Thu, 6 May 2021 09:17:58 +0000 (11:17 +0200)]
refactor SSA rewriting timevars
This avoids too deep stacks of timevars during incremental
SSA rewrite and basically use TV_TREE_INTO_SSA for all into-SSA
rewrite work and TV_TREE_SSA_INCREMENTAL for update_ssa.
2021-05-06 Richard Biener <rguenther@suse.de>
* timevar.def (TV_TREE_INSERT_PHI_NODES): Remove.
(TV_TREE_SSA_REWRITE_BLOCKS): Likewise.
(TV_TREE_INTO_SSA): New.
* tree-into-ssa.c (insert_phi_nodes): Do not account separately.
(rewrite_blocks): Likewise.
(pass_data_build_ssa): Account to TV_TREE_INTO_SSA.
Jonathan Wakely [Thu, 6 May 2021 12:40:53 +0000 (13:40 +0100)]
libstdc++: Fix definition of std::remove_cvref_t
I originally defined std::remove_cvref_t in terms of the internal
__remove_cvref_t trait, to avoid instantiating the remove_cvref class
template. However, as described in P1715R0 that is observable by users
and is thus non-conforming.
This defines remove_cvref_t as specified in the standard.
libstdc++-v3/ChangeLog:
* include/std/type_traits (remove_cvref_t): Define in terms of
remove_cvref.
* testsuite/20_util/remove_cvref/value.cc: Check alias.
Jakub Jelinek [Thu, 6 May 2021 12:05:06 +0000 (14:05 +0200)]
phiopt: Use gphi *phi instead of gimple *phi some more
Various functions in phiopt are also called with a gphi * but use
gimple * argument for it.
2021-05-06 Jakub Jelinek <jakub@redhat.com>
* tree-ssa-phiopt.c (value_replacement, minmax_replacement,
abs_replacement, xor_replacement,
cond_removal_in_popcount_clz_ctz_pattern,
replace_phi_edge_with_variable): Change type of phi argument from
gimple * to gphi *.
Richard Biener [Thu, 6 May 2021 09:29:25 +0000 (11:29 +0200)]
Avoid update_ssa quadraticness in loop splitting
We already take care to not apply loop splitting to IL produced
by splitting so we should be able to delay updating SSA and
loop-closed SSA that was left broken after loop versioning
until after we processed all opportunities.
2021-05-06 Richard Biener <rguenther@suse.de>
* tree-ssa-loop-split.c (split_loop): Delay updating SSA form.
Output an opt-info message.
(do_split_loop_on_cond): Likewise.
(tree_ssa_split_loops): Update SSA form here.
Richard Biener [Thu, 6 May 2021 07:44:49 +0000 (09:44 +0200)]
Fix IPA SRA removal of DECL_BY_REFERENCE return
While doing bogus call LHS removal I noticed that cloning with
dropping a return value creates a bogus replacement for a
DECL_BY_REFERENCE DECL_RESULT, resulting in MEM_REFs of
aggregates rather than pointers. The following fixes this
latent issue.
The new test gcc.c-torture/execute/ieee/cdivchkld.c needs fmaxl(),
which may not be available, for instance on aarch64-elf with newlib.
As discussed in the PR, requiring c99_runtime enables to skip the test
in this case.
The builtin vec_permi is peculiar in that its immediate operand is
encoded differently than the immediate operand that is backing the
builtin. This fixes the check for the immediate operand, adding a
regression test in the process.
2021-05-06 Marius Hillenbrand <mhillen@linux.ibm.com>
gcc/ChangeLog:
* config/s390/s390-builtins.def (O_M5, O1_M5, ...): Remove unused macros.
(s390_vec_permi_s64, s390_vec_permi_b64, s390_vec_permi_u64)
(s390_vec_permi_dbl, s390_vpdi): Use the O3_U2 type for the immediate
operand.
* config/s390/s390.c (s390_const_operand_ok): Remove unused
values.
gcc/testsuite/ChangeLog:
* gcc.target/s390/zvector/imm-range-error-1.c: Fix test for
__builtin_s390_vpdi.
* gcc.target/s390/zvector/vec-permi.c: New test for builtin
vec_permi.
Jakub Jelinek [Thu, 6 May 2021 08:15:40 +0000 (10:15 +0200)]
phiopt: Optimize (x <=> y) cmp z [PR94589]
genericize_spaceship genericizes i <=> j to approximately
({ int c; if (i == j) c = 0; else if (i < j) c = -1; else c = 1; c; })
for strong ordering and
({ int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; c; })
for partial ordering.
The C++ standard supports then == or != comparisons of that against
strong/partial ordering enums, or </<=/==/!=/>/>= comparisons of <=> result
against literal 0.
In some cases we already optimize that but in many cases we keep performing
all the 2 or 3 comparisons, compute the spaceship value and then compare
that.
The following patch recognizes those patterns if the <=> operands are
integral types or floating point (the latter only for -ffast-math) and
optimizes it to the single comparison that is needed (plus adds debug stmts
if needed for the spaceship result).
There is one thing I'd like to address in a follow-up: the pr94589-2.C
testcase should be matching just 12 times each, but runs
into operator>=(partial_ordering, unspecified) being defined as
(_M_value&1)==_M_value
rather than _M_value>=0. When not honoring NaNs, the 2 case should be
unreachable and so (_M_value&1)==_M_value is then equivalent to _M_value>=0,
but is not a single use but two uses. I'll need to pattern match that case
specially.
* gcc.dg/pr94589-1.c: New test.
* gcc.dg/pr94589-2.c: New test.
* gcc.dg/pr94589-3.c: New test.
* gcc.dg/pr94589-4.c: New test.
* g++.dg/opt/pr94589-1.C: New test.
* g++.dg/opt/pr94589-2.C: New test.
* g++.dg/opt/pr94589-3.C: New test.
* g++.dg/opt/pr94589-4.C: New test.
emutls figured that tls uses in debug-insns need lowering but
that obviously has effects on code-generation as can be seen
in the following IL diff with the new testcase:
where it figured the debug use of b in the original
<bb 2> [local count: 1073741824]:
# DEBUG BEGIN_STMT
# DEBUG D#1 => b
# DEBUG d => (long int) D#1
# DEBUG BEGIN_STMT
a = 0;
needs lowering (it maybe does when we want to produce perfect
debug but that's just bad luck).
The following patch fixes this by avoiding to create a new
emutls address when visiting debug stmts and instead resets them.
Another option might be to simply not lower debug stmt uses
but I have no way to verify actual debug info for this.
2021-05-05 Richard Biener <rguenther@suse.de>
PR ipa/100373
* tree-emutls.c (gen_emutls_addr): Pass in whether we're
dealing with a debug use and only query existing addresses
if so.
(lower_emutls_1): Avoid splitting out addresses for debug
stmts, reset the debug stmt when we fail to find existing
lowered addresses.
(lower_emutls_phi_arg): Set wi.stmt.
Javier Miranda [Sun, 24 Jan 2021 18:57:18 +0000 (13:57 -0500)]
[Ada] ACATS 4.1R-c611a04: Class-wide preconditions in dispatching calls
gcc/ada/
* exp_disp.adb (Build_Class_Wide_Check): Extending the
functionality of this routine to climb to the ancestors
searching for the enclosing overridden dispatching primitive
that has a class-wide precondition to generate the check.
Arnaud Charlet [Fri, 22 Jan 2021 13:55:13 +0000 (08:55 -0500)]
[Ada] Bad expansion with -gnato2 and if expression
gcc/ada/
* exp_ch4.adb (Expand_N_If_Expression):
Apply_Arithmetic_Overflow_Check will not deal with
Then/Else_Actions so skip minimizing overflow checks if any
actions are present.
Piotr Trojanek [Wed, 20 Jan 2021 16:41:09 +0000 (17:41 +0100)]
[Ada] Remove repeated calls in Resolve_Range
gcc/ada/
* sem_res.adb (First_Last_Ref): Simplify "if [condition] then
return True" in "return [condition]".
(Resolve_Range): Remove calls appearing in IF condition from the
THEN statements.
Piotr Trojanek [Wed, 20 Jan 2021 11:41:16 +0000 (12:41 +0100)]
[Ada] Use high-level Make_Character_Literal instead of low-level New_Node
gcc/ada/
* sem_case.adb (Missing_Choice): Fix typo in comment.
(Lit_Of): Simplify with Make_Character_Literal.
(Check_Choices): Remove extra spaces in parameter
specifications.
* sem_case.ads: Same reformatting.
Ed Schonberg [Wed, 20 Jan 2021 21:15:30 +0000 (16:15 -0500)]
[Ada] Missing semantic error on ineffective Others_Clause
gcc/ada/
* exp_aggr.adb (Expand_Array_Aggregate): If the expression in an
Others_Clause has not been analyzed because previous analysis of
the enclosing aggregate showed the clause to be ineffective i.e.
cover a null range, analyze it now to detect a possible type
illegality.
Piotr Trojanek [Fri, 8 Jan 2021 20:43:10 +0000 (21:43 +0100)]
[Ada] Set Raises_CE flag only in Apply_Compile_Time_Constraint_Error
gcc/ada/
* sem_ch4.adb (Analyze_Selected_Component): Remove explicit call
to Set_Raises_Constraint_Error on statically missing component.
* sem_eval.adb (Eval_Arithmetic_Op): Likewise for static
divisions by integer and real zeros.
* sem_util.adb (Apply_Compile_Time_Constraint_Error): Call
Set_Raises_Constraint_Error before exiting early in GNATprove
mode.
Eric Botcazou [Mon, 18 Jan 2021 18:30:27 +0000 (19:30 +0100)]
[Ada] Document a few more characteristics of floating-point support
gcc/ada/
* doc/gnat_rm/implementation_defined_characteristics.rst (3.5.7):
Mention the IEEE standard explicitly. Use current format names.
Document assumed rounding mode and new features of I/O support.
* gnat_rm.texi: Regenerate.
Piotr Trojanek [Fri, 15 Jan 2021 23:00:35 +0000 (00:00 +0100)]
[Ada] Fix restriction No_Enumeration_Maps on both Image attributes
gcc/ada/
* sem_attr.adb (Check_Enum_Image): Reword comment; add
Check_Enumeration_Maps parameter. Now this routine combines
both referencing enumeration literals and checking restriction
No_Enumeration_Maps, if required.
(Analyze_Attribute): Remove duplicated code and instead call
Check_Enum_Image.
Gary Dismukes [Fri, 15 Jan 2021 19:45:42 +0000 (14:45 -0500)]
[Ada] Add mention of underscore and fix grammar error in doc for -gnatd
gcc/ada/
* doc/gnat_ugn/building_executable_programs_with_gnat.rst: Add
mention of underscore and fix grammar error in doc for -gnatd.
* gnat_ugn.texi: Regenerate.
Eric Botcazou [Thu, 14 Jan 2021 12:16:16 +0000 (13:16 +0100)]
[Ada] Implement tiered support for floating-point exponentiation
gcc/ada/
* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add s-exponr, s-exnflt
and s-exnlfl.
* exp_ch4.adb (Expand_N_Op_Expon): Use RE_Exn_Float for Short_Float.
* rtsfind.ads (RTU_Id): Add System_Exn_Flt and System_Exn_LFlt.
(RE_Id): Adjust entries for RE_Exn_Float and RE_Exn_Long_Float.
(RE_Unit_Table): Likewise.
* libgnat/s-exnflt.ads: New file.
* libgnat/s-exnlfl.ads: Likewise.
* libgnat/s-exnllf.ads: Change to mere instantiation.
* libgnat/s-exnllf.adb: Move implementation to...
* libgnat/s-exponr.ads: New generic unit.
* libgnat/s-exponr.adb: ...here and also make it generic.
(Expon): Do the computation in double precision internally.
Ed Schonberg [Thu, 14 Jan 2021 22:54:05 +0000 (17:54 -0500)]
[Ada] Crash on if_expression used as index of discriminant-dependent array
gcc/ada/
* sem_res.adb (Resolve_If_Expression): If the context of the
expression is an indexed_component, resolve the expression and
its dependent_expressions with the base type of the index, to
ensure that an index check is generated when resolving the
enclosing indexxed_component, and avoid an improper use of
discriminants out of scope, when the index type is
discriminant-dependent.
On RISC-V we are facing the fact, that our conditional branches
require Pmode conditions. Currently, we generate them explicitly
with a check for Pmode and then calling the proper generator
(i.e. gen_cbranchdi4 on RV64 and gen_cbranchsi4 on RV32).
Let's simplify this code by generating the INSN helpers
and use gen_cbranch4 (Pmode).
gcc/
PR target/100266
* config/riscv/riscv.c (riscv_block_move_loop): Use cbranch helper.
* config/riscv/riscv.md (cbranch<mode>4): Generate helpers.
(stack_protect_test): Use cbranch helper.
Eric Botcazou [Wed, 5 May 2021 20:48:51 +0000 (22:48 +0200)]
Fix PR target/100402
This is a regression for 64-bit Windows present from mainline down to the 9
branch and introduced by the fix for PR target/99234. Again SEH, but with
a twist related to the way MinGW implements setjmp/longjmp, which turns out
to be piggybacked on SEH with recent versions of MinGW, i.e. the longjmp
performs a bona-fide unwinding of the stack, because it calls RtlUnwindEx
with the second argument initially passed to setjmp, which is the result of
__builtin_frame_address (0) in the MinGW header file:
This means that we directly expose the frame pointer to the SEH machinery
here (unlike with regular exception handling where we use an intermediate
CFA) and thus that we cannot do whatever we want with it. The old code
would leave it unaligned, i.e. not multiple of 16, whereas the new code
aligns it, but this breaks for some reason; at least it appears that a
.seh_setframe directive with 0 as second argument always works, so the
fix aligns it this way.
gcc/
PR target/100402
* config/i386/i386.c (ix86_compute_frame_layout): For a SEH target,
always return the establisher frame for __builtin_frame_address (0).
gcc/testsuite/
* gcc.c-torture/execute/20210505-1.c: New test.
The problem was caused by the fact that internally every invocation of
__builtin_cpu_supports built a new variable __cpu_model and a new type
__processor_model. Because of this, GIMPLE level optimizers weren't able
to CSE the loads of __cpu_model and optimize bit-operations properly.
Improve GCC -O2 code generation by caching __cpu_model and__cpu_features2
variables as well as their types:
Patrick Palka [Wed, 5 May 2021 16:07:32 +0000 (12:07 -0400)]
libstdc++: Implement LWG 3517/3520 for join_view/transform_view
libstdc++-v3/ChangeLog:
* include/std/ranges (transform_view::_Iterator::iter_swap):
Remove as per LWG 3520.
(join_view::_Iterator::iter_swap): Add indirectly_swappable
constraint as per LWG 3517.
Eric Botcazou [Wed, 5 May 2021 14:50:55 +0000 (16:50 +0200)]
Fix PR rtl-optimization/100411
This is the bootstrap failure of GCC 11 on MinGW64 configured with --enable-
tune=nocona. The bottom line is that SEH does not support CFI for epilogues
but the x86 back-end nevertheless attaches it to instructions, so we have to
filter it out and this is done by detecting the end of the prologue by means
of the NOTE_INSN_PROLOGUE_END note.
But the compiler manages to generate a second epilogue before this note in
the RTL stream and this fools the aforementioned logic. The root cause is
cross-jumping, which inserts a jump before the end of the prologue, in fact
just before the note; the rest (CFG cleanup, BB reordering, etc) is downhill
from there.
gcc/
PR rtl-optimization/100411
* cfgcleanup.c (try_crossjump_to_edge): Also skip end of prologue
and beginning of function markers.
Harald Anlauf [Wed, 5 May 2021 13:25:50 +0000 (15:25 +0200)]
PR fortran/100274 - ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131
When the check for the length of formal and actual character arguments
found a mismatch and emitted a warning, it would skip further checks
like that could lead to errors. Fix that by continuing the checking.
Also catch a NULL pointer dereference.
gcc/fortran/ChangeLog:
PR fortran/100274
* interface.c (gfc_compare_actual_formal): Continue checks after
emitting warning for argument length mismatch.
* trans-expr.c (gfc_conv_procedure_call): Check for NULL pointer
dereference.
gcc/testsuite/ChangeLog:
PR fortran/100274
* gfortran.dg/argument_checking_25.f90: New test.
Eric Botcazou [Wed, 5 May 2021 10:07:24 +0000 (12:07 +0200)]
Generate debug info for local dynamic record types
In Ada you can embed VLAs in local record types and thus end up with
dynamic offsets in record types, which are not well described in DWARF
because 1) the temporaries generated for them by the gimplifier are
naturally marked DECL_IGNORED_P and 2) when the types are referenced
in nested subprograms, the DWARF back-end does not correctly handle
the rewritten references.
gcc/
* dwarf2out.c (loc_list_from_tree_1) <DECL>: During early DWARF, do
not expand the VALUE_EXPR of variables put in the non-local frame.
* gimplify.c (gimplify_type_sizes) <RECORD_TYPE>: If the type is not
to be ignored for debug info, ensure its variable offsets are not.
gcc/testsuite/
* gnat.dg/debug8.adb: Minor tweak.
* gnat.dg/debug11.adb: Likewise.
* gnat.dg/debug16.adb: Likewise.
* gnat.dg/debug17.adb: New test.
* gnat.dg/specs/debug1.ads: Minor tweak.
Piotr Trojanek [Wed, 13 Jan 2021 21:53:32 +0000 (22:53 +0100)]
[Ada] Refine types of variables with call to Scope as their initial values
gcc/ada/
* exp_ch4.adb (User_Defined_Primitive_Equality_Op): Refine type
of a local variable.
* exp_dbug.adb (Scope_Contains): Refine all types from Node_Id
to Entity_Id; rename parameters to match those of the
Scope_Within routine (which is similar but not the same); also,
simplify an OR ELSE into a membership test.
Piotr Trojanek [Tue, 12 Jan 2021 20:37:26 +0000 (21:37 +0100)]
[Ada] Remove redundant checks for empty lists
gcc/ada/
* exp_ch4.adb (Variant_Is_Unconstrained_UU): Remove redundant
check for empty list.
* exp_disp.adb (Find_Entry_Index): Simplify by removing
redundant check and counting from zero; fix type of a local
variable.
* sem_ch12.adb (Save_Global_Descendant): Remove an unnecessary
special-case for empty lists.
Ed Schonberg [Tue, 12 Jan 2021 15:46:26 +0000 (10:46 -0500)]
[Ada] Spurious warning on useless assignment with target name
gcc/ada/
* sem_ch5.adb (Analyze_Assignment): Do not emit the warning that
a previous value of the target object is useless if the
right-hand side of the assignment includes target names.
Eric Botcazou [Tue, 12 Jan 2021 15:01:15 +0000 (16:01 +0100)]
[Ada] Do not use hash function for enumeration Value with trampolines
gcc/ada/
* exp_imgv.adb: Add with/use clauses for Targparm.
(Build_Enumeration_Image_Tables): Set type of Threshold to Nat and
initialize it to Nat'Last if the type is local and the target does
not support descriptors. Adjust Threshold_For_Size similarly.
(Expand_Value_Attribute): Minor tweaks.
Eric Botcazou [Tue, 12 Jan 2021 09:38:53 +0000 (10:38 +0100)]
[Ada] Small cleanup in the Expand_Image_Attribute procedure
gcc/ada/
* exp_imgv.adb (Is_User_Defined_Enumeration_Type): Delete.
(Expand_Image_Attribute): Move inline expansion into normal flow of
control, move down declarations and remove superfluous processing.
Ed Schonberg [Sat, 9 Jan 2021 21:57:21 +0000 (16:57 -0500)]
[Ada] Handle defaults in declare_expressions in postconditions
gcc/ada/
* sem_ch3.adb (Find_Type_Of_Object): When In_Spec_Expression is
set and the object declaration generates a subtype indication,
build the corresponding subtype declaration and place it in tree
without the use of Insert_Actions, which is disabled in this
context.
Eric Botcazou [Tue, 12 Jan 2021 12:25:24 +0000 (13:25 +0100)]
[Ada] Use inline expansion of Image for standard boolean by default
gcc/ada/
* debug.adb (d_x): Document extended usage.
* exp_imgv.adb (Expand_Standard_Boolean_Image): New procedure.
(Expand_Image_Attribute): Call it to expand in line the attribute
for standard boolean by default.
Eric Botcazou [Mon, 11 Jan 2021 07:51:16 +0000 (08:51 +0100)]
[Ada] Use inline expansion of Image for enumeration types by default
gcc/ada/
* debug.adb (d_x): Document new usage.
* exp_imgv.adb (Expand_User_Defined_Enumeration_Image): Add Typ
parameter and use it throughout the processing.
(Expand_Image_Attribute): Retrieve the underlying type of the
prefix and use the inline expansion for user-defined enumeration
types with a literal string by default.
Eric Botcazou [Sun, 10 Jan 2021 17:28:35 +0000 (18:28 +0100)]
[Ada] Adjust expansion of perfect hash function for Value
gcc/ada/
* exp_imgv.ads (Build_Enumeration_Image_Tables): Adjust comment.
* exp_imgv.adb (Build_Enumeration_Image_Tables): Add the
declaration nodes of the 4 tables to the declaration list of the
function body.
Piotr Trojanek [Fri, 8 Jan 2021 18:53:41 +0000 (19:53 +0100)]
[Ada] Speed up enumeration'Value with perfect hash function
gcc/ada/
* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add s-imagen, s-imen16,
s-imen32, s-imenu8, s-pehage, s-valuen, s-vaen16, s-vaen32 and
s-vaenu8. Remove s-imenne, s-imgenu and s-valenu.
* debug.adb (d_h): Document new usage.
* einfo.ads (Lit_Hash): New attribute for enumeration types.
(Set_Lit_Hash): Declare.
* einfo.adb (Lit_Hash): New function.
(Set_Lit_Hash): New procedure.
(Write_Field21_Name): Print Lit_Hash for Enumeration_Kind.
* exp_imgv.ads (Build_Enumeration_Image_Tables): Fix description
and document the hash function and its tables.
* exp_imgv.adb: Add with/use clauses for Debug. Add with clause
for System.Perfect_Hash_Generators.
(Append_Table_To): New helper routine.
(Build_Enumeration_Image_Tables): Call it to build the tables.
In the main unit, register the literals with the hash generator.
If they are sufficiently many and -gnatd_h is not passed, generate
a perfect hash function and its tables; otherwise, generate a dummy
hash function. For the other units, generate only the declaration.
In all cases, set Lit_Hash to the entity of the function, if any.
(Expand_Value_Attribute): Pass the 'Unrestricted_Access of Lit_Hash,
if any, as third argument to the Value_Enumeration_NN function.
* gnat1drv.adb (Adjust_Global_Switches): force simpler implementation
of 'Value in CodePeer_Mode.
* lib.ads (Synchronize_Serial_Number): Add SN parameter.
* lib.adb (Synchronize_Serial_Number): Assert that it is larger than
the serial number of the current unit and set the latter to it only
in this case.
* rtsfind.ads (RTU_Id): Add System_Img_Enum_8, System_Img_Enum_16,
System_Img_Enum_32, System_Val_Enum_8, System_Val_Enum_16 and
System_Val_Enum_32. Remove System_Img_Enum, System_Img_Enum_New
and System_Val_Enum.
* sem_attr.adb (Analyze_Access_Attribute): Do not flag a compiler
generated Unrestricted_Access attribute as illegal in a declare
expression.
(RE_Unit_Table): Adjust to above changes.
* libgnat/g-heasor.ads: Add pragma Compiler_Unit_Warning.
* libgnat/g-table.ads: Likewise.
* libgnat/g-pehage.ads: Add with clause and local renaming for
System.Perfect_Hash_Generators.
(Optimization): Turn into derived type.
(Verbose): Turn into renaming.
(Too_Many_Tries): Likewise.
(Table_Name): Move to System.Perfect_Hash_Generators.
(Define): Likewise.
(Value): Likewise.
* libgnat/g-pehage.adb: Remove with clause for Ada.Directories,
GNAT.Heap_Sort_G and GNAT.Table. Move bulk of implementation
to System.Perfect_Hash_Generators, only keep the output part.
* libgnat/s-imagen.ads: New generic unit.
* libgnat/s-imagen.adb: New body.
* libgnat/s-imen16.ads: New unit.
* libgnat/s-imen32.ads: Likewise.
* libgnat/s-imenu8.ads: Likewise.
* libgnat/s-imenne.ads: Adjust description.
* libgnat/s-imgenu.ads: Delete.
* libgnat/s-imgenu.adb: Likewise.
* libgnat/s-pehage.ads: New unit from GNAT.Perfect_Hash_Generators.
* libgnat/s-pehage.adb: New body from GNAT.Perfect_Hash_Generators.
* libgnat/s-valuen.ads: New generic unit.
* libgnat/s-valuen.adb: New body.
* libgnat/s-vaen16.ads: New unit.
* libgnat/s-vaen32.ads: Likewise.
* libgnat/s-vaenu8.ads: Likewise.
* libgnat/s-valenu.ads: Delete.
* libgnat/s-valenu.adb: Likewise.
* gcc-interface/Make-lang.in (GNAT_ADA_OBJS): Add s-pehage.o.
(GNATBIND_OBJS): Remove s-imgenu.o.
Piotr Trojanek [Fri, 8 Jan 2021 18:53:41 +0000 (19:53 +0100)]
[Ada] Remove unnecessary parameter of Apply_Compile_Time_Constraint_Error
gcc/ada/
* sem_util.ads (Apply_Compile_Time_Constraint_Error): Remove
parameter Rep from the function spec and "and if the flag Rep is
set" from the comment.
* sem_util.adb (Apply_Compile_Time_Constraint_Error): Remove
parameter Rep.
Ed Schonberg [Fri, 8 Jan 2021 01:12:34 +0000 (20:12 -0500)]
[Ada] Ongoing work for AI12-0212: container aggregates
gcc/ada/
* sem_aggr.adb (Resolve_Indexed_Aggregate): For indexed
aggregates with component associations verify that if there is
more than one component association then all the choices are
static, that the set of choices define a continuous sequence of
values, and that if loop specfications appear, they do not
include iterator filters or key expressions.
Eric Botcazou [Wed, 6 Jan 2021 14:27:15 +0000 (15:27 +0100)]
[Ada] Implement tiered support for floating-point output operations
gcc/ada/
* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add s-dourea, s-imager,
s-imgflt, s-imglfl and s-imgllf.
(LIBGNAT_TARGET_PAIRS) [PowerPC/VxWorks]: Use s-dorepr__fma.adb.
(LIBGNAT_TARGET_PAIRS) [PowerPC/VxWorksAE]: Likewise.
(LIBGNAT_TARGET_PAIRS) [Aarch64/VxWorks]: Likewise.
(LIBGNAT_TARGET_PAIRS) [Aarch64/QNX]: Likewise.
(LIBGNAT_TARGET_PAIRS) [Aarch64/FreeBSD]: Likewise.
(LIBGNAT_TARGET_PAIRS) [PowerPC/Linux]: Likewise.
(LIBGNAT_TARGET_PAIRS) [Aarch64/Linux]: Likewise.
(LIBGNAT_TARGET_PAIRS) [IA-64/Linux]: Likewise.
(LIBGNAT_TARGET_PAIRS) [IA-64/HP-UX]: Likewise.
(LIBGNAT_TARGET_PAIRS) [RISC-V/Linux]: Likewise.
(LIBGNAT_TARGET_PAIRS) [PowerPC/Darwin]: Likewise.
* exp_attr.adb (Expand_N_Attribute_Reference) [Attribute_Fore]: Use
Fixed suffix and Long_Float type.
* exp_imgv.adb (Expand_Image_Attribute): For floating-point types,
use the routine of the corresponding root type. For ordinary fixed
point types, use Fixed suffix and Long_Float type.
(Expand_Value_Attribute): Revert latest change for Long_Long_Float.
* gcc-interface/Make-lang.in (GNAT_ADA_OBJS): Remove libgnat units
g-hesora.o and s-imgenu.o, add g-heasor.o, g-table.o and s-pehage.o.
(GNATBIND_OBJS): Remove libgnat unit s-imgenu.o.
* rtsfind.ads (RTU_Id): Add System_Img_Flt, System_Img_LFlt and
System_Img_LLF. Remove System_Img_Real.
(RE_Id): Rename RE_Fore_Real to RE_Fore_Fixed. Add RE_Image_Float,
RE_Image_Long_Float and RE_Image_Long_Long_Float. Rename
RE_Image_Ordinary_Fixed_Point to RE_Image_Fixed.
(RE_Unit_Table): Adjust to above changes.
* libgnat/a-nbnbre.adb (Fixed_Conversions): Use Long_Float instead
of Long_Long_Float.
* libgnat/a-textio.ads (Field): Remove obsolete comment.
* libgnat/a-ticoau.ads (Aux): Adjust ancestor package.
* libgnat/a-ticoau.adb: Remove with/use clause for System.Img_Real.
(Puts): Call Aux.Set_Image instead of Set_Image_Real.
* libgnat/a-ticoio.adb: Add with/use clauses for System.Img_Flt,
System.Img_LFlt and System.Img_LLF.
(Scalar_Float): Add third actual parameter.
(Scalar_Long_Float): Likewise.
(Scalar_Long_Long_Float): Likewise.
* libgnat/a-tifiio.adb: Add with/use clauses for System.Img_LFlt
and System.Val_LFlt. Remove the one for System.Val_LLF. Replace
Long_Long_Float with Long_Float throughout.
* libgnat/a-tifiio__128.adb: Likewise.
* libgnat/a-tiflau.ads: Add Set_Image formal parameter.
* libgnat/a-tiflau.adb: Add with/use clause for System.Img_Util,
remove the one for System.Img_Real.
(Put): Call Set_Image instead of Set_Image_Real.
(Puts): Likewise.
* libgnat/a-tiflio.adb: Add with/use clause for System.Img_Flt,
System.Img_LFlt and System.Img_LLF.
(Aux_Float): Add third actual parameter.
(Aux_Long_Float): Likewise.
(Aux_Long_Long_Float): Likewise.
* libgnat/a-witeio.ads (Field): Remove obsolete comment.
* libgnat/a-wtcoau.ads (Aux): Adjust ancestor package.
* libgnat/a-wtcoau.adb: Remove with/use clause for System.Img_Real.
(Puts): Call Aux.Set_Image instead of Set_Image_Real.
* libgnat/a-wtcoio.adb: Add with/use clauses for System.Img_Flt,
System.Img_LFlt and System.Img_LLF.
(Scalar_Float): Add third actual parameter.
(Scalar_Long_Float): Likewise.
(Scalar_Long_Long_Float): Likewise.
* libgnat/a-wtfiio.adb: Add with/use clauses for System.Img_LFlt
and System.Val_LFlt. Remove the one for System.Val_LLF. Replace
Long_Long_Float with Long_Float throughout.
* libgnat/a-wtfiio__128.adb: Likewise.
* libgnat/a-wtflau.ads: Add Set_Image formal parameter.
* libgnat/a-wtflau.adb: Add with/use clause for System.Img_Util,
remove the one for System.Img_Real.
(Put): Call Set_Image instead of Set_Image_Real.
(Puts): Likewise.
* libgnat/a-wtflio.adb: Add with/use clause for System.Img_Flt,
System.Img_LFlt and System.Img_LLF.
(Aux_Float): Add third actual parameter.
(Aux_Long_Float): Likewise.
(Aux_Long_Long_Float): Likewise.
* libgnat/a-ztexio.ads (Field): Remove obsolete comment.
* libgnat/a-ztcoau.ads (Aux): Adjust ancestor package.
* libgnat/a-ztcoau.adb: Remove with/use clause for System.Img_Real.
(Puts): Call Aux.Set_Image instead of Set_Image_Real.
* libgnat/a-ztcoio.adb: Add with/use clauses for System.Img_Flt,
System.Img_LFlt and System.Img_LLF.
(Scalar_Float): Add third actual parameter.
(Scalar_Long_Float): Likewise.
(Scalar_Long_Long_Float): Likewise.
* libgnat/a-ztfiio.adb: Add with/use clauses for System.Img_LFlt
and System.Val_LFlt. Remove the one for System.Val_LLF. Replace
Long_Long_Float with Long_Float throughout.
* libgnat/a-ztfiio__128.adb: Likewise.
* libgnat/a-ztflau.ads: Add Set_Image formal parameter.
* libgnat/a-ztflau.adb: Add with/use clause for System.Img_Util,
remove the one for System.Img_Real.
(Put): Call Set_Image instead of Set_Image_Real.
(Puts): Likewise.
* libgnat/a-ztflio.adb: Add with/use clause for System.Img_Flt,
System.Img_LFlt and System.Img_LLF.
(Aux_Float): Add third actual parameter.
(Aux_Long_Float): Likewise.
(Aux_Long_Long_Float): Likewise.
* libgnat/s-dorepr.adb: New file.
* libgnat/s-dorepr__fma.adb: Likewise.
* libgnat/s-dourea.ads: Likewise.
* libgnat/s-dourea.adb: Likewise.
* libgnat/s-forrea.ads (Fore_Real): Rename into...
(Fore_Fixed): ...this and take Long_Float parameters.
* libgnat/s-forrea.adb (Fore_Real): Likewise.
(Fore_Fixed): Likewise.
* libgnat/s-imgrea.ads: Move to...
(Set_Image_Real): Turn into mere renaming.
* libgnat/s-imager.ads: ...here.
(Image_Ordinary_Fixed_Point): Turn into...
(Image_Fixed_Point): ...this.
* libgnat/s-imgrea.adb: Add pragma No_Body. Move to...
* libgnat/s-imager.adb: ...here.
(Image_Ordinary_Fixed_Point): Turn into...
(Image_Fixed_Point): ...this.
(Is_Negative): Replace Long_Long_Float with Num.
(Set_Image_Real): Likewise. Use Double_T instead of single Num
throughout the algorithm.
* libgnat/s-imgflt.ads: New file.
* libgnat/s-imglfl.ads: Likewise.
* libgnat/s-imgllf.ads: Likewise.
* libgnat/s-imagef.ads: Adjust comment.
* libgnat/s-imguti.ads (Max_Real_Image_Length): New named number.
* libgnat/s-powflt.ads (Maxpow): Adjust.
(Powten): Turn into an exact table of double Float.
* libgnat/s-powlfl.ads (Maxpow): Adjust.
(Powten): Turn into an exact table of double Long_Float.
* libgnat/s-powllf.ads (Maxpow): Adjust.
(Powten): Turn into an exact table of double Long_Long_Float.
* libgnat/s-valrea.ads: Change order of formal parameters.
* libgnat/s-valrea.adb: Add with clause for System.Double_Real.
(Double_Real): New instantiation.
(Fast2Sum): Delete.
(Large_Powten): New function.
(Integer_to_Real): Use Quick_Two_Sum instead of Fast2Sum. Convert
the value to Double_T. Do the scaling in Double_T for base 10.
* libgnat/s-valflt.ads: Remove with/use clasue for Interfaces,
add it for System.Unsigned_Types. Use Unsigned.
* libgnat/s-vallfl.ads: Remove with/use clasue for Interfaces,
add it for System.Unsigned_Types. Use Long_Unsigned.
* libgnat/s-valllf.ads: Remove with/use clasue for Interfaces,
add it for System.Unsigned_Types. Use Long_Long_Unsigned.
Piotr Trojanek [Fri, 8 Jan 2021 13:31:25 +0000 (14:31 +0100)]
[Ada] Set constraint error on real division just like on integer division
gcc/ada/
* sem_eval.adb (Eval_Arithmetic_Op): Call
Set_Raises_Constraint_Error on real division by zero just like
it is called for integer division by zero earlier in this
routine.
Piotr Trojanek [Fri, 8 Jan 2021 12:07:30 +0000 (13:07 +0100)]
[Ada] Refactor repeated call to Next when pretty-printing if-expressions
gcc/ada/
* pprint.adb (Expr_Name): Introduce local constants to make the
code more readable and avoid repeated calls to Next to reach the
ELSE part of an if-expression.
Richard Biener [Tue, 4 May 2021 13:51:20 +0000 (15:51 +0200)]
tree-optimization/79333 - fold stmts following SSA edges in VN
This makes sure to follow SSA edges when folding eliminated stmts.
This reaps the same benefit as forwprop folding all stmts, not
waiting for one to produce copysign in the new testcase.
2021-05-04 Richard Biener <rguenther@suse.de>
PR tree-optimization/79333
* tree-ssa-sccvn.c (eliminate_dom_walker::eliminate_stmt):
Fold stmt following SSA edges.
* gcc.dg/tree-ssa/ssa-fre-94.c: New testcase.
* gcc.dg/graphite/fuse-1.c: Adjust.
* gcc.dg/pr43864-4.c: Likewise.
Richard Biener [Mon, 3 May 2021 13:11:28 +0000 (15:11 +0200)]
middle-end/100394 - avoid DSE/DCE of pure call that throws
There is -fdelete-dead-exceptions now and we're tracking
nothrow and const/pure bits separately and I do remember that
const or pure does _not_ imply nothrow.
Now, in the light of the PR100382 fix which added a
stmt_unremovable_because_of_non_call_eh_p guard to DSEs "DCE"
I wondered how -fdelete-dead-exceptions applies to calls and
whether stmt_unremovable_because_of_non_call_eh_p doing
really should conditionalize itself on
fun->can_throw_non_call_exceptions. In fact DCE happily elides
pure function calls that throw without a LHS (probably a
consistency bug). The following testcase shows this:
int x, y;
int __attribute__((pure,noinline)) foo () { if (x) throw 1; return y; }
int main()
{
int a[2];
x = 1;
try {
int res = foo ();
a[0] = res;
} catch (...) {
return 0;
}
return 1;
}
note that if you wrap foo () into another noinline
wrap_foo () { foo (); return 1; } function then we need to make
sure to not DCE this call either even though it only throws
externally.
2021-05-03 Richard Biener <rguenther@suse.de>
PR middle-end/100394
* calls.c (expand_call): Preserve possibly throwing calls.
* cfgexpand.c (expand_call_stmt): When a call can throw signal
RTL expansion there are side-effects.
* tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Simplify,
mark all possibly throwing stmts necessary unless we can elide
dead EH.
* tree-ssa-dse.c (pass_dse::execute): Preserve exceptions unless
-fdelete-dead-exceptions.
* tree.h (DECL_PURE_P): Add note about exceptions.
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: avoid extra string copies
PR c/94669 points out that a couple of spots in libcc1 take a
std::string where a reference would do. This changes these spots to
take a const char *, to reduce the number of copies.
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: use variadic templates for callbacks
This patch completes the transition of libcc1 from the use of separate
template functions for different arities to the use of variadic
functions. This is how I had wanted it to work from the very
beginning, and is possible now with C++11.
I had thought that variadic callbacks required C++17, but it turns out
that the approach taken here is basically equivalent to std::apply --
just a bit wordier.
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: fix a memory leak
libcc1 has a memory leak when calling fork_exec -- it allocates a new
vector of arguments, but then does not free it anywhere. This patch
changes this code to use std::vector instead.
Note that the previous code tried to avoid bad_alloc. I don't believe
this is very important. For one thing, plenty of other allocations do
not bother with this.
Tom Tromey [Tue, 4 May 2021 21:26:58 +0000 (15:26 -0600)]
libcc1: share the GCC interface code
Both the C and C++ side of the GDB plugin in libcc1 share a lot of
code relating to the base GCC interface. It was all copy-and-pasted,
but is essentially identical between the two. This is by design, as
the base GCC API is intended to be shared.
This patch merges the implementations into base_gdb_plugin, which was
introduced earlier for this purpose.