Re: [PATCH][2/n] Change dw2_asm_output_offset to allow assembling extra offset

2016-09-17 Thread Andreas Schwab
* config/ia64/ia64.h (ASM_OUTPUT_DWARF_OFFSET): Add cast.
* config/i386/cygming.h (ASM_OUTPUT_DWARF_OFFSET): Likewise.

diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h
index faf8fa4..60e11b4 100644
--- a/gcc/config/i386/cygming.h
+++ b/gcc/config/i386/cygming.h
@@ -110,7 +110,8 @@ along with GCC; see the file COPYING3.  If not see
fputs ("\t.secrel32\t", FILE);  \
assemble_name (FILE, LABEL);\
if ((OFFSET) != 0)  \
- fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC, OFFSET)   \
+ fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC,   \
+  (HOST_WIDE_INT) (OFFSET))\
break;  \
   case 8:  \
/* This is a hack.  There is no 64-bit section relative \
@@ -121,7 +122,8 @@ along with GCC; see the file COPYING3.  If not see
fputs ("\t.secrel32\t", FILE);  \
assemble_name (FILE, LABEL);\
if ((OFFSET) != 0)  \
- fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC, OFFSET)   \
+ fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC,   \
+  (HOST_WIDE_INT) (OFFSET))\
fputs ("\n\t.long\t0", FILE);   \
break;  \
   default: \
diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h
index 00516bb..ac0cb86 100644
--- a/gcc/config/ia64/ia64.h
+++ b/gcc/config/ia64/ia64.h
@@ -1587,7 +1587,8 @@ do {  
\
 fputs ("@secrel(", FILE);  \
 assemble_name (FILE, LABEL);   \
 if ((OFFSET) != 0) \
-  fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC, OFFSET); \
+  fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC,  \
+  (HOST_WIDE_INT) (OFFSET));   \
 fputc (')', FILE); \
   } while (0)
 
-- 
2.10.0

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Re: [PATCH][2/n] Change dw2_asm_output_offset to allow assembling extra offset

2016-09-17 Thread Richard Biener
On September 17, 2016 11:48:37 AM GMT+02:00, Andreas Schwab 
 wrote:
>   * config/ia64/ia64.h (ASM_OUTPUT_DWARF_OFFSET): Add cast.
>   * config/i386/cygming.h (ASM_OUTPUT_DWARF_OFFSET): Likewise.

OK.

Richard.

>diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h
>index faf8fa4..60e11b4 100644
>--- a/gcc/config/i386/cygming.h
>+++ b/gcc/config/i386/cygming.h
>@@ -110,7 +110,8 @@ along with GCC; see the file COPYING3.  If not see
>   fputs ("\t.secrel32\t", FILE);  \
>   assemble_name (FILE, LABEL);\
>   if ((OFFSET) != 0)  \
>-fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC, OFFSET)   \
>+fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC,   \
>+ (HOST_WIDE_INT) (OFFSET))\
>   break;  \
>   case 8: \
>   /* This is a hack.  There is no 64-bit section relative \
>@@ -121,7 +122,8 @@ along with GCC; see the file COPYING3.  If not see
>   fputs ("\t.secrel32\t", FILE);  \
>   assemble_name (FILE, LABEL);\
>   if ((OFFSET) != 0)  \
>-fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC, OFFSET)   \
>+fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC,   \
>+ (HOST_WIDE_INT) (OFFSET))\
>   fputs ("\n\t.long\t0", FILE);   \
>   break;  \
>   default:\
>diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h
>index 00516bb..ac0cb86 100644
>--- a/gcc/config/ia64/ia64.h
>+++ b/gcc/config/ia64/ia64.h
>@@ -1587,7 +1587,8 @@ do { 
>\
> fputs ("@secrel(", FILE); \
> assemble_name (FILE, LABEL);  \
> if ((OFFSET) != 0)\
>-  fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC, OFFSET);\
>+  fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC, \
>+ (HOST_WIDE_INT) (OFFSET));   \
> fputc (')', FILE);\
>   } while (0)
> 




[PATCH] Define pretty printers for C++17 library components

2016-09-17 Thread Jonathan Wakely

This tweaks the existing printers for Fundamentals TS components to
work for the C++17 versions, and adds a printer for std::variant.

* python/libstdcxx/v6/printers.py (StdVariantPrinter): Define.
(StdExpAnyPrinter, StdExpOptionalPrinter, StdExpStringViewPrinter):
Register for C++17 components in namespace std. Strip inline namespace
from typename.

Tested x86_64-linux, committed to trunk.

commit 2cff0a92fabf0baf847e10609083ce950af0281e
Author: Jonathan Wakely 
Date:   Sat Sep 17 15:07:04 2016 +0100

Define pretty printers for C++17 library components

* python/libstdcxx/v6/printers.py (StdVariantPrinter): Define.
(StdExpAnyPrinter, StdExpOptionalPrinter, StdExpStringViewPrinter):
Register for C++17 components in namespace std. Strip inline namespace
from typename.

diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py 
b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 977e63f..8c29760 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -920,10 +920,10 @@ class SingleObjContainerPrinter(object):
 
 
 class StdExpAnyPrinter(SingleObjContainerPrinter):
-"Print a std::experimental::any"
+"Print a std::any or std::experimental::any"
 
 def __init__ (self, typename, val):
-self.typename = 'std::experimental::any'
+self.typename = re.sub('^std::experimental::fundamentals_v\d::', 
'std::experimental::', typename, 1)
 self.val = val
 self.contained_type = None
 contained_value = None
@@ -932,11 +932,11 @@ class StdExpAnyPrinter(SingleObjContainerPrinter):
 if mgr != 0:
 func = gdb.block_for_pc(int(mgr.cast(gdb.lookup_type('intptr_t'
 if not func:
-raise ValueError("Invalid function pointer in 
std::experimental::any")
+raise ValueError("Invalid function pointer in %s" % 
self.typename)
 rx = r"""({0}::_Manager_\w+<.*>)::_S_manage\({0}::_Op, {0} 
const\*, {0}::_Arg\*\)""".format(typename)
 m = re.match(rx, func.function.name)
 if not m:
-raise ValueError("Unknown manager function in 
std::experimental::any")
+raise ValueError("Unknown manager function in %s" % 
self.typename)
 
 # FIXME need to expand 'std::string' so that gdb.lookup_type works
 mgrname = re.sub("std::string(?!\w)", 
str(gdb.lookup_type('std::string').strip_typedefs()), m.group(1))
@@ -948,7 +948,7 @@ class StdExpAnyPrinter(SingleObjContainerPrinter):
 elif '::_Manager_external' in mgrname:
 valptr = self.val['_M_storage']['_M_ptr']
 else:
-raise ValueError("Unknown manager function in 
std::experimental::any")
+raise ValueError("Unknown manager function in %s" % 
self.typename)
 contained_value = 
valptr.cast(self.contained_type.pointer()).dereference()
 visualizer = gdb.default_visualizer(contained_value)
 super(StdExpAnyPrinter, self).__init__ (contained_value, visualizer)
@@ -963,11 +963,11 @@ class StdExpAnyPrinter(SingleObjContainerPrinter):
 return desc + valtype
 
 class StdExpOptionalPrinter(SingleObjContainerPrinter):
-"Print a std::experimental::optional"
+"Print a std::optional or std::experimental::optional"
 
 def __init__ (self, typename, val):
 valtype = self._recognize (val.type.template_argument(0))
-self.typename = "std::experimental::optional<%s>" % valtype
+self.typename = 
re.sub('^std::(experimental::|)(fundamentals_v\d::|)(.*)', r'std::\1\3<%s>' % 
valtype, typename, 1)
 self.val = val
 contained_value = val['_M_payload'] if self.val['_M_engaged'] else None
 visualizer = gdb.default_visualizer (val['_M_payload'])
@@ -980,8 +980,44 @@ class StdExpOptionalPrinter(SingleObjContainerPrinter):
 return self.typename + " containing " + self.visualizer.to_string 
()
 return self.typename
 
+class StdVariantPrinter(SingleObjContainerPrinter):
+"Print a std::variant"
+
+def __init__(self, typename, val):
+alternatives = self._template_args(val)
+self.alts = alternatives
+self.typename = "%s<%s>" % (typename, ', '.join([self._recognize(alt) 
for alt in alternatives]))
+self.index = val['_M_index']
+if self.index >= len(alternatives):
+self.contained_type = None
+contained_value = None
+visualizer = None
+else:
+self.contained_type = alternatives[int(self.index)]
+addr = val['_M_first']['_M_storage'].address
+contained_value = 
addr.cast(self.contained_type.pointer()).dereference()
+visualizer = gdb.default_visualizer(contained_value)
+super (StdVariantPrinter, self).__init__(contained_value, visualizer)
+
+def _template_args(self, val):
+n = 0

Re: [PATCH] ada/77535: GNAT.Perfect_Hash_Generators for non-1-based strings

2016-09-17 Thread Florian Weimer
* Florian Weimer:

> This patch fixes GNAT.Perfect_Hash_Generators for strings which are
> not 1-based.  It does this by introducing its own storage type which
> fixes the first index as 1.  This is also a minor optimization because
> it avoids the need to store the index.
>
> Okay for trunk?
>
> Should I try to construct a new test case for this?  I don't see any
> existing tests for this package.
>
> 2016-09-08  Florian Weimer  
>
>   PR ada/77535
>   Make all word strings start with 1.
>   * g-pehage.adb (Word_Storage): New type.
>   (Word_Type): Use Word_Storage.
>   (Free_Word): Instantiate Unchecked_Deallocation.
>   (Apply_Position_Selection, Put_Initial_Keys, Put_Reduced_Keys)
>   (Resize_Word, Select_Char_Position, Select_Character_Set): Adjust
>   indirection through Word_Type.
>   (New_Word): Allocate Word_Storage instead of String.

Ping?

  


Re: [Patch, fortran] Initializing components of derived type variables

2016-09-17 Thread Steve Kargl
On Fri, Mar 04, 2016 at 11:42:48AM -0500, Fritz Reese wrote:
> 
> Here I propose a patch to gfortran which allows initializing
> components of derived type variables with a new compile flag.
> 
> Currently the options -finit-integer=, -finit-real=, -finit-logical=,
> and -finit-character= are avaialable to initialize variables of each
> respective type; however, there is no way (other than explicitly in
> source) to initialize derived type variables.
> 
> In this patch I add the flag -finit-derived. This flag allows
> components of derived type variables to be initialized as with local
> variables. This flag obeys the values given to the other -finit-*=
> flags; with -finit-local-zero derived type variables are initialized
> to zero.
> 
> The brunt of the work happens in expr.c (gfc_default_initializer). I
> add a boolean parameter to gfc_default_initializer which indicates
> whether or not to generate initializers for components that do not
> already have them. If true, an expression is generated for each
> component which does not already have an explicit initializer.
> 
> This parameter is passed potentially as true in two places in
> resolve.c (apply_default_init and resolve_fl_variable_derived).
> Generation is guarded by can_create_initializer, which ensures similar
> conditions as in resolve.c (build_default_init_expr).
> 
> To do the generation, gfc_default_initializer calls upon a new
> function component_init in expr.c. In order to use the -finit-* flags
> this calls upon the behavior formerly implemented in resolve.c
> (build_default_init_expr); I moved this behavior to the public
> function gfc_build_default_init_expr in expr.c;
> build_default_init_expr in resolve.c now simply wraps this function to
> protect it from being called on invalid symbols.
> 
> I wrestled with whether to change the interface for
> gfc_default_initializer or create an entirely new function (like
> gfc_generate_derived_initializer). I decided to change the old
> function because their behaviors would be almost identical, and there
> are only a few calls to the former.
> 
> The patch is based on trunk. It builds and passes all regression tests
> on x86-64-gnu-linux.

Fritz,

I'm trying to catch up in my inbox.  Has anyone reviewed
this patch?

-- 
steve


Re: [PATCH] Fix cgraph_node::rtl_info (PR target/77587)

2016-09-17 Thread Jan Hubicka
> Hi!
> 
> On the following testcase the weak alias can be overridden, so we shouldn't
> assume because we see bar to be alias to foo and have foo definition that
> call to bar will bind to the current TU's foo.
> cgraph_node::rtl_info calls ultimate_alias_target without checking if it can
> be overridden or not.
> The following patch fixes that, the decl != current_function_decl in there
> is there so that for the current function it always returns non-NULL,
> otherwise we ICE during bootstrap, and the node->decl != current_function_decl
> is there e.g. for the case where we'd call an alias ultimately pointing to
> the current function (TREE_ASM_WRITTEN would still not be set in that case).
> 
> The patch also removes extra calls to ultimate_alias_target, the function
> called it up to 4 times, while only one is enough.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK, thanks.
It may make sense to backrport this eventually to release branches.

Honza
> 
> 2016-09-16  Jakub Jelinek  
>   Jan Hubicka  
> 
>   PR target/77587
>   * cgraph.c (cgraph_node::rtl_info): Pass &avail to
>   ultimate_alias_target call, return NULL if avail < AVAIL_AVAILABLE.
>   Call ultimate_alias_target just once, not up to 4 times.
> 
>   * gcc.dg/pr77587.c: New test.
>   * gcc.dg/pr77587a.c: New file.
> 
> --- gcc/cgraph.c.jj   2016-08-06 12:11:49.0 +0200
> +++ gcc/cgraph.c  2016-09-16 14:19:31.553999007 +0200
> @@ -1955,14 +1955,17 @@ cgraph_node::rtl_info (tree decl)
>cgraph_node *node = get (decl);
>if (!node)
>  return NULL;
> -  node = node->ultimate_alias_target ();
> -  if (node->decl != current_function_decl
> -  && !TREE_ASM_WRITTEN (node->decl))
> +  enum availability avail;
> +  node = node->ultimate_alias_target (&avail);
> +  if (decl != current_function_decl
> +  && (avail < AVAIL_AVAILABLE
> +   || (node->decl != current_function_decl
> +   && !TREE_ASM_WRITTEN (node->decl
>  return NULL;
> -  /* Allocate if it doesnt exist.  */
> -  if (node->ultimate_alias_target ()->rtl == NULL)
> -node->ultimate_alias_target ()->rtl = ggc_cleared_alloc 
> ();
> -  return node->ultimate_alias_target ()->rtl;
> +  /* Allocate if it doesn't exist.  */
> +  if (node->rtl == NULL)
> +node->rtl = ggc_cleared_alloc ();
> +  return node->rtl;
>  }
>  
>  /* Return a string describing the failure REASON.  */
> --- gcc/testsuite/gcc.dg/pr77587.c.jj 2016-09-15 14:06:09.449901026 +0200
> +++ gcc/testsuite/gcc.dg/pr77587.c2016-09-15 14:18:53.615467361 +0200
> @@ -0,0 +1,14 @@
> +/* PR target/77587 */
> +/* { dg-do run } */
> +/* { dg-require-weak-override "" } */
> +/* { dg-additional-sources "pr77587a.c" } */
> +
> +void
> +bar (long x, long y, long z)
> +{
> +  struct __attribute__((aligned (16))) S { long a, b, c, d; } s;
> +  char *p = (char *) &s;
> +  __asm ("" : "+r" (p));
> +  if (((__UINTPTR_TYPE__) p) & 15)
> +__builtin_abort ();
> +}
> --- gcc/testsuite/gcc.dg/pr77587a.c.jj2016-09-15 14:05:58.873031952 
> +0200
> +++ gcc/testsuite/gcc.dg/pr77587a.c   2016-09-15 14:16:57.242903986 +0200
> @@ -0,0 +1,23 @@
> +/* PR target/77587 */
> +/* { dg-do compile } */
> +/* { dg-require-weak-override "" } */
> +
> +void
> +foo (long x, long y, long z)
> +{
> +}
> +
> +void bar (long x, long y, long z) __attribute__ ((weak, alias ("foo")));
> +
> +void
> +baz (long x, long y, long z)
> +{
> +  bar (0, 0, 0);
> +}
> +
> +int
> +main ()
> +{
> +  baz (0, 0, 0);
> +  return 0;
> +}
> 
>   Jakub


