[committed] tilegx: Unbreak build

2020-05-02 Thread Jakub Jelinek via Gcc-patches
../../gcc/config/tilegx/tilegx.md:4109:1: ambiguous attribute 'n'; could be '1' 
(via 'I124MODE:n') or '4' (via 'I48MODE:n')
../../gcc/config/tilegx/tilegx.md:4109:1: ambiguous attribute 'n'; could be '1' 
(via 'I124MODE:n') or '' (via 'I48MODE:n')
../../gcc/config/tilegx/tilegx.md:4109:1: ambiguous attribute 'n'; could be '2' 
(via 'I124MODE:n') or '4' (via 'I48MODE:n')
../../gcc/config/tilegx/tilegx.md:4109:1: ambiguous attribute 'n'; could be '2' 
(via 'I124MODE:n') or '' (via 'I48MODE:n')
../../gcc/config/tilegx/tilegx.md:4109:1: ambiguous attribute 'n'; could be '4' 
(via 'I124MODE:n') or '' (via 'I48MODE:n')

The insn name already uses  explicitly, just the preparation
stmts don't, and as it creates a I124MODE lowpart subreg of a word mode
register,  seems obviously correct.

Committed as obvious.

2020-05-02  Jakub Jelinek  

* config/tilegx/tilegx.md
(insn_stnt_add): Use 
rather than just .

--- gcc/config/tilegx/tilegx.md.jj  2020-01-12 11:54:36.431413137 +0100
+++ gcc/config/tilegx/tilegx.md 2020-05-02 12:04:14.092322428 +0200
@@ -4110,7 +4110,7 @@ (define_expand "insn_stnt_ad
   operands[1] = simplify_gen_subreg (mode, operands[1],
 DImode,
 BYTES_BIG_ENDIAN
-? UNITS_PER_WORD -  : 0);
+? UNITS_PER_WORD -  : 0);
 })
 
 (define_insn "*insn_stnt_add"


Jakub



[PATCH] x86: Add UNSPECV_PATCHABLE_AREA

2020-05-02 Thread H.J. Lu via Gcc-patches
Currently patchable area is at the wrong place.  It is placed immediately
after function label, before both .cfi_startproc and ENDBR.  This patch
adds UNSPECV_PATCHABLE_AREA for pseudo patchable area instruction and
changes ENDBR insertion pass to also insert patchable area instruction.
TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY is defined to avoid placing
patchable area before .cfi_startproc and ENDBR.

OK for master?

Thanks.

H.J.
---
gcc/

PR target/93492
* config/i386/i386-features.c (rest_of_insert_endbranch):
Renamed to ...
(rest_of_insert_endbr_and_patchable_area): Change return type
to void. Add need_endbr and patchable_area_size arguments.
Don't call timevar_push nor timevar_pop.  Replace
endbr_queued_at_entrance with insn_queued_at_entrance.  Insert
UNSPECV_PATCHABLE_AREA for patchable area.
(pass_data_insert_endbranch): Renamed to ...
(pass_data_insert_endbr_and_patchable_area): This.  Change
pass name to endbr_and_patchable_area.
(pass_insert_endbranch): Renamed to ...
(pass_insert_endbr_and_patchable_area): This.  Add need_endbr
and patchable_area_size;.
(pass_insert_endbr_and_patchable_area::gate): Set and check
need_endbr and patchable_area_size.
(pass_insert_endbr_and_patchable_area::execute): Call
timevar_push and timevar_pop.  Pass need_endbr and
patchable_area_size to rest_of_insert_endbr_and_patchable_area.
(make_pass_insert_endbranch): Renamed to ...
(make_pass_insert_endbr_and_patchable_area): This.
* config/i386/i386-passes.def: Replace pass_insert_endbranch
with pass_insert_endbr_and_patchable_area.
* config/i386/i386-protos.h (ix86_output_patchable_area): New.
(make_pass_insert_endbranch): Renamed to ...
(make_pass_insert_endbr_and_patchable_area): This.
* config/i386/i386.c (ix86_asm_output_function_label): Set
function_label_emitted to true.
(ix86_print_patchable_function_entry): New function.
(ix86_output_patchable_area): Likewise.
(x86_function_profiler): Replace endbr_queued_at_entrance with
insn_queued_at_entrance.  Generate ENDBR only for TYPE_ENDBR.
Call ix86_output_patchable_area to generate patchable area if
needed.
(TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY): New.
* i386.h (queued_insn_type): New.
(machine_function): Add function_label_emitted.  Replace
endbr_queued_at_entrance with insn_queued_at_entrance.
* config/i386/i386.md (UNSPECV_PATCHABLE_AREA): New.
(patchable_area): New.

gcc/testsuite/

PR target/93492
* gcc.target/i386/pr93492-1.c: New test.
* gcc.target/i386/pr93492-2.c: Likewise.
* gcc.target/i386/pr93492-3.c: Likewise.
* gcc.target/i386/pr93492-4.c: Likewise.
* gcc.target/i386/pr93492-5.c: Likewise.
---
 gcc/config/i386/i386-features.c   | 142 ++
 gcc/config/i386/i386-passes.def   |   2 +-
 gcc/config/i386/i386-protos.h |   5 +-
 gcc/config/i386/i386.c|  51 +++-
 gcc/config/i386/i386.h|  14 ++-
 gcc/config/i386/i386.md   |  17 +++
 gcc/testsuite/gcc.target/i386/pr93492-1.c |  73 +++
 gcc/testsuite/gcc.target/i386/pr93492-2.c |  12 ++
 gcc/testsuite/gcc.target/i386/pr93492-3.c |  13 ++
 gcc/testsuite/gcc.target/i386/pr93492-4.c |  11 ++
 gcc/testsuite/gcc.target/i386/pr93492-5.c |  12 ++
 11 files changed, 296 insertions(+), 56 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr93492-1.c
 create mode 100644 gcc/testsuite/gcc.target/i386/pr93492-2.c
 create mode 100644 gcc/testsuite/gcc.target/i386/pr93492-3.c
 create mode 100644 gcc/testsuite/gcc.target/i386/pr93492-4.c
 create mode 100644 gcc/testsuite/gcc.target/i386/pr93492-5.c

diff --git a/gcc/config/i386/i386-features.c b/gcc/config/i386/i386-features.c
index 78fb373db6e..41cc8b583b6 100644
--- a/gcc/config/i386/i386-features.c
+++ b/gcc/config/i386/i386-features.c
@@ -1941,48 +1941,83 @@ make_pass_stv (gcc::context *ctxt)
   return new pass_stv (ctxt);
 }
 
