]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 years agoanalyzer: eliminate enum binding_key [PR95006]
David Malcolm [Wed, 30 Jun 2021 13:39:04 +0000 (09:39 -0400)] 
analyzer: eliminate enum binding_key [PR95006]

I rewrote the way the analyzer's region_model tracks the state of memory
in GCC 11 (in 808f4dfeb3a95f50f15e71148e5c1067f90a126d), which
introduced a store with a binding_map class, mapping binding keys to
symbolic values.

The GCC 11 implementation of binding keys has an enum binding_kind,
which can be "default" vs "direct"; the idea being that direct
bindings take priority over default bindings, where the latter could
be used to represent e.g. a zero-fill of a buffer, and the former
expresses those subregions that have since been touched.

This doesn't work well: it doesn't express the idea of filling
different subregions with different values, or a memset that only
touches part of a buffer, leading to numerous XFAILs in the memset
test cases (and elsewhere).

As preparatory work towards tracking uninitialized values, this patch
eliminates the enum binding_kind, so that all bindings have
equal weight; the order in which they happen is all that matters.
If a write happens which partially overwrites an existing binding,
the new code can partially overwrite a binding, potentially punching a
hole so that an existing binding is split into two parts.

The patch adds some new classes:
- a new "bits_within_svalue" symbolic value to support extracting
  parts of an existing value when its binding is partially clobbered
- a new "repeated_svalue" symbolic value to better express filling
  a region with repeated copies of a symbolic value (e.g. constant
  zero)
- a new "sized_region" region to express accessing a subregion
  with a symbolic size in bytes
and it rewrites e.g. how memset is implemented, so that we can precisely
track which bits in a region have not been touched.

That said, the patch doesn't actually implement "uninitialized" values;
I'm saving that for a followup.

