aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-09-07libstdc++: small dynamic_cast optimizationJason Merrill1-0/+6
This change speeds up the simple benchmark below by about 40%. struct A { virtual ~A() {} }; struct B: A { } b; A* ap = &b; void *sink; int main() { for (long i = 0; i < 4000000000L; ++i) sink = dynamic_cast<B*>(ap); } libstdc++-v3/ChangeLog: * libsupc++/dyncast.cc (__dynamic_cast): Avoid virtual function call in simple success case.
2022-09-07c: New C2x keywordsJoseph Myers15-55/+188
C2x follows C++ in making alignas, alignof, bool, false, static_assert, thread_local and true keywords; implement this accordingly. This implementation makes them normal keywords in C2x mode just like any other keyword (C2x leaves open the possibility of implementation using predefined macros instead - thus, there aren't any testcases asserting that they aren't macros). As in C++ and previous versions of C, true and false are handled like signed 1 and 0 in #if (there was an intermediate state in some C2x drafts where they had different macro expansions that were unsigned in #if). Bootstrapped with no regressions for x86_64-pc-linux-gnu. As with the removal of unprototyped functions, this change has a high risk of breaking some old code and people doing GNU/Linux distribution builds may wish to see how much is broken in a build with a -std=gnu2x default. gcc/ * ginclude/stdalign.h [defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L]: Disable all content. * ginclude/stdbool.h [defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L] (bool, true, false): Do not define. gcc/c-family/ * c-common.cc (c_common_reswords): Use D_C2X instead of D_CXXONLY for alignas, alignof, bool, false, static_assert, thread_local and true. gcc/c/ * c-parser.cc (c_parser_static_assert_declaration_no_semi) (c_parser_alignas_specifier, c_parser_alignof_expression): Allow for C2x spellings of keywords. (c_parser_postfix_expression): Handle RID_TRUE and RID_FALSE. gcc/testsuite/ * gcc.dg/c11-keywords-1.c, gcc.dg/c2x-align-1.c, gcc.dg/c2x-align-6.c, gcc.dg/c2x-bool-2.c, gcc.dg/c2x-static-assert-3.c, gcc.dg/c2x-static-assert-4.c, gcc.dg/c2x-thread-local-1.c: New tests. * gcc.dg/c2x-bool-1.c: Update expectations. libcpp/ * include/cpplib.h (struct cpp_options): Add true_false. * expr.cc (eval_token): Check true_false not cplusplus to determine whether to handle true and false keywords. * init.cc (struct lang_flags): Add true_false. (lang_defaults): Update. (cpp_set_lang): Set true_false.
2022-09-07Restore XCOFF for DWARF on AIX.Martin Liska5-35/+97
PR bootstrap/106855 gcc/ChangeLog: * collect2.cc (scan_prog_file): Restore if XCOFF_DEBUGGING_INFO. * config/rs6000/rs6000.cc (rs6000_option_override_internal): Restore usage of XCOFF_DEBUGGING_INFO. * config/rs6000/xcoff.h (XCOFF_DEBUGGING_INFO): Restore. * dwarf2asm.cc (XCOFF_DEBUGGING_INFO): Restore support for XCOFF_DEBUGGING_INFO. (dw2_asm_output_nstring): Likewise. (USE_LINKONCE_INDIRECT): Likewise. * dwarf2out.cc (XCOFF_DEBUGGING_INFO): Likewise. (HAVE_XCOFF_DWARF_EXTRAS): Likewise. (output_fde): Likewise. (output_call_frame_info): Likewise. (have_macinfo): Likewise. (add_AT_loc_list): Likewise. (add_AT_view_list): Likewise. (output_compilation_unit_header): Likewise. (output_pubnames): Likewise. (output_aranges): Likewise. (output_line_info): Likewise. (output_macinfo): Likewise. (dwarf2out_finish): Likewise. (dwarf2out_early_finish): Likewise.
2022-09-07tree-optimization/106866 - avoid dead abnormal edges from DCERichard Biener2-7/+79
When DCE clears cfun->calls_setjmp then suddenly we don't need any abnormal call edges anymore. The following makes sure to prune them which otherwise can confuse other passes. PR tree-optimization/106866 * tree-ssa-dce.cc (eliminate_unnecessary_stmts): When we changed cfun->calls_setjmp make sure to purge all abnormal call edges. * gcc.dg/uninit-pr106866.c: New testcase.
2022-09-07[gdb/build] Fix build breaker with --enable-sharedTom de Vries2-4/+12
When building gdb with --enable-shared, I run into: ... ld: build/zlib/libz.a(libz_a-inffast.o): relocation R_X86_64_32S against \ `.rodata' can not be used when making a shared object; recompile with -fPIC ld: build/zlib/libz.a(libz_a-inflate.o): warning: relocation against \ `inflateResetKeep' in read-only section `.text' collect2: error: ld returned 1 exit status make[3]: *** [libbfd.la] Error 1 ... This is a regression since commit a08bdb159bb ("[gdb/build] Fix gdbserver build with -fsanitize=thread"). The problem is that a single case statement in configure is shared to handle special requirements for both the host libiberty and host zlib, which has the effect that only one is handled. Fix this by handling libiberty and zlib each in its own case statement. Build on x86_64-linux, with and without --enable-shared. ChangeLog: 2022-09-07 Tom de Vries <tdevries@suse.de> * configure.ac: Set extra_host_libiberty_configure_flags and extra_host_zlib_configure_flags in separate case statements. * configure: Regenerate.
2022-09-07[PR106867] Add test for PR.Aldy Hernandez1-0/+16
PR tree-optimization/106867 gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr106867.c: New test.
2022-09-07C-SKY: Fix expanding of float LE comparing with zero for fpuv3.Xianmiao Qu2-3/+5
The original code will cause the warning: /usr/lib/gcc-snapshot/bin/g++ -fno-PIE -c -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace -o csky.o -MT csky.o -MMD -MP -MF ./.deps/csky.TPo ../../gcc/gcc/config/csky/csky.cc In file included from ../../gcc/gcc/config/csky/csky.h:183, from ./tm.h:20, from ../../gcc/gcc/backend.h:28, from ../../gcc/gcc/config/csky/csky.cc:27: ../../gcc/gcc/config/csky/csky.cc: In function 'bool csky_emit_compare_float(rtx_code, rtx, rtx)': ../../gcc/gcc/config/csky/csky_isa.h:29:37: error: enum constant in boolean context [-Werror=int-in-bool-context] 29 | #define CSKY_ISA_FEATURE_DEFINE(x) isa_bit_ ## x | ^~~~~~~~ ../../gcc/gcc/config/csky/csky_isa.h:30:37: note: in expansion of macro 'CSKY_ISA_FEATURE_DEFINE' 30 | #define CSKY_ISA_FEATURE_GET(x) CSKY_ISA_FEATURE_DEFINE (x) | ^~~~~~~~~~~~~~~~~~~~~~~ ../../gcc/gcc/config/csky/csky.cc:6346:43: note: in expansion of macro 'CSKY_ISA_FEATURE_GET' 6346 | || CSKY_ISA_FEATURE_GET(fpv2_df) | ^~~~~~~~~~~~~~~~~~~~ ../../gcc/gcc/config/csky/csky_isa.h:29:37: error: enum constant in boolean context [-Werror=int-in-bool-context] 29 | #define CSKY_ISA_FEATURE_DEFINE(x) isa_bit_ ## x | ^~~~~~~~ ../../gcc/gcc/config/csky/csky_isa.h:30:37: note: in expansion of macro 'CSKY_ISA_FEATURE_DEFINE' 30 | #define CSKY_ISA_FEATURE_GET(x) CSKY_ISA_FEATURE_DEFINE (x) | ^~~~~~~~~~~~~~~~~~~~~~~ ../../gcc/gcc/config/csky/csky.cc:6346:43: note: in expansion of macro 'CSKY_ISA_FEATURE_GET' 6346 | || CSKY_ISA_FEATURE_GET(fpv2_df) | ^~~~~~~~~~~~~~~~~~~~ ../../gcc/gcc/config/csky/csky_isa.h:29:37: error: enum constant in boolean context [-Werror=int-in-bool-context] 29 | #define CSKY_ISA_FEATURE_DEFINE(x) isa_bit_ ## x | ^~~~~~~~ ../../gcc/gcc/config/csky/csky_isa.h:30:37: note: in expansion of macro 'CSKY_ISA_FEATURE_DEFINE' 30 | #define CSKY_ISA_FEATURE_GET(x) CSKY_ISA_FEATURE_DEFINE (x) | ^~~~~~~~~~~~~~~~~~~~~~~ ../../gcc/gcc/config/csky/csky.cc:6347:43: note: in expansion of macro 'CSKY_ISA_FEATURE_GET' 6347 | || CSKY_ISA_FEATURE_GET(fpv2_divd))) | ^~~~~~~~~~~~~~~~~~~~ The 'CSKY_ISA_FEATURE_DEFINE (x)' is an enum contant, it will cause the condition always being true. In addition to warning, it will let FPUV3 to generate a move instruction, which is unnecessary. In a simple test case, the move instruction can be combined, so it was not found in the testsuite. But in some complex scenarios, this may generate some redundant instructions. The correct way is to use 'CSKY_ISA_FEATURE' instead of 'CSKY_ISA_FEATURE_DEFINE'. gcc/ * config/csky/csky.cc (csky_emit_compare_float): Fix the expanding of float LE comparing with zero for fpuv3. * config/csky/csky.h (TARGET_SUPPORT_FPV2): New, true if any fpuv2 features are enabled.
2022-09-07tree-optimization/106860 - fix profile scaling in split_loopRichard Biener2-6/+33
The following fixes a mistake in loop splitting which assumes loop latches have a single predecessor and that edge is from the exit test. Instead work from the single exit edge we have to find the edge towards the latch. PR tree-optimization/106860 * tree-ssa-loop-split.cc (split_loop): Find the exit to latch edge from the loop exit edge instead of from the latch. Verify we're going to find it. * g++.dg/opt/pr106860.C: New testcase.
2022-09-07mark region also for USE predicate discoveryRichard Biener1-8/+19
The following makes sure to mark the dominating region also for USE predicate discovery, avoiding compute_control_dep_chain to walk to unrelated areas, eating up walking budget. * gimple-predicate-analysis.cc (dfs_mark_dominating_region): Adjust to take the region exit source as argument. (uninit_analysis::init_from_phi_def): Adjust. (uninit_analysis::init_use_preds): Mark the dominating region before computing control dependences.
2022-09-07aarch64: Fix +nosimd handling of FPR movesRichard Sandiford12-16/+729
8-bit and 16-bit FPR moves would ICE for +nosimd+fp, and some other moves would handle FPR<-zero inefficiently. This is very much a niche case at the moment, but something like it becomes more important with SME streaming mode. The si, di and vector tests already passed, they're just included for completeness. We're a bit inconsistent about whether alternatives involving FPRs are marked with arch==fp or arch=* (i.e. default). E.g. FPR loads and stores are sometimes * and sometimes fp. IMO * makes more sense. FPRs should not be used at all without TARGET_FLOAT, so TARGET_FLOAT represents the base architecture when FPRs are enabled. I think it's more useful if non-default arches represent a genuine restriction. gcc/ * config/aarch64/aarch64.md (*mov<SHORT:mode>_aarch64): Extend w<-w, r<-w and w<-r alternatives to !simd, using 32-bit moves in that case. Extend w<-r to w<-Z. (*mov<HFBF:mode>_aarch64): Likewise, but with Y instead of Z. (*movti_aarch64): Use an FMOV from XZR for w<-Z if MOVI is not available. (define_split): Do not apply the floating-point immediate-to-register split to zeros, even if MOVI is not available. gcc/testsuite/ * gcc.target/aarch64/movqi_1.c: New test. * gcc.target/aarch64/movhi_1.c: Likewise. * gcc.target/aarch64/movsi_1.c: Likewise. * gcc.target/aarch64/movdi_2.c: Likewise. * gcc.target/aarch64/movti_2.c: Likewise. * gcc.target/aarch64/movhf_1.c: Likewise. * gcc.target/aarch64/movsf_1.c: Likewise. * gcc.target/aarch64/movdf_1.c: Likewise. * gcc.target/aarch64/movtf_2.c: Likewise. * gcc.target/aarch64/movv8qi_1.c: Likewise. * gcc.target/aarch64/movv16qi_1.c: Likewise.
2022-09-07aarch64: Prevent FPR register asms for +nofpRichard Sandiford2-0/+20
+nofp disabled the automatic allocation of FPRs, but it didn't stop users from explicitly putting register variables in FPRs. We'd then either report an ICE or generate unsupported instructions. It's still possible (and deliberately redundant) to specify FPRs in clobber lists. gcc/ * config/aarch64/aarch64.cc (aarch64_conditional_register_usage): Disallow use of FPRs in register asms for !TARGET_FLOAT. gcc/testsuite/ * gcc.target/aarch64/nofp_2.c: New test.
2022-09-07LoongArch: Fix pr106828 by define hook TARGET_ASAN_SHADOW_OFFSET in ↵Lulu Cheng2-0/+17
loongarch backend [PR106828]. gcc/ChangeLog: PR target/106828 * config/loongarch/loongarch.cc (loongarch_asan_shadow_offset): New. (TARGET_ASAN_SHADOW_OFFSET): New. gcc/testsuite/ChangeLog: PR target/106828 * g++.target/loongarch/pr106828.C: New test.
2022-09-07openmp: Fix handling of target constructs in static member functions [PR106829]Jakub Jelinek2-9/+23
Just calling current_nonlambda_class_type in static member functions returns non-NULL, but something that isn't *this and if unlucky can match part of the IL and can be added to target clauses. if (DECL_NONSTATIC_MEMBER_P (decl) && current_class_ptr) is a guard used elsewhere (in check_accessibility_of_qualified_id). 2022-09-07 Jakub Jelinek <jakub@redhat.com> PR c++/106829 * semantics.cc (finish_omp_target_clauses): If current_function_decl isn't a nonstatic member function, don't set data.current_object to non-NULL. * g++.dg/gomp/pr106829.C: New test.
2022-09-07libcpp: Named universal character escapes and delimited escape sequence tweaksJakub Jelinek14-19/+228
On Tue, Aug 30, 2022 at 09:10:37PM +0000, Joseph Myers wrote: > I'm seeing build failures of glibc for powerpc64, as illustrated by the > following C code: > > #if 0 > \NARG > #endif > > (the actual sysdeps/powerpc/powerpc64/sysdep.h code is inside #ifdef > __ASSEMBLER__). > > This shows some problems with this feature - and with delimited escape > sequences - as it affects C. It's fine to accept it as an extension > inside string and character literals, because \N or \u{...} would be > invalid in the absence of the feature (i.e. the syntax for such literals > fails to match, meaning that the rule about undefined behavior for a > single ' or " as a pp-token applies). But outside string and character > literals, the usual lexing rules apply, the \ is a pp-token on its own and > the code is valid at the preprocessing level, and with expansion of macros > appearing before or after the \ (e.g. u defined as a macro in the \u{...} > case) it may be valid code at the language level as well. I don't know > what older C++ versions say about this, but for C this means e.g. > > #define z(x) 0 > #define a z( > int x = a\NARG); > > needs to be accepted as expanding to "int x = 0;", not interpreted as > using the \N feature in an identifier and produce an error. The following patch changes this, so that: 1) outside of string/character literals, \N without following { is never treated as an error nor warning, it is silently treated as \ separate token followed by whatever is after it 2) \u{123} and \N{LATIN SMALL LETTER A WITH ACUTE} are not handled as extension at all outside of string/character literals in the strict standard modes (-std=c*) except for -std=c++{23,2b}, only in the -std=gnu* modes, because it changes behavior on valid sources, e.g. #define z(x) 0 #define a z( int x = a\u{123}); int y = a\N{LATIN SMALL LETTER A WITH ACUTE}); 3) introduces -Wunicode warning (on by default) and warns for cases of what looks like invalid delimited escape sequence or named universal character escape outside of string/character literals and is treated as separate tokens 2022-09-07 Jakub Jelinek <jakub@redhat.com> libcpp/ * include/cpplib.h (struct cpp_options): Add cpp_warn_unicode member. (enum cpp_warning_reason): Add CPP_W_UNICODE. * init.cc (cpp_create_reader): Initialize cpp_warn_unicode. * charset.cc (_cpp_valid_ucn): In possible identifier contexts, don't handle \u{ or \N{ specially in -std=c* modes except -std=c++2{3,b}. In possible identifier contexts, don't emit an error and punt if \N isn't followed by {, or if \N{} surrounds some lower case letters or _. In possible identifier contexts when not C++23, don't emit an error but warning about unknown character names and treat as separate tokens. When treating as separate tokens \u{ or \N{, emit warnings. gcc/ * doc/invoke.texi (-Wno-unicode): Document. gcc/c-family/ * c.opt (Winvalid-utf8): Use ObjC instead of objC. Remove " in comments" from description. (Wunicode): New option. gcc/testsuite/ * c-c++-common/cpp/delimited-escape-seq-4.c: New test. * c-c++-common/cpp/delimited-escape-seq-5.c: New test. * c-c++-common/cpp/delimited-escape-seq-6.c: New test. * c-c++-common/cpp/delimited-escape-seq-7.c: New test. * c-c++-common/cpp/named-universal-char-escape-5.c: New test. * c-c++-common/cpp/named-universal-char-escape-6.c: New test. * c-c++-common/cpp/named-universal-char-escape-7.c: New test. * g++.dg/cpp23/named-universal-char-escape1.C: New test. * g++.dg/cpp23/named-universal-char-escape2.C: New test.
2022-09-07rs6000: remove unused splitter on const_scalar_int_operandJiufu Guo1-12/+0
There are two splitters, both are calling rs6000_emit_set_const to emit instructions for constant building. One splitter checks `const_int_operand`, this splitter is always used. Another spitter checks `const_scalar_int_operand`, this one is never used now. Checking the history, that splitter is introduced around 1999 for HOST_BITS_PER_WIDE_INT=32, as below: (define_split [(set (match_operand:DI 0 "gpc_reg_operand" "") (match_operand:DI 1 "const_double_operand" ""))] "HOST_BITS_PER_WIDE_INT == 32 && TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1" And `HOST_BITS_PER_WIDE_INT == 32` is eliminated later, since it is `const_double_operand` can cover it. When wide_int is introduced, `const_double_operand` is replaced by `const_scalar_int_operand`. Now, HOST_BITS_PER_WIDE_INT is forced to 64, this splitter is safe to remove. gcc/ChangeLog: * config/rs6000/rs6000.md (const_scalar_int splitter): Remove.
2022-09-07rs6000: fix misleading new patterns of splittersJiufu Guo1-9/+3
As a comment in https://gcc.gnu.org/pipermail/gcc-patches/2022-August/599556.html Those splitters call rs6000_emit_set_const directly, and the replacements are never used. Using (pc) would be less misleading. gcc/ChangeLog: * config/rs6000/rs6000.md: (constant splitters): Use "(pc)" as the replacements.
2022-09-06runtime: ignore __morestack function in runtime.CallersIan Lance Taylor2-2/+2
We were ignoring all functions starting with "__morestack_", but not the function "__morestack" itself. Without this change, some tests such as recover.go started failing recently, though I'm not sure exactly what changed. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/427935
2022-09-06rs6000/test: Fix empty TU in some cases of effective targets [PR106345]Kewen Lin1-0/+33
As the failure of test case gcc.target/powerpc/pr92398.p9-.c in PR106345 shows, some test sources for some powerpc effective targets use empty translation unit wrongly. The test sources could go with options like "-ansi -pedantic-errors", then those effective target checkings will fail unexpectedly with the error messages like: error: ISO C forbids an empty translation unit [-Wpedantic] This patch is to fix empty TUs with one dummy function definition accordingly. PR testsuite/106345 gcc/testsuite/ChangeLog: * lib/target-supports.exp (check_effective_target_powerpc_sqrt): Add a function definition to avoid pedwarn about empty translation unit. (check_effective_target_has_arch_pwr5): Likewise. (check_effective_target_has_arch_pwr6): Likewise. (check_effective_target_has_arch_pwr7): Likewise. (check_effective_target_has_arch_pwr8): Likewise. (check_effective_target_has_arch_pwr9): Likewise. (check_effective_target_has_arch_pwr10): Likewise. (check_effective_target_has_arch_ppc64): Likewise. (check_effective_target_ppc_float128): Likewise. (check_effective_target_ppc_float128_insns): Likewise. (check_effective_target_powerpc_vsx): Likewise.
2022-09-07Extend vectorizer to handle nonlinear induction for neg, mul/lshift/rshift ↵liuhongt9-14/+1062
with a constant. For neg, the patch create a vec_init as [ a, -a, a, -a, ... ] and no vec_step is needed to update vectorized iv since vf is always multiple of 2(negative * negative is positive). For shift, the patch create a vec_init as [ a, a >> c, a >> 2*c, ..] as vec_step as [ c * nunits, c * nunits, c * nunits, ... ], vectorized iv is updated as vec_def = vec_init >>/<< vec_step. For mul, the patch create a vec_init as [ a, a * c, a * pow(c, 2), ..] as vec_step as [ pow(c,nunits), pow(c,nunits),...] iv is updated as vec_def = vec_init * vec_step. The patch handles nonlinear iv for 1. Integer type only, floating point is not handled. 2. No slp_node. 3. iv_loop should be same as vector loop, not nested loop. 4. No UD is created, for mul, use unsigned mult to avoid UD, for shift, shift count should be less than type precision. gcc/ChangeLog: PR tree-optimization/103144 * tree-vect-loop.cc (vect_is_nonlinear_iv_evolution): New function. (vect_analyze_scalar_cycles_1): Detect nonlinear iv by upper function. (vect_create_nonlinear_iv_init): New function. (vect_peel_nonlinear_iv_init): Ditto. (vect_create_nonlinear_iv_step): Ditto (vect_create_nonlinear_iv_vec_step): Ditto (vect_update_nonlinear_iv): Ditto (vectorizable_nonlinear_induction): Ditto. (vectorizable_induction): Call vectorizable_nonlinear_induction when induction_type is not vect_step_op_add. * tree-vect-loop-manip.cc (vect_update_ivs_after_vectorizer): Update nonlinear iv for epilogue loop. * tree-vectorizer.h (enum vect_induction_op_type): New enum. (STMT_VINFO_LOOP_PHI_EVOLUTION_TYPE): New Macro. gcc/testsuite/ChangeLog: * gcc.target/i386/pr103144-mul-1.c: New test. * gcc.target/i386/pr103144-mul-2.c: New test. * gcc.target/i386/pr103144-neg-1.c: New test. * gcc.target/i386/pr103144-neg-2.c: New test. * gcc.target/i386/pr103144-shift-1.c: New test. * gcc.target/i386/pr103144-shift-2.c: New test.
2022-09-07Daily bump.GCC Administrator10-1/+617
2022-09-06c++: C++23 operator[] allows default argumentsJason Merrill2-6/+12
This usage was intended to be allowed by P2128, but it didn't make it into the final wording. Fixed by CWG 2507. DR2507 gcc/cp/ChangeLog: * decl.cc (grok_op_properties): Return sooner for C++23 op[]. gcc/testsuite/ChangeLog: * g++.dg/cpp23/subscript8.C: New test.
2022-09-06tree-optimization/106754 - fix compute_control_dep_chain defectRichard Biener3-80/+180
The following handles the situation of a loop exit along the control path to the PHI def or from there to the use in a different way, aoviding premature abort of the walks as noticed in the two cases where the exit is outermost (gcc.dg/uninit-pred-11.c) or wrapped in a condition that is on the path (gcc.dg/uninit-pred-12.c). Instead of handling such exits during recursion we now pick them up in the parent when walking post-dominators. That requires an additional post-dominator walk at the outermost level which is facilitated by splitting out the walk to a helper function and the existing wrapper added earlier. The patch also removes the bogus early exit from uninit_analysis::init_use_preds, fixing a simplified version of the PR106155 testcase. PR tree-optimization/106754 * gimple-predicate-analysis.cc (compute_control_dep_chain_pdom): New function, split out from compute_control_dep_chain. Handle loop-exit like conditions here by pushing to the control vector. (compute_control_dep_chain): Adjust and streamline dumping. In the wrapper perform a post-dominator walk as well. (uninit_analysis::init_use_preds): Remove premature early exit. * gcc.dg/uninit-pred-12.c: New testcase. * gcc.dg/uninit-pr106155-1.c: Likewise.
2022-09-06xtensa: gcc: add static PIE supportMax Filippov1-2/+3
gcc/ * config/xtensa/linux.h (LINK_SPEC): Add static-pie.
2022-09-06Handle > INF and < INF correctly in range-op-float.ccAldy Hernandez2-24/+90
The gfortran.dg/minlocval*.f90 tests are generating conditionals past the infinities. For example: if (x <= +Inf) foo (x); else bar (x); It seems to me that the only possible value for x on the false side is either NAN or undefined (for !HONOR_NANS). gcc/ChangeLog: * range-op-float.cc (build_le): Handle NANs and going past infinity. (build_lt): Same. (build_ge): Same. (build_gt): Same. (foperator_lt::op1_range): Avoid adjustments to range if build_* returned false. (foperator_lt::op2_range): Same. (foperator_le::op1_range): Same. (foperator_le::op2_range): Same. (foperator_gt::op1_range): Same. (foperator_gt::op2_range): Same. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/vrp-float-inf-1.c: New test.
2022-09-06Fix use predicate computation for uninit analysisRichard Biener1-15/+39
In uninit analysis we try to prove that a use is always properly guarded so it is never reached when the used value is not initialized. This fails to be conservative when during the computation of the use predicate components of the || .. || .. chain are dropped so we have to detect this case and fall back to the conservative computation. * gimple-predicate-analysis.cc (compute_control_dep_chain): Add output flag to indicate whether we possibly have dropped any chains. Return whether the info is complete from the wrapping overload. (uninit_analysis::init_use_preds): Adjust accordingly, with a workaround for PR106754. (uninit_analysis::init_from_phi_def): Properly guard the case where we complete an empty chain.
2022-09-06libstdc++: Fix pretty printer tests of tuple indexesPhilipp Fent2-3/+3
Signed-off-by: Philipp Fent <fent@in.tum.de> libstdc++-v3/ChangeLog: * testsuite/libstdc++-prettyprinters/48362.cc: Fix expected tuple indices. * testsuite/libstdc++-prettyprinters/cxx11.cc: Likewise.
2022-09-06Document unused function argumentJan-Benedict Glaw1-1/+1
This patch fixes a small warning about the unused outer_rtx argument in the msp430 backend. 2022-09-06 Jan-Benedict Glaw <jbglaw@lug-owl.de> gcc/ChangeLog: * config/msp430/msp430.cc (msp430_single_op_cost): Document unused argument.
2022-09-06tree-ssa-forwprop.cc: Adjust res_type when operands have differing vector ↵Prathamesh Kulkarni1-1/+3
lengths. gcc/ * tree-ssa-forwprop.cc (simplify_permutation): Set res_type to a vector type with same element type as arg0, and length as op2.
2022-09-06tree-optimization/106844 - fix ICE in init_use_predsRichard Biener2-1/+17
The following fixes an oversight in the last change to compute_control_dep_chain where we have to return whether we found a chain. PR tree-optimization/106844 * gimple-predicate-analysis.cc (compute_control_dep_chain): Return whether we found a chain. * gcc.dg/pr106844.c: New testcase.
2022-09-06tree-optimization/106841 - gather and hybrid SLPRichard Biener2-0/+61
Hybrid SLP detection currently fails to consider a not direct offset operand of a scatter/gather operation. The following fixes this. PR tree-optimization/106841 * tree-vect-slp.cc (vect_detect_hybrid_slp): Also process scatter/gather offset. * g++.dg/vect/pr106841.cc: New testcase.
2022-09-06Fix Fortran/openmp: Partial OpenMP 5.2 doacrossTobias Burnus1-4/+0
This removed a checking snippet which accidentally was left in in commit r13-2446-g938cda536019cd6a1bc0dd2346381185b420bbf8 ; this caused fails in gfortran.dg/gomp/doacross-5.f90 (added in that very commit). Note that a similar but refined check is now done in the middle end. (The ME version additionally checks whether doacross is present.) gcc/fortran/ * openmp.cc (resolve_omp_clauses): Remove ordered/linear check as it is handled now in the middle end.
2022-09-06openmp: Be consistent on parsing offsets between normal sink vector and ↵Jakub Jelinek3-6/+24
omp_cur_iteration - 1 For normal sink vectors, we just check that the token is CPP_NUMBER and with INTEGER_CST value, while for omp_cur_iteration I was additionally requiring integer_type_node type (so only 1, 001, 0x0001 but not 1L or 1ULL etc.). I think we need to clarify what we actually should allow in the standard, until then it is better to be consistent. 2022-09-06 Jakub Jelinek <jakub@redhat.com> gcc/c/ * c-parser.cc (c_parser_omp_clause_doacross_sink): Don't verify val in omp_cur_iteration - 1 has integer_type_node type. gcc/cp/ * parser.cc (cp_parser_omp_clause_doacross_sink): Don't verify val in omp_cur_iteration - 1 has integer_type_node type. gcc/testsuite/ * c-c++-common/gomp/doacross-6.c (corge): Don't expect an error here. Add a few further tests.
2022-09-06openmp: Fix ICE when splitting invalid depend(source)/depend(sink:vec)Jakub Jelinek2-0/+15
As we now create OMP_CLAUSE_DOACROSS rather than OMP_CLAUSE_DEPEND when depend is used with source/sink modifiers, c_omp_split_clauses can see OMP_CLAUSE_DOACROSS clause too before we diagnose it as erroneous. The following patch treats it like OMP_CLAUSE_DEPEND during the splitting but adds an assertion. 2022-09-06 Jakub Jelinek <jakub@redhat.com> PR c/106836 * c-omp.cc (c_omp_split_clauses): Handle OMP_CLAUSE_DOACROSS. * c-c++-common/gomp/pr106836.c: New test.
2022-09-06No actual regclasses for bpfJan-Benedict Glaw1-1/+1
Building for for bpf-unknown-none target, recent GCCs will issue an unused variable warning as the REGNO_REG_CLASS macro doesn't actually use its argument. Reference the argument as (void) to silence the warning. .../gcc/configure --prefix=... --enable-werror-always --enable-languages=all --disable-gcov --disable-shared --disable-threads --target=bpf-unknown-none --without-headers [...] make V=1 all-gcc [...] /usr/lib/gcc-snapshot/bin/g++ -fno-PIE -c -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace -o regcprop.o -MT regcprop.o -MMD -MP -MF ./.deps/regcprop.TPo ../../gcc/gcc/regcprop.cc ../../gcc/gcc/regcprop.cc: In function 'bool copyprop_hardreg_forward_1(basic_block, value_data*)': ../../gcc/gcc/regcprop.cc:794:24: error: unused variable 'regno' [-Werror=unused-variable] 794 | unsigned int regno = REGNO (SET_SRC (set)); | ^~~~~ cc1plus: all warnings being treated as errors make[1]: *** [Makefile:1146: regcprop.o] Error 1 make[1]: Leaving directory '/var/lib/laminar/run/gcc-bpf-unknown-none/1/toolchain-build/gcc' make: *** [Makefile:4565: all-gcc] Error 2 gcc/ * config/bpf/bpf.h (REGNO_REG_CLASS): Reference arguments as (void).
2022-09-06openmp: Introduce gimple_omp_ordered_standalone_pJakub Jelinek7-18/+54
On Sat, Sep 03, 2022 at 10:07:27AM +0200, Jakub Jelinek via Gcc-patches wrote: > Incrementally, I'd like to change the way we differentiate between > stand-alone and block-associated ordered constructs, because the current > way of looking for presence of doacross clause doesn't work well if those > clauses are removed because they had been invalid (wrong syntax or > unknown variables in it etc.) The following, so far only lightly tested, patch implements that. 2022-09-06 Jakub Jelinek <jakub@redhat.com> gcc/ * gimple.h (enum gf_mask): Add GF_OMP_ORDERED_STANDALONE enumerator. (gimple_omp_subcode): Use GIMPLE_OMP_ORDERED instead of GIMPLE_OMP_TEAMS as upper bound. (gimple_omp_ordered_standalone_p, gimple_omp_ordered_standalone): New inline functions. * gimplify.cc (find_standalone_omp_ordered): Look for OMP_ORDERED with NULL OMP_ORDERED_BODY rather than with OMP_DOACROSS clause. (gimplify_expr): Call gimple_omp_ordered_standalone for OMP_ORDERED with NULL OMP_ORDERED_BODY. * omp-low.cc (check_omp_nesting_restrictions): Use gimple_omp_ordered_standalone_p test instead of omp_find_clause (..., OMP_CLAUSE_DOACROSS). (lower_omp_ordered): Likewise. * omp-expand.cc (expand_omp, build_omp_regions_1, omp_make_gimple_edges): Likewise. gcc/cp/ * pt.cc (tsubst_expr) <case OMP_ORDERED>: If OMP_BODY was NULL, keep it NULL after instantiation too. gcc/testsuite/ * c-c++-common/gomp/sink-3.c: Don't expect a superfluous error during error recovery. * c-c++-common/gomp/doacross-6.c (foo): Add further tests.
2022-09-06[Ada] Mark artificial formal parameters in the debug infoEric Botcazou1-0/+1
gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_param): Set DECL_ARTIFICIAL.
2022-09-06[Ada] Fix problematic line debug info attached to call to finalizerEric Botcazou1-5/+13
The End_Label is not defined for body nodes so a small tweak is needed. gcc/ada/ * gcc-interface/trans.cc (At_End_Proc_to_gnu): Use the End_Label of the child Handled_Statement_Sequence for body nodes. (set_end_locus_from_node): Minor tweaks.
2022-09-06[Ada] Fix internal error on double renaming of private constantEric Botcazou1-25/+43
The first renaming uses the type of the full view of the constant but not the second, which introduces problematic view conversions downstream. gcc/ada/ * gcc-interface/trans.cc (Full_View_Of_Private_Constant): New function returning the Full_View of a private constant, after looking through a chain of renamings, if any. (Identifier_to_gnu): Call it on the entity. Small cleanup.
2022-09-06[Ada] Fix missing name for access type in generic instantiationEric Botcazou1-12/+16
Pointer types aren't named types in C so we need to take extra care in Ada to make sure that the name of access types is preserved. gcc/ada/ * gcc-interface/utils.cc (gnat_pushdecl): Preserve named TYPE_DECLs consistently for all kind of pointer types.
2022-09-06[Ada] Extend No_Dependence restriction to code generation (continued)Eric Botcazou1-0/+25
gcc/ada/ * gcc-interface/trans.cc (gnat_to_gnu) <N_Op_Divide>: Report a violation of No_Dependence on System.GCC if the result type is larger than a word. <N_Op_Shift>: Likewise. <N_Op_Mod>: Likewise. <N_Op_Rem>: Likewise. (convert_with_check): Report a violation of No_Dependence on System.GCC for a conversion between an integer type larger than a word and a floating-point type.
2022-09-06[Ada] Disable lock free protected implementation if target lacks supportSteve Baird1-0/+5
Do not select a lock free implementation if Targparm.Support_Atomic_Primitives is False (which indicates that the target cannot support it). gcc/ada/ * sem_ch9.adb (Allows_Lock_Free_Implementation): Return False if Support_Atomic_Primitives is False.
2022-09-06[Ada] Enable lock free protected implementation by defaultSteve Baird9-746/+679
In the past, the Lock_Free aspect of a protected type (including an anonymous type) defaulted to False. In the case where an explicit "Lock_Free => True" aspect specification would be legal, the aspect now defaults to True (which means that a lock-free implementation is used to implement the type's protected operations); this is like the previous behavior of the compiler with the -gnatd9 switch specified. Support for the Lock_Free attribute (which should not be confused with the Lock_Free aspect) is removed. gcc/ada/ * debug.adb: Remove comment regarding the -gnatd9 switch. * doc/gnat_rm/implementation_defined_attributes.rst: Remove all mention of the Lock_Free attribute. * gnat_rm.texi, gnat_ugn.texi: Regenerate. * exp_attr.adb, sem_attr.adb: Remove all mention of the former Attribute_Lock_Free enumeration element of the Attribute_Id type. * sem_ch9.adb (Allows_Lock_Free_Implementation): Remove the Debug_Flag_9 test. Return False in the case of a protected function whose result type requires use of the secondary stack. (Satisfies_Lock_Free_Requirements): This functions checks for certain constructs and returns False if one is found. In the case of a protected function, there is no need to check to see if the protected object is being modified. So it is ok to omit *some* checks in the case of a protected function. But other checks which are required (e.g., the test for a reference to a variable that is not part of the protected object) were being incorrectly omitted. This could result in accepting "Lock_Free => True" aspect specifications that should be rejected. * snames.adb-tmpl: Name_Lock_Free no longer requires special treatment in Get_Pragma_Id or Is_Pragma_Name (because it is no longer an attribute name). * snames.ads-tmpl: Move the declaration of Name_Lock_Free to reflect the fact that it is no longer the name of an attribute. Delete Attribute_Lock_Free from the Attribute_Id enumeration type.
2022-09-06[Ada] Restore missing Aggregate aspect for Ada.Containers.Ordered_Sets.SetSteve Baird1-3/+3
Ada RM A.18.9 includes a specification of the Aggregate aspect for the type Ada.Containers.Ordered_Sets. That aspect specification was deliberately commented out in a-coorse.ads at one time, but that workaround is no longer needed. gcc/ada/ * libgnat/a-coorse.ads: Restore Aggregate aspect specification for type Set.
2022-09-06[Ada] Fix formal parameters list for secondary stack allocation procedureMarc Poulhiès1-1/+2
The introduction of the Alignment parameter for the secondary stack allocator in previous change was missing the corresponding change in the Build_Allocate_Deallocate_Proc when creating the formal parameters list. gcc/ada/ * exp_util.adb (Build_Allocate_Deallocate_Proc): Add Alignment_Param in the formal list for calls to SS_Allocate.
2022-09-06[Ada] Retain Has_Private_View flag for actuals of inlined subprogramsPiotr Trojanek1-0/+10
When instantiating a body to inline (either because frontend inlining is enabled with switch -gnatN or because of inlining-for-proof in GNATprove mode) we rewrite occurrences of formal parameters into the corresponding actual parameters. Then we switch type views, so that if the formal had a full view in the body to inline then the corresponding actual will have a full view in the particular inlined body. However, when rewriting occurrences of the formal parameter we were losing information about whether the formal had a private view. gcc/ada/ * inline.adb (Process_Formals): Preserve Has_Private_View flag while rewriting formal into actual parameters.
2022-09-06[Ada] Enforce matching of extra formalsJavier Miranda12-438/+1148
This patch enforces matching of extra formals in overridden subprograms, subprogram renamings, and subprograms to which attributes 'Access, 'Unchecked_Access, or 'Unrestricted_Access is applied (for these access cases the subprogram is checked against its corresponding subprogram type). gcc/ada/ * debug.adb (Debug_Flag_Underscore_X): Switch added temporarily to allow disabling extra formal checks. * exp_attr.adb (Expand_N_Attribute_Reference [access types]): Add extra formals to the subprogram referenced in the prefix of 'Unchecked_Access, 'Unrestricted_Access or 'Access; required to check that its extra formals match the extra formals of the corresponding subprogram type. * exp_ch3.adb (Stream_Operation_OK): Declaration moved to the public part of the package. (Validate_Tagged_Type_Extra_Formals): New subprogram. (Expand_Freeze_Record_Type): Improve the code that takes care of adding the extra formals of dispatching primitives; extended to add also the extra formals to renamings of dispatching primitives. * exp_ch3.ads (Stream_Operation_OK): Declaration moved from the package body. * exp_ch6.adb (Has_BIP_Extra_Formal): Subprogram declaration moved to the public part of the package. In addition, a parameter has been added to disable an assertion that requires its use with frozen entities. (Expand_Call_Helper): Enforce assertion checking extra formals on thunks. (Is_Build_In_Place_Function): Return False for entities with foreign convention. (Make_Build_In_Place_Call_In_Object_Declaration): Occurrences of Is_Return_Object replaced by the local variable Is_OK_Return_Object that evaluates to False for scopes with foreign convention. (Might_Have_Tasks): Fix check of class-wide limited record types. (Needs_BIP_Task_Actuals): Remove assertion to allow calling this function in more contexts; in addition it returns False for functions returning objects with foreign convention. (Needs_BIP_Finalization_Master): Likewise. (Needs_BIP_Alloc_Form): Likewise. * exp_ch6.ads (Stream_Operation_OK): Declaration moved from the package body. In addition, a parameter has been added to disable assertion that requires its use with frozen entities. * freeze.adb (Check_Itype): Add extra formals to anonymous access subprogram itypes. (Freeze_Expression): Improve code that disables the addition of extra formals to functions with foreign convention. (Check_Extra_Formals): Moved to package Sem_Ch6 as Extra_Formals_OK. (Freeze_Subprogram): Add extra formals to non-dispatching subprograms. * sem_ch3.adb (Access_Subprogram_Declaration): Defer the addition of extra formals to the freezing point so that we know the convention. (Check_Anonymous_Access_Component): Likewise. (Derive_Subprogram): Fix documentation. * sem_ch6.adb (Check_Anonymous_Return): Fix check of access to class-wide limited record types. (Check_Untagged_Equality): Placed in alphabetical order. (Extra_Formals_OK): Subprogram moved from freeze.adb. (Extra_Formals_Match_OK): New subprogram. (Has_BIP_Formals): New subprogram. (Has_Extra_Formals): New subprograms. (Needs_Accessibility_Check_Extra): New subprogram. (Needs_Constrained_Extra): New subprogram. (Parent_Subprogram): New subprogram. (Add_Extra_Formal): Minor code cleanup. (Create_Extra_Formals): Enforce matching extra formals on overridden and aliased entities. (Has_Reliable_Extra_Formals): New subprogram. * sem_ch6.ads (Extra_Formals_OK): Subprogram moved from freeze.adb. (Extra_Formals_Match_OK): New subprogram. * sem_eval.adb (Compile_Time_Known_Value): Improve predicate to avoid assertion failure; found working on this ticket; this change does not affect the behavior of the compiler because this subprogram has an exception handler that returns False when the assertion fails. * sem_util.adb (Needs_Result_Accessibility_Level): Do not return False for dispatching operations compiled with Ada_Version < 2012 since they they may be overridden by primitives compiled with Ada_Version >= Ada_2012.
2022-09-06[Ada] Disable if expression optimization for LLVMArnaud Charlet1-0/+5
gcc/ada/ * exp_ch4.adb (Expand_N_If_Expression): Disable optimization for LLVM.
2022-09-06[Ada] Report error in non-legal class-wide conditionsJavier Miranda1-5/+3
gcc/ada/ * sem_prag.adb (Analyze_Pre_Post_Condition_In_Decl_Part): Improve check to report an error in non-legal class-wide conditions.
2022-09-06[Ada] Slice length computation bug in Generic_Bounded_Length genericsSteve Baird3-21/+16
In some cases involving null slices, the Slice subprograms (both the function and the procedure) in each of the three Generic_Bounded_Length generic packages (for String, Wide_String, and Wide_Wide_String) could raise Constraint_Error in cases where this is incorrect. gcc/ada/ * libgnat/a-strsup.adb, libgnat/a-stwisu.adb, libgnat/a-stzsup.adb (Super_Slice function and procedure): fix slice length computation.
2022-09-06[Ada] Improve documentation of validation checking control switchesSteve Baird2-72/+88
Correct incorrect text and clarify unclear text that has been identified in the "Validity Checking" section of the GNAT UG. gcc/ada/ * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Improve -gnatVa, -gnatVc, -gnatVd, -gnatVe, -gnatVf, -gnatVo, -gnatVp, -gnatVr, and -gnatVs switch descriptions. * gnat_ugn.texi: Regenerate.