-/* Inserting ENDBRANCH instructions.  */
+/* Inserting ENDBR and pseudo patchable-area instructions.  */
 
-static unsigned int
-rest_of_insert_endbranch (void)
+static void
+rest_of_insert_endbr_and_patchable_area (bool need_endbr,
+unsigned int patchable_area_size)
 {
-  timevar_push (TV_MACH_DEP);
-
-  rtx cet_eb;
+  rtx endbr;
   rtx_insn *insn;
+  rtx_insn *endbr_insn = NULL;
   basic_block bb;
 
-  /* Currently emit EB if it's a tracking function, i.e. 'nocf_check' is
- absent among function attributes.  Later an optimization will be
- introduced to make analysis if an address of a static function is
- taken.  A static function whose address is not taken will get a
- nocf_check attribute.  This w

[pushed] Darwin: Fix a diagnostic spelling [PR93861]

2020-05-02 Thread Iain Sandoe
Hi,

As noted in the PR, there’s a missing ‘-‘ at the start of a diagnostic
switch.  Fixed thus.

tested on x86_64-darwin16,
applied to master,
thanks
Iain

gcc/ChangeLog:

2020-05-02  Iain Sandoe  

PR translation/93861
* config/darwin-driver.c (darwin_driver_init): Adjust spelling in
a warning.
---
 gcc/ChangeLog  | 6 ++
 gcc/config/darwin-driver.c | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)


--- a/gcc/config/darwin-driver.c
+++ b/gcc/config/darwin-driver.c
@@ -321,7 +321,7 @@ darwin_driver_init (unsigned int *decoded_options_count,
  vers_string =
validate_macosx_version_min ((*decoded_options)[i].arg);
  if (vers_string == NULL)
-   warning (0, "%qs is not valid for %",
+   warning (0, "%qs is not valid for %<-mmacosx-version-min%>",
 (*decoded_options)[i].arg);
  else if (vers_string == (*decoded_options)[i].arg)
vers_string = xstrndup ((*decoded_options)[i].arg, 32);
-- 
2.24.1




[PATCH] fix Ada bootstrap on Cygwin64 (PR bootstrap/94918)

2020-05-02 Thread Mikael Pettersson via Gcc-patches
This fixes three compilation errors preventing bootstrap of gcc-10/11
with Ada on x86_64-pc-cygwin.  See PR bootstrap/94918 for details.

Tested by bootstrapping on x86_64-pc-cygwin, and since it touches code
shared with mingw, also by building a cross to x86_64-w64-mingw32.

Ok for master and gcc-10 branch?

(I don't have commit rights, so I will need assistance with that.)

(The patch is also attached, since gmail _will_ corrupt this text.)

gcc/ada/

2020-05-02  Mikael Pettersson  

PR bootstrap/94918

* mingw32.h: Prevent windows.h from including emmintrin.h on Cygwin64.
* libgnat/g-sercom__mingw.adb (Open): Insert missing type conversion.

libgcc/

2020-05-02  Mikael Pettersson  

PR bootstrap/94918

* unwind-generic.h (__SEH__): Prevent windows.h from including
x86intrin.h and emmintrin.h.

--- gcc-10.1.0-RC-20200430/gcc/ada/libgnat/g-sercom__mingw.adb.~1~
 2020-04-30 22:51:33.0 +0200
+++ gcc-10.1.0-RC-20200430/gcc/ada/libgnat/g-sercom__mingw.adb
2020-05-02 16:36:49.565719571 +0200
@@ -103,6 +103,7 @@ package body GNAT.Serial_Communications
is
   C_Name  : constant String := String (Name) & ASCII.NUL;
   Success : BOOL;
+  HFile   : HANDLE;
   pragma Unreferenced (Success);

begin
@@ -110,7 +111,7 @@ package body GNAT.Serial_Communications
  Success := CloseHandle (HANDLE (Port.H));
   end if;

-  Port.H := CreateFileA
+  HFile := CreateFileA
 (lpFileName=> C_Name (C_Name'First)'Address,
  dwDesiredAccess   => GENERIC_READ or GENERIC_WRITE,
  dwShareMode   => 0,
@@ -118,6 +119,7 @@ package body GNAT.Serial_Communications
  dwCreationDisposition => OPEN_EXISTING,
  dwFlagsAndAttributes  => 0,
  hTemplateFile => 0);
+  Port.H := Serial_Port_Descriptor (HFile);

   pragma Assert (INVALID_HANDLE_VALUE = -1);

--- gcc-10.1.0-RC-20200430/gcc/ada/mingw32.h.~1~2020-04-30
22:51:33.0 +0200
+++ gcc-10.1.0-RC-20200430/gcc/ada/mingw32.h2020-05-02
16:36:44.485724702 +0200
@@ -56,6 +56,7 @@
 /* Note: windows.h on cygwin-64 includes x86intrin.h which uses malloc.
That fails to compile, if malloc is poisoned, i.e. if !IN_RTS.  */
 #define _X86INTRIN_H_INCLUDED
+#define _EMMINTRIN_H_INCLUDED
 #endif
 #include 

--- gcc-10.1.0-RC-20200430/libgcc/unwind-generic.h.~1~  2020-04-30
22:51:36.0 +0200
+++ gcc-10.1.0-RC-20200430/libgcc/unwind-generic.h  2020-05-02
16:36:44.485724702 +0200
@@ -30,6 +30,8 @@

 #if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
 /* Only for _GCC_specific_handler.  */
+#define _X86INTRIN_H_INCLUDED
+#define _EMMINTRIN_H_INCLUDED
 #include 
 #endif
gcc/ada/

2020-05-02  Mikael Pettersson  

PR bootstrap/94918

* mingw32.h: Prevent windows.h from including emmintrin.h on Cygwin64.
* libgnat/g-sercom__mingw.adb (Open): Insert missing type conversion.

libgcc/

2020-05-02  Mikael Pettersson  

PR bootstrap/94918

* unwind-generic.h (__SEH__): Prevent windows.h from including
x86intrin.h and emmintrin.h.

--- gcc-10.1.0-RC-20200430/gcc/ada/libgnat/g-sercom__mingw.adb.~1~  
2020-04-30 22:51:33.0 +0200
+++ gcc-10.1.0-RC-20200430/gcc/ada/libgnat/g-sercom__mingw.adb  2020-05-02 
16:36:49.565719571 +0200
@@ -103,6 +103,7 @@ package body GNAT.Serial_Communications
is
   C_Name  : constant String := String (Name) & ASCII.NUL;
   Success : BOOL;
+  HFile   : HANDLE;
   pragma Unreferenced (Success);
 
begin
@@ -110,7 +111,7 @@ package body GNAT.Serial_Communications
  Success := CloseHandle (HANDLE (Port.H));
   end if;
 
-  Port.H := CreateFileA
+  HFile := CreateFileA
 (lpFileName=> C_Name (C_Name'First)'Address,
  dwDesiredAccess   => GENERIC_READ or GENERIC_WRITE,
  dwShareMode   => 0,
@@ -118,6 +119,7 @@ package body GNAT.Serial_Communications
  dwCreationDisposition => OPEN_EXISTING,
  dwFlagsAndAttributes  => 0,
  hTemplateFile => 0);
+  Port.H := Serial_Port_Descriptor (HFile);
 
   pragma Assert (INVALID_HANDLE_VALUE = -1);
 
--- gcc-10.1.0-RC-20200430/gcc/ada/mingw32.h.~1~2020-04-30 
22:51:33.0 +0200
+++ gcc-10.1.0-RC-20200430/gcc/ada/mingw32.h2020-05-02 16:36:44.485724702 
+0200
@@ -56,6 +56,7 @@
 /* Note: windows.h on cygwin-64 includes x86intrin.h which uses malloc.
That fails to compile, if malloc is poisoned, i.e. if !IN_RTS.  */
 #define _X86INTRIN_H_INCLUDED
+#define _EMMINTRIN_H_INCLUDED
 #endif
 #include 
 
--- gcc-10.1.0-RC-20200430/libgcc/unwind-generic.h.~1~  2020-04-30 
22:51:36.0 +0200
+++ gcc-10.1.0-RC-20200430/libgcc/unwind-generic.h  2020-05-02 
16:36:44.485724702 +0200
@@ -30,6 +30,8 @@
 
 #if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
 /* Only for _GCC_specific_handler.  */
+#define _X86INTRIN_H_INCLUDED
+#define

Re: [PATCH] fix Ada bootstrap on Cygwin64 (PR bootstrap/94918)

2020-05-02 Thread Arnaud Charlet
> This fixes three compilation errors preventing bootstrap of gcc-10/11
> with Ada on x86_64-pc-cygwin.  See PR bootstrap/94918 for details.
> 
> Tested by bootstrapping on x86_64-pc-cygwin, and since it touches code
> shared with mingw, also by building a cross to x86_64-w64-mingw32.
> 
> Ok for master and gcc-10 branch?

No, the libgnat/g-sercom__mingw.adb is wrong and isn't needed.

If there is an issue, it would be in "s-oscons-tmplt.c" which is supposed
to define Serial_Port_Descriptor as:

   subtype Serial_Port_Descriptor is System.Win32.HANDLE;

See:

#if defined (__MINGW32__) || defined (__CYGWIN__)
# define TARGET_OS "Windows"
# define Serial_Port_Descriptor "System.Win32.HANDLE"
TXT("with System.Win32;")

The mingw32.h change is kludgy but probably not worse than the current state
so probably OK I guess (if some cygwin specialist could confirm that
would be great though).

> libgcc/
> 
> 2020-05-02  Mikael Pettersson  
> 
> PR bootstrap/94918
> 
> * unwind-generic.h (__SEH__): Prevent windows.h from including
> x86intrin.h and emmintrin.h.

Same comment here, I'll let someone review this part (and comment on
the mingw32.h change at the same time since both are basically similar.

> --- gcc-10.1.0-RC-20200430/gcc/ada/mingw32.h.~1~2020-04-30
> 22:51:33.0 +0200
> +++ gcc-10.1.0-RC-20200430/gcc/ada/mingw32.h2020-05-02
> 16:36:44.485724702 +0200
> @@ -56,6 +56,7 @@
>  /* Note: windows.h on cygwin-64 includes x86intrin.h which uses malloc.
> That fails to compile, if malloc is poisoned, i.e. if !IN_RTS.  */
>  #define _X86INTRIN_H_INCLUDED
> +#define _EMMINTRIN_H_INCLUDED
>  #endif
>  #include 
> 
> --- gcc-10.1.0-RC-20200430/libgcc/unwind-generic.h.~1~  2020-04-30
> 22:51:36.0 +0200
> +++ gcc-10.1.0-RC-20200430/libgcc/unwind-generic.h  2020-05-02
> 16:36:44.485724702 +0200
> @@ -30,6 +30,8 @@
> 
>  #if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
>  /* Only for _GCC_specific_handler.  */
> +#define _X86INTRIN_H_INCLUDED
> +#define _EMMINTRIN_H_INCLUDED
>  #include 
>  #endif


[PATCH] gfortran: Get asan library from TEST_ALWAYS_FLAGS

2020-05-02 Thread H.J. Lu via Gcc-patches
On Fri, May 1, 2020 at 6:04 AM Thomas Koenig via Gcc-patches
 wrote:
>
> Hello world,
>
> because the test case for PR 94788 requires -fsanitize=address to expose
> the double free, I have created a subdirectory under gfortran.dg
> where such test cases can go.
>
> I have tested this with
>
> make check-fortran RUNTESTFLAGS="asan.exp=*"
>
> and it works; with a compiler that introduces the double free bug
> into the test case, the result is as expected:
>
> FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O0
> execution test
> FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O1
> execution test
> FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O2
> execution test
> FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O3
> -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer
> -finline-functions  execution test
> FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O3 -g
> execution test
> FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -Os
> execution test
>
> So, any comments regarding style, functionality etc?  If not, I plan
> on committing this to trunk within the next couple of days.
>

I checked in this patch to fix:

https://gcc.gnu.org/pipermail/gcc-regression/2020-May/072549.html

FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O0
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O0
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O0
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O1
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O1
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O1
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O2
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O2
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O2
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O3
-fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer
-finline-functions  (test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O3
-fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer
-finline-functions  (test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O3
-fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer
-finline-functions  (test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O3
-g  (test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O3
-g  (test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O3
-g  (test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -Os
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -Os
(test for excess errors)
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -Os
(test for excess errors)

-- 
H.J.
From 6abe1c3084798d3e5f32926c352643e557073e01 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" 
Date: Sat, 2 May 2020 12:46:44 -0700
Subject: [PATCH] gfortran: Get asan library from TEST_ALWAYS_FLAGS

Update gfortran_target_compile to get the newly built asan library from
TEST_ALWAYS_FLAGS to avoid:

/usr/bin/ld: cannot find libasan_preinit.o: No such file or directory
/usr/bin/ld: cannot find -lasan
collect2: error: ld returned 1 exit status
compiler exited with status 1
FAIL: gfortran.dg/asan/pointer_assign_16.f90 -fsanitize=address  -O0  (test for excess errors)

	PR fortran/94788
	* lib/gfortran.exp (gfortran_target_compile): Get asan library
	from TEST_ALWAYS_FLAGS.
---
 gcc/testsuite/ChangeLog| 6 ++
 gcc/testsuite/lib/gfortran.exp | 8 
 2 files changed, 14 insertions(+)

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a9c72f982fe..b0c6f9a8cef 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2020-05-02  H.J. Lu  
+
+	PR fortran/94788
+	* lib/gfortran.exp (gfortran_target_compile): Get asan library
+	from TEST_ALWAYS_FLAGS.
+
 2020-05-02  Thomas Koenig  
 
 	PR fortran/94788
diff --git a/gcc/testsuite/lib/gfortran.exp b/gcc/testsuite/lib/gfortran.exp
index 016d77ca4f8..fe99111788f 100644
--- a/gcc/testsuite/lib/gfortran.exp
+++ b/gcc/testsuite/lib/gfortran.exp
@@ -234,6 +234,7 @@ proc gfortran_target_compile { source dest type options } {
 global gluefile wrap_flags
 global ALWAYS_GFORTRANFLAGS
 global GFORTRAN_UNDER_TEST
+global TEST_ALWAYS_FLAGS
 global flags_to_postpone
 global board_info
 
@@ -242,6 +243,13 @@ proc gfortran_target_compile { source dest type options } {
 	lappend options "ldflags=${wrap_flags}"