gcc/analyzer/ChangeLog:
PR analyzer/95006
* analyzer.h (class repeated_svalue): New forward decl.
(class bits_within_svalue): New forward decl.
(class sized_region): New forward decl.
(get_field_at_bit_offset): New forward decl.
* engine.cc (exploded_graph::get_or_create_node): Validate the
merged state.
(exploded_graph::maybe_process_run_of_before_supernode_enodes):
Validate the states at each stage.
* program-state.cc (program_state::validate): Validate
m_region_model.
* region-model-impl-calls.cc (region_model::impl_call_memset):
Replace special-case logic for handling constant sizes with
a call to fill_region of a sized_region with the given fill value.
* region-model-manager.cc (maybe_undo_optimize_bit_field_compare):
Drop DK_direct.
(region_model_manager::maybe_fold_sub_svalue):  Fold element-based
subregions of an initial value into initial values of an element.
Fold subvalues of repeated svalues.
(region_model_manager::maybe_fold_repeated_svalue): New.
(region_model_manager::get_or_create_repeated_svalue): New.
(get_bit_range_for_field): New.
(get_byte_range_for_field): New.
(get_field_at_byte_range): New.
(region_model_manager::maybe_fold_bits_within_svalue): New.
(region_model_manager::get_or_create_bits_within): New.
(region_model_manager::get_sized_region): New.
(region_model_manager::log_stats): Update for addition of
m_repeated_values_map, m_bits_within_values_map, and
m_sized_regions.
* region-model.cc (region_model::validate): New.
(region_model::on_assignment): Drop enum binding_kind.
(region_model::get_initial_value_for_global): Likewise.
(region_model::get_rvalue_for_bits): Replace body with call to
get_or_create_bits_within.
(region_model::get_capacity): Handle RK_SIZED.
(region_model::set_value): Drop enum binding_kind.
(region_model::fill_region): New.
(region_model::get_representative_path_var_1): Handle RK_SIZED.
* region-model.h (visitor::visit_repeated_svalue): New.
(visitor::visit_bits_within_svalue): New.
(region_model_manager::get_or_create_repeated_svalue): New decl.
(region_model_manager::get_or_create_bits_within): New decl.
(region_model_manager::get_sized_region): New decl.
(region_model_manager::maybe_fold_repeated_svalue): New decl.
(region_model_manager::maybe_fold_bits_within_svalue): New decl.
(region_model_manager::repeated_values_map_t): New typedef.
(region_model_manager::m_repeated_values_map): New field.
(region_model_manager::bits_within_values_map_t): New typedef.
(region_model_manager::m_bits_within_values_map): New field.
(region_model_manager::m_sized_regions): New field.
(region_model::fill_region): New decl.
* region.cc (region::get_base_region): Handle RK_SIZED.
(region::base_region_p): Likewise.
(region::get_byte_size_sval): New.
(get_field_at_bit_offset): Make non-static.
(region::calc_offset): Move implementation of cases to
get_relative_concrete_offset vfunc implementations.  Handle
RK_SIZED.
(region::get_relative_concrete_offset): New.
(decl_region::get_svalue_for_initializer): Drop enum binding_kind.
(field_region::get_relative_concrete_offset): New, from
region::calc_offset.
(element_region::get_relative_concrete_offset): Likewise.
(offset_region::get_relative_concrete_offset): Likewise.
(sized_region::accept): New.
(sized_region::dump_to_pp): New.
(sized_region::get_byte_size): New.
(sized_region::get_bit_size): New.
* region.h (enum region_kind): Add RK_SIZED.
(region::dyn_cast_sized_region): New.
(region::get_byte_size): Make virtual.
(region::get_bit_size): Likewise.
(region::get_byte_size_sval): New decl.
(region::get_relative_concrete_offset): New decl.
(field_region::get_relative_concrete_offset): New decl.
(element_region::get_relative_concrete_offset): Likewise.
(offset_region::get_relative_concrete_offset): Likewise.
(class sized_region): New.
* store.cc (binding_kind_to_string): Delete.
(binding_key::make): Drop enum binding_kind.
(binding_key::dump_to_pp): Delete.
(binding_key::cmp_ptrs): Drop enum binding_kind.
(bit_range::contains_p): New.
(byte_range::dump): New.
(byte_range::contains_p): New.
(byte_range::cmp): New.
(concrete_binding::dump_to_pp): Drop enum binding_kind.
(concrete_binding::cmp_ptr_ptr): Likewise.
(symbolic_binding::dump_to_pp): Likewise.
(symbolic_binding::cmp_ptr_ptr): Likewise.
(binding_map::apply_ctor_val_to_range): Likewise.
(binding_map::apply_ctor_pair_to_child_region): Likewise.
(binding_map::get_overlapping_bindings): New.
(binding_map::remove_overlapping_bindings): New.
(binding_cluster::validate): New.
(binding_cluster::bind): Drop enum binding_kind.
(binding_cluster::bind_compound_sval): Likewise.
(binding_cluster::purge_region): Likewise.
(binding_cluster::zero_fill_region): Reimplement in terms of...
(binding_cluster::fill_region): New.
(binding_cluster::mark_region_as_unknown): Drop enum binding_kind.
(binding_cluster::get_binding): Likewise.
(binding_cluster::get_binding_recursive): Likewise.
(binding_cluster::get_any_binding): Likewise.
(binding_cluster::maybe_get_compound_binding): Reimplement.
(binding_cluster::get_overlapping_bindings): Delete.
(binding_cluster::remove_overlapping_bindings): Reimplement in
terms of binding_map::remove_overlapping_bindings.
(binding_cluster::can_merge_p): Update for removal of
enum binding_kind.
(binding_cluster::on_unknown_fncall): Drop enum binding_kind.
(binding_cluster::maybe_get_simple_value): Likewise.
(store_manager::get_concrete_binding): Likewise.
(store_manager::get_symbolic_binding): Likewise.
(store::validate): New.
(store::set_value): Drop enum binding_kind.
(store::zero_fill_region): Reimplement in terms of...
(store::fill_region): New.
(selftest::test_binding_key_overlap): Drop enum binding_kind.
* store.h (enum binding_kind): Delete.
(binding_kind_to_string): Delete decl.
(binding_key::make): Drop enum binding_kind.
(binding_key::dump_to_pp): Make pure virtual.
(binding_key::get_kind): Delete.
(binding_key::mark_deleted): Delete.
(binding_key::mark_empty): Delete.
(binding_key::is_deleted): Delete.
(binding_key::is_empty): Delete.
(binding_key::binding_key): Delete.
(binding_key::impl_hash): Delete.
(binding_key::impl_eq): Delete.
(binding_key::m_kind): Delete.
(bit_range::get_last_bit_offset): New.
(bit_range::contains_p): New.
(byte_range::contains_p): New.
(byte_range::operator==): New.
(byte_range::get_start_byte_offset): New.
(byte_range::get_next_byte_offset): New.
(byte_range::get_last_byte_offset): New.
(byte_range::as_bit_range): New.
(byte_range::cmp): New.
(concrete_binding::concrete_binding): Drop enum binding_kind.
(concrete_binding::hash): Likewise.
(concrete_binding::operator==): Likewise.
(concrete_binding::mark_deleted): New.
(concrete_binding::mark_empty): New.
(concrete_binding::is_deleted): New.
(concrete_binding::is_empty): New.
(default_hash_traits<ana::concrete_binding>::empty_zero_p): Make false.
(symbolic_binding::symbolic_binding): Drop enum binding_kind.
(symbolic_binding::hash): Likewise.
(symbolic_binding::operator==): Likewise.
(symbolic_binding::mark_deleted): New.
(symbolic_binding::mark_empty): New.
(symbolic_binding::is_deleted): New.
(symbolic_binding::is_empty): New.
(binding_map::remove_overlapping_bindings): New decl.
(binding_map::get_overlapping_bindings): New decl.
(binding_cluster::validate): New decl.
(binding_cluster::bind): Drop enum binding_kind.
(binding_cluster::fill_region): New decl.
(binding_cluster::get_binding): Drop enum binding_kind.
(binding_cluster::get_binding_recursive): Likewise.
(binding_cluster::get_overlapping_bindings): Delete.
(store::validate): New decl.
(store::set_value): Drop enum binding_kind.
(store::fill_region): New decl.
(store_manager::get_concrete_binding): Drop enum binding_kind.
(store_manager::get_symbolic_binding): Likewise.
* svalue.cc (svalue::cmp_ptr): Handle SK_REPEATED and
SK_BITS_WITHIN.
(svalue::extract_bit_range): New.
(svalue::maybe_fold_bits_within): New.
(constant_svalue::maybe_fold_bits_within): New.
(unknown_svalue::maybe_fold_bits_within): New.
(unaryop_svalue::maybe_fold_bits_within): New.
(repeated_svalue::repeated_svalue): New.
(repeated_svalue::dump_to_pp): New.
(repeated_svalue::accept): New.
(repeated_svalue::all_zeroes_p): New.
(repeated_svalue::maybe_fold_bits_within): New.
(bits_within_svalue::bits_within_svalue): New.
(bits_within_svalue::dump_to_pp): New.
(bits_within_svalue::maybe_fold_bits_within): New.
(bits_within_svalue::accept): New.
(bits_within_svalue::implicitly_live_p): New.
(compound_svalue::maybe_fold_bits_within): New.
* svalue.h (enum svalue_kind): Add SK_REPEATED and SK_BITS_WITHIN.
(svalue::dyn_cast_repeated_svalue): New.
(svalue::dyn_cast_bits_within_svalue): New.
(svalue::extract_bit_range): New decl.
(svalue::maybe_fold_bits_within): New vfunc decl.
(region_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
(region_svalue::key_t::is_empty): Likewise.
(default_hash_traits<region_svalue::key_t>::empty_zero_p): Make false.
(constant_svalue::maybe_fold_bits_within): New.
(unknown_svalue::maybe_fold_bits_within): New.
(poisoned_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
(poisoned_svalue::key_t::is_empty): Likewise.
(default_hash_traits<poisoned_svalue::key_t>::empty_zero_p): Make
false.
(setjmp_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
(setjmp_svalue::key_t::is_empty): Likewise.
(default_hash_traits<setjmp_svalue::key_t>::empty_zero_p): Make
false.
(unaryop_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
(unaryop_svalue::key_t::is_empty): Likewise.
(unaryop_svalue::maybe_fold_bits_within): New.
(default_hash_traits<unaryop_svalue::key_t>::empty_zero_p): Make
false.
(binop_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
(binop_svalue::key_t::is_empty): Likewise.
(default_hash_traits<binop_svalue::key_t>::empty_zero_p): Make
false.
(sub_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
(sub_svalue::key_t::is_empty): Likewise.
(default_hash_traits<sub_svalue::key_t>::empty_zero_p): Make
false.
(class repeated_svalue): New.
(is_a_helper <const repeated_svalue *>::test): New.
(struct default_hash_traits<repeated_svalue::key_t>): New.
(class bits_within_svalue): New.
(is_a_helper <const bits_within_svalue *>::test): New.
(struct default_hash_traits<bits_within_svalue::key_t>): New.
(widening_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
(widening_svalue::key_t::is_empty): Likewise.
(default_hash_traits<widening_svalue::key_t>::empty_zero_p): Make
false.
(compound_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
(compound_svalue::key_t::is_empty): Likewise.
(compound_svalue::maybe_fold_bits_within): New.
(default_hash_traits<compound_svalue::key_t>::empty_zero_p): Make
false.

gcc/testsuite/ChangeLog:
PR analyzer/95006
* gcc.dg/analyzer/clobbers-1.c: New test.
* gcc.dg/analyzer/clobbers-2.c: New test.
* gcc.dg/analyzer/data-model-1.c (test_26): Mark xfail as fixed.
(test_28): Likewise.
(test_52): Likewise.  Add coverage for end of buffer.
* gcc.dg/analyzer/explode-1.c: Add leak warning.
* gcc.dg/analyzer/memset-1.c (test_3): Mark xfail as fixed.
(test_4): Use char.  Mark xfail as fixed.
(test_6b): New.
(test_7): Mark xfail as fixed.  Add coverage for start of buffer.
(test_8): New.
(test_9): New.
* gcc.dg/analyzer/memset-CVE-2017-18549-1.c: New test.
* gcc.dg/analyzer/symbolic-8.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agogcc.c: Add -foffload= to display_help
Tobias Burnus [Wed, 30 Jun 2021 12:49:48 +0000 (14:49 +0200)] 
gcc.c: Add -foffload= to display_help

gcc/ChangeLog:

* common.opt (foffload): Remove help as Driver only.
* gcc.c (display_help): Add -foffload.

2 years ago[testsuite]: Add missing dg-add-options float16 to gcc.dg/debug/ctf/ctf-skip-types-2.c
Christophe Lyon [Wed, 30 Jun 2021 11:44:00 +0000 (11:44 +0000)] 
[testsuite]: Add missing dg-add-options float16 to gcc.dg/debug/ctf/ctf-skip-types-2.c

The test already checks dg-require-effective-target float16, but this
is not sufficient to use the flags needed, if any.
This patch makes the test pass on arm.

2021-06-30  Christophe Lyon  <christophe.lyon@foss.st.com>

gcc/testsuite/
* gcc.dg/debug/ctf/ctf-skip-types-2.c: Add dg-add-options float16.

2 years agogcc.c's check_offload_target_name: Fixes to inform hints
Tobias Burnus [Wed, 30 Jun 2021 11:17:54 +0000 (13:17 +0200)] 
gcc.c's check_offload_target_name: Fixes to inform hints

gcc/ChangeLog:

* gcc.c (close_at_file, execute): Replace alloca by XALLOCAVEC.
(check_offload_target_name): Fix splitting OFFLOAD_TARGETS into
a candidate list; better inform no offload target is configured
and fix hint extraction when passed target is not '\0' at [len].
* common.opt (foffload): Add tailing '.'.
(foffload-options): Likewise; fix flag name in the help string.

2 years agoarm/66791: Gate comparison in vca intrinsics on __FAST_MATH__.
prathamesh.kulkarni [Wed, 30 Jun 2021 09:42:06 +0000 (15:12 +0530)] 
arm/66791: Gate comparison in vca intrinsics on __FAST_MATH__.

gcc/ChangeLog:

PR target/66791
* config/arm/arm_neon.h: Move vabs intrinsics before vcage_f32.
(vcage_f32): Gate comparison on __FAST_MATH__.
(vcageq_f32): Likewise.
(vcale_f32): Likewise.
(vcaleq_f32): Likewise.
(vcagt_f32): Likewise.
(vcagtq_f32): Likewise.
(vcalt_f32): Likewise.
(vcaltq_f32): Likewise.
(vcage_f16): Likewise.
(vcageq_f16): Likewise.
(vcale_f16): Likewise.
(vcaleq_f16): Likewise.
(vcagt_f16): Likewise.
(vcagtq_f16): Likewise.
(vcalt_f16): Likewise.
(vcaltq_f16): Likewise.

2 years agotree-optimization/101264 - rework SLP "any" permute forward prop
Richard Biener [Wed, 30 Jun 2021 07:48:37 +0000 (09:48 +0200)] 
tree-optimization/101264 - rework SLP "any" permute forward prop

This integrates the forward propagation of SLP "any" permutes into
the main propagation stage as a separate single-pass propagation
didn't work out.

2021-06-30  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101264
* tree-vect-slp.c (vect_optimize_slp): Propagate the
computed perm_in to all "any" permute successors
we cannot de-duplicate immediately.

* gfortran.dg/pr101264.f90: New testcase.

2 years agoMAINTAINERS: Add myself for write after approval
Xi Ruoyao [Wed, 30 Jun 2021 02:47:17 +0000 (10:47 +0800)] 
MAINTAINERS: Add myself for write after approval

ChangeLog:

* MAINTAINERS (Write After Approval): Add myself.

2 years agofixinc: don't "fix" machine names in __has_include(...) [PR91085]
Xi Ruoyao [Mon, 28 Jun 2021 05:54:58 +0000 (13:54 +0800)] 
fixinc: don't "fix" machine names in __has_include(...) [PR91085]

fixincludes/

PR other/91085
* fixfixes.c (check_has_inc): New static function.
  (machine_name_fix): Don't replace header names in
  __has_include(...).
* inclhack.def (machine_name): Adjust test.
* tests/base/testing.h: Update.

2 years agoThe upper bits of FIXUPIMMS{S,D} should come from src1 not dest.
liuhongt [Mon, 28 Jun 2021 11:27:23 +0000 (19:27 +0800)] 
The upper bits of FIXUPIMMS{S,D} should come from src1 not dest.

gcc/ChangeLog:

PR target/101248
* config/i386/sse.md
(avx512f_sfixupimm<mode><sd_maskz_name><round_saeonly_name>):
Refined to ..
(avx512f_sfixupimm<mode><maskz_scalar_name><round_saeonly_name>):
this.
(avx512f_sfixupimm<mode>_mask<round_saeonly_name>"): Refined.
* config/i386/subst.md (maskz_scalar): New define_subst.
(maskz_scalar_name): New subst_attr.
(maskz_scalar_op5): Ditto.
(round_saeonly_maskz_scalar_op5): Ditto.
(round_saeonly_maskz_scalar_operand5): Ditto.

gcc/testsuite/ChangeLog

PR target/101248
* gcc.target/i386/pr101248.c: New test.

2 years agoaix: align text CSECTs to at least 32 bytes.
David Edelsohn [Wed, 12 May 2021 01:07:19 +0000 (21:07 -0400)] 
aix: align text CSECTs to at least 32 bytes.

gcc/ChangeLog:

* config/rs6000/rs6000.c (rs6000_xcoff_section_type_flags):
Increase code CSECT alignment to at least 32 bytes.
* config/rs6000/xcoff.h (TEXT_SECTION_ASM_OP): Add 32 byte
alignment designation.

2 years agoDaily bump.
GCC Administrator [Wed, 30 Jun 2021 00:16:52 +0000 (00:16 +0000)] 
Daily bump.

2 years agodocs: Fix s/net yet/not yet/ typo
Sergei Trofimovich [Tue, 29 Jun 2021 21:11:39 +0000 (22:11 +0100)] 
docs: Fix s/net yet/not yet/ typo

gcc/ChangeLog:

* doc/generic.texi: Fix s/net yet/not yet/ typo.

2 years agoc++: don't treat member var as var template
Jason Merrill [Tue, 29 Jun 2021 19:11:25 +0000 (15:11 -0400)] 
c++: don't treat member var as var template

While looking at a partial instantiation issue I noticed that we were
wrongly hitting the partial instantiation code when instantiating a static
data member of a class template.  I don't think this broke anything, but we
don't need to do that (small) extra work.

gcc/cp/ChangeLog:

* pt.c (instantiate_decl): Only consider partial specializations of
actual variable templates.

2 years agocompiler: don't generate temporaries for composite literals
Ian Lance Taylor [Tue, 29 Jun 2021 19:53:02 +0000 (12:53 -0700)] 
compiler: don't generate temporaries for composite literals

We were generating temporaries for composite literals when a
conversion to interface type was required.  However, Cherry's
https://golang.org/cl/176459 changed the compiler to insert explicit
type conversions.  And those explicit type conversions insert the
required temporaries in Type_conversion_expression::do_flatten.
So in practice the composite literal do_flatten methods would never
insert temporaries, as the values they see would always be multi_eval_safe.
So just remove the unnecessary do_flatten methods.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/331691

2 years agogo-gcc: set DECL_NAMELESS for temporary variables
Ian Lance Taylor [Tue, 29 Jun 2021 19:12:16 +0000 (12:12 -0700)] 
go-gcc: set DECL_NAMELESS for temporary variables

* go-gcc.cc (Gcc_backend::static_chain_variable): Set
DECL_NAMELESS on the new decl.
(Gcc_backend::temporary_variable): Likewise.
(Gcc_backend::function): Set DECL_NAMELESS on the result decl.

2 years agoFix MINUS_EXPR relations.
Andrew MacLeod [Tue, 29 Jun 2021 14:52:58 +0000 (10:52 -0400)] 
Fix MINUS_EXPR relations.

Flesh out and correct relations for both wrapping and non-wrapping values.

gcc/
PR tree-optimization/101254
* range-op.cc (operator_minus::op1_op2_relation_effect): Check for
wrapping/non-wrapping when setting the result range.

gcc/testsuite
* gcc.dg/pr101254.c: New.

2 years agoAllow PHIs to pick up global values.
Andrew MacLeod [Fri, 25 Jun 2021 19:31:39 +0000 (15:31 -0400)] 
Allow PHIs to pick up global values.

We can also apply known global values to PHI nodes in EVRP.

* value-query.cc (gimple_range_global): Allow phis.

2 years agoAdd stmt context in simplify_using_ranges.
Andrew MacLeod [Fri, 25 Jun 2021 15:24:30 +0000 (11:24 -0400)] 
Add stmt context in simplify_using_ranges.

There were places simplify_using_ranges was not utilzing the stmt context.

* vr-values.c (vr_values::vrp_stmt_computes_nonzero): Use stmt.
(simplify_using_ranges::op_with_boolean_value_range_p): Add a
statement for location context.
(check_for_binary_op_overflow): Ditto.
(simplify_using_ranges::get_vr_for_comparison): Ditto.
(simplify_using_ranges::compare_name_with_value): Ditto.
(simplify_using_ranges::compare_names): Ditto.
(vrp_evaluate_conditional_warnv_with_ops_using_ranges): Ditto.
(simplify_using_ranges::simplify_truth_ops_using_ranges): Ditto.
(simplify_using_ranges::simplify_min_or_max_using_ranges): Ditto.
(simplify_using_ranges::simplify_internal_call_using_ranges): Ditto.
(simplify_using_ranges::two_valued_val_range_p): Ditto.
(simplify_using_ranges::simplify): Ditto.
* vr-values.h: Adjust prototypes.

2 years agocompiler: in composite literals use temps only for interfaces
Ian Lance Taylor [Mon, 28 Jun 2021 23:47:55 +0000 (16:47 -0700)] 
compiler: in composite literals use temps only for interfaces

For a composite literal we only need to introduce a temporary variable
if we may be converting to an interface type, so only do it then.
This saves over 80% of compilation time when using gccgo to compile
cmd/internal/obj/x86, as the GCC middle-end spends a lot of time
pointlessly computing interactions between temporary variables.

For PR debug/101064
For golang/go#46600

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/331513

2 years agoi386: Add V2SFmode vec_addsub pattern [PR95046]
Uros Bizjak [Tue, 29 Jun 2021 17:14:35 +0000 (19:14 +0200)] 
i386: Add V2SFmode vec_addsub pattern [PR95046]

gcc/

2021-06-21  Uroš Bizjak  <ubizjak@gmail.com>

PR target/95046
* config/i386/mmx.md (vec_addsubv2sf3): New insn pattern.

gcc/testsuite/

2021-06-21  Uroš Bizjak  <ubizjak@gmail.com>

PR target/95046
* gcc.target/i386/pr95046-9.c: New test.

2 years agoFortran: Re-enable 128-bit integers for AMD GCN
Julian Brown [Fri, 11 Jun 2021 21:44:36 +0000 (14:44 -0700)] 
Fortran: Re-enable 128-bit integers for AMD GCN

This patch reverts the part of Tobias's patch for PR target/96306 that
disables 128-bit integer support for AMD GCN.

2021-06-18  Julian Brown  <julian@codesourcery.com>

libgfortran/
PR target/96306
* configure.ac: Remove stanza that removes KIND=16 integers for AMD GCN.
* configure: Regenerate.

2 years agoamdgcn: Enable support for TImode for AMD GCN
Julian Brown [Wed, 9 Jun 2021 13:18:23 +0000 (06:18 -0700)] 
amdgcn: Enable support for TImode for AMD GCN

This patch enables support for TImode for AMD GCN, the lack of which
is currently causing a number of test failures for the target and which
is also needed to support "omp_depend_kind" for OpenMP 5.0, since that
is implemented as a 128-bit integer.

Several libgcc support routines are built by default for the "word size"
of a machine, and also for "2 * word size" of the machine.  The libgcc
build for AMD GCN is changed so that it builds for a "word size" of 64
bits, in order to better match the (64-bit) host compiler.  However it
isn't really true that we have 64-bit words -- GCN has 32-bit registers,
so changing UNITS_PER_WORD unconditionally would be the wrong thing to do.

Changing this setting for libgcc (only) means that support routines
are built for "single word" operations that are DImode (64 bits), and
those for "double word" operations are built for TImode (128 bits).
That leaves some gaps regarding previous operations that were built
for a "single word" size of 32 bits and a "double word" size of 64 bits
(generic code doesn't cover both alternatives for all operations that
might be needed).  Those gaps are filled in by this patch, or by the
preceding patches in the series.

2021-06-18  Julian Brown  <julian@codesourcery.com>

gcc/
* config/gcn/gcn.c (gcn_init_libfuncs): New function.
(TARGET_INIT_LIBFUNCS): Define target hook using above function.
* config/gcn/gcn.h (UNITS_PER_WORD): Define to 8 for IN_LIBGCC2, 4
otherwise.
(LIBGCC2_UNITS_PER_WORD, BITS_PER_WORD): Remove definitions.
(MAX_FIXED_MODE_SIZE): Change to 128.

libgcc/
* config/gcn/lib2-bswapti2.c: New file.
* config/gcn/lib2-divmod-di.c: New file.
* config/gcn/lib2-gcn.h (DItype, UDItype, TItype, UTItype): Add
typedefs.
(__divdi3, __moddi3, __udivdi3, __umoddi3): Add prototypes.
* config/gcn/t-amdgcn (LIB2ADD): Add lib2-divmod-di.c and
lib2-bswapti2.c.

2 years agoamdgcn: Add clrsbsi2/clrsbdi2 implementation
Julian Brown [Thu, 17 Jun 2021 17:52:51 +0000 (10:52 -0700)] 
amdgcn: Add clrsbsi2/clrsbdi2 implementation

This patch adds an open-coded implementation of the clrsb<mode>2
(count leading redundant sign bit) standard names using the GCN flbit_i*
instructions for SImode and DImode.  Those don't count exactly as we need,
so we need a couple of other instructions to fix up the result afterwards.

These patterns are lost from libgcc if we build it for DImode/TImode
rather than SImode/DImode, a change we make in a later patch in this
series.

2021-06-18  Julian Brown  <julian@codesourcery.com>

gcc/
* config/gcn/gcn.md (UNSPEC_FLBIT_INT): New unspec constant.
(s_mnemonic): Add clrsb.
(gcn_flbit<mode>_int): Add insn pattern for SImode/DImode.
(clrsb<mode>2): Add expander for SImode/DImode.

2 years agoamdgcn: Add [us]mulsid3/muldi3 patterns
Julian Brown [Tue, 29 Jun 2021 10:57:31 +0000 (03:57 -0700)] 
amdgcn: Add [us]mulsid3/muldi3 patterns

This patch improves 64-bit multiplication for AMD GCN: patterns for
unsigned and signed 32x32->64 bit multiplication have been added, and
also 64x64->64 bit multiplication is now open-coded rather than calling
a library function (which may be a win for code size as well as speed:
the function calling sequence isn't particularly concise for GCN).

This version of the patch uses define_insn_and_split in order to keep
multiply operations together during RTL optimisations up to register
allocation: this appears to produce more compact code via inspection on
small test cases than the previous approach using an expander.

The DImode multiply implementation is lost from libgcc if we build it
for DImode/TImode rather than SImode/DImode, a change we make in a later
patch in this series.

2021-06-29  Julian Brown  <julian@codesourcery.com>

gcc/
* config/gcn/gcn.md (<su>mulsidi3, <su>mulsidi3_reg, <su>mulsidi3_imm,
muldi3): Add patterns.

2 years agoamdgcn: Add [us]mulsi3_highpart SGPR alternatives
Julian Brown [Thu, 17 Jun 2021 18:02:55 +0000 (11:02 -0700)] 
amdgcn: Add [us]mulsi3_highpart SGPR alternatives

This patch splits the <su>mulsi3_highpart pattern into an expander and
register/immediate alternatives (to avoid meaningless sign/zero_extends on
constants), and adds alternatives for SGPR high-part multiply instructions
on GCN5+.

2021-06-29  Julian Brown  <julian@codesourcery.com>

gcc/
* config/gcn/gcn.md (<su>mulsi3_highpart): Change to expander.
(<su>mulsi3_highpart_reg, <su>mulsi3_highpart_imm): New patterns.

2 years agoamdgcn: Mark s_mulk_i32 as clobbering SCC
Julian Brown [Mon, 28 Jun 2021 13:58:52 +0000 (06:58 -0700)] 
amdgcn: Mark s_mulk_i32 as clobbering SCC

The s_mulk_i32 instruction sets the SCC status register according to
whether the multiplication overflows, but that is not currently modelled
in the GCN backend.  AFAIK this is a latent bug and hasn't been noticed
"in the wild", but it should be fixed.

2021-06-29  Julian Brown  <julian@codesourcery.com>

gcc/
* config/gcn/gcn.md (mulsi3): Make s_mulk_i32 variant clobber SCC.

2 years agoamdgcn: Use unsigned types for udivsi3/umodsi3 libgcc helper args/return
Julian Brown [Thu, 17 Jun 2021 17:55:48 +0000 (10:55 -0700)] 
amdgcn: Use unsigned types for udivsi3/umodsi3 libgcc helper args/return

This patch changes the argument and return types for the libgcc __udivsi3
and __umodsi3 helper functions for GCN to USItype instead of SItype.
This is probably just cosmetic in practice.

2021-06-18  Julian Brown  <julian@codesourcery.com>

libgcc/
* config/gcn/lib2-divmod.c (__udivsi3, __umodsi3): Change argument and
return types to USItype.
* config/gcn/lib2-gcn.h (__udivsi3, __umodsi3): Update prototypes.

2 years agobootstrap: Include memmodel.h in btfout.c and ctfout.c before tm_p.h
Joseph Myers [Tue, 29 Jun 2021 15:10:17 +0000 (15:10 +0000)] 
bootstrap: Include memmodel.h in btfout.c and ctfout.c before tm_p.h

This fixes a "use of enum 'memmodel' without previous declaration"
error in sparc-protos.h.

Minimally tested that this fixes the build-many-glibcs.py compilers
build for sparc64-linux-gnu.

* btfout.c, ctfout.c: Include "memmodel.h".

2 years agogcc.c: Silence warning in check_offload_target_name
Tobias Burnus [Tue, 29 Jun 2021 14:35:42 +0000 (16:35 +0200)] 
gcc.c: Silence warning in check_offload_target_name

gcc/ChangeLog:

* gcc.c (check_offload_target_name): Cast len argument to
%q.*s to 'int'; avoid -Wstringop-truncation warning.

2 years ago[Ada] Make copies of entities being declared when copying block
Richard Kenner [Wed, 21 Apr 2021 12:35:24 +0000 (08:35 -0400)] 
[Ada] Make copies of entities being declared when copying block

gcc/ada/

* sem_util.adb (Visit_Node): Add handling for N_Block_Statement
with declarations.

2 years ago[Ada] Expose symmetry between Known_ and Unknown_ query routines
Piotr Trojanek [Tue, 20 Apr 2021 08:53:06 +0000 (10:53 +0200)] 
[Ada] Expose symmetry between Known_ and Unknown_ query routines

gcc/ada/

* einfo-utils.adb
(Unknown_Alignment): Simply negate the Known_ counterpart.
(Unknown_Component_Bit_Offset): Likewise.
(Unknown_Esize): Likewise.
(Unknown_Normalized_First_Bit): Likewise.
(Unknown_Normalized_Position): Likewise.
(Unknown_Normalized_Position_Max): Likewise.
(Unknown_RM_Size): Likewise.

2 years ago[Ada] Do not catch 'N mod -1' in CodePeer_Mode
Boris Yakobowski [Mon, 19 Apr 2021 10:17:07 +0000 (12:17 +0200)] 
[Ada] Do not catch 'N mod -1' in CodePeer_Mode

gcc/ada/

* exp_ch4.adb (Expand_N_Op_Mod): Remove special case for mod -1
in CodePeer_Mode.

2 years ago[Ada] Add support for Aarch64 in System.Object_Reader
Aleksandra Pasek [Wed, 14 Apr 2021 14:44:04 +0000 (10:44 -0400)] 
[Ada] Add support for Aarch64 in System.Object_Reader

gcc/ada/

* libgnat/s-objrea.adb (EM_AARCH64): New Constant.
(Initialize): Handle EM_AARCH64 case.
(Read_Address): Handle AARCH64 case.
* libgnat/s-objrea.ads (Object_Arch): Add AARCH64 record
component.

2 years ago[Ada] Fix the -gnatyr switch so it works in record rep clauses
Bob Duff [Sun, 18 Apr 2021 13:45:04 +0000 (09:45 -0400)] 
[Ada] Fix the -gnatyr switch so it works in record rep clauses

gcc/ada/

* sem_ch13.adb (Analyze_Record_Representation_Clause): Call
Set_Entity_With_Checks instead of Set_Entity, so we perform the
check for correct casing.
* style.adb (Check_Identifier): Minor comment improvement.
Cleanup overly complicated code.

2 years ago[Ada] Crash on limited array object with address clause
Ed Schonberg [Fri, 16 Apr 2021 16:52:50 +0000 (12:52 -0400)] 
[Ada] Crash on limited array object with address clause

gcc/ada/

* exp_aggr.adb (Convert_Aggr_In_Object_Decl): After expansion of
the aggregate, the expression can be removed from the
declaration, except if the object is class-wide, in which case
the aggregate provides the actual type. In other cases the
presence of the expression may lead to spurious freezing issue.
* exp_ch3.adb (Expand_N_Object_Declaration): If the expression
in the declaration is an aggregate with delayed expansion (as is
the case for objects of a limited type, or a subsequent address
specification) the aggregate must be resolved at this point.
This resolution must not include expansion, because the
expansion of the enclosing declaration will construct the
necessary aggregate expansion.

2 years ago[Ada] Remove an obsolete variant of Adjust_Name_Case used only by SPARK
Piotr Trojanek [Thu, 15 Apr 2021 16:00:52 +0000 (18:00 +0200)] 
[Ada] Remove an obsolete variant of Adjust_Name_Case used only by SPARK

gcc/ada/

* errout.ads (Adjust_Name_Case): Remove obsolete and now unused
variant.
* errout.adb (Adjust_Name_Case): Likewise; fix variant that uses
a custom buffer to also use it for names in Standard_Location.

2 years ago[Ada] Small tweak in a couple of comments
Eric Botcazou [Thu, 15 Apr 2021 15:22:46 +0000 (17:22 +0200)] 
[Ada] Small tweak in a couple of comments

gcc/ada/

* sem_ch12.adb (Freeze_Subprogram_Body): Add missing "freeze".
(Install_Body): Likewise.

2 years ago[Ada] Remove a special case for forking-for-expect from ordinary spawn
Piotr Trojanek [Thu, 15 Apr 2021 12:17:48 +0000 (14:17 +0200)] 
[Ada] Remove a special case for forking-for-expect from ordinary spawn

gcc/ada/

* adaint.c (__gnat_portable_spawn): Revert change that
introduced setting of __gnat_in_child_after_fork.

2 years ago[Ada] Ensure System.Tasking.Debug.Known_Tasks component access is atomic
Patrick Bernardi [Wed, 14 Apr 2021 03:50:57 +0000 (13:50 +1000)] 
[Ada] Ensure System.Tasking.Debug.Known_Tasks component access is atomic

gcc/ada/

* libgnarl/s-tasdeb.ads (Known_Tasks): Add Atomic_Components
aspect.

2 years ago[Ada] vx7-shared-libs: Unused variable __gnat_user_int_connect
Doug Rupp [Mon, 12 Apr 2021 19:03:48 +0000 (12:03 -0700)] 
[Ada] vx7-shared-libs: Unused variable __gnat_user_int_connect

gcc/ada/

* Makefile.rtl (x86_64-vx7r2) [EXTRA_GNATRTL_TASKING_OBJS]: Move
i-vxinco.o out of RTP runtime.

2 years ago[Ada] Disable Pre/Post in formal containers
Claire Dross [Mon, 12 Apr 2021 07:48:48 +0000 (09:48 +0200)] 
[Ada] Disable Pre/Post in formal containers

gcc/ada/

* libgnat/a-cfdlli.ads: Use pragma Assertion_Policy to disable
pre and postconditions.
* libgnat/a-cfhama.ads: Likewise.
* libgnat/a-cfhase.ads: Likewise.
* libgnat/a-cfinve.ads: Likewise.
* libgnat/a-cforma.ads: Likewise.
* libgnat/a-cforse.ads: Likewise.
* libgnat/a-cofove.ads: Likewise.

2 years ago[Ada] Fix style in Get_Fullest_View
Piotr Trojanek [Tue, 6 Apr 2021 11:11:09 +0000 (13:11 +0200)] 
[Ada] Fix style in Get_Fullest_View

gcc/ada/

* sem_util.ads (Get_Fullest_View): Refill comment; remove extra
extra after period.
* sem_util.adb (Get_Fullest_View): Fix style.

2 years ago[Ada] Remove redundant check for empty list
Piotr Trojanek [Thu, 8 Apr 2021 19:19:54 +0000 (21:19 +0200)] 
[Ada] Remove redundant check for empty list

gcc/ada/

* sem_ch3.adb (Analyze_Declarations): Remove explicit check for
missing, because a subsequent call to Is_Empty_List will detect
them anyway.

2 years ago[Ada] Reuse Is_Subprogram_Or_Entry where possible
Piotr Trojanek [Thu, 8 Apr 2021 19:17:33 +0000 (21:17 +0200)] 
[Ada] Reuse Is_Subprogram_Or_Entry where possible

gcc/ada/

* freeze.adb (Freeze_All): Simplify by reusing
Is_Subprogram_Or_Entry.
* sem_ch11.adb (Analyze_Handled_Statement): Likewise.

2 years ago[Ada] More robust guard against cascaded errors with overlapping actuals
Piotr Trojanek [Mon, 12 Apr 2021 14:56:23 +0000 (16:56 +0200)] 
[Ada] More robust guard against cascaded errors with overlapping actuals

gcc/ada/

* sem_warn.adb (Warn_On_Overlapping_Actuals): Prevent cascaded
errors once for the subprogram call, not for every pair of
actual parameters.

2 years ago[Ada] Simplify detection of local types
Piotr Trojanek [Tue, 6 Apr 2021 11:10:01 +0000 (13:10 +0200)] 
[Ada] Simplify detection of local types

gcc/ada/

* sem_ch3.adb (Is_Local_Type): Simplify by reusing Scope_Within.

2 years ago[Ada] Overriding errors on renamings and instances overriding predefined operators
Gary Dismukes [Mon, 12 Apr 2021 21:20:33 +0000 (17:20 -0400)] 
[Ada] Overriding errors on renamings and instances overriding predefined operators

gcc/ada/

* sem_ch6.ads (Can_Override_Operator): Function declaration
moved from package body to package spec.
* sem_ch6.adb (Check_Overriding_Indicator): Now use test of
whether the subprogram's Chars is an operator name, to handle
cases of function instances whose entity is
N_Defining_Identifier rather than N_Defining_Operator_Symbol.
(Can_Override_Operator): Function declaration moved to package
spec.  Now use test of whether the subprogram's Chars is an
operator name, to handle cases of function instances whose
entity is N_Defining_Identifier rather than
N_Defining_Operator_Symbol.
* sem_ch8.adb (Analyze_Renamed_Subprogram): Check for
possibility of an overridden predefined operator, and suppress
the "not overriding" message in that case.

2 years ago[Ada] vx7-shared-libs - x86_64-vx7r2 (gnat runtime)
Doug Rupp [Wed, 31 Mar 2021 17:29:37 +0000 (10:29 -0700)] 
[Ada] vx7-shared-libs - x86_64-vx7r2 (gnat runtime)

gcc/ada/

* Makefile.rtl: Add a new ifeq for vx7r2 shared gnatlib.

2 years ago[Ada] Accept arrays and scalars as type views that can be validated
Piotr Trojanek [Thu, 8 Apr 2021 07:42:28 +0000 (09:42 +0200)] 
[Ada] Accept arrays and scalars as type views that can be validated

gcc/ada/

* exp_attr.adb (Build_Array_VS_Func): Restore uses of
Validated_View.
(Build_Record_VS_Func): Likewise.
(Expand_N_Attribute_Reference): Likewise.
* sem_util.adb (Validated_View): Behave as an identity function
for arrays and scalars.

2 years ago[Ada] tech debt: Parent (Empty) is not allowed
Bob Duff [Fri, 9 Apr 2021 18:53:56 +0000 (14:53 -0400)] 
[Ada] tech debt: Parent (Empty) is not allowed

gcc/ada/

* atree.adb, atree.ads (Parent, Set_Parent): Assert node is
Present.
(Copy_Parent, Parent_Kind): New helper routines.
* gen_il-gen.adb: Add with clause.
* nlists.adb (Parent): Assert Parent of list is Present.
* aspects.adb, checks.adb, exp_aggr.adb, exp_ch6.adb,
exp_util.adb, lib-xref-spark_specific.adb, osint.ads,
sem_ch12.adb, sem_ch13.adb, sem_ch3.adb, sem_ch6.adb,
sem_dim.adb, sem_prag.adb, sem_res.adb, sem_util.adb,
treepr.adb: Do not call Parent and Set_Parent on the Empty node.
* libgnat/a-stwiun__shared.adb, libgnat/a-stzunb__shared.adb:
Minor: Fix typos in comments.
* einfo.ads: Minor comment update.
* sinfo-utils.ads, sinfo-utils.adb (Parent_Kind, Copy_Parent):
New functions.

2 years ago[Ada] Fix old typo in comment
Eric Botcazou [Sat, 10 Apr 2021 17:17:54 +0000 (19:17 +0200)] 
[Ada] Fix old typo in comment

gcc/ada/

* repinfo-input.adb (Read_JSON_Stream): Fix typo.

2 years ago[Ada] Further adjustment and optimization of System.Value_N
Eric Botcazou [Fri, 9 Apr 2021 11:29:44 +0000 (13:29 +0200)] 
[Ada] Further adjustment and optimization of System.Value_N

gcc/ada/

* rtsfind.ads (RE_Id): Change RE_Valid_Enumeration_Value_NN into
RE_Valid_Value_Enumeration_NN.
(RE_Unit_Table): Adjust to above renaming.
* exp_imgv.adb (Expand_Valid_Value_Attribute): Likewise.
* libgnat/s-valuen.ads (Invalid): Remove.
(Value_Enumeration_Pos): Move to...
* libgnat/s-valuen.adb (Value_Enumeration_Pos): ...here.
Return -1 instead of Invalid.
(Value_Enumeration): Compare against 0 instead of Invalid.
(Valid_Enumeration_Value): Likewise.  Rename to...
(Valid_Value_Enumeration): ...this.
* libgnat/s-vaenu8.ads (Valid_Enumeration_Value_8): Rename into...
(Valid_Value_Enumeration_8): ...this.
* libgnat/s-vaen16.ads (Valid_Enumeration_Value_16): Rename into...
(Valid_Value_Enumeration_16): ...this.
* libgnat/s-vaen32.ads (Valid_Enumeration_Value_32): Rename into...
(Valid_Value_Enumeration_32): ...this.

2 years ago[Ada] tech debt: clean up Component_Size
Bob Duff [Fri, 9 Apr 2021 12:56:23 +0000 (08:56 -0400)] 
[Ada] tech debt: clean up Component_Size

gcc/ada/

* einfo.ads (Component_Bit_Offset, Component_Size): Update
documentation: Repinfo is the package where these negative
values are documented.
* einfo-utils.adb (Known_Component_Size,
Known_Static_Component_Size, Unknown_Component_Size): Remove
calls to Implementation_Base_Type, because Component_Size is an
Impl_Base_Type_Only field (see Gen_Entities).
* sem_ch13.ads, sem_ch13.adb (Check_Size): Do not set Esize and
RM_Size. This is unnecessary in the case of Size. For
Component_Size, it is wrong, because we would be setting the
Esize and RM_Size of the component type.

2 years ago[Ada] Add some OS constants to control keepalive on TCP connections
Pascal Obry [Wed, 7 Apr 2021 07:05:06 +0000 (09:05 +0200)] 
[Ada] Add some OS constants to control keepalive on TCP connections

gcc/ada/

* s-oscons-tmplt.c: Add some OS constants.

2 years ago[Ada] Rewrite Validated_View in recursive style
Piotr Trojanek [Tue, 6 Apr 2021 11:10:40 +0000 (13:10 +0200)] 
[Ada] Rewrite Validated_View in recursive style

gcc/ada/

* sem_util.ads (Validated_View): Fix style in comment.
* sem_util.adb (Validated_View): Rewrite in recursive style.

2 years ago[Ada] Ignore again errors when running gen_il-main
Eric Botcazou [Wed, 7 Apr 2021 16:23:44 +0000 (18:23 +0200)] 
[Ada] Ignore again errors when running gen_il-main

gcc/ada/

* Make-generated.in (ada/stamp-gen_il): Ignore errors from
running gen_il-main.

2 years ago[Ada] Factor out many fields in entities
Richard Kenner [Wed, 7 Apr 2021 12:15:13 +0000 (08:15 -0400)] 
[Ada] Factor out many fields in entities

gcc/ada/

* gen_il-gen-gen_entities.adb (Record_Field_Kind,
Allocatable_Kind): Add new abstract kinds.
(Constant_Or_Variable_Kind): Likewise.
(E_Constant, E_Variable, E_Loop_Parameter): Use them.
(E_Discriminant, E_Component): Likewise.
* gen_il-types.ads (type Opt_Type_Enum): Add them.

2 years ago[Ada] Fix bug in node/entity kind numbers in sinfo/einfo.h
Bob Duff [Wed, 7 Apr 2021 11:52:07 +0000 (07:52 -0400)] 
[Ada] Fix bug in node/entity kind numbers in sinfo/einfo.h

gcc/ada/

* gen_il-gen.adb (Put_C_Type_And_Subtypes): Put the correct
numbers.
* gen_il-internals.ads, gen_il-internals.adb: (Pos): Remove this
function. It was assuming that the order of the enumeration
literals in Type_Enum is the same as the order of the generated
types Node_Kind and Entity_Kind, which is not true.

2 years ago[Ada] Consistently use Validated_View for Valid_Scalars on records
Piotr Trojanek [Wed, 7 Apr 2021 08:16:55 +0000 (10:16 +0200)] 
[Ada] Consistently use Validated_View for Valid_Scalars on records

gcc/ada/

* exp_attr.adb (Expand_N_Attribute_Reference): Explicitly use
Validated_View for record objects.

2 years agoAdd forward propagation to SLP "any" permutes
Richard Biener [Tue, 29 Jun 2021 13:26:29 +0000 (15:26 +0200)] 
Add forward propagation to SLP "any" permutes

This adds a forward propagation phase to the permute optimization
machinery which allows us to handle "any" permute for all kinds of
nodes.  To match previous behavior cost-wise we still do not allow
non-external/constant nodes to be duplicated for multiple permutes
and this is ensured during propagation itself.

2021-06-29  Richard Biener  <rguenther@suse.de>

* tree-vect-slp.c (vect_optimize_slp): Forward propagate
to "any" permute nodes and relax "any" permute proapgation
during iterative backward propagation.

2 years agoAdd 'default' to -foffload=; document that flag [PR67300]
Tobias Burnus [Tue, 29 Jun 2021 13:58:21 +0000 (15:58 +0200)] 
Add 'default' to -foffload=; document that flag [PR67300]

As -foffload={options,targets,targets=options} is very convoluted,
it has been split into -foffload=targets (supporting the old syntax
for backward compatibilty) and -foffload-options={options,target=options}.

Only the new syntax is documented.

Additionally, -foffload=default is supported, which can reset the
devices after -foffload=disable / -foffload=targets to the default,
if needed.

gcc/ChangeLog:

PR other/67300
* common.opt (-foffload=): Update description.
(-foffload-options=): New.
* doc/invoke.texi (C Language Options): Document
-foffload and -foffload-options.
* gcc.c (check_offload_target_name): New, split off from
handle_foffload_option.
(check_foffload_target_names): New.
(handle_foffload_option): Handle -foffload=default.
(driver_handle_option): Update for -foffload-options.
* lto-opts.c (lto_write_options): Use -foffload-options
instead of -foffload.
* lto-wrapper.c (merge_and_complain, append_offload_options):
Likewise.
* opts.c (common_handle_option): Likewise.

libgomp/ChangeLog:

PR other/67300
* testsuite/libgomp.c-c++-common/reduction-16.c: Replace
-foffload=nvptx-none= by -foffload-options=nvptx-none= to
avoid disabling other offload targets.
* testsuite/libgomp.c-c++-common/reduction-5.c: Likewise.
* testsuite/libgomp.c-c++-common/reduction-6.c: Likewise.
* testsuite/libgomp.c/target-44.c: Likewise.

2 years agolibgomp.fortran/defaultmap-8.f90: Fix non-shared memory handling
Tobias Burnus [Tue, 29 Jun 2021 13:50:23 +0000 (15:50 +0200)] 
libgomp.fortran/defaultmap-8.f90: Fix non-shared memory handling

Disable some more parts of the test as firstprivate does not work yet
due to PR fortran/90742.

libgomp/
* testsuite/libgomp.fortran/defaultmap-8.f90 (bar): Determine whether
target has shared memory and disable some scalar pointer/allocatable
checks if not as firstprivate does not work.

2 years agodoc/invoke.texi: Sort flags in 'C Language Options'
Tobias Burnus [Tue, 29 Jun 2021 12:40:43 +0000 (14:40 +0200)] 
doc/invoke.texi: Sort flags in 'C Language Options'

As discussed during the review of
'[Patch] Add 'default' to -foffload=; document that flag [PR67300]'.

gcc/ChangeLog:

* doc/invoke.texi (C Language Options): Sort options
alphabetically in optlist and also the description itself.
Remove leftover -fallow-single-precision from and add missing
-fgnu-tm to the optlist.

2 years agoRefactor SLP permute opt propagation
Richard Biener [Tue, 29 Jun 2021 09:30:23 +0000 (11:30 +0200)] 
Refactor SLP permute opt propagation

This rewrites the SLP permute opt propagation to elide the visited
bit for an incoming permute of -1 as well as allowing the initial
propagation to take more than one iteration before starting on
materialization.  As we still lack propagation in the reverse
direction I've added gcc.dg/vect/bb-slp-71.c and a stopgap to
restrict "any" permute handling to the supported cases.

2021-06-29  Richard Biener  <rguenther@suse.de>

* tree-vect-slp.c (slpg_vertex::visited): Remove.
(vect_slp_perms_eq): Handle -1 permutes.
(vect_optimize_slp): Rewrite permute propagation.

* gcc.dg/vect/pr67790.c: Un-XFAIL.
* gcc.dg/vect/bb-slp-71.c: New testcase.

2 years agomatch.pd: Avoid (intptr_t)x eq/ne CST to x eq/ne (typeof x) CST opt in GENERIC when...
Jakub Jelinek [Tue, 29 Jun 2021 09:24:38 +0000 (11:24 +0200)] 
match.pd: Avoid (intptr_t)x eq/ne CST to x eq/ne (typeof x) CST opt in GENERIC when sanitizing [PR101210]

When we have (intptr_t) x == cst where x has REFERENCE_TYPE, this
optimization creates x == cst out of it where cst has REFERENCE_TYPE.
If it is done in GENERIC folding, it can results in ubsan failures
where the INTEGER_CST with REFERENCE_TYPE is instrumented.

Fixed by deferring it to GIMPLE folding in this case.

2021-06-29  Jakub Jelinek  <jakub@redhat.com>

PR c++/101210
* match.pd ((intptr_t)x eq/ne CST to x eq/ne (typeof x) CST): Don't
perform the optimization in GENERIC when sanitizing and x has a
reference type.

* g++.dg/ubsan/pr101210.C: New test.

2 years agotree-optimization/101242 - fix reverse graph entry detection
Richard Biener [Tue, 29 Jun 2021 07:33:24 +0000 (09:33 +0200)] 
tree-optimization/101242 - fix reverse graph entry detection

This avoids detecting random unrelated nodes as possible entries
to not backwards reachable regions of the SLP graph.  Instead
explicitely add the problematic nodes.

This temporary XFAILs gcc.dg/vect/pr67790.c until I get the
permute propagation adjusted to when it needs more than one
optimistic iteration.

2021-06-29  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101242
* tree-vect-slp.c (vect_slp_build_vertices): Force-add
PHIs with not represented initial values as leafs.

* gcc.dg/vect/bb-slp-pr101242.c: New testcase.
* gcc.dg/vect/pr67790.c: XFAIL scan for zero VEC_PERM_EXPR.

2 years agopdp11: Fix signednedd warnings, remove "register" keywords
Jan-Benedict Glaw [Tue, 29 Jun 2021 07:23:07 +0000 (09:23 +0200)] 
pdp11: Fix signednedd warnings, remove "register" keywords

gcc/ChangeLog:
* config/pdp11/pdp11.h (ASM_OUTPUT_SKIP): Fix signedness warning.
* config/pdp11/pdp11.c (pdp11_asm_print_operand_punct_valid_p): Remove
"register" keyword.
(pdp11_initial_elimination_offset) Remove unused variable.
(pdp11_cmp_length) Ditto.
(pdp11_insn_cost): Ditto, and fix signedness warning.

2 years agobootstrap: Include tm_p.h in btfout.c and ctfout.c.
David Edelsohn [Tue, 29 Jun 2021 02:54:42 +0000 (22:54 -0400)] 
bootstrap: Include tm_p.h in btfout.c and ctfout.c.

btfout.c and ctfout.c reference target-specific macros that
may reference target-specific functions that are declared in a
target-specific header.  tm_p.h must be included to provide the
target-specific header.

gcc/ChangeLog:

* btfout.c: Include tm_p.h.
* ctfout.c: Same.

2 years agoDaily bump.
GCC Administrator [Tue, 29 Jun 2021 00:16:42 +0000 (00:16 +0000)] 
Daily bump.

2 years agoanalyzer: introduce byte_range and use to simplify dumps
David Malcolm [Mon, 28 Jun 2021 23:18:06 +0000 (19:18 -0400)] 
analyzer: introduce byte_range and use to simplify dumps

gcc/analyzer/ChangeLog:
* analyzer.h (byte_offset_t): New typedef.
* store.cc (bit_range::dump_to_pp): Dump as a byte range if
possible.
(bit_range::as_byte_range): New.
(byte_range::dump_to_pp): New.
* store.h (class byte_range): New forward decl.
(struct bit_range): Add comment.
(bit_range::as_byte_range): New decl.
(struct byte_range): New.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoRegression tests for TREE_NO_WARNING enhancement to warning groups [PR74765, PR74762].
Martin Sebor [Mon, 28 Jun 2021 21:14:50 +0000 (15:14 -0600)] 
Regression tests for TREE_NO_WARNING enhancement to warning groups [PR74765, PR74762].

PR middle-end/74765 - missing uninitialized warning (parenthesis, TREE_NO_WARNING abuse)
PR middle-end/74762 - [9/10/11/12 Regression] missing uninitialized warning (C++, parenthesized expr, TREE_NO_WARNING)

gcc/testsuite/ChangeLog:

* g++.dg/uninit-pr74762.C: New test.
* g++.dg/warn/uninit-pr74765.C: Same.

2 years agoobjc: Add support for per-location warning groups.
Martin Sebor [Mon, 28 Jun 2021 21:13:17 +0000 (15:13 -0600)] 
objc: Add support for per-location warning groups.

gcc/objc/ChangeLog:

* objc-act.c (objc_maybe_build_modify_expr): Replace direct uses
of TREE_NO_WARNING with warning_suppressed_p, and suppress_warning.
(objc_build_incr_expr_for_property_ref): Same.
(objc_build_struct): Same.
(synth_module_prologue): Same.
* objc-gnu-runtime-abi-01.c (gnu_runtime_01_initialize): Same.
* objc-next-runtime-abi-01.c (next_runtime_01_initialize): Same.
* objc-next-runtime-abi-02.c (next_runtime_02_initialize): Same.

2 years agolibcc1: Add support for per-location warning groups.
Martin Sebor [Mon, 28 Jun 2021 21:09:46 +0000 (15:09 -0600)] 
libcc1: Add support for per-location warning groups.

libcc1/ChangeLog:

* libcp1plugin.cc (record_decl_address): Replace a direct use
of TREE_NO_WARNING with suppress_warning.

2 years agofortran: Add support for per-location warning groups.
Martin Sebor [Mon, 28 Jun 2021 20:47:21 +0000 (14:47 -0600)] 
fortran: Add support for per-location warning groups.

gcc/fortran/ChangeLog:

* trans-array.c (trans_array_constructor): Replace direct uses
of TREE_NO_WARNING with warning_suppressed_p, and suppress_warning.
* trans-decl.c (gfc_build_qualified_array): Same.
(gfc_build_dummy_array_decl): Same.
(generate_local_decl): Same.
(gfc_generate_function_code): Same.
* trans-openmp.c (gfc_omp_clause_default_ctor): Same.
(gfc_omp_clause_copy_ctor): Same.
* trans-types.c (get_dtype_type_node): Same.
(gfc_get_desc_dim_type): Same.
(gfc_get_array_descriptor_base): Same.
(gfc_get_caf_vector_type): Same.
(gfc_get_caf_reference_type): Same.
* trans.c (gfc_create_var_np): Same.

2 years agoada: Add support for per-location warning groups.
Martin Sebor [Mon, 28 Jun 2021 20:18:06 +0000 (14:18 -0600)] 
ada: Add support for per-location warning groups.

gcc/ada/ChangeLog:

* gcc-interface/trans.c (Handled_Sequence_Of_Statements_to_gnu):
Replace TREE_NO_WARNING with suppress_warning.
(gnat_gimplify_expr): Same.
* gcc-interface/utils.c (gnat_pushdecl): Same.

2 years agolibbacktrace: improve XCOFF support
Ian Lance Taylor [Mon, 28 Jun 2021 17:34:58 +0000 (10:34 -0700)] 
libbacktrace: improve XCOFF support

libbacktrace/ChangeLog:
2021-06-28  Clément Chigot  <clement.chigot@atos.net>

* xcoff.c (SSUBTYP_DWRNGES): New define.
(xcoff_add): Use correct XCOFF DWARF section subtype
for DEBUG_RANGES. Remove lineoff workaround.
Adjust base_address.
(xcoff_initialize_syminfo): Adapt to new base_address.
(xcoff_lookup_pc): Likewise.
(xcoff_initialize_fileline): Likewise.

2 years agolibiberty: copy over .BTF section when using LTO
Indu Bhagat [Fri, 28 May 2021 00:10:56 +0000 (17:10 -0700)] 
libiberty: copy over .BTF section when using LTO

libiberty/ChangeLog:

* simple-object.c (handle_lto_debug_sections): Copy over .BTF section.

2 years agoEnable BTF generation in the BPF backend
Indu Bhagat [Thu, 20 May 2021 18:21:39 +0000 (11:21 -0700)] 
Enable BTF generation in the BPF backend

This patch changes the BPF GCC backend in order to use the DWARF debug
hooks and therefore enables the user to generate BTF debugging
information with -gbtf.  Generating BTF is crucial when compiling BPF
programs, since the CO-RE (compile-once, run-everwhere) mechanism
used by the kernel BPF loader relies on it.

Note that since in eBPF it is not possible to unwind frames due to the
restrictive nature of the target architecture, we are disabling the
generation of CFA in this target.

2021-06-28  David Faust <david.faust@oracle.com>

* config/bpf/bpf.c (bpf_expand_prologue): Do not mark insns as
frame related.
(bpf_expand_epilogue): Likewise.
* config/bpf/bpf.h (DWARF2_FRAME_INFO): Define to 0.
Do not define DBX_DEBUGGING_INFO.

2 years agoCTF/BTF documentation
Indu Bhagat [Thu, 20 May 2021 18:20:50 +0000 (11:20 -0700)] 
CTF/BTF documentation

This commit documents the new command line options introduced by the
CTF and BTF debug formats.

2021-06-28  Indu Bhagat  <indu.bhagat@oracle.com>

* doc/invoke.texi: Document the CTF and BTF debug info options.

2 years agoCTF/BTF testsuites
Indu Bhagat [Thu, 20 May 2021 18:19:04 +0000 (11:19 -0700)] 
CTF/BTF testsuites

This commit adds a new testsuite for the CTF debug format.

2021-06-28  Indu Bhagat  <indu.bhagat@oracle.com>
    David Faust  <david.faust@oracle.com>

gcc/testsuite/

* lib/gcc-dg.exp (gcc-dg-frontend-supports-ctf): New procedure.
(gcc-dg-debug-runtest): Add -gctf support.
* gcc.dg/debug/btf/btf-1.c: New test.
* gcc.dg/debug/btf/btf-2.c: Likewise.
* gcc.dg/debug/btf/btf-anonymous-struct-1.c: Likewise.
* gcc.dg/debug/btf/btf-anonymous-union-1.c: Likewise.
* gcc.dg/debug/btf/btf-array-1.c: Likewise.
* gcc.dg/debug/btf/btf-bitfields-1.c: Likewise.
* gcc.dg/debug/btf/btf-bitfields-2.c: Likewise.
* gcc.dg/debug/btf/btf-bitfields-3.c: Likewise.
* gcc.dg/debug/btf/btf-cvr-quals-1.c: Likewise.
* gcc.dg/debug/btf/btf-enum-1.c: Likewise.
* gcc.dg/debug/btf/btf-forward-1.c: Likewise.
* gcc.dg/debug/btf/btf-function-1.c: Likewise.
* gcc.dg/debug/btf/btf-function-2.c: Likewise.
* gcc.dg/debug/btf/btf-int-1.c: Likewise.
* gcc.dg/debug/btf/btf-pointers-1.c: Likewise.
* gcc.dg/debug/btf/btf-struct-1.c: Likewise.
* gcc.dg/debug/btf/btf-typedef-1.c: Likewise.
* gcc.dg/debug/btf/btf-union-1.c: Likewise.
* gcc.dg/debug/btf/btf-variables-1.c: Likewise.
* gcc.dg/debug/btf/btf.exp: Likewise.
* gcc.dg/debug/ctf/ctf-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-2.c: Likewise.
* gcc.dg/debug/ctf/ctf-anonymous-struct-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-anonymous-union-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-array-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-array-2.c: Likewise.
* gcc.dg/debug/ctf/ctf-array-3.c: Likewise.
* gcc.dg/debug/ctf/ctf-array-4.c: Likewise.
* gcc.dg/debug/ctf/ctf-attr-mode-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-attr-used-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-bitfields-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-bitfields-2.c: Likewise.
* gcc.dg/debug/ctf/ctf-bitfields-3.c: Likewise.
* gcc.dg/debug/ctf/ctf-bitfields-4.c: Likewise.
* gcc.dg/debug/ctf/ctf-complex-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-cvr-quals-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-cvr-quals-2.c: Likewise.
* gcc.dg/debug/ctf/ctf-cvr-quals-3.c: Likewise.
* gcc.dg/debug/ctf/ctf-cvr-quals-4.c: Likewise.
* gcc.dg/debug/ctf/ctf-enum-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-enum-2.c: Likewise.
* gcc.dg/debug/ctf/ctf-file-scope-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-float-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-forward-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-forward-2.c: Likewise.
* gcc.dg/debug/ctf/ctf-func-index-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-function-pointers-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-function-pointers-2.c: Likewise.
* gcc.dg/debug/ctf/ctf-function-pointers-3.c: Likewise.
* gcc.dg/debug/ctf/ctf-functions-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-int-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-objt-index-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-pointers-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-pointers-2.c: Likewise.
* gcc.dg/debug/ctf/ctf-preamble-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-skip-types-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-skip-types-2.c: Likewise.
* gcc.dg/debug/ctf/ctf-skip-types-3.c: Likewise.
* gcc.dg/debug/ctf/ctf-skip-types-4.c: Likewise.
* gcc.dg/debug/ctf/ctf-skip-types-5.c: Likewise.
* gcc.dg/debug/ctf/ctf-skip-types-6.c: Likewise.
* gcc.dg/debug/ctf/ctf-str-table-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-struct-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-struct-2.c: Likewise.
* gcc.dg/debug/ctf/ctf-struct-array-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-struct-pointer-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-struct-pointer-2.c: Likewise.
* gcc.dg/debug/ctf/ctf-typedef-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-typedef-2.c: Likewise.
* gcc.dg/debug/ctf/ctf-typedef-3.c: Likewise.
* gcc.dg/debug/ctf/ctf-typedef-struct-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-typedef-struct-2.c: Likewise.
* gcc.dg/debug/ctf/ctf-typedef-struct-3.c: Likewise.
* gcc.dg/debug/ctf/ctf-union-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-variables-1.c: Likewise.
* gcc.dg/debug/ctf/ctf-variables-2.c: Likewise.
* gcc.dg/debug/ctf/ctf.exp: Likewise.

2 years agoCTF/BTF debug formats
Indu Bhagat [Thu, 20 May 2021 18:15:52 +0000 (11:15 -0700)] 
CTF/BTF debug formats

This commit introduces support for generating CTF debugging
information and BTF debugging information from GCC.

2021-06-28  Indu Bhagat  <indu.bhagat@oracle.com>
    David Faust  <david.faust@oracle.com>
    Jose E. Marchesi  <jose.marchesi@oracle.com>
    Weimin Pan  <weimin.pan@oracle.com>

gcc/

* Makefile.in: Add ctfc.*, ctfout.c and btfout.c files to
GTFILES.  Add new object files.
* common.opt: Add CTF and BTF debug info options.
* btfout.c: New file.
* ctfc.c: Likewise.
* ctfc.h: Likewise.
* ctfout.c: Likewise.
* dwarf2ctf.c: Likewise.
* dwarf2ctf.h: Likewise.
* dwarf2cfi.c (dwarf2out_do_frame): Acknowledge CTF_DEBUG and
BTF_DEBUG.
* dwarf2out.c (dwarf2out_source_line): Likewise.
(dwarf2out_finish): Skip emitting DWARF if CTF or BTF are to
be generated.
(debug_format_do_cu): New function.
(dwarf2out_early_finish): Traverse DIEs and emit CTF/BTF for
them if requested.
Include dwarf2ctf.c.
* final.c (dwarf2_debug_info_emitted_p): Acknowledge DWARF-based debug
formats.
* flag-types.h (enum debug_info_type): Add CTF_DEBUG and BTF_DEBUG.
(CTF_DEBUG): New bitmask.
(BTF_DEBUG): Likewise.
(enum ctf_debug_info_levels): New enum.
* gengtype.c (open_base_files): Handle ctfc.h.
(main): Handle uint32_t type.
* flags.h (btf_debuginfo_p): New definition.
(dwarf_based_debuginfo_p): Likewise.
* opts.c (debug_type_names): Add entries for CTF and BTF.
(btf_debuginfo_p): New function.
(dwarf_based_debuginfo_p): Likewise.
(common_handle_option): Handle -gctfN and -gbtf options.
(set_debug_level): Set CTF_DEBUG, BTF_DEBUG whenever appropriate.
* toplev.c (process_options): Inform the user and ignore -gctfLEVEL if
frontend is not C.

include/

* ctf.h: New file.
* btf.h: Likewise.

libiberty/

* simple-object.c (handle_lto_debug_sections): Copy over .ctf
sections.

2 years agodejagnu: modularize gcc-dg-debug-runtest a bit
Indu Bhagat [Thu, 20 May 2021 17:32:38 +0000 (10:32 -0700)] 
dejagnu: modularize gcc-dg-debug-runtest a bit

Move some functionality into a procedure of its own. This is only so that when
the patch for ctf comes along, the gcc-dg-debug-runtest procedure looks bit
more uniform.

gcc/testsuite/ChangeLog:

* lib/gcc-dg.exp (gcc-dg-target-supports-debug-format): New procedure.

2 years agodwarf: externalize some DWARF internals for needs of CTF/BTF
Indu Bhagat [Thu, 20 May 2021 17:30:13 +0000 (10:30 -0700)] 
dwarf: externalize some DWARF internals for needs of CTF/BTF

This patch externalizes some internal DIE structures and their attributes
for the use of DWARF-based debug formats like CTF and BTF.

The following functions which were previously defined as static in
dwarf2out.c are now non-static, and extern prototypes for them have
been added to dwarf2out.h:

- get_AT
- AT_int
- AT_class
- AT_loc
- get_AT_ref
- get_AT_string
- get_AT_class
- AT_unsigned
- get_AT_unsigned
- get_AT_flag
- add_name_attribute
- new_die_raw
- base_type_die
- lookup_decl_die
- get_AT_file

Note how this patch doens't change the names of these functions to
avoid a massive renaming in dwarf2out.c, but in the future we probably
want these functions to sport a dw_* prefix.

Also, some type definitions have been moved from dwarf2out.c to
dwarf2out.h:

- dw_attr_node
- struct dwarf_file_data

Finally, three new accessor functions have been added to dwarf2out.c
with prototypes in dwarf2out.h:

- dw_get_die_child
- dw_get_die_sib
- dw_get_die_tag

2021-06-28  Jose E. Marchesi  <jose.marchesi@oracle.com>

* dwarf2out.c (AT_class): Function is no longer static.
(AT_int): Likewise.
(AT_unsigned): Likewise.
(AT_loc): Likewise.
(get_AT): Likewise.
(get_AT_string): Likewise.
(get_AT_flag): Likewise.
(get_AT_unsigned): Likewise.
(get_AT_ref): Likewise.
(new_die_raw): Likewise.
(lookup_decl_die): Likewise.
(base_type_die): Likewise.
(add_name_attribute): Likewise.
(add_AT_int): Likewise.
(add_AT_unsigned): Likewise.
(add_AT_loc): Likewise.
(dw_get_die_tag): New function.
(dw_get_die_child): Likewise.
(dw_get_die_sib): Likewise.
(struct dwarf_file_data): Move from here to dwarf2out.h
(struct dw_attr_struct): Likewise.
* dwarf2out.h: Analogous changes.

2 years agoipa-sra: Introduce a mini-DCE to tree-inline.c (PR 93385)
Martin Jambor [Mon, 28 Jun 2021 16:20:00 +0000 (18:20 +0200)] 
ipa-sra: Introduce a mini-DCE to tree-inline.c (PR 93385)

I was asked by Richi to split my fix for PR 93385 for easier review
into IPA-SRA materialization refactoring and the actual DCE addition.
This is the second part that actually contains the DCE of statements
that IPA-SRA should not leave behind because they can have problematic
side effects, even if they are useless, so that we do not depend on
tree-dce to remove them for correctness.

The patch fixes the problem by doing a def-use walk when materializing
clones, marking which statements should not be copied and which
SSA_NAMEs do not need to be computed because eventually they would be
DCEd.  We do this on the original function body and tree-inline simply
does not copy statements which are "dead."

The only complication is removing dead argument calls because that
needs to be communicated to callee redirection code using the
infrastructure introduced by the previous patch.

I added all testcases of the original patch to this one, although some
probably test behavior introduced in the previous patch.

gcc/ChangeLog:

2021-05-12  Martin Jambor  <mjambor@suse.cz>

PR ipa/93385
* ipa-param-manipulation.h (class ipa_param_body_adjustments): New
members m_dead_stmts and m_dead_ssas.
* ipa-param-manipulation.c
(ipa_param_body_adjustments::mark_dead_statements): New function.
(ipa_param_body_adjustments::common_initialization): Call it on
all removed but not split parameters.
(ipa_param_body_adjustments::ipa_param_body_adjustments): Initialize
new mwmbers.
(ipa_param_body_adjustments::modify_call_stmt): Remove arguments that
are dead.
* tree-inline.c (remap_gimple_stmt): Do not copy dead statements, reset
dead debug statements.
(copy_phis_for_bb): Do not copy dead PHI nodes.

gcc/testsuite/ChangeLog:

2021-03-22  Martin Jambor  <mjambor@suse.cz>

PR ipa/93385
* gcc.dg/ipa/pr93385.c: New test.
* gcc.dg/ipa/ipa-sra-23.c: Likewise.
* gcc.dg/ipa/ipa-sra-24.c: Likewise.
* g++.dg/ipa/ipa-sra-4.C: Likewise.

2 years agoipa-sra: Restructure how cloning and call redirection communicate (PR 93385)
Martin Jambor [Mon, 28 Jun 2021 16:20:00 +0000 (18:20 +0200)] 
ipa-sra: Restructure how cloning and call redirection communicate (PR 93385)

I was asked by Richi to split my fix for PR 93385 for easier review
into IPA-SRA materialization refactoring and the actual DCE addition.
Fortunately it was mostly natural except for a temporary weird
condition in ipa_param_body_adjustments::modify_call_stmt.
Additionally.  In addition to the patch I posted previously, this one
also deallocated the newly added summary in toplev::finalize and fixes
a mistakenly uninitialized field.

This is the first part which basically replaces performed_splits in
clone_info and the code which generates it, keeps it up-to-date and
consumes it with new edge summaries which are much nicer.  It simply
contains 1) a mapping from the original argument indices to the actual
indices in the call statement as it is now, 2) information needed to
identify arguments representing pass-through IPA-SRA splits with which
have been added to the call arguments in place of an original
argument/reference and 3) a delta to the index where va_args may start
- so basically directly all the information that the consumer of
performed_splits had to compute and we also do not need the weird
dummy declarations.

The main disadvantage is that the information has to be created (and
kept up-to-date) for all call graph edges associated with the given
statement from all clones (including inline clones) of the clone where
splitting or removal happened first.  But all of this happens during
clone materialization so the only effect on WPA memory consumption is
the removal of a pointer from clone_info.

The statement modification code also has to know the statement from
the original function in order to be able to locate the edge summaries
which at this point are still keyed to these.  However, the code is
already quite heavily dependant on how things are structured in
tree-inline.c and in order to fix bugs like these it probably has to
be.

The subsequent patch needs this new information to be able to remove
arguments from calls during materialization and communicate this
information to the call redirection.

gcc/ChangeLog:

2021-05-17  Martin Jambor  <mjambor@suse.cz>

PR ipa/93385
* symtab-clones.h (clone_info): Removed member param_adjustments.
* ipa-param-manipulation.h: Adjust initial comment to reflect how we
deal with pass-through splits now.
(ipa_param_performed_split): Removed.
(ipa_param_adjustments::modify_call): Adjusted parameters.
(class ipa_param_body_adjustments): Adjusted parameters of
register_replacement, modify_gimple_stmt and modify_call_stmt.
(ipa_verify_edge_has_no_modifications): Declare.
(ipa_edge_modifications_finalize): Declare.
* cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Remove
performed_splits processing, pas only edge to padjs->modify_call,
check that call arguments were not modified if they should not have
been.
* cgraphclones.c (cgraph_node::create_clone): Do not copy performed
splits.
* ipa-param-manipulation.c (struct pass_through_split_map): New type.
(ipa_edge_modification_info): Likewise.
(ipa_edge_modification_sum): Likewise.
(ipa_edge_modifications): New edge summary.
(ipa_verify_edge_has_no_modifications): New function.
(transitive_split_p): Removed.
(transitive_split_map): Likewise.
(init_transitive_splits): Likewise.
(ipa_param_adjustments::modify_call): Adjusted to use the new edge
summary instead of performed_splits.
(ipa_param_body_adjustments::register_replacement): Drop dummy
parameter, set base_index of the created ipa_param_body_replacement.
(phi_arg_will_live_p): New function.
(ipa_param_body_adjustments::common_initialization): Do not create
IPA_SRA dummy decls.
(simple_tree_swap_info): Removed.
(remap_split_decl_to_dummy): Likewise.
(record_argument_state_1): New function.
(record_argument_state): Likewise.
(ipa_param_body_adjustments::modify_call_stmt): New parameter
orig_stmt.  Do not work with dummy decls, save necessary info about
changes to ipa_edge_modifications.
(ipa_param_body_adjustments::modify_gimple_stmt): New parameter
orig_stmt, pass it to modify_call_stmt.
(ipa_param_body_adjustments::modify_cfun_body): Adjust call to
modify_gimple_stmt.
(ipa_edge_modifications_finalize): New function.
* tree-inline.c (remap_gimple_stmt): Pass original statement to
modify_gimple_stmt.
(copy_phis_for_bb): Do not copy dead PHI nodes.
(expand_call_inline): Do not remap performed_splits.
(update_clone_info): Likewise.
* toplev.c: Include ipa-param-manipulation.h.
(toplev::finalize): Call ipa_edge_modifications_finalize.

2 years agolibstdc++: Remove redundant explicit instantiations
Jonathan Wakely [Mon, 28 Jun 2021 14:16:08 +0000 (15:16 +0100)] 
libstdc++: Remove redundant explicit instantiations

These function templates are explicitly specialized for char and wchar_t
streambufs, so the explicit instantiations do nothing. Remove them, to
avoid confusion.

libstdc++-v3/ChangeLog:

* include/bits/streambuf.tcc (__copy_streambufs_eof): Remove
explicit instantiation declarations.
* src/c++11/streambuf-inst.cc (__copy_streambufs_eof): Remove
explicit instantiation definitions.

2 years agolibstdc++: Fix backwards logic in 17_intro/names.cc test [PR 97088]
Jonathan Wakely [Mon, 28 Jun 2021 14:13:34 +0000 (15:13 +0100)] 
libstdc++: Fix backwards logic in 17_intro/names.cc test [PR 97088]

I meant to undef the names that clash with newlib headers for newlib,
but I only undef'd them for non-newlib targets. This means they still
cause errors for newlib, and aren't tested for other targets.

This fixes the test to check those names for non-newlib targets, and to
undef them to avoid errors for newlib.

libstdc++-v3/ChangeLog:

PR libstdc++/97088
* testsuite/17_intro/names.cc: Fix #if condition for names used
by newlib headers.

2 years agolibstdc++: Allow unique_ptr<Incomplete[]>::operator[] [PR 101236]
Jonathan Wakely [Mon, 28 Jun 2021 11:59:19 +0000 (12:59 +0100)] 
libstdc++: Allow unique_ptr<Incomplete[]>::operator[] [PR 101236]

PR libstdc++/101236 shows that LLVM depends on being able to use
unique_ptr<T[]>::operator[] when T is incomplete. This is undefined, but
previously worked with libstdc++. When I added the conditional noexcept
to that operator we started to diagnose the incomplete type.

This change restores support for that case, by making the noexcept
condition check that the type is complete before checking whether
indexing on the pointer can throw.  A workaround for PR c++/101239 is
needed to avoid a bogus error where G++ fails to do SFINAE on the
ill-formed p[n] expression and gets an ICE. Instead of checking that the
p[n] expression is valid in the trailing-return-type, we only check that
the element_type is complete.

libstdc++-v3/ChangeLog:

PR libstdc++/101236
* include/bits/unique_ptr.h (unique_ptr<T[], D>::operator[]):
Fail gracefully if element_type is incomplete.
* testsuite/20_util/unique_ptr/cons/incomplete.cc: Clarify that
the standard doesn't require this test to work for array types.
* testsuite/20_util/unique_ptr/lwg2762.cc: Check that incomplete
types can be used with array specialization.
* testsuite/20_util/unique_ptr/101236.cc: New test.

2 years agolibstdc++: Implement LWG 415 for std::ws
Jonathan Wakely [Fri, 25 Jun 2021 20:33:02 +0000 (21:33 +0100)] 
libstdc++: Implement LWG 415 for std::ws

For C++11 std::ws changed to be an unformatted input function, meaning
it constructs a sentry and sets badbit on exceptions.

libstdc++-v3/ChangeLog:

* doc/xml/manual/intro.xml: Document LWG 415 change.
* doc/html/manual/bugs.html: Regenerate.
* include/bits/istream.tcc (ws): Create sentry and catch
exceptions.
* testsuite/27_io/basic_istream/ws/char/lwg415.cc: New test.
* testsuite/27_io/basic_istream/ws/wchar_t/lwg415.cc: New test.

2 years agomklog: Handle correctly long lines.
Martin Liska [Mon, 28 Jun 2021 11:08:10 +0000 (13:08 +0200)] 
mklog: Handle correctly long lines.

contrib/ChangeLog:

* mklog.py: Handle correctly long lines.
* test_mklog.py: Test it.

2 years agoDuplicate the range information of the phi onto the new ssa_name
Andrew Pinski [Sat, 19 Jun 2021 17:08:21 +0000 (10:08 -0700)] 
Duplicate the range information of the phi onto the new ssa_name

Since match_simplify_replacement uses gimple_simplify, there is a new
ssa name created sometimes and then we go and replace the phi edge with
this new ssa name, the range information on the phi is lost.
Placing this in replace_phi_edge_with_variable is the best option instead
of doing it in each time replace_phi_edge_with_variable is called which is
what is done today.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

* tree-ssa-phiopt.c (replace_phi_edge_with_variable): Duplicate range
info if we're the only things setting the target PHI.
(value_replacement): Don't duplicate range here.
(minmax_replacement): Likewise.

2 years agotree-optimization/101229 - fix vectorizer SLP hybrid detection with PHIs
Richard Biener [Mon, 28 Jun 2021 09:05:46 +0000 (11:05 +0200)] 
tree-optimization/101229 - fix vectorizer SLP hybrid detection with PHIs

This fixes the missing handling of PHIs in gimple_walk_op which causes
the new vectorizer SLP hybrid detection scheme to fail.

2021-06-28  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101229
* gimple-walk.c (gimple_walk_op): Handle PHIs.

* gcc.dg/torture/pr101229.c: New testcase.

2 years agov850: silent 2 warnings
Martin Liska [Wed, 23 Jun 2021 13:48:28 +0000 (15:48 +0200)] 
v850: silent 2 warnings

Silents:

/home/marxin/Programming/gcc/gcc/config/v850/v850.c: In function ‘char* construct_dispose_instruction(rtx)’:
/home/marxin/Programming/gcc/gcc/config/v850/v850.c:2690:22: warning: ‘%s’ directive writing up to 99 bytes into a region of size between 79 and 89 [-Wformat-overflow=]
 2690 |       sprintf (buff, "dispose %d {%s}, r31", stack_bytes / 4, regs);
      |                      ^~~~~~~~~~~~~~~~~~~~~~                   ~~~~
/home/marxin/Programming/gcc/gcc/config/v850/v850.c:2690:15: note: ‘sprintf’ output between 18 and 127 bytes into a destination of size 100
 2690 |       sprintf (buff, "dispose %d {%s}, r31", stack_bytes / 4, regs);
      |       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/marxin/Programming/gcc/gcc/config/v850/v850.c: In function ‘char* construct_prepare_instruction(rtx)’:
/home/marxin/Programming/gcc/gcc/config/v850/v850.c:2814:22: warning: ‘%s’ directive writing up to 99 bytes into a region of size 91 [-Wformat-overflow=]
 2814 |       sprintf (buff, "prepare {%s}, %d", regs, (- stack_bytes) / 4);
      |                      ^~~~~~~~~~~~~~~~~~  ~~~~
/home/marxin/Programming/gcc/gcc/config/v850/v850.c:2814:15: note: ‘sprintf’ output between 14 and 123 bytes into a destination of size 100
 2814 |       sprintf (buff, "prepare {%s}, %d", regs, (- stack_bytes) / 4);
      |       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

gcc/ChangeLog:

* config/v850/v850.c (construct_dispose_instruction): Allocate
a bigger buffer.
(construct_prepare_instruction): Likewise.

2 years agov850: add v850_can_inline_p target hook
Martin Liska [Wed, 23 Jun 2021 13:46:22 +0000 (15:46 +0200)] 
v850: add v850_can_inline_p target hook

gcc/ChangeLog:

* config/v850/v850.c (v850_option_override): Build default
target node.
(v850_can_inline_p): New.  Allow MASK_PROLOG_FUNCTION to be
ignored for inlining.
(TARGET_CAN_INLINE_P): New.

2 years agotree-optimization/101207 - fix BB reduc permute elide with life stmts
Richard Biener [Mon, 28 Jun 2021 07:42:58 +0000 (09:42 +0200)] 
tree-optimization/101207 - fix BB reduc permute elide with life stmts

This fixes breakage of live lane extracts from permuted loads we elide
from BB reduction vectorization by handling the un-permuting the same
as in the regular eliding code - apply the reverse permute to
both the scalar stmts and the load permutation.

2021-06-28  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101207
* tree-vect-slp.c (vect_optimize_slp): Do BB reduction
permute eliding for load permutations properly.

* gcc.dg/vect/bb-slp-pr101207.c: New testcase.

2 years agotree-optimization/101173 - fix interchange dependence checking
Richard Biener [Wed, 23 Jun 2021 07:59:28 +0000 (09:59 +0200)] 
tree-optimization/101173 - fix interchange dependence checking

This adjusts the loop interchange dependence checking to disallow
an outer loop dependence distance of zero.

2021-06-23  Richard Biener  <rguenther@suse.de>

PR tree-optimization/101173
* gimple-loop-interchange.cc
(tree_loop_interchange::valid_data_dependences): Disallow outer
loop dependence distance of zero.

* gcc.dg/torture/pr101173.c: New testcase.

2 years agoFor 128/256-bit vec_cond_expr, When mask operands is lt reg const0_rtx, blendv can...
liuhongt [Mon, 24 May 2021 02:57:52 +0000 (10:57 +0800)] 
For 128/256-bit vec_cond_expr, When mask operands is lt reg const0_rtx, blendv can be used instead of avx512 mask.

gcc/ChangeLog:

PR target/100648
* config/i386/sse.md (*avx_cmp<mode>3_lt): New
define_insn_and_split.
(*avx_cmp<mode>3_ltint): Ditto.
(*avx2_pcmp<mode>3_3): Ditto.
(*avx2_pcmp<mode>3_4): Ditto.
(*avx2_pcmp<mode>3_5): Ditto.

gcc/testsuite/ChangeLog:

PR target/100648
* g++.target/i386/avx2-pr54700-2.C: Adjust testcase.
* g++.target/i386/avx512vl-pr54700-1a.C: New test.
* g++.target/i386/avx512vl-pr54700-1b.C: New test.
* g++.target/i386/avx512vl-pr54700-2a.C: New test.
* g++.target/i386/avx512vl-pr54700-2b.C: New test.
* gcc.target/i386/avx512vl-pr100648.c: New test.
* gcc.target/i386/avx512vl-blendv-1.c: New test.
* gcc.target/i386/avx512vl-blendv-2.c: New test.

2 years agoFold blendv builtins into gimple.
liuhongt [Fri, 21 May 2021 01:48:18 +0000 (09:48 +0800)] 
Fold blendv builtins into gimple.

Fold __builtin_ia32_pblendvb128 (a, b, c) as VEC_COND_EXPR (c < 0, b,
a), similar for float version but with mask operand VIEW_CONVERT_EXPR
to same sized integer vectype.

gcc/ChangeLog:

* config/i386/i386-builtin.def (IX86_BUILTIN_BLENDVPD256,
IX86_BUILTIN_BLENDVPS256, IX86_BUILTIN_PBLENDVB256,
IX86_BUILTIN_BLENDVPD, IX86_BUILTIN_BLENDVPS,
IX86_BUILTIN_PBLENDVB128): Replace icode with
CODE_FOR_nothing.
* config/i386/i386.c (ix86_gimple_fold_builtin): Fold blendv
builtins.
* config/i386/sse.md (*<sse4_1_avx2>_pblendvb_lt_subreg_not):
New pre_reload splitter.

gcc/testsuite/ChangeLog:

* gcc.target/i386/funcspec-8.c: Replace
__builtin_ia32_blendvpd with  __builtin_ia32_roundps_az.
* gcc.target/i386/blendv-1.c: New test.
* gcc.target/i386/blendv-2.c: New test.

2 years agoDaily bump.
GCC Administrator [Mon, 28 Jun 2021 00:16:30 +0000 (00:16 +0000)] 
Daily bump.

2 years agoFix PR 101230: ICE in fold_cond_expr_with_comparison
Andrew Pinski [Sun, 27 Jun 2021 20:14:48 +0000 (13:14 -0700)] 
Fix PR 101230: ICE in fold_cond_expr_with_comparison

This fixes PR 101230 where I had messed up and forgot that
invert_tree_comparison can return ERROR_MARK if the comparsion
is not invertable (floating point types).

Committed as obvious after a bootstrap/test on x86_64-linux-gnu-gnu

gcc/ChangeLog:

PR middle-end/101230
* fold-const.c (fold_ternary_loc): Check
the return value of invert_tree_comparison.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr101230-1.c: New test.