Commit Graph

164052 Commits

Author SHA1 Message Date
Andre Simoes Dias Vieira 28a7b5df3b aarch64: Implement ACLE Data Intrinsics
This patch adds support for the ACLE Data Intrinsics to the AArch64 port.

gcc/ChangeLog:

2022-07-25  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	* config/aarch64/aarch64.md (rbit<mode>2): Rename this ...
	(@aarch64_rbit<mode>): ... to this and change it in...
	(ffs<mode>2,ctz<mode>2): ... here.
	(@aarch64_rev16<mode>): New.
	* config/aarch64/aarch64-builtins.cc: (aarch64_builtins):
	Define the following enum AARCH64_REV16, AARCH64_REV16L,
	AARCH64_REV16LL, AARCH64_RBIT, AARCH64_RBITL, AARCH64_RBITLL.
	(aarch64_init_data_intrinsics): New.
	(aarch64_general_init_builtins): Add call to
	aarch64_init_data_intrinsics.
	(aarch64_expand_builtin_data_intrinsic): New.
	(aarch64_general_expand_builtin): Add call to
	aarch64_expand_builtin_data_intrinsic.
	* config/aarch64/arm_acle.h (__clz, __clzl, __clzll, __cls, __clsl,
	__clsll, __rbit, __rbitl, __rbitll, __rev, __revl, __revll, __rev16,
	__rev16l, __rev16ll, __ror, __rorl, __rorll, __revsh): New.

gcc/testsuite/ChangeLog:

2022-07-25  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	* gcc.target/aarch64/acle/data-intrinsics.c: New test.

(cherry picked from commit eb966d393d)
2022-08-11 16:18:08 +01:00
GCC Administrator bc52af4817 Daily bump. 2022-08-11 00:19:22 +00:00
Tobias Burnus 68b8c55c7e OpenMP: Fix folding with simd's linear clause [PR106492]
gcc/ChangeLog:

	PR middle-end/106492
	* omp-low.cc (lower_rec_input_clauses): Add missing folding
	to data type of linear-clause list item.

gcc/testsuite/ChangeLog:

	PR middle-end/106492
	* g++.dg/gomp/pr106492.C: New test.

(cherry picked from commit 8a16b9f983)
2022-08-10 19:17:35 +02:00
Richard Biener ab2ca2dbd5 tree-optimization/106513 - fix mistake in bswap symbolic number shifts
This fixes a mistake in typing a local variable in the symbolic
shift routine.

	PR tree-optimization/106513
	* gimple-ssa-store-merging.cc (do_shift_rotate): Use uint64_t
	for head_marker.

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

(cherry picked from commit f675afa4ee)
2022-08-10 16:39:38 +02:00
Richard Biener 4769ac6c5d lto/106540 - fix LTO tree input wrt dwarf2out_register_external_die
I've revisited the earlier two workarounds for dwarf2out_register_external_die
getting duplicate entries.  It turns out that r11-525-g03d90a20a1afcb
added dref_queue pruning to lto_input_tree but decl reading uses that
to stream in DECL_INITIAL even when in the middle of SCC streaming.
When that SCC then gets thrown away we can end up with debug nodes
registered which isn't supposed to happen.  The following adjusts
the DECL_INITIAL streaming to go the in-SCC way, using lto_input_tree_1,
since no SCCs are expected at this point, just refs.

	PR lto/106540
	PR lto/106334
	* lto-streamer-in.cc (lto_read_tree_1): Use lto_input_tree_1
	to input DECL_INITIAL, avoiding to commit drefs.

(cherry picked from commit 2a1448f276)
2022-08-10 16:29:47 +02:00
GCC Administrator 04e3c9a18b Daily bump. 2022-08-10 00:19:29 +00:00
Vibhav Pant 92f2582f3e libgccjit.h: Uncomment macro definition for testing gcc_jit_context_new_bitcast support
(cherry-picked from r13-2004-g9385cd9c74cf66)

The macro definition for LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
was earlier located in the documentation comment for
gcc_jit_context_new_bitcast, making it unavailable to code that
consumed libgccjit.h. This commit moves the definition out of the
comment, making it effective.

gcc/jit/ChangeLog:
	* libgccjit.h (LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast): Move
	definition out of comment.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-08-09 19:06:52 -04:00