[BUILDROBOT] vax-netbsdelf / vax-linux: ‘ELIMINABLE_REGS’ was not declared in this scope (was: [PATCH] Remove support for INITIAL_FRAME_POINTER_OFFSET)

2016-09-17 Thread Jan-Benedict Glaw
On Fri, 2016-09-09 21:40:38 +, Bernd Edlinger  
wrote:
> Hi,
> 
> I think it is time to remove support for INITIAL_FRAME_POINTER_OFFSET, which 
> is no longer
> used by any target today.  This removes a bunch of conditional code, and 
> fixes a few bits
> in the documentation.  I'd say that part of the documentation is quite out of 
> sync, but I just
> have to stop somewhere.
> 
> 
> Bootstrapped and reg-tested on x86_64-pc-linux.gnu

The vax backend doesn't yet define ELIMINABLE_REGS.

MfG, JBG

-- 
  Jan-Benedict Glaw  jbg...@lug-owl.de  +49-172-7608481
Signature of:   Warum ist Scheiße braun? ...weil braun schon immer scheiße 
ist!
the second  :


signature.asc
Description: Digital signature


Re: [BUILDROBOT] vax-netbsdelf / vax-linux: ‘ELIMINABLE_REGS’ was not declared in this scope

2016-09-17 Thread Bernd Edlinger
On 09/17/16 22:29, Jan-Benedict Glaw wrote:
> On Fri, 2016-09-09 21:40:38 +, Bernd Edlinger  
> wrote:
>> Hi,
>>
>> I think it is time to remove support for INITIAL_FRAME_POINTER_OFFSET, which 
>> is no longer
>> used by any target today.  This removes a bunch of conditional code, and 
>> fixes a few bits
>> in the documentation.  I'd say that part of the documentation is quite out 
>> of sync, but I just
>> have to stop somewhere.
>>
>>
>> Bootstrapped and reg-tested on x86_64-pc-linux.gnu
>
> The vax backend doesn't yet define ELIMINABLE_REGS.
>

