Commit Graph

162088 Commits

Author SHA1 Message Date
H.J. Lu
97cad5113b libitm/x86: Correct offsets of __private_tm and pointer_guard
In glibc, sysdeps/i386/nptl/tls.h has

typedef struct
{
  void *tcb;            /* Pointer to the TCB.  Not necessarily the
                           thread descriptor used by libpthread.  */
  dtv_t *dtv;
  void *self;           /* Pointer to the thread descriptor.  */
  int multiple_threads;
  uintptr_t sysinfo;
  uintptr_t stack_guard;
  uintptr_t pointer_guard;
  int gscope_flag;
  int __glibc_reserved1;
  /* Reservation of some values for the TM ABI.  */
  void *__private_tm[4];
  /* GCC split stack support.  */
  void *__private_ss;
} tcbhead_t;

and sysdeps/x86_64/nptl/tls.h has

typedef struct
{
  void *tcb;            /* Pointer to the TCB.  Not necessarily the
                           thread descriptor used by libpthread.  */
  dtv_t *dtv;
  void *self;           /* Pointer to the thread descriptor.  */
  int multiple_threads;
  int gscope_flag;
  uintptr_t sysinfo;
  uintptr_t stack_guard;
  uintptr_t pointer_guard;
  unsigned long int vgetcpu_cache[2];
  int __glibc_reserved1;
  int __glibc_unused1;
  /* Reservation of some values for the TM ABI.  */
  void *__private_tm[4];
  /* GCC split stack support.  */
  void *__private_ss;
  long int __glibc_reserved2;
  /* Must be kept even if it is no longer used by glibc since programs,
     like AddressSanitizer, depend on the size of tcbhead_t.  */
  __128bits __glibc_unused2[8][4] __attribute__ ((aligned (32)));

  void *__padding[8];
} tcbhead_t;

The offsets of __private_tm are

i386:   36 bytes
x32:    48 bytes
x86_64: 80 bytes

and the offsets of pointer_guard are:

i386:   24 bytes
x32:    28 bytes
x86_64: 48 bytes

But config/linux/x86/tls.h had

 #ifdef __x86_64__
 #ifdef __LP64__
 # define SEG_READ(OFS)          "movq\t%%fs:(" #OFS "*8),%0"
 # define SEG_WRITE(OFS)         "movq\t%0,%%fs:(" #OFS "*8)"
 # define SEG_DECODE_READ(OFS)   SEG_READ(OFS) "\n\t" \
                                 "rorq\t$17,%0\n\t" \
                                 "xorq\t%%fs:48,%0"
 # define SEG_ENCODE_WRITE(OFS)  "xorq\t%%fs:48,%0\n\t" \
                                 "rolq\t$17,%0\n\t" \
                                 SEG_WRITE(OFS)
 #else
 // For X32.
 # define SEG_READ(OFS)          "movl\t%%fs:(" #OFS "*4),%0"
 # define SEG_WRITE(OFS)         "movl\t%0,%%fs:(" #OFS "*4)"
 # define SEG_DECODE_READ(OFS)   SEG_READ(OFS) "\n\t" \
                                 "rorl\t$9,%0\n\t" \
                                 "xorl\t%%fs:24,%0"
 # define SEG_ENCODE_WRITE(OFS)  "xorl\t%%fs:24,%0\n\t" \
                                 "roll\t$9,%0\n\t" \
                                 SEG_WRITE(OFS)
 #endif
 #else
 # define SEG_READ(OFS)  "movl\t%%gs:(" #OFS "*4),%0"
 # define SEG_WRITE(OFS) "movl\t%0,%%gs:(" #OFS "*4)"
 # define SEG_DECODE_READ(OFS)   SEG_READ(OFS) "\n\t" \
                                 "rorl\t$9,%0\n\t" \
                                 "xorl\t%%gs:24,%0"
 # define SEG_ENCODE_WRITE(OFS)  "xorl\t%%gs:24,%0\n\t" \
                                 "roll\t$9,%0\n\t" \
                                 SEG_WRITE(OFS)
 #endif

static inline struct gtm_thread *gtm_thr(void)
{
  struct gtm_thread *r;
  asm volatile (SEG_READ(10) : "=r"(r));
  return r;
}

static inline void set_gtm_thr(struct gtm_thread *x)
{
  asm volatile (SEG_WRITE(10) : : "r"(x));
}

static inline struct abi_dispatch *abi_disp(void)
{
  struct abi_dispatch *r;
  asm volatile (SEG_DECODE_READ(11) : "=r"(r));
  return r;
}

static inline void set_abi_disp(struct abi_dispatch *x)
{
  void *scratch;
  asm volatile (SEG_ENCODE_WRITE(11) : "=r"(scratch) : "0"(x));
}

SEG_READ, SEG_WRITE, SEG_DECODE_READ and SEG_ENCODE_WRITE were correct
only for x86-64.

Update SEG_READ and SEG_WRITE to use the offset of __private_tm as base
and correct the offset of pointer_guard for x32.  This patch doesn't
change ABI of libitm.

	PR libitm/85988
	* config/linux/x86/tls.h (SEG_READ): Use the offset of
	__private_tm as base.
	(SEG_WRITE): Likewise.
	(SEG_ENCODE_WRITE): Correct the offset of pointer_guard for x32.
	(gtm_thr): Replace SEG_READ(10) with SEG_READ(0).
	(set_gtm_thr): Replace SEG_WRITE(10) with SEG_WRITE(0).
	(abi_disp): Replace SEG_DECODE_READ(11) with SEG_DECODE_READ(1).
	(set_abi_disp): Replace SEG_ENCODE_WRITE(11) with
	SEG_ENCODE_WRITE(1).

From-SVN: r261491
2018-06-12 04:08:52 -07:00
Matthew Fortune
6a3361e8d4 MIPS: Add i6500 processor as an alias for i6400.
gcc/ChangeLog:

