Skip to content
Snippets Groups Projects
  1. Jan 07, 2025
  2. Jan 06, 2025
    • Alexandre Oliva's avatar
      expand: drop stack adjustments after barrier [PR118006] · 1b1a33f7
      Alexandre Oliva authored
      A gimple block with __builtin_unreachable () can't have code after it,
      and gimple optimizers ensure there isn't any, even without
      optimization.  But if the block requires stack adjustments,
      e.g. because of a call that passes arguments on the stack, expand will
      emit that after the barrier, and then rtl checkers rightfully
      complain.  Arrange to discard adjustments after a barrier.
      
      Strub expanders seem to be necessary to bring about the exact
      conditions that require stack adjustments after the block that ends
      with a __builtin_unreachable call.
      
      
      for  gcc/ChangeLog
      
      	PR middle-end/118006
      	* cfgexpand.cc (expand_gimple_basic_block): Do not emit
      	pending stack adjustments after a barrier.
      
      for  gcc/testsuite/ChangeLog
      
      	PR middle-end/118006
      	* gcc.target/i386/strub-pr118006.c: New.
      1b1a33f7
    • Akram Ahmad's avatar
      aarch64: remove extra XTN in vector concatenation · 6069f02a
      Akram Ahmad authored
      GIMPLE code which performs a narrowing truncation on the result of a
      vector concatenation currently results in an unnecessary XTN being
      emitted following a UZP1 to concate the operands. In cases such as this,
      UZP1 should instead use a smaller arrangement specifier to replace the
      XTN instruction. This is seen in cases such as in this GIMPLE example:
      
      	int32x2_t foo (svint64_t a, svint64_t b)
      	{
      	  vector(2) int vect__2.8;
      	  long int _1;
      	  long int _3;
      	  vector(2) long int _12;
      
      	  <bb 2> [local count: 1073741824]:
      	  _1 = svaddv_s64 ({ -1, 0, 0, 0, 0, 0, 0, 0, ... }, a_6(D));
      	  _3 = svaddv_s64 ({ -1, 0, 0, 0, 0, 0, 0, 0, ... }, b_7(D));
      	  _12 = {_1, _3};
      	  vect__2.8_13 = (vector(2) int) _12;
      	  return vect__2.8_13;
      
      	}
      
      Original assembly generated:
      
      	bar:
      	        ptrue   p3.b, all
      	        uaddv   d0, p3, z0.d
      	        uaddv   d1, p3, z1.d
      	        uzp1    v0.2d, v0.2d, v1.2d
      	        xtn     v0.2s, v0.2d
      	        ret
      
      This patch therefore defines the *aarch64_trunc_concat<mode> insn which
      truncates the concatenation result, rather than concatenating the
      truncated operands (such as in *aarch64_narrow_trunc<mode>), resulting
      in the following optimised assembly being emitted:
      
      	bar:
      	        ptrue   p3.b, all
      	        uaddv   d0, p3, z0.d
      	        uaddv   d1, p3, z1.d
      	        uzp1    v0.2s, v0.2s, v1.2s
      	        ret
      
      This patch passes all regression tests on aarch64 with no new failures.
      A supporting test for this optimisation is also written and passes.
      
      OK for master? I do not have commit rights so I cannot push the patch
      myself.
      
      gcc/ChangeLog:
      
      	* config/aarch64/aarch64-simd.md: (*aarch64_trunc_concat)
      	new insn definition.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/aarch64/sve/truncated_concatenation_1.c: new test
      	for the above example and other modes covered by insn
      	definitions.
      6069f02a
    • Stefan Schulze Frielinghaus's avatar
      Fix type in some Min() calls (#119248) · 7a7903de
      Stefan Schulze Frielinghaus authored
      This is a follow-up to 6dec33834d1fd89f16e271dde9607c1de9554144 and
      pull requests #116957 and #119114.
      
      Cherry picked from LLVM commit 65a2eb0b1589590ae78cc1e5f05cd004b3b3bec5.
      
      libsanitizer/ChangeLog:
      
      	PR sanitizer/117725
      	* sanitizer_common/sanitizer_common_interceptors.inc: Cherry
      	picked from LLVM commit 65a2eb0b1589590ae78cc1e5f05cd004b3b3bec5.
      7a7903de
    • Vitaly Buka's avatar
      Fix few size types in memprof (#119114) · f0b82562
      Vitaly Buka authored
      
      Fix type in a few related Min() calls.
      
      Follow up to #116957.
      
      Cherry picked from LLVM commit 6dec33834d1fd89f16e271dde9607c1de9554144
      (removed memprof part).
      
      libsanitizer/ChangeLog:
      
      	PR sanitizer/117725
      	* asan/asan_interceptors.cpp: Cherry picked from LLVM commit
      	6dec33834d1fd89f16e271dde9607c1de9554144.
      	* sanitizer_common/sanitizer_common_interceptors.inc: Ditto.
      
      Co-authored-by: default avatarStefan Schulze Frielinghaus <stefansf@linux.ibm.com>
      f0b82562
    • Stefan Schulze Frielinghaus's avatar
      Add type __sanitizer::ssize (#116957) · 1bd03564
      Stefan Schulze Frielinghaus authored
      Since the sanitizer merge in commit r15-5164-gfa321004f3f628 of GCC
      which entails LLVM commit 61a6439f35b6de28ff4aff4450d6fca970292fd5, GCCs
      bootstrap is broken on s390 -m31. This is due to commit
      ec68dc1ca4d967b599f1202855917d5ec9cae52f which introduces stricter type
      checking which is why GCC bootstrap fails with
      
      ```
      In file included from /gcc/src/libsanitizer/interception/interception.h:18,
                       from /gcc/src/libsanitizer/interception/interception_type_test.cpp:14:
      /gcc/src/libsanitizer/interception/interception_type_test.cpp:30:61: error: static assertion failed
         30 | COMPILER_CHECK((__sanitizer::is_same<::SSIZE_T, ::ssize_t>::value));
            |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
      /gcc/src/libsanitizer/sanitizer_common/sanitizer_internal_defs.h:363:44: note: in definition of macro 'COMPILER_CHECK'
        363 | #define COMPILER_CHECK(pred) static_assert(pred, "")
            |                                            ^~~~
      make[8]: *** [Makefile:469: interception_type_test.lo] Error 1
      ```
      
      The culprit seems to be that we don't check for equality of type sizes
      anymore but rather whether the types are indeed the same. On s390 -m31
      we have that `sizeof(int)==sizeof(long)` holds which is why previously
      the checks succeeded. They fail now because
      
      ```
      size_t      => unsigned long
      ssize_t     => long
      ptrdiff_t   => int
      ::SSIZE_T   => __sanitizer::sptr => int
      ::PTRDIFF_T => __sanitizer::sptr => int
      ```
      
      This is fixed by mapping `SSIZE_T` to `long` in the end.
      
      ```
      typedef long ssize;
      typedef sptr ssize;
      
      ```
      
      Cherry picked from LLVM commit ce44640fe29550461120d22b0358e6cac4aed822.
      
      libsanitizer/ChangeLog:
      
      	PR sanitizer/117725
      	* interception/interception.h: Cherry picked from LLVM commit
      	ce44640fe29550461120d22b0358e6cac4aed822.
      	* sanitizer_common/sanitizer_internal_defs.h: Ditto.
      1bd03564
    • Stefan Schulze Frielinghaus's avatar
      Replace uptr by usize/SIZE_T in interfaces · 0bb38b27
      Stefan Schulze Frielinghaus authored
      For some targets uptr is mapped to unsigned int and size_t to unsigned
      long and sizeof(int)==sizeof(long) holds.  Still, these are distinct
      types and type checking may fail.  Therefore, replace uptr by
      usize/SIZE_T wherever a size_t is expected.
      
      Part of #116957
      
      Cherry picked from LLVM commit 9a156f6b2b0c892d8713ba907f07f027b24953d8
      (removed memprof, msan, and nsan parts).
      
      libsanitizer/ChangeLog:
      
      	PR sanitizer/117725
      	* asan/asan_interceptors.cpp: Cherry picked LLVM commit
      	9a156f6b2b0c892d8713ba907f07f027b24953d8.
      	* asan/asan_interceptors.h: Ditto.
      	* asan/asan_interceptors_memintrinsics.h: Ditto.
      	* sanitizer_common/sanitizer_common_interceptors.inc: Ditto.
      	* sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:
      	Ditto.
      	* sanitizer_common/sanitizer_platform_limits_posix.h: Ditto.
      	* tsan/tsan_interceptors_posix.cpp: Ditto.
      0bb38b27
    • Ian Lance Taylor's avatar
      crypto/tls: fix Config.Time in tests using expired certificates · ed1493e1
      Ian Lance Taylor authored
      This is a backport of https://go.dev/cl/640237 from the main repo.
      
      Fixes PR go/118286
      
      Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/640435
      ed1493e1
    • Stafford Horne's avatar
      or1k: add .note.GNU-stack section on linux · 803808b4
      Stafford Horne authored
      In the OpenRISC build we get the following warning:
      
          ld: warning: __modsi3_s.o: missing .note.GNU-stack section implies executable stack
          ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
      
      Fix this by adding a .note.GNU-stack to indicate the stack does not need to be
      executable for the lib1funcs.
      
      Note, this is also needed for the upcoming glibc 2.41.
      
      libgcc/
      	* config/or1k/lib1funcs.S: Add .note.GNU-stack section on linux.
      803808b4
    • Fangrui Song's avatar
      Respect -fprofile-prefix-map for getcwd in .gcno files · fa778ba7
      Fangrui Song authored
      so that
      `gcc -c a.cc --coverage -fprofile-prefix-map=$PWD=.`
      does not emit $PWD in the generated a.gcno file.
      
      gcc/ChangeLog:
      
      	PR gcov-profile/96092
      	* coverage.cc (coverage_init): Remap getpwd().
      fa778ba7
    • Jennifer Schmitz's avatar
      SVE intrinsics: Fold svmul by -1 to svneg for unsigned types · f9c99d40
      Jennifer Schmitz authored
      As follow-up to
      https://gcc.gnu.org/pipermail/gcc-patches/2024-October/665472.html
      
      ,
      this patch implements folding of svmul by -1 to svneg for
      unsigned SVE vector types. The key idea is to reuse the existing code that
      does this fold for signed types and feed it as callback to a helper function
      that adds the necessary type conversions.
      
      For example, for the test case
      svuint64_t foo (svuint64_t x, svbool_t pg)
      {
        return svmul_n_u64_x (pg, x, -1);
      }
      
      the following gimple sequence is emitted (-O2 -mcpu=grace):
      svuint64_t foo (svuint64_t x, svbool_t pg)
      {
        svint64_t D.12921;
        svint64_t D.12920;
        svuint64_t D.12919;
      
        D.12920 = VIEW_CONVERT_EXPR<svint64_t>(x);
        D.12921 = svneg_s64_x (pg, D.12920);
        D.12919 = VIEW_CONVERT_EXPR<svuint64_t>(D.12921);
        goto <D.12922>;
        <D.12922>:
        return D.12919;
      }
      
      In general, the new helper gimple_folder::convert_and_fold
      - takes a target type and a function pointer,
      - converts the lhs and all non-boolean vector types to the target type,
      - passes the converted lhs and arguments to the callback,
      - receives the new gimple statement from the callback function,
      - adds the necessary view converts to the gimple sequence,
      - and returns the new call.
      
      Because all arguments are converted to the same target types, the helper
      function is only suitable for folding calls whose arguments are all of
      the same type. If necessary, this could be extended to convert the
      arguments to different types differentially.
      
      The patch was bootstrapped and tested on aarch64-linux-gnu, no regression.
      OK for mainline?
      
      Signed-off-by: default avatarJennifer Schmitz <jschmitz@nvidia.com>
      
      gcc/ChangeLog:
      
      	* config/aarch64/aarch64-sve-builtins-base.cc
      	(svmul_impl::fold): Wrap code for folding to svneg in lambda
      	function and pass to gimple_folder::convert_and_fold to enable
      	the transform for unsigned types.
      	* config/aarch64/aarch64-sve-builtins.cc
      	(gimple_folder::convert_and_fold): New function that converts
      	operands to target type before calling callback function, adding the
      	necessary conversion statements.
      	(gimple_folder::redirect_call): Set fntype of redirected call.
      	(get_vector_type): Move from here to aarch64-sve-builtins.h.
      	* config/aarch64/aarch64-sve-builtins.h
      	(gimple_folder::convert_and_fold): Declare function.
      	(get_vector_type): Move here as inline function.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/aarch64/sve/acle/asm/mul_u8.c: Adjust expected outcome.
      	* gcc.target/aarch64/sve/acle/asm/mul_u16.c: Likewise.
      	* gcc.target/aarch64/sve/acle/asm/mul_u32.c: Likewise.
      	* gcc.target/aarch64/sve/acle/asm/mul_u64.c: New test and adjust
      	expected outcome.
      f9c99d40
    • Eric Botcazou's avatar
      Ada: fix spurious relinking of gnatbind for cross compilers · 144ddb0c
      Eric Botcazou authored
      The problem has been introduced by r15-1881.
      
      gcc/ada
      	PR ada/118247
      	* gcc-interface/Make-lang.in (GNATTOOLS_CROSS_MV): Copy gnatbind
      	instead of moving it.
      144ddb0c
    • Martin Jambor's avatar
      ipa-cp: Make dumping of bit masks representing -1 nicer · 72b27315
      Martin Jambor authored
      Dumps of the lattices representing bit-values and of propagation
      results of bit-values can print a really long hexadecimal value when
      the bit-value represents -1 (all bits set).  This patch simply detect
      that situation and prints the string "-1" in that case, making the
      dumps somewhat nicer.
      
      gcc/ChangeLog:
      
      2025-01-03  Martin Jambor  <mjambor@suse.cz>
      
      	* ipa-cp.cc (ipcp_print_widest_int): New function.
      	(ipcp_store_vr_results): Use it.
      	(ipcp_bits_lattice::print): Likewise.  Fix formatting.
      72b27315
    • Mark Wielaard's avatar
      tree-switch-conversion: don't apply switch size limit on jump tables · 668cad04
      Mark Wielaard authored
      commit 56946c80 ("gimple: Add limit after which slower switchlower
      algs are used [PR117091] [PR117352]") introduced a limit on the number
      of cases of a switch. It also bails out on finding jump tables if the
      switch is too large. This introduces a compile time regression during
      bootstrap. A riscv bootstrap takes hours longer. Particularly
      insn-attrtab.cc will take hours instead of minutes. Fix this by not
      applying the switch size limit on jump tables.
      
      An alternative would be to implement greedy switch clustering for jump
      tables as is done for switch bitmap clustering.
      
      gcc/ChangeLog:
      
      	PR tree-optimization/118032
      	* tree-switch-conversion.cc (jump_table_cluster::find_jump_tables):
      	Remove param_switch_lower_slow_alg_max_cases check.
      668cad04
    • Tamar Christina's avatar
      AArch64: Implement four and eight chunk VLA concats [PR118272] · 830bead4
      Tamar Christina authored
      The following testcase
      
        #pragma GCC target ("+sve")
        extern char __attribute__ ((simd, const)) fn3 (int, short);
        void test_fn3 (float *a, float *b, double *c, int n)
        {
          for (int i = 0; i < n; ++i)
            a[i] = fn3 (b[i], c[i]);
        }
      
      at -Ofast ICEs because my previous patch only added support for combining 2
      partial SVE vectors into a bigger vector.  However There can also 4 and 8
      piece subvectors.
      
      This patch fixes this by implementing the missing expansions.
      
      gcc/ChangeLog:
      
      	PR target/96342
      	PR target/118272
      	* config/aarch64/aarch64-sve.md (vec_init<mode><Vquad>,
      	vec_initvnx16qivnx2qi): New.
      	* config/aarch64/aarch64.cc (aarch64_sve_expand_vector_init_subvector):
      	Rewrite to support any arbitrary combinations.
      	* config/aarch64/iterators.md (SVE_NO2E): Update to use SVE_NO4E
      	(SVE_NO2E, Vquad): New.
      
      gcc/testsuite/ChangeLog:
      
      	PR target/96342
      	PR target/118272
      	* gcc.target/aarch64/vect-simd-clone-3.c: New test.
      830bead4
    • Eric Botcazou's avatar
      ada: Fix small thinko in previous change to two-pass aggregate expansion · f345ae3e
      Eric Botcazou authored
      We need a type tailored to the base index type to compute the length.
      
      gcc/ada/ChangeLog:
      
      	* exp_aggr.adb (Two_Pass_Aggregate_Expansion): Use the base type of
      	the index type to find the type used to compute the length.
      f345ae3e
    • Eric Botcazou's avatar
      ada: Streamline runtime support of finalization collections · ad8242d6
      Eric Botcazou authored
      Finalization collections are declared as (limited) controlled types so that
      they can be naturally attached to a finalization master, but the same result
      can be achieved by means of (limited) finalizable types, which need not be
      tagged and thus avoid dragging the runtime support of tagged types.
      
      gcc/ada/ChangeLog:
      
      	* libgnat/s-finpri.ads: Remove clause for Ada.Finalization.
      	(Finalization_Collection): Change to limited private type with the
      	Finalizable aspect.
      	(Initialize): Remove "overriding" keyword.
      	(Finalize): Likewise.
      	* libgnat/s-finpri.adb (Initialize): Likewise.
      	(Finalize): Likewise.
      ad8242d6
    • Eric Botcazou's avatar
      ada: Fix predicate involving array indexing rejected in generic package · 0d736433
      Eric Botcazou authored
      The indexing is rejected with the message:
      
        error: reference to current instance of type does not denote a type
      
      when it is applied to a prefix which is the current instance of the type
      to which the predicate is applied.
      
      There is already a specific handling of component selection for this case
      present in Find_Selected_Component, so this adds an equivalent specific
      handling of indexing for this case to Analyze_Indexed_Component_Form.
      
      gcc/ada/ChangeLog:
      
      	PR ada/117569
      	* sem_ch4.adb (Analyze_Indexed_Component_Form): Do not rewrite the
      	node as a type conversion if it is the current instance of a type
      	in a generic unit.
      	* sem_ch8.adb (Find_Selected_Component): Restrict the special case
      	of the current instance of a type to a generic unit.
      0d736433
    • Bob Duff's avatar
      ada: Fix incorrect RM reference in s-imagef.adb · 06bc21f4
      Bob Duff authored
      gcc/ada/ChangeLog:
      
      	* libgnat/s-imagef.adb (Set_Image_Integer):
      	Change "RM A.3.10" to be "RM A.10.9".
      06bc21f4
    • Alexandre Oliva's avatar
      ada: Reduce footprint of C++ exception interoperation support · 2d2b018d
      Alexandre Oliva authored
      The initial C++ base-type exception interoperation support change
      brought all of GNAT.CPP* along with raise-gcc, because of
      [__gnat_]Convert_Caught_Object.  Move that private but pragma-exported
      function to GNAT.CPP.Std.Type_Info, so that it can rely on the C++
      virtual/dispatch calls that justified the introduction of the Ada
      wrapper type, to avoid emulating virtual calls in C or bringing in a
      dependency on the C++ compiler and runtime.
      
      Drop the CharPtr package instantiation, that brought a huge amount of
      unnecessary code, and use string and storage primitives instead, using
      the strcmp builtin directly for the C string compares.
      
      Move the conversion to Ada String in Name to the wrapper interface in
      GNAT.CPP.Std, adjusting the private internal type to shave off a few
      more bytes from the only unit that raise-gcc will still need.
      
      Finally, disable heap finalization for Type_Info_Ptr, to avoid
      dragging in all of the finalization code.  Thank to Eric Botcazou for
      the suggestion.
      
      gcc/ada/ChangeLog:
      
      	* libgnat/g-cppexc.adb (Convert_Caught_Object): Move...
      	* libgnat/g-cstyin.adb (Convert_Caught_Object):  ... here.
      	Use object call notation.
      	(strcmp): New.
      	(Char_Arr, CharPtr, Char_Pointer, To_chars_ptr): Drop.  Do not
      	import Interfaces.C.Pointers.
      	(To_Pointer): Convert from System.Address.
      	(Name_Starts_With_Asterisk): Rename local variable.
      	(Name_Past_Asterisk): Rewrite with System.Address and strcmp.
      	Import System.Storage_Elements.
      	(Equals): Use strcmp.
      	(Before): Fix logic error.  Use strcmp.
      	(Name): Move conversion to String...
      	* libgnat/g-cppstd.adb (Name): ... here.  Import
      	Interfaces.C.Strings.
      	* libgnat/g-cppstd.ads (Type_Info_Ptr): Disable heap
      	finalization.
      	* libgnat/g-cstyin.ads (Name): Change return type.
      2d2b018d
    • Claire Dross's avatar
      ada: Support new SPARK aspect Exit_Cases · f49b098e
      Claire Dross authored
      The aspect Exit_Cases allows annotating a subprogram with a list of
      cases specifying, for all input which satisfy a guard, how the
      subprogram is allowed to terminate. For now, it can only be either
      returning normally or propagating an exception. This contract is not
      checked at runtime, it is only meant for static verification in SPARK.
      
      gcc/ada/ChangeLog:
      
      	* aspects.ads: Add aspect Aspect_Exit_Cases.
      	* contracts.adb (Analyze_Entry_Or_Subprogram_Contract): Handle Exit_Cases.
      	(Expand_Subprogram_Contract): Idem.
      	* einfo-utils.adb (Get_Pragma): Allow Pragma_Exit_Cases.
      	* einfo-utils.ads (Get_Pragma): Idem.
      	* exp_prag.adb (Expand_Pragma_Exit_Cases): Ignore the pragma, currently we don't expand it.
      	* exp_prag.ads (Expand_Pragma_Exit_Cases): Idem.
      	* inline.adb (Remove_Aspects_And_Pragmas): Add Exit_Cases to the list.
      	(Remove_Items): Idem.
      	* par-prag.adb (Last_Arg_Is_Reason): Idem.
      	* sem_ch12.adb: Idem.
      	* sem_ch13.adb: Idem.
      	* sem_util.adb: Idem.
      	* sem_util.ads: Idem.
      	* sinfo.ads: Idem.
      	* snames.ads-tmpl: Add names Name_Exit_Cases, Name_Exception_Raised, and Name_Normal_Return
      	as well as pragma Pragma_Exit_Cases.
      	* sem_prag.adb (Analyze_Exit_Cases_In_Decl_Part): Make sure that a
      	pragma or aspect Exit_Cases is well formed.
      	(Analyze_Pragma): Make sure that a pragma or aspect Exit_Cases is at the right place.
      	* sem_prag.ads (Analyze_Exit_Cases_In_Decl_Part): Declaration.
      	* doc/gnat_rm/implementation_defined_pragmas.rst: Document the Exit_Cases pragma.
      	* doc/gnat_rm/implementation_defined_aspects.rst: Document the Exit_Cases aspect.
      	* gnat_rm.texi: Regenerate.
      f49b098e
    • Bob Duff's avatar
      ada: Correct xref of operator expression function body · e3a67dcc
      Bob Duff authored
      For an expression function body that is an operator,
      make sure the xref entry in the ALI file points one past the
      double quote mark. For example, if the name is ">", point
      to the greater-than symbol, not the double quote.
      This was already the case for proper bodies.
      
      gcc/ada/ChangeLog:
      
      	* sem_util.adb (Copy_Subprogram_Spec): When copying
      	an N_Defining_Operator_Symbol, create an
      	N_Defining_Operator_Symbol rather than an N_Defining_Identifier.
      	This will cause Lib.Xref to "skip the initial quote for
      	navigation purposes" (as per comments in Lib.Xref body).
      e3a67dcc
    • Eric Botcazou's avatar
      ada: Small housekeeping work in Exp_Aggr · e4ed78fa
      Eric Botcazou authored
      This moves a few declarations around and tweaks a few comments.
      
      gcc/ada/ChangeLog:
      
      	* exp_aggr.adb (Case_Table_Type): Fix reference in comment.
      	(In_Place_Assign_OK): Move declaration around.
      	(Is_Build_In_Place_Aggregate_Return): Likewise and adjust.
      	(Expand_Array_Aggregate): Streamline for the sake of consistency.
      	(Aggr_Assignment_OK_For_Backend): Remove reference to Gigi/gcc.
      	(Backend_Processing_Possible): Likewise.
      	(Expand_Array_Aggregate): Add comment.
      e4ed78fa
    • Bob Duff's avatar
      ada: cleanup documentation for shift and rotate · 3861ac19
      Bob Duff authored
      Documentation updated.
      
      gcc/ada/ChangeLog:
      
      	* sinfo.ads (Shift_Count_OK): Update comments.
      	(Is_Power_Of_2_For_Shift): Likewise.
      3861ac19
    • Eric Botcazou's avatar
      ada: Fix memory leak when failing to initialize newly allocated memory · 7067e6f6
      Eric Botcazou authored
      This makes the compiler generate cleanup code to deallocate the memory when
      the evaluation of the expression of an allocator raises an exception, if the
      expression is a call to a function that may raise, i.e. is not declared with
      the No_Raise aspect/pragma.  This can also be disabled by means of -gnatdQ.
      
      gcc/ada/ChangeLog:
      
      	* debug.adb (dQ): Document usage.
      	* exp_ch4.ads (Build_Cleanup_For_Allocator): New declaration.
      	* exp_ch4.adb (Build_Cleanup_For_Allocator): New procedure.
      	(Expand_Allocator_Expression): Build a cleanup to deallocate the
      	memory when the evaluation of the expression raises an exception.
      	* exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Likewise.
      	* exp_util.adb (Build_Allocate_Deallocate_Proc): Do not generate the
      	detachment if the deallocation is for the cleanup of an allocator.
      	* gen_il-fields.ads (Opt_Field_Enum): Add For_Allocator.
      	* gen_il-gen-gen_nodes.adb (N_Free_Statement): Likewise.
      	* sinfo.ads (For_Allocator): Document usage on N_Free_Statement.
      7067e6f6
    • Eric Botcazou's avatar
      ada: Fix assertion failure on 'Old in post-condition with -gnat2022 · 6be06ae8
      Eric Botcazou authored
      It comes from a small oversight in the updated implementation for Ada 2022.
      
      gcc/ada/ChangeLog:
      
      	PR ada/117956
      	* sem_util.adb (Is_Known_On_Entry): Be prepared for constants coming
      	from a renaming declaration.
      6be06ae8
    • Tonu Naks's avatar
      ada: Declare that the new argument may not be used · 75e126db
      Tonu Naks authored
      gcc/ada/ChangeLog:
      
      	* adaint.c (__gnat_locate_exec_on_path): modify function signature
      75e126db
    • Piotr Trojanek's avatar
      ada: Fix crash on Depends contract with homonym functions · 798873d2
      Piotr Trojanek authored
      When resolving names in flow contracts, we refine the ordinary analysis by
      knowing that an overloaded name must refer to an abstract state and not a
      function. However, when all overloadings refer to function, we shouldn't
      crash, but instead let the error to be diagnosed later.
      
      gcc/ada/ChangeLog:
      
      	* sem_prag.adb (Resolve_State): Continue ordinary processing.
      798873d2
    • Javier Miranda's avatar
      ada: Crash in prefix notation with access to class-wide object · 0216cca1
      Javier Miranda authored
      The compiler crashes analyzing a prefix notation call when its
      prefix is an access to a class-wide object, an actual parameter
      is missing, and the sources are compiled with language extensions
      (-gnatX) and full errors (-gnatf).
      
      gcc/ada/ChangeLog:
      
      	* sem_ch4.adb (Try_Object_Operation): if no candidate interpretation
      	matches the context, redo the same analysis with Report_Error True
      	to report the error.
      0216cca1
    • Eric Botcazou's avatar
      ada: Plug small loophole in previous change · 145314b3
      Eric Botcazou authored
      The initial change only deals with the controlled record case for assignment
      statements, but the controlled array case needs the same treatment.
      
      gcc/ada/ChangeLog:
      
      	* exp_ch5.adb (Expand_Assign_Array): Bail out for controlled
      	components if the RHS is a function call and the assignment has
      	the No_Ctrl_Actions flag set.
      145314b3
    • Viljar Indus's avatar
      ada: Fix printing boolean attributes in the SARIF report · d47596b4
      Viljar Indus authored
      Boolean attributes should have the value true or false
      without any quotes.
      
      gcc/ada/ChangeLog:
      
      	* diagnostics-json_utils.adb: Add new method
      	Write_Boolean_Attribute.
      	* diagnostics-json_utils.ads: Likewise.
      	* diagnostics-sarif_emitter.adb (Print_Invocations): print
      	the executionSuccesful property value without extra quotes.
      d47596b4
    • Viljar Indus's avatar
      ada: Remove level attribute from Rules in the SARIF report · b4c9ba20
      Viljar Indus authored
      A Rule object in the SARIF report does not have a level
      attribute. Result objects are the elements in the SARIF
      reprot that have a level attribute that ultimately determines
      the level of each diagnostic object.
      
      Rules can have a defaultConfiguration attribute which has a level
      attribute that can be overridden in multiple ways. This can make
      the overall report more complex than it needs to be. It is simpler
      to remove the attribute from rules where it does not really matter
      and add it back in under the defaultConfiguration when there is an
      explicit need for it.
      
      gcc/ada/ChangeLog:
      
      	* diagnostics-sarif_emitter.adb (Print_Rule): Remove printing
      	of the level attribute since it does not match the SARIF schema.
      b4c9ba20
    • Piotr Trojanek's avatar
      ada: Avoid null-exclusion checks for Node_Field_Table · 92d50b9d
      Piotr Trojanek authored
      By generating the type of Node_Field_Table with a "not null" qualifier
      we check the null exclusion of its elements only once, at the object
      declaration.
      
      Tiny performance improvement for the debug builds (because in production
      builds checks are disabled anyway); semantics is unaffected.
      
      gcc/ada/ChangeLog:
      
      	* gen_il-gen.adb (Put_Tables): Add "not null" to the generated code.
      	* rtsfind.adb (Cstring_Ptr): Same for table with predefined RE_Id
      	error messages.
      	* impunit.adb (Aunit_Record): Same for array of alternative unit names.
      92d50b9d
    • Piotr Trojanek's avatar
      ada: Ada version used to compile runtime is constant · a172d6cf
      Piotr Trojanek authored
      Code cleanup.
      
      gcc/ada/ChangeLog:
      
      	* opt.ads (Ada_Version_Runtime): Now a constant, since it cannot
      	and should never be modified.
      a172d6cf
    • Bob Duff's avatar
      ada: null procedure cannot be used as compilation unit · 2a38c233
      Bob Duff authored
      This patch gives a syntax error if a null procedure is used as
      a compilation unit. The error was already given during semantic
      analysis; now it is given in the parser, which is more convenient
      for other tools like gprbuild, because the -gnats switch now
      gives the error.
      
      Note that the old message "null procedure cannot be declared at library
      level" was wrong; "library level" is not the same thing as "is a library
      unit".
      
      gcc/ada/ChangeLog:
      
      	* par-ch10.adb (P_Compilation_Unit): Give an error for "is null".
      	* sem_ch10.adb (Analyze_Subunit): Remove check for "is null"
      	as a subunit.
      	* sem_ch6.adb (Analyze_Subprogram_Declaration):
      	Remove check for "is null" as a library unit.
      2a38c233
    • Javier Miranda's avatar
      ada: Cleanup preanalysis of static expressions · fd52383f
      Javier Miranda authored
      Complete previous patch; required to avoid regressions in GNATProve.
      
      gcc/ada/ChangeLog:
      
      	* sem_ch6.adb (Analyze_Expression_Function): Set the parent of
      	the new node to be the parent of the original to get the proper
      	context, which is needed for complete error reporting and for
      	semantic analysis. Patch suggested by Eric Botcazou.
      fd52383f
    • Alexandre Oliva's avatar
      ada: C++ exception hierarchies: adjust for gnat-llvm · b8a94b0b
      Alexandre Oliva authored
      
      gnat-llvm doesn't support C++ imports, so arrange for the GNAT.CPP*
      units to be omitted from gnat-llvm builds.
      
      Drop G++ exception interoperability support from raise-gcc.c, so as to
      not require the GNAT.CPP* units that define some of the required
      symbols.
      
      Co-Authored-By: default avatarOlivier Hainque <hainque@adacore.com>
      
      gcc/ada/ChangeLog:
      
      	* Makefile.rtl (LLVM_BUILD): Define based on LLVM_CONFIG.
      	(GNATRTL_NONTASKING_OBJS): Make g-cpp, g-cppstd, and g-cstyin
      	conditional on -gcc or -arm EH, and on no LLVM_BUILD.
      	* raise-gcc.c (GXX_EH_INTEROP): Define as 0 on gnat-llvm or
      	CERT, and 1 otherwise.
      	(__gnat_get_cxx_dependent_exception) Omit on !GXX_EH_INTEROP.
      	(__gnat_maybe_get_cxx_dependent_exception): Likewise.
      	(__gnat_get_cxx_exception_type_info): Likewise.
      	(__gnat_obtain_caught_object): Likewise.
      	(is_handled_by): Omit eid parameter and G++ interop on
      	!GXX_EH_INTEROP.  Adjust callers.
      b8a94b0b
    • Eric Botcazou's avatar
      ada: Elide copy for calls as default values of nonlimited by-reference components · 0fe74112
      Eric Botcazou authored
      This prevents a temporary from being created on the primary stack to hold
      the result of the function calls before it is copied to the object being
      elaborated in the nonlimited by-reference case.
      
      That's already not done in the nonlimited non-by-reference case and there is
      no reason to do it in the former case either.  The main issue are the calls
      to Remove_Side_Effects in Expand_Ctrl_Function_Call (controlled case only)
      and in Expand_N_Assignment_Statement, which serve various purposes including
      very technical ones beside removing side effects.
      
      The change is therefore very conservative and only removes the copy in the
      case of a naked function call for the time being.
      
      gcc/ada/ChangeLog:
      
      	* einfo.ads (Returns_By_Ref): Fix description.
      	* exp_ch3.adb (Build_Record_Init_Proc.Build_Assignment): Do not
      	adjust the component manually (if need be), set No_Finalize_Actions
      	instead of No_Ctrl_Actions for this purpose.  Do not adjust when
      	the expression is a naked function call.
      	* exp_ch5.adb (Make_Tag_Ctrl_Assignment): Document the quirks of
      	the function.  Assert that the LHS of the assignment does not have
      	side effects and replace calls to Duplicate_Subexpr_No_Checks with
      	calls to New_Copy_Tree.  Rename local variable Asn to New_N.
      	(Expand_N_Assignment_Statement): In the tagged or controlled record
      	case, do remove side effects from both operands on entry.  Remove
      	them in the controlled record case, except if the RHS is a function
      	call and the assignment has the No_Ctrl_Actions flag set.
      	* exp_ch6.adb (Expand_Ctrl_Function_Call): Bail out when the parent
      	node is an assignment statement with the No_Ctrl_Actions flag set.
      	* sem_util.adb (Statically_Different): Return True for a function
      	call that does not return its result by reference.
      	* sinfo.ads (No_Ctrl_Actions): Adjust description and add a note for
      	the code generator.
      	(No_Finalize_Actions): Likewise.
      0fe74112
Loading