Oh, yes.  I see.  What a hack.

Then we should define it.

But simply returning zero for the fp to sp offset is not ok,
and even if the offset is not used for register eliminations
it should still be correct for rtx_addr_can_trap_p
to know the safe stack frame offset ranges.

I would assume a small performance improvement, when
rtx_addr_can_trap_p has correct data available.

How about this patch, it should at least fix the bootstrap.
Is it OK for trunk?


Thanks
Bernd.
2016-09-17  Bernd Edlinger  

	* config/var/vax.h (ELIMINABLE_REGS): Define.
	(INITIAL_ELIMINATION_OFFSET): Define.

Index: gcc/config/vax/vax.h
===
--- gcc/config/vax/vax.h	(revision 240215)
+++ gcc/config/vax/vax.h	(working copy)
@@ -333,6 +333,16 @@
 }\
   while (0)
 
+/* This macro specifies a table of register pairs used to eliminate
+   unneeded registers that point into the stack frame.  */
+#define ELIMINABLE_REGS {{FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}
+
+/* On the VAX, FRAME_POINTER_REQUIRED is always 1, so the definition of this
+   macro doesn't matter for register eliminations, but it should still
+   give realistic data for rtx_addr_can_trap_p.  */
+#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
+  ((OFFSET) = -get_frame_size ())
+
 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
the stack pointer does not matter.  The value is tested only in
functions that have frame pointers.


Fortran, committed: segfault with allocate and stat for derived types with default initialization (pr 68078)

2016-09-17 Thread Louis Krupp
Fixed in revision 240219.