2018-06-12  Matthew Fortune  <mfortune@gmail.com>

	* config/mips/mips-cpus.def: New MIPS_CPU for i6500.
	* config/mips/mips-tables.opt: Regenerate.
	* config/mips/mips.h (MIPS_ISA_LEVEL_SPEC): Mark i6500 as
	mips64r6.
	* doc/invoke.texi: Document -march=i6500.

From-SVN: r261490
2018-06-12 10:36:12 +00:00
Prachi Godbole
b74161d05d MIPS: Update I6400 scheduler.
gcc/ChangeLog:

2018-06-12  Prachi Godbole  <prachi.godbole@imgtec.com>

	* config/mips/i6400.md (i6400_gpmuldiv): Remove cpu_unit.
	(i6400_gpmul): Add cpu_unit.
	(i6400_gpdiv): Likewise.
	(i6400_msa_add_d): Update reservations.
	(i6400_msa_int_add) Likewise.
	(i6400_msa_short_logic3) Likewise.
	(i6400_msa_short_logic2) Likewise.
	(i6400_msa_short_logic) Likewise.
	(i6400_msa_move) Likewise.
	(i6400_msa_cmp) Likewise.
	(i6400_msa_short_float2) Likewise.
	(i6400_msa_div_d) Likewise.
	(i6400_msa_long_logic1) Likewise.
	(i6400_msa_long_logic2) Likewise.
	(i6400_msa_mult) Likewise.
	(i6400_msa_long_float2) Likewise.
	(i6400_msa_long_float4) Likewise.
	(i6400_msa_long_float5) Likewise.
	(i6400_msa_long_float8) Likewise.
	(i6400_fpu_fadd): Include frint type.
	(i6400_fpu_store): New define_insn_reservation.
	(i6400_fpu_load): Likewise.
	(i6400_fpu_move): Likewise.
	(i6400_fpu_fcmp): Likewise.
	(i6400_fpu_fmadd): Likewise.
	(i6400_int_mult): Include imul3nc type and update reservation.
	(i6400_int_div): Include idiv3 type and update reservation.
	(i6400_int_load): Update to check type not move_type.
	(i6400_int_store): Likewise.
	(i6400_int_prefetch): Set zero latency.

From-SVN: r261489
2018-06-12 10:35:46 +00:00
Eric Botcazou
57d0f7c6d7 ada-tree.h (TYPE_RETURN_BY_DIRECT_REF_P): Change from using TYPE_LANG_FLAG_4 to using TYPE_LANG_FLAG_0.
* gcc-interface/ada-tree.h (TYPE_RETURN_BY_DIRECT_REF_P): Change from
	using TYPE_LANG_FLAG_4 to using TYPE_LANG_FLAG_0.
	(TYPE_ALIGN_OK): Move around.
	(TYPE_PADDING_FOR_COMPONENT): Remove superfluous parentheses.
	* gcc-interface/decl.c (change_qualified_type): Move to...
	(gnat_to_gnu_entity): Adjust comment.
	* gcc-interface/gigi.h (change_qualified_type): ...here; make inline.
	(ceil_pow2): Use ceil_log2.
	* gcc-interface/utils.c (finish_subprog_decl): Add couple of comments
	and do not set TREE_SIDE_EFFECTS.
	(handle_noreturn_attribute): Use change_qualified_type.

From-SVN: r261486
2018-06-12 10:34:26 +00:00
Eric Botcazou
541bb35d87 decl.c (gnat_to_gnu_entity): Do not get the expression of a dispatch table that is not being defined.
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Constant>: Do not get
	the expression of a dispatch table that is not being defined.
	<E_Record_Subtype>: Remove obsolete kludge.

From-SVN: r261483
2018-06-12 10:19:40 +00:00
Eric Botcazou
81034751aa decl.c (warn_on_field_placement): Use specific wording for discriminants.
* gcc-interface/decl.c (warn_on_field_placement): Use specific wording
	for discriminants.
	(warn_on_list_placement): New static function.
	(components_to_record): Use it to warn on multiple fields in list.

From-SVN: r261480
2018-06-12 10:01:36 +00:00
Eric Botcazou
cd8ad45920 decl.c (variant_desc): Add AUX field.
* gcc-interface/decl.c (variant_desc): Add AUX field.
	(gnat_to_gnu_entity) <discrete_type>: Do not call compute_record_mode
	directly.
	(reverse_sort_field_list): New static function.
	(components_to_record): Place the variant part at the beginning of the
	field list when there is an obvious order of increasing position.
	(build_variant_list): Initialize it.
	(create_variant_part_from): Do not call compute_record_mode directly.
	(copy_and_substitute_in_layout): Likewise.  Always sort the fields with
	fixed position in order of increasing position, in the record and all
	the variants, in any.  Call reverse_sort_field_list.
	* gcc-interface/utils.c (make_packable_type): Compute the sizes before
	calling finish_record_type.  Do not call compute_record_mode directly.
	(finish_record_type): Overhaul final processing depending on REP_LEVEL
	and call finish_bitfield_layout if it is equal to one or two.

From-SVN: r261479
2018-06-12 09:51:26 +00:00
Tom de Vries
835d417373 [testsuite] Add gcc.dg-selftests/dg-final.exp
2018-06-12  Tom de Vries  <tdevries@suse.de>

	* gcc.dg-selftests/dg-final.exp: New file.

