PR debug/98716
* dwarf.c (read_v2_paths): Allocate zero entry for dirs and
filenames.
(read_line_program): Remove parameter u, change caller. Don't
subtract one from dirs and filenames index.
(read_function_entry): Don't subtract one from filenames index.
PPC64 can generate jumps with clobbered pseudo-regs and a BB with
such jump can have abnormal output edges. IRA hits an assert when trying
to split abnormal critical edge to deal with asm goto output reloads
later. The patch just skips splitting abnormal edges. It is assumed
that asm-goto with output reloads can not be in BB with output abnormal edges.
gcc/ChangeLog:
PR target/97847
* ira.c (ira): Skip abnormal critical edge splitting.
After r11-6614 made cp_walk_subtrees walk into the template of a CTAD
placeholder, we now correctly accept the below testcase. We used to
reject it because find_parameter_packs_r would fail to find the
parameter pack Ts inside the CTAD placeholder within the pack expansion.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/class-deduction77.C: New test.
I forgot one line, which means that if the second operand of the multiplication
isn't constant, it would be just the same as the first one.
2021-01-18 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/98727
* tree-ssa-math-opts.c (match_arith_overflow): Fix up computation of
second .MUL_OVERFLOW operand for signed multiplication with overflow
checking if the second operand of multiplication is not constant.
* gcc.c-torture/execute/pr98727.c: New test.
In dce6c58db8 msebor extended the
"malloc" attribute to support user-defined allocator/deallocator
pairs.
This patch extends the "malloc" checker within -fanalyzer to use
these attributes. It is based on an earlier patch:
'RFC: add "deallocated_by" attribute for use by analyzer'
https://gcc.gnu.org/pipermail/gcc-patches/2020-October/555544.html
which added a different attribute. The patch needed a lot of reworking
to support multiple deallocators per allocator.
My hope was that this would provide a minimal level of markup that would
support library-checking without requiring lots of further markup.
I attempted to use this to detect a memory leak within a Linux
driver (CVE-2019-19078), by adding the attribute to mark these fns:
extern struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags);
extern void usb_free_urb(struct urb *urb);
where there is a leak of a "urb" on an error-handling path.
Unfortunately I ran into the problem that there are various other fns
that take "struct urb *" and the analyzer conservatively assumes that a
urb passed to them might or might not be freed and thus stops tracking
state for them.
Hence this will only detect issues for the simplest cases (without
adding another attribute).
gcc/analyzer/ChangeLog:
* analyzer.h (is_std_named_call_p): New decl.
* diagnostic-manager.cc (path_builder::get_sm): New.
(state_change_event_creator::state_change_event_creator): Add "pb"
param.
(state_change_event_creator::on_global_state_change): Don't consider
state changes affecting other state_machines.
(state_change_event_creator::on_state_change): Likewise.
(state_change_event_creator::m_pb): New field.
(diagnostic_manager::add_events_for_eedge): Pass pb to visitor
ctor.
* region-model-impl-calls.cc
(region_model::impl_deallocation_call): New.
* region-model.cc: Include "attribs.h".
(region_model::on_call_post): Handle fndecls referenced by
__attribute__((deallocated_by(FOO))).
* region-model.h (region_model::impl_deallocation_call): New decl.
* sm-malloc.cc: Include "stringpool.h" and "attribs.h". Add
leading comment.
(class api): Delete.
(enum resource_state): Update comment for change from api to
deallocator and deallocator_set.
(allocation_state::allocation_state): Drop api param. Add
"deallocators" and "deallocator".
(allocation_state::m_api): Drop field in favor of...
(allocation_state::m_deallocators): New field.
(allocation_state::m_deallocator): New field.
(enum wording): Add WORDING_DEALLOCATED.
(struct deallocator): New.
(struct standard_deallocator): New.
(struct custom_deallocator): New.
(struct deallocator_set): New.
(struct custom_deallocator_set): New.
(struct standard_deallocator_set): New.
(struct deallocator_set_map_traits): New.
(malloc_state_machine::m_malloc): Drop field
(malloc_state_machine::m_scalar_new): Likewise.
(malloc_state_machine::m_vector_new): Likewise.
(malloc_state_machine::m_free): New field
(malloc_state_machine::m_scalar_delete): Likewise.
(malloc_state_machine::m_vector_delete): Likewise.
(malloc_state_machine::deallocator_map_t): New typedef.
(malloc_state_machine::m_deallocator_map): New field.
(malloc_state_machine::deallocator_set_cache_t): New typedef.
(malloc_state_machine::m_custom_deallocator_set_cache): New field.
(malloc_state_machine::custom_deallocator_set_map_t): New typedef.
(malloc_state_machine::m_custom_deallocator_set_map): New field.
(malloc_state_machine::m_dynamic_sets): New field.
(malloc_state_machine::m_dynamic_deallocators): New field.
(api::api): Delete.
(deallocator::deallocator): New ctor.
(deallocator::hash): New.
(deallocator::dump_to_pp): New.
(deallocator::cmp): New.
(deallocator::cmp_ptr_ptr): New.
(standard_deallocator::standard_deallocator): New ctor.
(deallocator_set::deallocator_set): New ctor.
(deallocator_set::dump): New.
(custom_deallocator_set::custom_deallocator_set): New ctor.
(custom_deallocator_set::contains_p): New.
(custom_deallocator_set::maybe_get_single): New.
(custom_deallocator_set::dump_to_pp): New.
(standard_deallocator_set::standard_deallocator_set): New ctor.
(standard_deallocator_set::contains_p): New.
(standard_deallocator_set::maybe_get_single): New.
(standard_deallocator_set::dump_to_pp): New.
(start_p): New.
(class mismatching_deallocation): Update for conversion from api
to deallocator_set and deallocator.
(double_free::emit): Use %qs.
(class use_after_free): Update for conversion from api to
deallocator_set and deallocator.
(malloc_leak::describe_state_change): Only emit "allocated here" on
a start->nonnull transition, rather than on other transitions to
nonnull.
(allocation_state::dump_to_pp): Update for conversion from api to
deallocator_set.
(allocation_state::get_nonnull): Likewise.
(malloc_state_machine::malloc_state_machine): Likewise.
(malloc_state_machine::~malloc_state_machine): New.
(malloc_state_machine::add_state): Update for conversion from api
to deallocator_set.
(malloc_state_machine::get_or_create_custom_deallocator_set): New.
(malloc_state_machine::maybe_create_custom_deallocator_set): New.
(malloc_state_machine::get_or_create_deallocator): New.
(malloc_state_machine::on_stmt): Update for conversion from api
to deallocator_set. Handle "__attribute__((malloc(FOO)))", and
the special attribute set on FOO.
(malloc_state_machine::on_allocator_call): Update for conversion
from api to deallocator_set. Add "returns_nonnull" param and use
it to affect which state to transition to.
(malloc_state_machine::on_deallocator_call): Update for conversion
from api to deallocator_set.
gcc/ChangeLog:
* attribs.h (fndecl_dealloc_argno): New decl.
* builtins.c (call_dealloc_argno): Split out second half of
function into...
(fndecl_dealloc_argno): New.
* doc/extend.texi (Common Function Attributes): Document the
interaction between the analyzer and the malloc attribute.
* doc/invoke.texi (Static Analyzer Options): Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/attr-malloc-1.c: New test.
* gcc.dg/analyzer/attr-malloc-2.c: New test.
* gcc.dg/analyzer/attr-malloc-4.c: New test.
* gcc.dg/analyzer/attr-malloc-5.c: New test.
* gcc.dg/analyzer/attr-malloc-6.c: New test.
* gcc.dg/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c: New test.
* gcc.dg/analyzer/attr-malloc-misuses.c: New test.
libstdc++-v3/ChangeLog:
PR libstdc++/98725
* testsuite/20_util/unique_ptr/io/lwg2948.cc: Do not try to
write to a wide character stream if wide character support is
disabled in the library.
Support for loop SLP splitting exposed that slp-11b.c has
folding that breaks SLP discovery which isn't what was intended
when the testcase was written. The following makes it SLP-able
and "only" run into the issue that a load permutation is required.
And tries to adjust the target selectors accordingly.
2021-01-18 Richard Biener <rguenther@suse.de>
PR testsuite/97494
* gcc.dg/vect/slp-11b.c: Adjust.
These two tests need:
dg-require-effective-target arm_crypto_ok
dg-add-options arm_crypto
because they use intrinsics that need -mfpu=crypto-neon-fp-armv8.
2021-01-18 Christophe Lyon <christophe.lyon@linaro.org>
gcc/testsuite/
PR target/71233
* gcc.target/arm/simd/vceqz_p64.c: Use arm_crypto options.
* gcc.target/arm/simd/vceqzq_p64.c: Likewise.
This avoids looking for permute optimization when SLP cannot be applied.
2021-01-18 Richard Biener <rguenther@suse.de>
PR testsuite/97299
* gcc.dg/vect/slp-reduc-3.c: Guard VEC_PERM_EXPR scan.
As mentioned in the PR, since the switch to DWARF5 by default instead of
DWARF4, gcc fails to build when configured against recent binutils.
The problem is that cxx11-ios_failure* is built in separate steps,
-S compilation (with -g -O2) followed by some sed and followed by
-c -g -O2 -g0 assembly. When gcc is configured against recent binutils
and DWARF5 is the default, we emit .file 0 "..." directive on which the
assembler then fails (unless --gdwarf-5 is passed to it, but we don't want
that generally because on the other side older assemblers don't like -g*
passed to it when invoked on *.s file with compiler generated debug info.
I hope the bug will be fixed soon on the binutils side, but it would be nice
to have a workaround.
The following patch is one of the possibilities, another one is to do that
but add configure check for whether it is needed,
essentially
echo 'int main () { return 0; }' > conftest.c
${CXX} ${CXXFLAGS} -g -O2 -S conftest.c -o conftest.s
${CXX} ${CXXFLAGS} -g -O2 -g0 -c conftest.s -o conftest.o
and if the last command fails, we need that -gno-as-loc-support.
Or yet another option would be I think do a different check, whether
${CXX} ${CXXFLAGS} -g -O2 -S conftest.c -o conftest.s
${CXX} ${CXXFLAGS} -g -O2 -c conftest.s -o conftest.o
works and if yes, don't add the -g0 to cxx11-ios_failure*.s assembly.
2021-01-18 Jakub Jelinek <jakub@redhat.com>
PR debug/98708
* src/c++11/Makefile.am (cxx11-ios_failure-lt.s, cxx11-ios_failure.s):
Compile with -gno-as-loc-support.
* src/c++11/Makefile.in: Regenerated.
This patch introduces gomp_sem_getcount wrapper, which uses sem_getvalue
for POSIX and atomic loads for linux futex and accel. rtems for now
remains broken.
2021-01-18 Jakub Jelinek <jakub@redhat.com>
* config/linux/sem.h (gomp_sem_getcount): New function.
* config/posix/sem.h (gomp_sem_getcount): New function.
* config/posix/sem.c (gomp_sem_getcount): New function.
* config/accel/sem.h (gomp_sem_getcount): New function.
* task.c (task_fulfilled_p): Use gomp_sem_getcount.
(omp_fulfill_event): Likewise.
Recent code generation changes have affected the count of some instructions.
This patch updates the instruction count for fold-vec-extract on P7 and P8.
Also, some of SSE emulation intrinsics only work on LE systems.
gcc/testsuite/ChangeLog:
* gcc.target/powerpc/fold-vec-extract-char.p7.c: Adjust addi count.
* gcc.target/powerpc/fold-vec-extract-double.p7.c: Same.
* gcc.target/powerpc/fold-vec-extract-float.p7.c: Same.
* gcc.target/powerpc/fold-vec-extract-float.p8.c: Same.
* gcc.target/powerpc/fold-vec-extract-int.p7.c: Same.
* gcc.target/powerpc/fold-vec-extract-int.p8.c: Same.
* gcc.target/powerpc/fold-vec-extract-short.p7.c: Same.
* gcc.target/powerpc/fold-vec-extract-short.p8.c: Same.
* gcc.target/powerpc/sse-andnps-1.c: Restrict to LE.
* gcc.target/powerpc/sse-movhps-1.c: Restrict to LE.
* gcc.target/powerpc/sse-movlps-1.c: Restrict to LE.
* gcc.target/powerpc/sse2-andnpd-1.c: Restrict to LE.
AIX does not support DWARF 5.
This patch skips the DWARF 5-specific testcases.
gcc/testsuite/ChangeLog:
* g++.dg/debug/dwarf2/inline-ns-2.C: Skip on AIX.
* g++.dg/debug/dwarf2/inline-var-2.C: Skip on AIX.
* g++.dg/debug/dwarf2/inline-var-3.C: Skip on AIX.
* g++.dg/debug/dwarf2/lang-cpp11.C: Skip on AIX.
* g++.dg/debug/dwarf2/lang-cpp14.C: Skip on AIX.
* g++.dg/debug/dwarf2/lang-cpp17.C: Skip on AIX.
* g++.dg/debug/dwarf2/lang-cpp20.C: Skip on AIX.
* gcc.dg/debug/dwarf2/inline6.c: Skip on AIX.
* gcc.dg/debug/dwarf2/lang-c11.c: Skip on AIX.
* gcc.dg/debug/dwarf2/pr41445-7.c: Skip on AIX.
* gcc.dg/debug/dwarf2/pr41445-8.c: Skip on AIX.
GCC now defaults to DWARF 5. AIX only supports DWARF 4 (3.5).
This patch overrides the default DWARF version to 4 unless explicitly
stated.
gcc/ChangeLog:
* config/rs6000/aix71.h (SUBTARGET_OVERRIDE_OPTIONS): Override
dwarf_version to 4.
* config/rs6000/aix72.h (SUBTARGET_OVERRIDE_OPTIONS): Same.
after switching to materialization of clones on demand, the verifier
can happen to see edges leading to a clone of a materialized clone.
This means its clone_of is NULL and former_clone_of needs to be
checked in order to verify that the callee is a clone of the original
decl, which it did not do and reported edges to pointing to a wrong
place.
Fixed with the following patch, which has been pre-approved by Honza.
Bootstrapped and tested on x86_64-linux, pushed to master.
Martin
gcc/ChangeLog:
2021-01-15 Martin Jambor <mjambor@suse.cz>
PR ipa/98222
* cgraph.c (clone_of_p): Check also former_clone_of as we climb
the clone tree.
gcc/testsuite/ChangeLog:
2021-01-15 Martin Jambor <mjambor@suse.cz>
PR ipa/98222
* gcc.dg/ipa/pr98222.c: New test.
2021-01-16 Jakub Jelinek <jakub@redhat.com>
* gfortran.dg/iso_fortran_binding_uint8_array_driver.c: Include
../../../libgfortran/ISO_Fortran_binding.h rather than
ISO_Fortran_binding.h.
This multilib supports Nios II configurations with the "Nios II Floating
Point Hardware 2 Component".
gcc/
* config/nios2/t-rtems: Reset all MULTILIB_* variables. Shorten
multilib directory names. Use MULTILIB_REQUIRED instead of
MULTILIB_EXCEPTIONS. Add -mhw-mul -mhw-mulx -mhw-div
-mcustom-fpu-cfg=fph2 multilib.
The new -mcustom-fpu-cfg=fph2 option variant is useful to build a
multilib for the "Nios II Floating Point Hardware 2 Component":
https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/ug/ug_nios2_custom_instruction.pdf
Directly using the corresponding -mcustom-insn=N options for this
floating-point unit leads to a combinatorial explosion in the potential
count of multilibs which may break the build.
gcc/
* config/nios2/nios2.c (NIOS2_FPU_CONFIG_NUM): Adjust value.
(nios2_init_fpu_configs): Provide register values for new
-mcustom-fpu-cfg=fph2 option variant.
* doc/invoke.texi (-mcustom-fpu-cfg=fph2): Document new option
variant.
Do not warn if custom instructions are not used due to missing
optimization flags. This prevents build errors with -Werror which
cannot be disabled via a dedicated warning option.
One reason to remove these warnings is to enable a multilib for the
"Nios II Floating Point Hardware 2 Component". For example, the
libatomic target library in GCC is built with -Werror and the warnings
removed by this patch resulted in errors like:
cc1: error: switch '-mcustom-fmins' has no effect unless '-ffinite-math-only' is specified [-Werror]
cc1: error: switch '-mcustom-fmaxs' has no effect unless '-ffinite-math-only' is specified [-Werror]
cc1: error: switch '-mcustom-round' has no effect unless '-fno-math-errno' is specified [-Werror]
gcc/
* config/nios2/nios2.c (nios2_custom_check_insns): Remove
custom instruction warnings.
While we had a ((1 << x) & 1) != 0 to x == 0 optimization already,
this patch adds ((cst << x) & 1) optimization too, this time the
second constant must be 1 though, not some power of two, but the first
one can be any constant. If it is even, the result is false, if it is
odd, the result is x == 0.
2021-01-16 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/96669
* match.pd ((CST << x) & 1 -> x == 0): New simplification.
* gcc.dg/tree-ssa/pr96669-1.c: Adjust regexp.
* gcc.dg/tree-ssa/pr96669-2.c: New test.
On the following testcase, handle_builtin_memcmp in the strlen pass folds
the memcmp into comparison of two MEM_REFs. But nothing triggers updating
of addressable vars afterwards, so even when the parameters are no longer
address taken, we force the parameters to stack and back anyway.
This patch causes TODO_update_address_taken to happen right before last forwprop
pass (at the end of last cd_dce), so after strlen1 too.
2021-01-16 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/96271
* passes.def: Pass false argument to first two pass_cd_dce
instances and true to last instance. Add comment that
last instance rewrites no longer addressed locals.
* tree-ssa-dce.c (pass_cd_dce): Add update_address_taken_p member and
initialize it.
(pass_cd_dce::set_pass_param): New method.
(pass_cd_dce::execute): Return TODO_update_address_taken from
last cd_dce instance.
* gcc.target/i386/pr96271.c: New test.
-fcf-protection is automatically enabled in libstdc++ on Linux/x86.
Starting from
commit 77d372abec
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Thu Jan 14 05:56:46 2021 -0800
x86: Error on -fcf-protection with incompatible target
GCC issues an error on -fcf-protection with incompatible target:
... -fcf-protection ... libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/explicit-hle.cc -m32 -O2 -g0 -fno-exceptions -fno-asynchronous-unwind-tables -march=i486 ...
cc1plus: error: '-fcf-protection' is not compatible with this target
FAIL: 29_atomics/atomic_flag/test_and_set/explicit-hle.cc (test for excess errors)
Add -fcf-protection=none to -march=i486 to compile explicit-hle.cc.
* testsuite/29_atomics/atomic_flag/test_and_set/explicit-hle.cc:
Add -fcf-protection=none to -march=i486.
Unlike the other global variables, it is not reset at the beginning of a
function so can leak into the next one.
gcc/ChangeLog:
* final.c (final_start_function_1): Reset force_source_line.
libgfortran/ChangeLog:
* runtime/ISO_Fortran_binding.c (CFI_establish): Fixed signed
char arrays. Signed char or uint8_t arrays would cause
crashes unless an element size is specified.
gcc/testsuite/ChangeLog:
* gfortran.dg/iso_fortran_binding_uint8_array.f90: New test.
* gfortran.dg/iso_fortran_binding_uint8_array_driver.c: New test.
This was an assert that was too picky. The reason I had to alter
array construction was that on stream in, we cannot dynamically determine
a type's dependentness. Thus on stream out of the 'problematic' types,
we save the dependentness for reconstruction. Fortunately the paths into
cp_build_qualified_type_real from streamin with arrays do have the array's
dependentess set as needed.
PR c++/98538
gcc/cp/
* tree.c (cp_build_qualified_type_real): Propagate an array's
dependentness to the copy, if known.
gcc/testsuite/
* g++.dg/template/pr98538.C: New.
I missed some testsuite fall out with my patch to fix mkdeps file
mangling.
PR preprocessor/95253
gcc/testsuite/
* g++.dg/modules/dep-1_a.C: Adjust expected output.
* g++.dg/modules/dep-1_b.C: Likewise.
* g++.dg/modules/dep-2.C: Likewise.
The following patch generalizes the PR64309 simplifications, so that instead
of working only with constants 1 and 1 it works with any two power of two
constants, and works also for right shift (in that case it rules out the
first one being negative, as it is arithmetic shift then).
2021-01-15 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/96669
* match.pd (((1 << A) & 1) != 0 -> A == 0,
((1 << A) & 1) == 0 -> A != 0): Generalize for 1s replaced by
possibly different power of two constants and to right shift too.
* gcc.dg/tree-ssa/pr96669-1.c: New test.
This patch simplifies comparisons that test the sign bit xored together.
If the comparisons are both < 0 or both >= 0, then we should xor the operands
together and compare the result to < 0, if the comparisons are different,
we should compare to >= 0.
2021-01-15 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/96681
* match.pd ((x < 0) ^ (y < 0) to (x ^ y) < 0): New simplification.
((x >= 0) ^ (y >= 0) to (x ^ y) < 0): Likewise.
((x < 0) ^ (y >= 0) to (x ^ y) >= 0): Likewise.
((x >= 0) ^ (y < 0) to (x ^ y) >= 0): Likewise.
* gcc.dg/tree-ssa/pr96681.c: New test.
The -dumpbase and -dumpdir options are excluded from the producer
string output in debug information, but -dumpbase-ext was not. This
patch excludes it as well.
for gcc/ChangeLog
* opts.c (gen_command_line_string): Exclude -dumpbase-ext.
Here, initializing from { } implies a call to the default constructor for
base. We were then seeing that we're initializing a base subobject, so we
tried to copy the result of that call. This is clearly wrong; we should
initialize the base directly from its default constructor.
This patch does a lot of refactoring of unsafe_copy_elision_p and adds
make_safe_copy_elision that will also try to do the base constructor
rewriting from the last patch.
gcc/cp/ChangeLog:
PR c++/98642
* call.c (unsafe_return_slot_p): Return int.
(init_by_return_slot_p): Split out from...
(unsafe_copy_elision_p): ...here.
(unsafe_copy_elision_p_opt): New name for old meaning.
(build_over_call): Adjust.
(make_safe_copy_elision): New.
* typeck2.c (split_nonconstant_init_1): Elide copy from safe
list-initialization.
* cp-tree.h: Adjust.
gcc/testsuite/ChangeLog:
PR c++/98642
* g++.dg/cpp1z/elide5.C: New test.
While working on PR98642 I noticed that in this testcase we were eliding the
copy, calling the complete default constructor to initialize the B base
subobject, and therefore wrongly initializing the non-existent A subobject
of B. The test doesn't care whether the copy is elided or not, but checks
that we are actually calling a base constructor for B.
The patch preserves the elision, but changes the initializer to call the
base constructor instead of the complete constructor.
gcc/cp/ChangeLog:
* call.c (base_ctor_for, make_base_init_ok): New.
(build_over_call): Use make_base_init_ok.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/elide4.C: New test.
build_vec_init_elt models initialization from some arbitrary object of the
type, i.e. copy, but in the case of list-initialization we don't do a copy
from the elements, we initialize them directly.
gcc/cp/ChangeLog:
PR c++/63707
* tree.c (build_vec_init_expr): Don't call build_vec_init_elt
if we got a CONSTRUCTOR.
gcc/testsuite/ChangeLog:
PR c++/63707
* g++.dg/cpp0x/initlist-array13.C: New test.