Iain Buclaw 79a86a6086 d: Fix undefined reference to pragma(inline) symbol (PR106563)
Functions that are declared `pragma(inline)' should be treated as if
they are defined in every translation unit they are referenced from,
regardless of visibility protection.  Ensure they always get
DECL_ONE_ONLY linkage, and start emitting them into other modules that
import them.

	PR d/106563

gcc/d/ChangeLog:

	* decl.cc (DeclVisitor::visit (FuncDeclaration *)): Set semanticRun
	before generating its symbol.
	(function_defined_in_root_p): New function.
	(function_needs_inline_definition_p): New function.
	(maybe_build_decl_tree): New function.
	(get_symbol_decl): Call maybe_build_decl_tree before returning symbol.
	(start_function): Use function_defined_in_root_p instead of inline
	test for locally defined symbols.
	(set_linkage_for_decl): Check for inline functions before private or
	protected symbols.

gcc/testsuite/ChangeLog:

	* gdc.dg/torture/torture.exp (srcdir): New proc.
	* gdc.dg/torture/imports/pr106563math.d: New test.
	* gdc.dg/torture/imports/pr106563regex.d: New test.
	* gdc.dg/torture/imports/pr106563uni.d: New test.
	* gdc.dg/torture/pr106563.d: New test.

(cherry picked from commit 04284176d5)
2022-08-09 14:42:11 +02:00
GCC Administrator e62a644fb3 Daily bump. 2022-08-09 00:19:21 +00:00
Iain Buclaw fc7166a7c4 d: Fix ICE in in add_stack_var, at cfgexpand.cc:476
The type that triggers the ICE never got completed by the semantic
analysis pass.  Checking for size forces it to be done, or issue a
compile-time error.

	PR d/106555

gcc/d/ChangeLog:

	* d-target.cc (Target::isReturnOnStack): Check for return type size.

gcc/testsuite/ChangeLog:

	* gdc.dg/imports/pr106555.d: New test.
	* gdc.dg/pr106555.d: New test.

(cherry picked from commit 4b0253b019)
2022-08-08 20:29:04 +02:00
GCC Administrator 556e5a3b1e Daily bump. 2022-08-08 00:19:17 +00:00
GCC Administrator b8d9acc373 Daily bump. 2022-08-07 00:19:25 +00:00
GCC Administrator 4178af1a5f Daily bump. 2022-08-06 00:19:27 +00:00
Michael Meissner 25b11619a8 Do not enable -mblock-ops-vector-pair.
Testing has shown that using the load vector pair and store vector pair
instructions for block moves has some performance issues on power10.

A patch on June 11th modified the code so that GCC would not set
-mblock-ops-vector-pair by default if we are tuning for power10, but it would
set the option if we were tuning for a different machine and have load and store
vector pair instructions enabled.

This patch eliminates the code setting -mblock-ops-vector-pair.  If you want to
generate load vector pair and store vector pair instructions for block moves,
you must use -mblock-ops-vector-pair.

2022-08-05   Michael Meissner  <meissner@linux.ibm.com>

gcc/

	* config/rs6000/rs6000.cc (rs6000_option_override_internal): Remove code
	setting -mblock-ops-vector-pair.  Back port patch from trunk on 8/3.
2022-08-05 18:54:33 -04:00
GCC Administrator 99679c0ff7 Daily bump. 2022-08-05 00:19:14 +00:00
GCC Administrator c749de4937 Daily bump. 2022-08-04 00:19:28 +00:00
GCC Administrator eb941a6d65 Daily bump. 2022-08-03 00:19:18 +00:00
Peter Bergner 5f583aa1c5 rs6000: Adjust -mdejagnu-cpu to filter out -mtune [PR106345]
As PR106345 shows, when configuring compiler with an explicit
option --with-tune=<value>, it would cause some test cases to
fail if their test points are sensitive to tune setting, such
as: group_ending_nop, loop align etc.  It doesn't help that
even to specify one explicit -mcpu=.

This patch is to adjust the behavior of -mdejagnu-cpu by
filtering out all -mcpu= and -mtune= options, then test cases
would use <cpu> as tune as the one specified by -mdejagnu-cpu.

2022-07-25  Peter Bergner  <bergner@linux.ibm.com>
	    Kewen Lin  <linkw@linux.ibm.com>

	PR testsuite/106345

gcc/ChangeLog:

	* config/rs6000/rs6000.h (DRIVER_SELF_SPECS): Adjust -mdejagnu-cpu
	to filter out all -mtune options.

(cherry picked from commit 75d20d6c84)
2022-08-01 21:27:15 -05:00
Kewen Lin bd521701c8 rs6000: Preserve REG_EH_REGION when replacing load/store [PR106091]
As test case in PR106091 shows, rs6000 specific pass swaps
doesn't preserve the reg_note REG_EH_REGION when replacing
some load insn at the end of basic block, it causes the
flow info verification to fail unexpectedly.  Since memory
reference rtx may trap, this patch is to ensure we copy
REG_EH_REGION reg_note while replacing swapped aligned load
or store.

	PR target/106091

gcc/ChangeLog:

	* config/rs6000/rs6000-p8swap.cc (replace_swapped_aligned_store): Copy
	REG_EH_REGION when replacing one store insn having it.
	(replace_swapped_aligned_load): Likewise.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pr106091.c: New test.

(cherry picked from commit f428660193)
2022-08-01 21:27:10 -05:00
GCC Administrator e04785d99d Daily bump. 2022-08-02 00:19:17 +00:00
Lewis Hyatt 98e2676558 c: Fix location for _Pragma tokens [PR97498]
The handling of #pragma GCC diagnostic uses input_location, which is not always
as precise as needed; in particular the relative location of some tokens and a
_Pragma directive will crucially determine whether a given diagnostic is enabled
or suppressed in the desired way. PR97498 shows how the C frontend ends up with
input_location pointing to the beginning of the line containing a _Pragma()
directive, resulting in the wrong behavior if the diagnostic to be modified
pertains to some tokens found earlier on the same line. This patch fixes that by
addressing two issues:

    a) libcpp was not assigning a valid location to the CPP_PRAGMA token
    generated by the _Pragma directive.
    b) C frontend was not setting input_location to something reasonable.

With this change, the C frontend is able to change input_location to point to
the _Pragma token as needed.

This is just a two-line fix (one for each of a) and b)), the testsuite changes
were needed only because the location on the tested warnings has been somewhat
improved, so the tests need to look for the new locations.

gcc/c/ChangeLog:

	PR preprocessor/97498
	* c-parser.cc (c_parser_pragma): Set input_location to the
	location of the pragma, rather than the start of the line.

libcpp/ChangeLog:

	PR preprocessor/97498
	* directives.cc (destringize_and_run): Override the location of
	the CPP_PRAGMA token from a _Pragma directive to the location of
	the expansion point, as is done for the tokens lexed from it.

gcc/testsuite/ChangeLog:

	PR preprocessor/97498
	* c-c++-common/pr97498.c: New test.
	* c-c++-common/gomp/pragma-3.c: Adapt for improved warning locations.
	* c-c++-common/gomp/pragma-5.c: Likewise.
	* gcc.dg/pragma-message.c: Likewise.

libgomp/ChangeLog:

	* testsuite/libgomp.oacc-c-c++-common/reduction-5.c: Adapt for
	improved warning locations.
	* testsuite/libgomp.oacc-c-c++-common/vred2d-128.c: Likewise.

(cherry picked from commit 0587cef3d7)
2022-08-01 13:38:24 -04:00
GCC Administrator d2bafe190c Daily bump. 2022-08-01 00:19:26 +00:00
GCC Administrator caf633624f Daily bump. 2022-07-31 00:19:07 +00:00
Jakub Jelinek 681c73db9b openmp: Fix up handling of non-rectangular simd loops with pointer type iterators [PR106449]
There were 2 issues visible on this new testcase, one that we didn't have
special POINTER_TYPE_P handling in a few spots of expand_omp_simd - for
pointers we need to use POINTER_PLUS_EXPR and need to have the non-pointer
part in sizetype, for non-rectangular loop on the other side we can rely on
multiplication factor 1, pointers can't be multiplied, without those changes
we'd ICE.  The other issue was that we put n2 expression directly into a
comparison in a condition and regimplified that, for the &a[512] case that
and with gimplification being destructed that unfortunately meant modification
of original fd->loops[?].n2.  Fixed by unsharing the expression.  This was
causing a runtime failure on the testcase.

2022-07-29  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/106449
	* omp-expand.cc (expand_omp_simd): Fix up handling of pointer
	iterators in non-rectangular simd loops.  Unshare fd->loops[i].n2
	or n2 before regimplifying it inside of a condition.

	* testsuite/libgomp.c-c++-common/pr106449.c: New test.

(cherry picked from commit 97d32048c0)
2022-07-30 11:34:31 +02:00
Jakub Jelinek 0062d8491c cgraphunit: Don't emit asm thunks for -dx [PR106261]
When -dx option is used (didn't know we have it and no idea what is it
useful for), we just expand functions to RTL and then omit all further
RTL passes, so the normal functions aren't actually emitted into assembly,
just variables.
The following testcase ICEs, because we don't emit the methods, but do
emit thunks pointing to that and those thunks have unwind info and rely on
at least some real functions to be emitted (which is normally the case,
thunks are only emitted for locally defined functions) because otherwise
there are no CIEs, only FDEs and dwarf2out is upset about it.

The following patch fixes that by not emitting assembly thunks for -dx
either.

2022-07-27  Jakub Jelinek  <jakub@redhat.com>

	PR debug/106261
	* cgraphunit.cc (cgraph_node::assemble_thunks_and_aliases): Don't
	output asm thunks for -dx.

	* g++.dg/debug/pr106261.C: New test.

(cherry picked from commit f9671b60f9)
2022-07-30 11:34:30 +02:00
Jakub Jelinek 527dccb33e wide-int: Fix up wi::shifted_mask [PR106144]
As the following self-test testcase shows, wi::shifted_mask sometimes
doesn't create canonicalized wide_ints, which then fail to compare equal
to canonicalized wide_ints with the same value.
In particular, wi::mask (128, false, 128) gives { -1 } with len 1 and prec 128,
while wi::shifted_mask (0, 128, false, 128) gives { -1, -1 } with len 2
and prec 128.
The problem is that the code is written with the assumption that there are
3 bit blocks (or 2 if start is 0), but doesn't consider the possibility
where there are 2 bit blocks (or 1 if start is 0) where the highest block
isn't present.  In that case, there is the optional block of negate ? 0 : -1
elts, followed by just one elt (either one from the if (shift) or just
negate ? -1 : 0) and the rest is implicit sign-extension.
Only if end < prec there is 1 or more bits above it that have different bit
value and so we need to emit all the elts till end and then one more elt.

if (end == prec) would work too, because we have:
  if (width > prec - start)
    width = prec - start;
  unsigned int end = start + width;
so end is guaranteed to be end <= prec, dunno what is preferred.

2022-07-01  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/106144
	* wide-int.cc (wi::shifted_mask): If end >= prec, return right after
	emitting element for shift or if shift is 0 first element after start.
	(wide_int_cc_tests): Add tests for equivalency of wi::mask and
	wi::shifted_mask with 0 start.

(cherry picked from commit e52592073f)
2022-07-30 11:34:30 +02:00
GCC Administrator 2339ee2c89 Daily bump. 2022-07-30 00:18:55 +00:00
GCC Administrator 8351dd9620 Daily bump. 2022-07-29 00:19:13 +00:00
GCC Administrator b2ae75fd2a Daily bump. 2022-07-28 00:19:00 +00:00
David Malcolm 7455e982f0 analyzer: fix stray get_element decls
(cherry picked from r13-1847-g0460ba622e833d)

These were copy&paste errors.

gcc/analyzer/ChangeLog:
	* region.h (code_region::get_element): Remove stray decl.
	(function_region::get_element): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-07-27 17:54:51 -04:00
David Malcolm 71a4f739c2 analyzer: fix false positives from -Wanalyzer-tainted-divisor [PR106225]
(cherry picked from r13-1562-g897b3b31f0a94b)

gcc/analyzer/ChangeLog:
	PR analyzer/106225
	* sm-taint.cc (taint_state_machine::on_stmt): Move handling of
	assignments from division to...
	(taint_state_machine::check_for_tainted_divisor): ...this new
	function.  Reject warning when the divisor is known to be non-zero.
	* sm.cc: Include "analyzer/program-state.h".
	(sm_context::get_old_region_model): New.
	* sm.h (sm_context::get_old_region_model): New decl.

gcc/testsuite/ChangeLog:
	PR analyzer/106225
	* gcc.dg/analyzer/taint-divisor-1.c: Add test coverage for various
	correct and incorrect checks against zero.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-07-27 17:54:44 -04:00
David Malcolm 09cb9c88ef analyzer: fix uninit false positive with -ftrivial-auto-var-init= [PR106204]
(cherry picked from r13-1517-gb33dd7874523af)

-fanalyzer handles -ftrivial-auto-var-init= by special-casing
IFN_DEFERRED_INIT to be a no-op, so that e.g.:

  len_2 = .DEFERRED_INIT (4, 2, &"len"[0]);

is treated as a no-op, so that len_2 is still uninitialized after the
stmt.

PR analyzer/106204 reports that -fanalyzer gives false positives from
-Wanalyzer-use-of-uninitialized-value on locals that have their address
taken, due to e.g.:

  _1 = .DEFERRED_INIT (4, 2, &"len"[0]);
  len = _1;

where -fanalyzer leaves _1 uninitialized, and then complains about
the assignment to "len".

Fixed thusly by suppressing the warning when assigning from such SSA
names.

gcc/analyzer/ChangeLog:
	PR analyzer/106204
	* region-model.cc (within_short_circuited_stmt_p): Move extraction
	of assign_stmt to caller.
	(due_to_ifn_deferred_init_p): New.
	(region_model::check_for_poison): Move extraction of assign_stmt
	from within_short_circuited_stmt_p to here.  Share logic with
	call to due_to_ifn_deferred_init_p.

gcc/testsuite/ChangeLog:
	PR analyzer/106204
	* gcc.dg/analyzer/torture/uninit-pr106204.c: New test.
	* gcc.dg/analyzer/uninit-pr106204.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-07-27 17:54:37 -04:00
David Malcolm 9fa11419ef analyzer: show saved diagnostics as nodes in .eg.dot dumps
(cherry picked from r13-1117-gc540077a3bf600)

I've been using this tweak to the output of
-fdump-analyzer-exploded-graph in my working copies for a while;
the extra red nodes make it *much* easier to find the places where
diagnostics are being emitted (or rejected by the diagnostic_manager).

gcc/analyzer/ChangeLog:
	* diagnostic-manager.cc (saved_diagnostic::dump_dot_id): New.
	(saved_diagnostic::dump_as_dot_node): New.
	* diagnostic-manager.h (saved_diagnostic::dump_dot_id): New decl.
	(saved_diagnostic::dump_as_dot_node): New decl.
	* engine.cc (exploded_node::dump_dot): Add nodes for saved
	diagnostics.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-07-27 17:54:31 -04:00
David Malcolm 4eac9fa087 analyzer: add more uninit test coverage
(cherry picked from r13-1116-g44681d45473883)

gcc/testsuite/ChangeLog:
	* gcc.dg/analyzer/uninit-1.c: Add test coverage of attempts
	to jump through an uninitialized function pointer, and of attempts
	to pass an uninitialized value to a function call.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-07-27 17:54:26 -04:00
David Malcolm 6fd39b0604 json: fix escaping of '\'
(cherry picked from r13-965-g4f9ad0b4b0a8c7)

gcc/ChangeLog:
	* json.cc (string::print): Fix escaping of '\'.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-07-27 17:54:19 -04:00
David Malcolm 1d38fa564e analyzer: fix memory leaks
(cherry picked from r13-334-g99988b0e8b57b3)

These leaks all relate to logging within -fdump-analyzer[-stderr]
or are one-time leaks; seen with valgrind.

gcc/analyzer/ChangeLog:
	* checker-path.cc (state_change_event::get_desc): Call maybe_free
	on label_text temporaries.
	* diagnostic-manager.cc
	(diagnostic_manager::prune_for_sm_diagnostic): Likewise.
	* engine.cc (exploded_graph::~exploded_graph): Fix leak of
	m_per_point_data and m_per_call_string_data values.  Simplify
	cleanup of m_per_function_stats and m_per_point_data values.
	(feasibility_state::maybe_update_for_edge): Fix leak of result of
	superedge::get_description.
	* region-model-manager.cc
	(region_model_manager::~region_model_manager): Move cleanup of
	m_setjmp_values to match the ordering of the fields within
	region_model_manager.  Fix leak of values within
	m_repeated_values_map, m_bits_within_values_map,
	m_asm_output_values_map, and m_const_fn_result_values_map.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-07-27 17:54:12 -04:00
David Malcolm 05530fcea0 analyzer: handle repeated accesses after init of unknown size [PR105285]
(cherry-picked from r13-7-g00c4405cd7f6a144d0a439e4d848d246920e6ff3)

PR analyzer/105285 reports a false positive from
-Wanalyzer-null-dereference on git.git's reftable/reader.c.

A reduced version of the problem can be seen in test_1a of
gcc.dg/analyzer/symbolic-12.c in the following:

void test_1a (void *p, unsigned next_off)
{
  struct st_1 *r = p;

  external_fn();

  if (next_off >= r->size)
    return;

  if (next_off >= r->size)
    /* We should have already returned if this is the case.  */
    __analyzer_dump_path (); /* { dg-bogus "path" } */
}

where the analyzer erroneously considers this path, where
(next_off >= r->size) is both false and then true:

symbolic-12.c: In function ‘test_1a’:
symbolic-12.c:22:5: note: path
   22 |     __analyzer_dump_path (); /* { dg-bogus "path" } */
      |     ^~~~~~~~~~~~~~~~~~~~~~~
  ‘test_1a’: events 1-5
    |
    |   17 |   if (next_off >= r->size)
    |      |      ^
    |      |      |
    |      |      (1) following ‘false’ branch...
    |......
    |   20 |   if (next_off >= r->size)
    |      |      ~            ~~~~~~~
    |      |      |             |
    |      |      |             (2) ...to here
    |      |      (3) following ‘true’ branch...
    |   21 |     /* We should have already returned if this is the case.  */
    |   22 |     __analyzer_dump_path (); /* { dg-bogus "path" } */
    |      |     ~~~~~~~~~~~~~~~~~~~~~~~
    |      |     |
    |      |     (4) ...to here
    |      |     (5) here
    |

The root cause is that, at the call to the external function, the
analyzer considers the cluster for *p to have been touched, binding it
to a conjured_svalue, but because p is void * no particular size is
known for the write, and so the cluster is bound using a symbolic key
covering the base region.  Later, the accesses to r->size are handled by
binding_cluster::get_any_binding, but binding_cluster::get_binding fails
to find a match for the concrete field lookup, due to the key for the
binding being symbolic, and reaching this code:

1522  /* If this cluster has been touched by a symbolic write, then the content
1523     of any subregion not currently specifically bound is "UNKNOWN".  */
1524  if (m_touched)
1525    {
1526      region_model_manager *rmm_mgr = mgr->get_svalue_manager ();
1527      return rmm_mgr->get_or_create_unknown_svalue (reg->get_type ());
1528    }

Hence each access to r->size is an unknown svalue, and thus the
condition (next_off >= r->size) isn't tracked, leading to the path with
contradictory conditions being treated as satisfiable.

In the original reproducer in git's reftable/reader.c, the call to the
external fn is:
  reftable_record_type(rec)
which is considered to possibly write to *rec, which is *tab, where tab
is the void * argument to reftable_reader_seek_void, and thus after the
call to reftable_record_type some arbitrary amount of *rec could have
been written to.

This patch fixes things by detecting the "this cluster has been 'filled'
with a conjured value of unknown size" case, and handling
get_any_binding on it by returning a sub_svalue of the conjured_svalue,
so that repeated accesses to r->size give the same symbolic value, so
that the constraint manager rejects the bogus execution path, fixing the
false positive.

gcc/analyzer/ChangeLog:
	PR analyzer/105285
	* store.cc (binding_cluster::get_any_binding): Handle accessing
	sub_svalues of clusters where the base region has a symbolic
	binding.

gcc/testsuite/ChangeLog:
	PR analyzer/105285
	* gcc.dg/analyzer/symbolic-12.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-07-27 17:54:04 -04:00
David Malcolm 1321183a13 analyzer: add .fpath.txt dumps to -fdump-analyzer-feasibility
(cherry picked from r13-6-gd8586b00dd00a1783862da5f0c8811a740400074)

I found this extension to -fdump-analyzer-feasibility very helpful when
debugging PR analyzer/105285.

gcc/analyzer/ChangeLog:
	* diagnostic-manager.cc (epath_finder::process_worklist_item):
	Call dump_feasible_path when a path that reaches the the target
	enode is found.
	(epath_finder::dump_feasible_path): New.
	* engine.cc (feasibility_state::dump_to_pp): New.
	* exploded-graph.h (feasibility_state::dump_to_pp): New decl.
	* feasible-graph.cc (feasible_graph::dump_feasible_path): New.
	* feasible-graph.h (feasible_graph::dump_feasible_path): New
	decls.
	* program-point.cc (function_point::print): Fix missing trailing
	newlines.
	* program-point.h (program_point::print_source_line): Remove
	unimplemented decl.

gcc/ChangeLog:
	* doc/invoke.texi (-fdump-analyzer-feasibility): Mention the
	fpath.txt output.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-07-27 17:53:54 -04:00
Maciej W. Rozycki 4c1c38ba95 RISC-V: Remove duplicate backslashes from `stack_protect_set_<mode>'
Remove redundant duplicate backslash characters from \t sequences in the
output pattern of the `stack_protect_set_<mode>' RTL insn.

	gcc/
	* config/riscv/riscv.md (stack_protect_set_<mode>): Remove
	duplicate backslashes.

(cherry picked from commit 3cf07cc5e5)
2022-07-27 11:12:22 +01:00
Richard Biener 5b8458bc35 tree-optimization/106189 - avoid division by zero exception
The diagnostic code can end up with zero sized array elements
with T[][0] and the wide-int code nicely avoids exceptions when
dividing by zero in one codepath but not in another.  The following
fixes the exception by using wide-int in both paths.

	PR tree-optimization/106189
	* gimple-array-bounds.cc (array_bounds_checker::check_mem_ref):
	Divide using offset_ints.

	* gcc.dg/pr106189.c: New testcase.

(cherry picked from commit bb04f9f23a)
2022-07-27 11:23:45 +02:00
Joseph Myers d2892faac6 lto: Fix option merging [PR106129]
The LTO merging of options from different input files was broken by:

commit 227a2ecf66
Author: Martin Liska <mliska@suse.cz>
Date:   Fri Mar 12 11:53:47 2021 +0100

    lto-wrapper: Use vec<cl_decoded_option> data type.

Previously, find_and_merge_options would merge options it read into
those in *opts. After this commit, options in *opts on entry to
find_and_merge_options are ignored; the only merging that takes place
is between multiple sets of options in the same input file that are
read in the same call to this function (not sure how that case can
occur at all). The effects include, for example, that if some objects
are built with PIC enabled and others with it disabled, and the last
LTO object processed has PIC enabled, the choice of PIC for the last
object will result in the whole program being built as PIC, when the
merging logic is intended to ensure that a mixture of PIC and non-PIC
objects results in the whole program being built as non-PIC.

Fix this with an extra argument to find_and_merge_options to determine
whether merging should take place.  This shows up a second issue with
that commit (which I think wasn't actually intended to change code
semantics at all): once merging is enabled again, the check for
-Xassembler options became an infinite loop in the case where both
inputs had -Xassembler options, with the same first option, so fix
that loop to restore the previous semantics.

Note that I'm not sure how LTO option merging might be tested in the
testsuite (clearly there wasn't sufficient, if any, coverage to detect
these bugs).

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

	PR lto/106129
	* lto-wrapper.cc (find_option): Add argument start.
	(merge_and_complain): Loop over existing_opt_index and
	existing_opt2_index for Xassembler check.  Update calls to
	find_option.
	(find_and_merge_options): Add argument first to determine whether
	to merge options with those passed in *opts.
	(run_gcc): Update calls to find_and_merge_options.

(cherry picked from commit 8a8ee37a33)
2022-07-27 11:23:45 +02:00
Andrew Pinski e0e388998b Fix tree-opt/PR106087: ICE with inline-asm with multiple output and assigned only static vars
The problem here is that when we mark the ssa name that was referenced in the now removed
dead store (to a write only static variable), the inline-asm would also be removed
even though it was defining another ssa name. This fixes the problem by checking
to make sure that the statement was only defining one ssa name.

Committed as approved after a bootstrapped and tested on x86_64 with no regressions.

	PR tree-optimization/106087

gcc/ChangeLog:

	* tree-ssa-dce.cc (simple_dce_from_worklist): Check
	to make sure the statement is only defining one operand.

gcc/testsuite/ChangeLog:

	* gcc.c-torture/compile/inline-asm-1.c: New test.

(cherry picked from commit 71e3daa31c)
2022-07-27 11:23:44 +02:00
Dimitar Dimitrov 019a9ef7f7 testsuite: Require int128 for gcc.dg/pr106063.c
Require effective target int128 for gcc.dg/pr106063.c.

	PR tree-optimization/106063

gcc/testsuite/ChangeLog:

	* gcc.dg/pr106063.c: Require effective target int128.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
(cherry picked from commit 4ebbf39068)
2022-07-27 11:23:44 +02:00
Tamar Christina 13d23c3133 middle-end: don't lower past veclower [PR106063]
Hi All,

My previous patch can cause a problem if the pattern matches after veclower
as it may replace the construct with a vector sequence which the target may not
directly support.

As such don't perform the rewriting if after veclower unless the target supports
the operation.  If before veclower do the rewriting as well if the target didn't
support the original operation either.

gcc/ChangeLog:

	PR tree-optimization/106063
	* match.pd: Do not apply pattern after veclower is not supported.

gcc/testsuite/ChangeLog:

	PR tree-optimization/106063
	* gcc.dg/pr106063.c: New test.

(cherry picked from commit f7854e2faf)
2022-07-27 11:23:44 +02:00
Alexandre Oliva 4ca164a637 [PR105665] ivopts: check defs of names in base for undefs
The patch for PR 100810 tested for undefined SSA_NAMEs appearing
directly in the base expression of the potential IV candidate, but
that's not enough.  The testcase for PR105665 shows an undefined
SSA_NAME has the same ill effect if it's referenced as an PHI_NODE arg
in the referenced SSA_NAME.  The variant of that test shows it can be
further removed from the referenced SSA_NAME.

To avoid deep recursion, precompute maybe-undefined SSA_NAMEs: start
from known-undefined nonvirtual default defs, and propagate them to
any PHI nodes reached by a maybe-undefined arg, as long as there
aren't intervening non-PHI uses, that would imply the maybe-undefined
name must be defined at that point, otherwise it would invoke
undefined behavior.  Also test for intervening non-PHI uses of DEFs in
the base expr.

The test for intervening uses implemented herein relies on dominance;
this could be further extended, regarding conditional uses in every
path leading to a point as an unconditional use dominating that point,
but I haven't implemented that.

for  gcc/ChangeLog

	PR tree-optimization/105665
	PR tree-optimization/100810
	* tree-ssa-loop-ivopts.cc
	(ssa_name_maybe_undef_p, ssa_name_set_maybe_undef): New.
	(ssa_name_any_use_dominates_bb_p, mark_ssa_maybe_undefs): New.
	(find_ssa_undef): Check precomputed flag and intervening uses.
	(tree_ssa_iv_optimize): Call mark_ssa_maybe_undefs.

for  gcc/testsuite/ChangeLog

	PR tree-optimization/105665
	PR tree-optimization/100810
	* gcc.dg/torture/pr105665.c: New.

(cherry picked from commit be2861fe8c)
2022-07-27 11:23:44 +02:00
GCC Administrator 5e45d078e3 Daily bump. 2022-07-27 00:19:35 +00:00
Iain Buclaw 81a0fa31ce d: Merge upstream dmd 76e3b41375, druntime 1462ebd1, phobos 5fef0d28f.
Updates D language version to v2.100.1.

D front-end changes:

    - Fix delegate literal with inferred return value that requires
      following alias-this to not use class cast.
    - Fix internal error on variadic template type instantiated with two
      arrays of classes.
    - `scope(failure)' blocks that contain `return' statements are now
      deprecated.
    - Fix regression where wrong cast was inserted for ternary operator
      and non-int enums.
    - Fix internal error in code generation trying to reference
      _d_arraysetctor.
    - Fix memory corruption when array literal is passed to map in
      lambda, then returned from nested function.
    - Generate invariant id on the basis of location rather than a
      global counter.
    - Make `noreturn' conversions work.
    - Fix segfault when `.stringof' of template alias overloaded with
      function accessed by trait.
    - Empty array literal passed to scope param not 'falsey' anymore.