From-SVN: r261476
2018-06-12 08:37:47 +00:00
Martin Liska
d23fa2eee0 Remove me from Write After Approval.
From-SVN: r261475
2018-06-12 08:27:13 +00:00
Eric Botcazou
e7208389c8 gcc.c: Document new %@{...} sequence.
* gcc.c: Document new %@{...} sequence.
	(LINK_COMMAND_SPEC): Use it for the -L switches.
	(cpp_unique_options): Use it for the -I switches.
	(at_file_argbuf): New global variable.
	(in_at_file): Likewise.
	(alloc_args): Create at_file_argbuf.
	(clear_args): Truncate at_file_argbuf.
	(store_arg): If in_at_file, push the argument onto at_file_argbuf.
	(open_at_file): New function.
	(close_at_file): Likewise.
	(create_at_file): Delete.
	(do_spec_1) <'i'>: Use open_at_file/close_at_file.
	<'o'>: Likewise.
	<'@'>: New case.
	(validate_switches_from_spec): Deal with %@{...} sequence.
	(validate_switches): Likewise.
	(driver::finalize): Call clear_args.

From-SVN: r261474
2018-06-12 06:52:55 +00:00
GCC Administrator
bfad8f6640 Daily bump.
From-SVN: r261472
2018-06-12 00:16:30 +00:00
Jason Merrill
ee7ae7ae1b PR c++/85792 -Wctor-dtor-privacy and inherited constructor.
* class.c (maybe_warn_about_overly_private_class): Handle inherited
	constructors.

From-SVN: r261459
2018-06-11 17:49:36 -04:00
Jason Merrill
c7e2d7adf0 PR c++/85963 - -Wunused-but-set with ?: in template.
* pt.c (tsubst_copy_and_build) [COND_EXPR]: Call mark_rvalue_use.

From-SVN: r261458
2018-06-11 17:49:30 -04:00
Rasmus Villemoes
8731c0fbbd vx-common.h (USE_TM_CLONE_REGISTRY): #define to 0.
2018-06-11  Rasmus Villemoes  <rasmus.villemoes@prevas.dk>

	* config/vx-common.h (USE_TM_CLONE_REGISTRY): #define to 0.

From-SVN: r261457
2018-06-11 15:39:10 -06:00
Paolo Carlini
dc327375bc decl.c (grok_op_properties): Consistently use the location of the decl...
/cp
2018-06-11  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl.c (grok_op_properties): Consistently use the location
	of the decl; remove special casing of POSTINCREMENT_EXPR and
	POSTDECREMENT_EXPR wrt default arguments.

/testsuite
2018-06-11  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/lookup/new2.C: Test locations too.
	* g++.dg/other/ellipsis1.C: Likewise.
	* g++.dg/other/operator1.C: Likewise.
	* g++.dg/other/operator2.C: Likewise.
	* g++.dg/overload/operator2.C: Likewise.
	* g++.dg/parse/defarg11.C: Likewise.
	* g++.dg/parse/operator4.C: Likewise.
	* g++.dg/template/error30.C: Likewise.
	* g++.dg/template/explicit-args3.C: Likewise.
	* g++.dg/warn/effc1.C: Likewise.
	* g++.old-deja/g++.brendan/prepost2.C: Likewise.
	* g++.old-deja/g++.brendan/prepost3.C: Likewise.
	* g++.old-deja/g++.bugs/900215_01.C: Likewise.
	* g++.old-deja/g++.jason/conversion5.C: Likewise.
	* g++.old-deja/g++.jason/operator.C: Likewise.

From-SVN: r261456
2018-06-11 21:13:41 +00:00
Paolo Carlini
fafd0db149 decl.c (grok_op_properties): Consistently use the location of the decl...
/cp
2018-06-11  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl.c (grok_op_properties): Consistently use the location
	of the decl; remove special casing of POSTINCREMENT_EXPR and
	POSTDECREMENT_EXPR wrt default arguments.

/testsuite
2018-06-11  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/lookup/new2.C: Test locations too.
	* g++.dg/other/ellipsis1.C: Likewise.
	* g++.dg/other/operator1.C: Likewise.
	* g++.dg/other/operator2.C: Likewise.
	* g++.dg/overload/operator2.C: Likewise.
	* g++.dg/parse/defarg11.C: Likewise.
	* g++.dg/parse/operator4.C: Likewise.
	* g++.dg/template/error30.C: Likewise.
	* g++.dg/template/explicit-args3.C: Likewise.
	* g++.dg/warn/effc1.C: Likewise.
	* g++.old-deja/g++.brendan/prepost2.C: Likewise.
	* g++.old-deja/g++.brendan/prepost3.C: Likewise.
	* g++.old-deja/g++.bugs/900215_01.C: Likewise.
	* g++.old-deja/g++.jason/conversion5.C: Likewise.
	* g++.old-deja/g++.jason/operator.C: Likewise.

From-SVN: r261455
2018-06-11 21:13:19 +00:00
Jason Merrill
9b0607def4 Fix ptrmem comparison for unions.
* constexpr.c (cxx_eval_binary_expression): Special case comparison
	of pointers to members of the same union.

From-SVN: r261454
2018-06-11 17:01:23 -04:00
Martin Sebor
960a58b949 invoke.texi (-Wall): List -Wc++17-compat.
gcc/ChangeLog:

	* doc/invoke.texi (-Wall): List -Wc++17-compat.
	(Wno-class-memaccess): Add @opindex.
	(Wno-templates, Wno-multiple-inheritance): Same.
	(Wno-virtual-inheritance, Wno-namespaces): Same.
	(Wno-pedantic, Wno-chkp, Wcoverage-mismatch): Same.
	(Wno-format-overflow, Wno-format-truncation): Same.
	(Wno-unused-local-typedefs, Walloc-size-larger-than): Same.
	(Wno-alloc-size-larger-than, Wframe-larger-than): Same
	(Wno-stack-usage, Wno-c++-compat, Wno-c++11-compat): Same.
	(Wno-c++14-compat, Wno-c++17-compat, Wno-openmp-simd): Same.
	(Wno-unsuffixed-float-constants, Wno-addr-space-convert): Same.
	(Wno-misspelled-isr): Same.

From-SVN: r261453
2018-06-11 14:32:24 -06:00
Martin Sebor
223c63e62a PR tree-optimization/86083 - handle non-constant assignments in strlen
gcc/ChangeLog:

	PR tree-optimization/86083
	* tree-ssa-strlen.c (handle_char_store): Use tree_expr_nonzero_p.

gcc/testsuite/ChangeLog:

	PR tree-optimization/86083
	* gcc.dg/strlenopt-44.c: New test.

From-SVN: r261452
2018-06-11 14:01:40 -06:00
Ian Lance Taylor
87cbbc45a9 libgo: add riscv and js/wasm as known targets
Incorporates cut down versions of https://golang.org/cl/102835 and
    https://golang.org/cl/106256 from the master sources.
    
    This will tell go/build to skip files with those tags.
    
    Reviewed-on: https://go-review.googlesource.com/117996

From-SVN: r261451
2018-06-11 19:16:34 +00:00
Zhouyi Zhou
c5ce6f3088 tree-eh.c (lower_eh_constructs_2): Add a comma to comment.
2018-06-11 Zhouyi Zhou <zhouzhouyi@gmail.com>

	* tree-eh.c (lower_eh_constructs_2): Add a comma to comment.

From-SVN: r261450
2018-06-11 13:13:01 -06:00
Janus Weil
c7927c3bb8 re PR fortran/45521 ([F08] GENERIC resolution with ALLOCATABLE/POINTER and PROCEDURE)
2018-06-11  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/45521
	* interface.c (compare_ptr_alloc): New function.
	(generic_correspondence): Call it.


2018-06-11  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/45521
	* gfortran.dg/generic_32.f90: New test.
	* gfortran.dg/generic_33.f90: New test.

From-SVN: r261448
2018-06-11 20:44:38 +02:00
Jason Merrill
46e318cff7 PR c++/86094 - wrong code with defaulted move ctor.
* tree.c (type_has_nontrivial_copy_init): Fix move ctor handling.

From-SVN: r261444
2018-06-11 14:38:52 -04:00
Jason Merrill
641c8da29b * doc/invoke.texi: Document -fabi-version=12.
From-SVN: r261443
2018-06-11 14:38:46 -04:00
Joseph Myers
61362140d7 * fr.po: Update.
From-SVN: r261439
2018-06-11 18:07:56 +01:00
Carl Love
26029dbef7 altivec-7.c (main): Remove tests vec_unpackh(vecubi[0]) and vec_unpackl(vecubi[0]) returning long...
gcc/testsuite/ChangeLog:

2018-06-11  Carl Love  <cel@us.ibm.com>
	* gcc.target/powerpc/altivec-7.c (main): Remove tests
	vec_unpackh(vecubi[0]) and vec_unpackl(vecubi[0]) returning
	long long bool.  Remove duplicate dg-final for xxlxor.  Update
	dg-final instruction counts.
	* gcc.target/powerpc/altivec-37.c (main): New file for
	tests vec_unpackh and vec_unpackl returning long long bool and
	long long int.

From-SVN: r261438
2018-06-11 16:38:42 +00:00
Segher Boessenkool
ee6760c291 rs6000: Put constraints on the correct operand in movdi (PR85755)
Some of the mov* patterns use ^ and $ constraint modifiers, which mean
give a penalty to this alternative if this operand needs a reload.  They
are meant here to give a penalty if a register operand needs reloading
(because it needs to be in a different kind of register), not when a
memory operand needs reloading (which is easy and cheap to do).

This patch fixes the movdi patterns.  This fixes PR85755.

The following are changed (name, old constraints, new constraints):
FPR store   ^m := d     m := ^d
FPR move    ^d := d     ^d := ^d
AVX store   ^wY := wb   wY := ^wb
AVX store   $Z := wv    Z := $wv
VSX move    ^wi := wi   ^wi := ^wi


	PR target/85755
	* config/rs6000/rs6000.md (*movdi_internal32): Put constraint modifiers
	on the correct operand.
	(*movdi_internal64): Ditto.