Phobos changes:

    - Avoid copying ranges in std.algorithm.comparison.equal.

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd 76e3b41375.
	* dmd/VERSION: Bump version to v2.100.1.
	* decl.cc (DeclVisitor::visit (VarDeclaration *)): Evaluate RHS
	  of noreturn declaration expressions first.
	* expr.cc (ExprVisitor::visit (AssignExp *)): Don't generate
	  assignment for noreturn types.

libphobos/ChangeLog:

	* libdruntime/MERGE: Merge upstream druntime 1462ebd1.
	* src/MERGE: Merge upstream phobos 5fef0d28f.
2022-07-26 23:43:13 +02:00
Harald Anlauf 2009850b2b Fortran: error recovery from calculation of storage size of a symbol [PR103504]
gcc/fortran/ChangeLog:

	PR fortran/103504
	* interface.cc (get_sym_storage_size): Array bounds and character
	length can only be of integer type.

gcc/testsuite/ChangeLog:

	PR fortran/103504
	* gfortran.dg/pr103504.f90: New test.

(cherry picked from commit 600956c81c)
2022-07-26 20:25:59 +02:00
Marek Polacek 9be0feeade c++: ICE with erroneous template redeclaration [PR106311]
Here we ICE trying to get DECL_SOURCE_LOCATION of the parm that happens
to be error_mark_node in this ill-formed test.  I kept running into this
while reducing code, so it'd be good to have it fixed.

	PR c++/106311

gcc/cp/ChangeLog:

	* pt.cc (redeclare_class_template): Check DECL_P before accessing
	DECL_SOURCE_LOCATION.

gcc/testsuite/ChangeLog:

	* g++.dg/template/redecl5.C: New test.

(cherry picked from commit 2333b58c98)
2022-07-26 09:21:56 -04:00
Jason Merrill 60954a06ce c++: aggregate prvalue as for range [PR106230]
Since my PR94041 work on temporary lifetime in aggregate initialization, we
end up calling build_vec_init to initialize the reference-extended temporary
for the artificial __for_range variable.  And build_vec_init uses
finish_for_stmt to implement its loop.  That function assumes that if
__for_range is in current_binding_level, we're finishing a range-for, and we
should fix up the variable as it goes out of scope.  But when called from
build_vec_init we aren't finishing a range-for, and do_poplevel doesn't
remove the variable from scope because stmts_are_full_exprs_p is false.  So
let's check that here as well, and leave the DECL_NAME alone.

	PR c++/106230

gcc/cp/ChangeLog:

	* semantics.cc (finish_for_stmt): Check stmts_are_full_exprs_p.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/range-for38.C: New test.
2022-07-25 23:12:08 -04:00