---
 gcc/config/rs6000/rs6000.md | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index a2605a0..f06591f 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -8567,16 +8567,16 @@ (define_insn_and_split "reload_gpr_from_vsxsf"
 
 (define_insn "*movdi_internal32"
   [(set (match_operand:DI 0 "nonimmediate_operand"
-         "=Y,        r,         r,         ^m,        ^d,         ^d,
-          r,         ^wY,       $Z,        ^wb,       $wv,        ^wi,
+         "=Y,        r,         r,         m,         ^d,         ^d,
+          r,         wY,        Z,         ^wb,       $wv,        ^wi,
           *wo,       *wo,       *wv,       *wi,       *wi,        *wv,
           *wv")
 
 	(match_operand:DI 1 "input_operand"
-          "r,        Y,         r,         d,         m,          d,
-           IJKnGHF,  wb,        wv,        wY,        Z,          wi,
-           Oj,       wM,        OjwM,      Oj,        wM,         wS,
-           wB"))]
+         "r,         Y,         r,         ^d,        m,          ^d,
+          IJKnGHF,   ^wb,       $wv,       wY,        Z,          ^wi,
+          Oj,        wM,        OjwM,      Oj,        wM,         wS,
+          wB"))]
 
   "! TARGET_POWERPC64
    && (gpc_reg_operand (operands[0], DImode)
@@ -8643,17 +8643,17 @@ (define_split
 (define_insn "*movdi_internal64"
   [(set (match_operand:DI 0 "nonimmediate_operand"
                "=YZ,       r,         r,         r,         r,          r,
-                ^m,        ^d,        ^d,        ^wY,       $Z,         $wb,
+                m,         ^d,        ^d,        wY,        Z,          $wb,
                 $wv,       ^wi,       *wo,       *wo,       *wv,        *wi,
                 *wi,       *wv,       *wv,       r,         *h,         *h,
                 ?*r,       ?*wg,      ?*r,       ?*wj")
 
 	(match_operand:DI 1 "input_operand"
-                "r,        YZ,        r,         I,         L,          nF,
-                 d,        m,         d,         wb,        wv,         wY,
-                 Z,        wi,        Oj,        wM,        OjwM,       Oj,
-                 wM,       wS,        wB,        *h,        r,          0,
-                 wg,       r,         wj,        r"))]
+               "r,         YZ,        r,         I,         L,          nF,
+                ^d,        m,         ^d,        ^wb,       $wv,        wY,
+                Z,         ^wi,       Oj,        wM,        OjwM,       Oj,
+                wM,        wS,        wB,        *h,        r,          0,
+                wg,        r,         wj,        r"))]
 
   "TARGET_POWERPC64
    && (gpc_reg_operand (operands[0], DImode)
-- 
1.8.3.1

From-SVN: r261435
2018-06-11 17:48:48 +02:00
Martin Liska
2dcab30bf7 Fix typo done in MPX removal (PR tree-optimization/86089).
2018-06-11  Martin Liska  <mliska@suse.cz>

        PR tree-optimization/86089
	* tree-ssa-strlen.c (get_string_length): Move back removed hunk.
2018-06-11  Martin Liska  <mliska@suse.cz>

        PR tree-optimization/86089
	* gcc.dg/tree-ssa/pr86089.c: New test.

From-SVN: r261434
2018-06-11 11:47:00 +00:00
Julia Koval
0c5a38a5f7 Remove redundant intrinsics
gcc/
	* config/i386/vaesintrin.h (_mm_aesdec_epi128, _mm_aesdeclast_epi128)
	_mm_aesenc_epi128, _mm_aesenclast_epi128: Remove.
	* config/i386/vpclmulqdqintrin.h (_mm_clmulepi64_epi128): Remove.
gcc/testsuite/
	* gcc.target/i386/avx512fvl-vaes-1.c: Remove 128bit versions from test.
	* gcc.target/i386/vpclmulqdq.c: Ditto.

From-SVN: r261433
2018-06-11 11:10:38 +00:00
Olivier Hainque
5cfcd77147 dwarf2out.c (gen_compile_unit_die): Fallout to DW_LANG_Ada83 for Ada with strict dwarf2.
2018-06-11  Olivier Hainque  <hainque@adacore.com>

        * dwarf2out.c (gen_compile_unit_die): Fallout to DW_LANG_Ada83
        for Ada with strict dwarf2.

	testsuite/

        * gnat.dg/lang-dw2.adb: New test.
        * gnat.dg/lang-dw3.adb: New test.

From-SVN: r261432
2018-06-11 09:42:54 +00:00
Eric Botcazou
259cc9a7e0 [Ada] Fix wrong code for initialization of fat pointer with -Og
2018-06-11  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

	* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Type>: Reuse the
	existing fields of a dummy fat pointer type, if any.  Clear the
	TYPE_DECL_SUPPRESS_DEBUG on the fat pointer type after completing it.

From-SVN: r261431
2018-06-11 09:19:51 +00:00
Hristian Kirtchev
a8531f7134 [Ada] Suppress the expansion of ignored assertion pragmas
This patch suppresses the expansion of ignored assertion pragmas.

2018-06-11  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* contracts.adb (Process_Body_Postconditions): Expand only checked
	postconditions.
	(Process_Contract_Cases_For): Expand only checked contract cases.
	(Process_Inherited_Preconditions): Ignored class-wide preconditions are
	partially expanded because some of their semantic checks are tied to
	the expansion.
	(Process_Preconditions_For): Expand only checked preconditions.
	(Process_Spec_Postconditions): Expand only checked preconditions.
	Ignored class-wide preconditions are partially expanded because some of
	their semantic checks are tied to the expansion.
	* exp_prag.adb (Expand_N_Pragma): Suppress the expansion of ignored
	assertion pragmas.
	* exp_util.adb (Add_Inherited_Invariants): Code clean up.
	* sem_util.adb (Propagate_Invariant_Attributes): Code clean up.

gcc/testsuite/

	* gnat.dg/assertion_policy1.adb, gnat.dg/assertion_policy1_pkg.adb,
	gnat.dg/assertion_policy1_pkg.ads: New testcase.

From-SVN: r261430
2018-06-11 09:19:46 +00:00
Hristian Kirtchev
1985767d65 [Ada] Minor reformatting
2018-06-11  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* exp_ch9.adb, exp_unst.adb, inline.adb, libgnat/a-ciorma.adb,
	libgnat/a-ciormu.adb, libgnat/a-ciorse.adb, libgnat/a-coorma.adb,
	libgnat/a-coormu.adb, libgnat/a-coorse.adb, sem_prag.adb: Minor
	reformatting.

From-SVN: r261429
2018-06-11 09:19:40 +00:00
Gary Dismukes
ed6a6b4ea9 [Ada] Typo fixes and minor reformatting
2018-06-11  Gary Dismukes  <dismukes@adacore.com>

gcc/ada/

	* exp_unst.ads, exp_unst.adb: Typo fixes and minor reformatting.

From-SVN: r261428
2018-06-11 09:19:35 +00:00
Hristian Kirtchev
7d1d3a5464 [Ada] Double finalization of limited controlled result
This patch disables a build-in-place optimization when a function returns a
limited controlled result because the optimization may violate the semantics of
finalizable types by performing illegal calls to Finalize.

In general, the optimization causes the result object of a build-in-place
function to be allocated at the caller site, with a pointer to the object
passed to the function. The function then simply initializes the caller-
allocated object.

This mode of operation however violates semantics of finalizable types when
the context of the call is allocation. The act of allocating the controlled
object at the caller site will place it on the associated access type's
finalization master. If the function fails the initialization of the object,
the malformed object will still be finalized when the finalization master
goes out of scope. This is dangerous, and must not happen.

------------
-- Source --
------------

--  pack.ads

with Ada.Finalization; use Ada.Finalization;

package Pack is
   type Lim_Ctrl is new Limited_Controlled with null record;
   procedure Finalize (Obj : in out Lim_Ctrl);

   type Lim_Ctrl_Ptr is access all Lim_Ctrl;

   function Make_Lim_Ctrl_Bad_Init return Lim_Ctrl;
   function Make_Lim_Ctrl_OK_Init return Lim_Ctrl;
end Pack;

--  pack.adb

with Ada.Text_IO; use Ada.Text_IO;

package body Pack is
   procedure Finalize (Obj : in out Lim_Ctrl) is
   begin
      Put_Line ("     Finalize");
   end Finalize;

   function Make_Lim_Ctrl_Bad_Init return Lim_Ctrl is
   begin
      return Result : Lim_Ctrl := raise Program_Error do
         null;
      end return;
   end Make_Lim_Ctrl_Bad_Init;

   function Make_Lim_Ctrl_OK_Init return Lim_Ctrl is
   begin
      return Result : Lim_Ctrl do
         raise Program_Error;
      end return;
   end Make_Lim_Ctrl_OK_Init;
end Pack;

--  main.adb

with Ada.Text_IO; use Ada.Text_IO;
with Pack;        use Pack;

procedure Main is
begin
   begin
      Put_Line ("1) Heap-allocated bad init");

      declare
         Obj : Lim_Ctrl_Ptr := new Lim_Ctrl'(Make_Lim_Ctrl_Bad_Init);
      begin
         Put_Line ("1) ERROR: Heap-allocated bad init: exception not raised");
      end;

   exception
      when Program_Error =>
         Put_Line ("1) Heap-allocated bad init: Program_Error raised");
      when others =>
         Put_Line ("1) ERROR: Heap-allocatd bad init: unexpected exception");
   end;

   begin
      Put_Line ("2) Stack-allocated bad init");

      declare
         Obj : Lim_Ctrl := Make_Lim_Ctrl_Bad_Init;
      begin
         Put_Line ("2) ERROR: Stack-allocated bad init: exception not raised");
      end;

   exception
      when Program_Error =>
         Put_Line ("2) Stack-allocated bad init: Program_Error raised");
      when others =>
         Put_Line ("2) ERROR: Stack-allocated bad init: unexpected exception");
   end;

   begin
      Put_Line ("3) Heap-allocated OK init");

      declare
         Obj : Lim_Ctrl_Ptr := new Lim_Ctrl'(Make_Lim_Ctrl_OK_Init);
      begin
         Put_Line ("3) ERROR: Heap-allocated OK init: exception not raised");
      end;

   exception
      when Program_Error =>
         Put_Line ("3) Heap-allocated OK init: Program_Error raised");
      when others =>
         Put_Line ("3) ERROR: Heap-allocatd OK init: unexpected exception");
   end;

   begin
      Put_Line ("4) Stack-allocated OK init");

      declare
         Obj : Lim_Ctrl := Make_Lim_Ctrl_OK_Init;
      begin
         Put_Line ("4) ERROR: Stack-allocated OK init: exception not raised");
      end;

   exception
      when Program_Error =>
         Put_Line ("4) Stack-allocated OK init: Program_Error raised");
      when others =>
         Put_Line ("4) ERROR: Stack-allocated OK init: unexpected exception");
   end;
end Main;

----------------------------
-- Compilation and output --
----------------------------

$ gnatmake -q main.adb
$ ./main
1) Heap-allocated bad init
1) Heap-allocated bad init: Program_Error raised
2) Stack-allocated bad init
2) Stack-allocated bad init: Program_Error raised
3) Heap-allocated OK init
     Finalize
3) Heap-allocated OK init: Program_Error raised
4) Stack-allocated OK init
     Finalize
4) Stack-allocated OK init: Program_Error raised

2018-06-11  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* exp_ch6.adb (Add_Unconstrained_Actuals_To_Build_In_Place_Call): Do
	not add any actuals when the size of the object is known, and the
	caller will allocate it.
	(Build_Heap_Allocator): Rename to Build_Heap_Or_Pool_Allocator to
	better illustrate its functionality. Update the comment on the
	generated code.  Generate a branch for the heap and pool cases where
	the object is not necessarity controlled.
	(Expand_N_Extended_Return_Statement): Expand the extended return
	statement into four branches depending the requested mode if the caller
	will not allocate the object on its side.
	(Make_Build_In_Place_Call_In_Allocator): Do not allocate a controlled
	object on the caller side because this will violate the semantics of
	finalizable types. Instead notify the function to allocate the object
	on the heap or a user-defined storage pool.
	(Needs_BIP_Alloc_Form): A build-in-place function needs to be notified
	which of the four modes to employ when returning a limited controlled
	result.
	* exp_util.adb (Build_Allocate_Deallocate_Proc): Remove a redundant
	guard which is already covered in Needs_Finalization.

From-SVN: r261427
2018-06-11 09:19:30 +00:00
Olivier Hainque
557b744a6e [Ada] Improve last exception info availability from C++ handlers
The Most_Recent_Exception service failed to provide accurate information on an
Ada exception caught by a C++ handler for foreign exceptions. The service
relies on updates of a "current exception buffer" from live exception objects
at various points of the propagation process and this update was not performed
early enough for the case of foreign exception handlers in non-Ada handlers.

The correction applied here consists in moving one of the updates earlier in
the raise process, just before unwinding starts, then refine the update API to
prevent a redundant copy during the unwinding search phase for the same
exception.

The example below, compiled with

gcc -c b.cc
gnatmake -g main.adb -largs b.o --LINK=g++

is expected to run and display

ada info:
Checking Most_Recent_Exception for CONSTRAINT_ERROR ... OK!

// b.cc

extern "C" {
 void foo ();
 extern void _ada_trigger ();
 extern void _ada_occurrence_info ();
}

void foo ()
{
 try {
   _ada_trigger ();
 } catch (const abi::__foreign_exception &e) {
   printf ("ada info:\n");
   _ada_occurrence_info();
 }
}

-- main.adb

with EH;
procedure Main is
begin
  EH.Foo;
end;

-- eh.adb

with Gnat.Most_Recent_Exception;
with Ada.Text_IO; use Ada.Text_IO;

package body EH is

  procedure Ada_Trigger is
  begin
     raise Constraint_Error;
  end;

  procedure Ada_Occurrence_Info is
  begin
     Check_MRE ("CONSTRAINT_ERROR");
  end;

  function Pre_Check_MRE (Ename : String) return Exception_Id is
     MROA : Exception_Occurrence_Access :=
       GNAT.Most_Recent_Exception.Occurrence_Access;
  begin
     Put ("Checking Most_Recent_Exception for " & Ename & " ... ");

     if MROA = null then
        Put_Line ("Most recent exception occurrence access is NULL");
        return Null_Id;
     else
        return Exception_Identity (MROA.all);
     end if;
  end;

  procedure Diagnose_MRE (MRID : Exception_Id; Ok : Boolean) is
  begin
     if Ok then
        Put_Line ("OK!");
     else
        Put_Line ("Err, Most_Recent_Exception was " & Exception_Name (MRID));
     end if;
  end;

  procedure Check_MRE (Eid : Exception_Id) is
     MRID : Exception_Id := Pre_Check_MRE (Ename => Exception_Name (Eid));
  begin
     Diagnose_MRE (MRID, Ok => Eid = MRID);
  end;

  procedure Check_MRE (Ename : String) is
     MRID : Exception_Id := Pre_Check_MRE (Ename => Ename);
  begin
     Diagnose_MRE (MRID, Ok => Ename = Exception_Name (MRID));
  end;

end;

-- eh.ads

with Ada.Exceptions; use Ada.Exceptions;
package EH is
  procedure Ada_Trigger with
    Export, Convention => C, External_Name => "_ada_trigger";

  procedure Ada_Occurrence_Info with
    Export, Convention => C, External_Name => "_ada_occurrence_info";

  procedure Foo with Import, Convention => C, External_Name => "foo";

  procedure Check_MRE (Eid : Exception_Id);
  procedure Check_MRE (Ename : String);

end;

2018-06-11  Olivier Hainque  <hainque@adacore.com>

gcc/ada/

	* libgnat/s-excmac*.ads: Factorize Unwind_Action definitions ...
	* libgnat/a-exexpr.adb: ... Here, then add comments describing the
	major datastructures associated with the current exception raised.
	(Setup_Current_Excep): Accept a "Phase" argument conveying the
	unwinding phase during which this subprogram is called.  For an Ada
	exception, don't update the current exception buffer from the raised
	exception object during SEARCH_PHASE, as this is redundant with the
	call now issued just before propagation starts.
	(Propagate_GCC_Exception): Move call to Setup_Current_Excep ahead of
	the unwinding start, conveying Phase 0.
	(Unhandled_Except_Handler): Pass UA_CLEANUP_PHASE as the Phase value on
	the call to Setup_Current_Excep.
	* raise-gcc.c (personality_body): Pass uw_phases as the Phase argument
	on calls to Setup_Current_Excep.

From-SVN: r261426
2018-06-11 09:19:22 +00:00
Ed Schonberg
fc0e632a99 [Ada] Unnesting: refactor handling of uplevel refs. for unconstrained arrays
2018-06-11  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* exp_unst.ads, exp_unst.adb (Needs_Fat_Pointer,
	Build_Access_Type_Decl): New subprograms to handle uplevel references
	to formals of an unconstrained array type. The activation record
	component for these is an access type, and the reference is rewritten
	as an explicit derefenrence of that component.

From-SVN: r261425
2018-06-11 09:19:17 +00:00
Bob Duff
6534852011 [Ada] Dangling cursor checks in Element function
In Ada.Containers.Ordered_Maps, if a dangling cursor is passed to the Element
function, execution is erroneous. Therefore, the compiler is not obligated to
detect this error. However, this patch inserts code that will detect this error
in some cases, and raise Program_Error. The same applies to Ordered_Sets,
Ordered_Multisets, Indefinite_Ordered_Maps, Indefinite_Ordered_Sets, and
Indefinite_Ordered_Multisets. No test available for erroneous execution.

2018-06-11  Bob Duff  <duff@adacore.com>

gcc/ada/

	* libgnat/a-ciorma.adb, libgnat/a-ciormu.adb, libgnat/a-ciorse.adb,
	libgnat/a-coorma.adb, libgnat/a-coormu.adb, libgnat/a-coorse.adb:
	(Element): Add code to detect dangling cursors in some cases.

From-SVN: r261424
2018-06-11 09:19:12 +00:00
Yannick Moy
90265b9343 [Ada] Mark parameters as coming from source for GNATprove
When building a separate subprogram declaration for possible inlining of
local subprograms in GNATprove mode, correctly mark subprogram parameters
as coming from source.

This has no impact on compilation.

2018-06-11  Yannick Moy  <moy@adacore.com>

gcc/ada/

	* sem_ch6.adb (Build_Subprogram_Declaration): Mark parameters as coming
	from source.

From-SVN: r261423
2018-06-11 09:19:07 +00:00
Ed Schonberg
20643f5032 [Ada] Missing predicate function body for derived type in nested package
This patch fixes a bug in the construction of predicate functions.  For a
derived type, we must ensure that the parent type is already frozen so that its
predicate function has been constructed already. This is necessary if the
parent is declared in a nested package and its own freeze point has not been
reached when the derived type is frozen by a local object declaration.

2018-06-11  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* sem_ch13.adb (Build_Predicate_Functions): For a derived type, ensure
	that its parent is already frozen so that its predicate function, if
	any, has already been constructed.

gcc/testsuite/

	* gnat.dg/predicate1.adb: New testcase.

From-SVN: r261422
2018-06-11 09:19:02 +00:00
Yannick Moy
577b1ab4b1 [Ada] Reject violation of SPARK 6.1.4(12) with enclosing task unit
SPARK 6.1.4(12) applies both to enclosing subprograms and enclosing task
units, but the latter was not correctly rejected.

2018-06-11  Yannick Moy  <moy@adacore.com>

gcc/ada/

	* sem_prag.adb (Check_Mode_Restriction_In_Enclosing_Context): Adapt for
	possible task unit as the enclosing context.

gcc/testsuite/

	* gnat.dg/spark1.adb, gnat.dg/spark1.ads: New testcase.

From-SVN: r261421
2018-06-11 09:18:56 +00:00
Eric Botcazou
e194729e56 [Ada] Minor tweaks for Repinfo
2018-06-11  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

	* gnat1drv.adb: Remove use clause for Repinfo.
	(Gnat1drv): Beef up comment about the interplay between -gnatc and
	back-end annotations.  Use full qualified name for List_Rep_Info.

From-SVN: r261420
2018-06-11 09:18:49 +00:00
Hristian Kirtchev
24d124a42a [Ada] Make GNAT.Array_Split a preelaborable unit
This patch makes GNAT.Array_Split a preelaborable unit. As a result, it can be
withed by other preelaborated untis.

2018-06-11  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* libgnat/g-arrspl.ads: Add pragma Preelaborate.

gcc/testsuite/

	* gnat.dg/gnat_array_split1.adb, gnat.dg/gnat_array_split1.ads: New
	testcase.

From-SVN: r261419
2018-06-11 09:18:44 +00:00
Arnaud Charlet
63254915a9 [Ada] Simplify expansion of "and then" in CodePeer mode
2018-06-11  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

	* exp_ch4.adb (Expand_Record_Equality): Remove extraneous "True and
	then" and general logical "ada" in codepeer mode.

From-SVN: r261418
2018-06-11 09:18:39 +00:00
Javier Miranda
09adaa8d12 [Ada] Crash on protected type entry family
The compiler may blow up compiling a the body of a protected type that has a
family entry whose entry index specification contains a call to a function.

2018-06-11  Javier Miranda  <miranda@adacore.com>

gcc/ada/

	* exp_ch9.adb (Expand_N_Protected_Body): Add missing handling of
	N_Call_Marker nodes.

gcc/testsuite/

	* gnat.dg/prot4.adb: New testcase.

From-SVN: r261417
2018-06-11 09:18:33 +00:00
Arnaud Charlet
3e6845df1e [Ada] Minor reformatting
2018-06-11  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

	* exp_ch3.adb, exp_unst.adb, inline.adb, sem_prag.adb: Minor
	reformatting.

From-SVN: r261416
2018-06-11 09:18:27 +00:00
Yannick Moy
62458cc143 [Ada] Add Suppressible argument to Assertion_Policy in documentation
2018-06-11  Yannick Moy  <moy@adacore.com>

gcc/ada/

	* doc/gnat_rm/implementation_defined_pragmas.rst: Add Suppressible
	argument to Assertion_Policy
	* gnat_rm.texi: Regenerate.

From-SVN: r261415
2018-06-11 09:18:18 +00:00
Yannick Moy
a19711197e [Ada] Do not query the representation information in CodePeer/GNATprove
Representation information generated when user calls the compiler with -gnatR
switch is not available when running the frontend inside CodePeer or GNATprove.
Do not query such information in that case, as this leads to spurious messages
that it is not available.

There is no impact on compilation.

2018-06-11  Yannick Moy  <moy@adacore.com>

gcc/ada/

	* gnat1drv.adb: Do not check representation information in CodePeer and
	GNATprove modes, as these modes call a special backend instead of gigi,
	so do not have the information.

From-SVN: r261414
2018-06-11 09:18:12 +00:00
Yannick Moy
d42dc0ade0 [Ada] Mark extended return of unconstrained type as never inlined
Calls to subprograms whose body was an extended return of an unconstrained
type were marked as not inlined, while the subprogram itself was marked as
always inlined. This was inconsistent and could lead to crash in GNATprove.
Now such subprograms are marked as not candidates for inlining.

This mostly impacts GNATprove, as it relates to frontend inlining which is
not used anymore in normal compilation.

2018-06-11  Yannick Moy  <moy@adacore.com>

gcc/ada/

	* inline.adb (Build_Body_To_Inline): Consider case of extended return
	of unconstrained type as one case where inlining is not supported.
	(Expand_Inlined_Call): Remove special case for body as extended return
	of unconstrained type.

From-SVN: r261413
2018-06-11 09:18:07 +00:00
Yannick Moy
d05bdd90e6 [Ada] Do not force Part_Of on generic units
This fixes the code checking SPARK RM 7.2.6(3) so that generic child units
are not forced to use Part_Of to relate their abstract state to the state
of their parent.

2018-06-11  Yannick Moy  <moy@adacore.com>

gcc/ada/

	* sem_prag.adb (Analyze_Part_Of): Only allow Part_Of on non-generic
	unit.
	(Check_Missing_Part_Of): Do not force Part_Of on generic unit.

gcc/testsuite/

	* gnat.dg/part_of1-instantiation.adb,
	gnat.dg/part_of1-instantiation.ads,
	gnat.dg/part_of1-private_generic.adb,
	gnat.dg/part_of1-private_generic.ads, gnat.dg/part_of1.ads: New
	testcase.

From-SVN: r261412
2018-06-11 09:18:01 +00:00