Re: [hsa merge 09/10] Majority of the HSA back-end

2016-01-16 Thread Jakub Jelinek
On Sat, Jan 16, 2016 at 12:49:12AM +0100, Martin Jambor wrote:
> bootstrapping on i686-linux revealed the need for the following simple
> patch.  I've run into two types of compilation errors on
> powerpc-ibm-aix (no htolenn functions and ASM_GENERATE_INTERNAL_LABEL
> somehow expanding to undeclared rs6000_xcoff_strip_dollar).  I plan to
> workaround them quickly by making most of the contents of hsa-*.c
> files compiled only conditionally (and leave potential hsa support on
> non-linux platforms for later), but I will not have time to do the
> change and test it properly until Monday.
> 
> But that will hopefully really be it,

IMHO you'd be best to write your own helpers for conversion to little
endian (and back).
gcc configure already has AC_C_BIGENDIAN (dunno how it handles pdp endian
host though, so not sure if it is safe to rely on that), for recent GCC
you can use __BYTE_ORDER__ macro to check endianity and __builtin_bswap*.
So perhaps just
#if GCC_VERSION >= 4006
// use __BYTE_ORDER__ and __builtin_bswap or nothing
#else
// provide a safe slower default, with shifts and masking
#endif

As for rs6000_xcoff_strip_dollar, look at other sources that use it what
headers they do include, bet you want to #include "tm_p.h" to make it work.

Jakub


Re: [hsa merge 09/10] Majority of the HSA back-end

2016-01-16 Thread Jakub Jelinek
On Sat, Jan 16, 2016 at 09:58:51AM +0100, Jakub Jelinek wrote:
> IMHO you'd be best to write your own helpers for conversion to little
> endian (and back).
> gcc configure already has AC_C_BIGENDIAN (dunno how it handles pdp endian
> host though, so not sure if it is safe to rely on that), for recent GCC
> you can use __BYTE_ORDER__ macro to check endianity and __builtin_bswap*.
> So perhaps just
> #if GCC_VERSION >= 4006
> // use __BYTE_ORDER__ and __builtin_bswap or nothing
> #else
> // provide a safe slower default, with shifts and masking
> #endif

Note e.g. libiberty/simple-object* uses the slow version with shifts and
masking all the time, so just optimizing the case of recent GCC host (and
therefore also bootstrapped compilers) might be enough.

Jakub


Re: [PATCH v2] libstdc++: Make certain exceptions transaction_safe.

2016-01-16 Thread Dominique d'Humières
> Addressed these, fixed a problem with using GLIBCXX_WEAK_DEFINITION
> (which is only set on Darwin despite the generic-sounding name -- so
> just use __attribute__((weak)) directly), and also updated
> testsuite_abi.cc so that it knows about CXXABI_1.3.10.
>
> Approved by Jonathan Wakely.  Committed as r232454.
This breaks bootstrap on darwin, see 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69310.

TIA

Dominique



Re: [hsa merge 07/10] IPA-HSA pass

2016-01-16 Thread Jan Hubicka
> On 01/15/2016 10:52 AM, Jan Hubicka wrote:
> > Do we really need to look that up in the hsa summary? Why these can not be 
> > partitioned the
> > usual way?
> 
> Hi.
> 
> Yes, it's needed as hsa-brig.c uses host function declaration of a kernel as 
> a key for libgomp.
> That's why we want to put the pair to a LTO partition.

Can't it be represented via explicit REF_ADDR or something like that?

Honza
> 
> Martin


Re: reject decl with incomplete struct/union type in check_global_declaration()

2016-01-16 Thread Prathamesh Kulkarni
On 16 January 2016 at 02:56, Joseph Myers  wrote:
> On Fri, 15 Jan 2016, Prathamesh Kulkarni wrote:
>
>> On 15 January 2016 at 03:27, Joseph Myers  wrote:
>> > On Thu, 14 Jan 2016, Prathamesh Kulkarni wrote:
>> >
>> >> Hi,
>> >> For test-case containing only the following declaration:
>> >> static struct undefined_struct object;
>> >> gcc rejects it at -O0 in assemble_variable() with error "storage size
>> >> of  is unknown",
>> >> however no error is reported when compiled with -O2.
>> >
>> > Cf bug 24293 (for the -fsyntax-only case) - does this patch fix that?
>> Ah this doesn't fix PR24293, it seems analyze_function() doesn't get
>> called for -fsyntax-only.
>> I don't have a good solution for this. I assume varpool won't be
>> populated for -fsyntax-only ?
>> And we need to walk over decls with incomplete struct/union types
>> after parsing the whole translation unit.
>> In the attached patch, I kept a global vec incomplete_record_decls;
>> In finish_decl(), if the decl is static, has type struct/union and
>> size 0 then it is appened to incomplete_record_decls.
>> In c_parser_translation_unit(), iterate over incomplete_record_decls
>> and if report error if any decl has size zero.
>> The patch passes testsuite.
>
> There's a GNU C extension allowing forward declarations of enums, and it
> seems that
>
> static enum e x;
>
> doesn't get diagnosed either with -fsyntax-only.  Thus I think you should
> cover that case as well.
Done in the attached patch. It regresses pr63549.c because the error
showed up there, adjusted
the test-case to accept the error.
OK to commit ?

Thanks,
Prathamesh
>
> --
> Joseph S. Myers
> jos...@codesourcery.com
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 915376d..d36fc67 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -4791,6 +4791,13 @@ finish_decl (tree decl, location_t init_loc, tree init,
   TREE_TYPE (decl) = error_mark_node;
 }
 
+  if ((RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl))
+ || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
+ && DECL_SIZE (decl) == 0 && TREE_STATIC (decl))
+   {
+ incomplete_record_decls.safe_push (decl);
+   }
+
   if (is_global_var (decl) && DECL_SIZE (decl) != 0)
{
  if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST)
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index a0e0052..3c8a496 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -59,6 +59,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimple-expr.h"
 #include "context.h"
 
+vec incomplete_record_decls = vNULL;
+
 void
 set_c_expr_source_range (c_expr *expr,
 location_t start, location_t finish)
@@ -1421,6 +1423,16 @@ c_parser_translation_unit (c_parser *parser)
}
   while (c_parser_next_token_is_not (parser, CPP_EOF));
 }
+
+  for (unsigned i = 0; i < incomplete_record_decls.length (); ++i)
+{
+  tree decl = incomplete_record_decls[i];
+  if (DECL_SIZE (decl) == 0 && TREE_TYPE (decl) != error_mark_node)
+   {
+ error ("storage size of %q+D isn%'t known", decl);
+ TREE_TYPE (decl) = error_mark_node;
+   }
+}
 }
 
 /* Parse an external declaration (C90 6.7, C99 6.9).
diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h
index 81a3d58..cf79ba7 100644
--- a/gcc/c/c-tree.h
+++ b/gcc/c/c-tree.h
@@ -731,4 +731,6 @@ set_c_expr_source_range (c_expr *expr,
 /* In c-fold.c */
 extern tree decl_constant_value_for_optimization (tree);
 
+extern vec incomplete_record_decls;
+
 #endif /* ! GCC_C_TREE_H */
diff --git a/gcc/testsuite/gcc.dg/Wcxx-compat-8.c 
b/gcc/testsuite/gcc.dg/Wcxx-compat-8.c
index f7e8c55..4e9ddc1 100644
--- a/gcc/testsuite/gcc.dg/Wcxx-compat-8.c
+++ b/gcc/testsuite/gcc.dg/Wcxx-compat-8.c
@@ -33,6 +33,7 @@ enum e3
 
 __typeof__ (struct s5 { int i; }) v5; /* { dg-warning "invalid in C\[+\]\[+\]" 
} */
 __typeof__ (struct t5) w5; /* { dg-bogus "invalid in C\[+\]\[+\]" } */
+  /* { dg-error "storage size of 'w5' isn't known" "" { target *-*-* } 35 } */
 
 int
 f1 (struct s1 *p)
@@ -64,4 +65,4 @@ f5 ()
   return &((struct t8) { });  /* { dg-warning "invalid in C\[+\]\[+\]" } */
 }
 
-/* { dg-error "invalid use of undefined type" "" { target *-*-* } 64 } */
+/* { dg-error "invalid use of undefined type" "" { target *-*-* } 65 } */
diff --git a/gcc/testsuite/gcc.dg/declspec-1.c 
b/gcc/testsuite/gcc.dg/declspec-1.c
index c19f107..b024601 100644
--- a/gcc/testsuite/gcc.dg/declspec-1.c
+++ b/gcc/testsuite/gcc.dg/declspec-1.c
@@ -9,13 +9,15 @@ typedef int t;
 /* These should all be diagnosed, but only once, not for every
identifier declared.  */
 struct s0 int x0, /* { dg-error "two or more data types" } */
-x1;
+/* { dg-error "storage size of 'x0' isn't known" "" { target *-*-* } 11 } */
+x1; /* { dg-error "storage size of 'x1' isn't known" } */ 
 
 char union u0 x2, /* { dg-error "two or more data types" } */
 x3;
 
 enum e0 struct s1 x4, /* { dg-error "two or more data types" } */
-x5;
+ /* { dg-error "storage si

Re: Prune BLOCK_VARs lists in free_lang_data

2016-01-16 Thread Jan Hubicka
> On Fri, 15 Jan 2016, Jan Hubicka wrote:
> 
> > Hi,
> > this is last of my patches to improve partitionability of programs. 
> > This patch compacts BLOCK_VARs lists and trows away TYPE_DECLs for -g0
> > and redundant TYPE_DECLs on all levels. It does make noticeable difference
> > on firefox, but I managed to erase the numbers (can re-test them if 
> > requested)
> > 
> > Bootstrapped/regtested x86_64-linux, OK?
> 
> Hmm.  So I wonder why remove_unused_locals does not do this then
> or if it does not because it would change code-gen based on -g/-g0
> I wonder why your patch wouldn't introduce that issue with LTO.

Usually the things stay to make DECL_UID stable across -g and -g0.  This is not
the case with LTO, so ATM we do not have same codegen with lto and -g/-g0.  I
guess it is something we can start shooting for once early debug is in.
> 
> That said - improve remove_unused_locals instead please?

Yep, that makes sense (though i am not sure every BLOCK_VARs seen by lto
streamer is also seen by this function).  Will update the patch and re-measure
the effect.

Honza


Re: Prune BLOCK_VARs lists in free_lang_data

2016-01-16 Thread Richard Biener
On January 16, 2016 11:27:09 AM GMT+01:00, Jan Hubicka  wrote:
>> On Fri, 15 Jan 2016, Jan Hubicka wrote:
>> 
>> > Hi,
>> > this is last of my patches to improve partitionability of programs.
>
>> > This patch compacts BLOCK_VARs lists and trows away TYPE_DECLs for
>-g0
>> > and redundant TYPE_DECLs on all levels. It does make noticeable
>difference
>> > on firefox, but I managed to erase the numbers (can re-test them if
>requested)
>> > 
>> > Bootstrapped/regtested x86_64-linux, OK?
>> 
>> Hmm.  So I wonder why remove_unused_locals does not do this then
>> or if it does not because it would change code-gen based on -g/-g0
>> I wonder why your patch wouldn't introduce that issue with LTO.
>
>Usually the things stay to make DECL_UID stable across -g and -g0. 

Only DECL_UID order needs to be stable I think.

>This is not
>the case with LTO,

I don't see how LTO does behave differently here.

 so ATM we do not have same codegen with lto and
>-g/-g0.  I
>guess it is something we can start shooting for once early debug is in.
>> 
>> That said - improve remove_unused_locals instead please?
>
>Yep, that makes sense (though i am not sure every BLOCK_VARs seen by
>lto
>streamer is also seen by this function).  Will update the patch and
>re-measure
>the effect.
>
>Honza




Re: Prune BLOCK_VARs lists in free_lang_data

2016-01-16 Thread Jakub Jelinek
On Sat, Jan 16, 2016 at 11:31:49AM +0100, Richard Biener wrote:
> On January 16, 2016 11:27:09 AM GMT+01:00, Jan Hubicka  wrote:
> >> On Fri, 15 Jan 2016, Jan Hubicka wrote:
> >> 
> >> > Hi,
> >> > this is last of my patches to improve partitionability of programs.
> >
> >> > This patch compacts BLOCK_VARs lists and trows away TYPE_DECLs for
> >-g0
> >> > and redundant TYPE_DECLs on all levels. It does make noticeable
> >difference
> >> > on firefox, but I managed to erase the numbers (can re-test them if
> >requested)
> >> > 
> >> > Bootstrapped/regtested x86_64-linux, OK?
> >> 
> >> Hmm.  So I wonder why remove_unused_locals does not do this then
> >> or if it does not because it would change code-gen based on -g/-g0
> >> I wonder why your patch wouldn't introduce that issue with LTO.
> >
> >Usually the things stay to make DECL_UID stable across -g and -g0. 
> 
> Only DECL_UID order needs to be stable I think.

There is certainly something we only care about order and not exact numbers,
but I'm not sure if it is DECL_UIDs - otherwise we'd happily use 
allocate_decl_uid ()
even for DECL_DEBUG_EXPRs, but we instead use a different counter for those.
Alex?

Jakub


Re: Prune BLOCK_VARs lists in free_lang_data

2016-01-16 Thread Jan Hubicka
> >Usually the things stay to make DECL_UID stable across -g and -g0. 
> 
> Only DECL_UID order needs to be stable I think.

Well, when you remove a reference to a declaration, the DECL_UID order will
change.  We stream declarations in the order they are inserted to the encoder
and that depends on specific references from the IL. Creating the decl and 
not inserting it to il/optimizing it out early is safe.  We do so with debug
statements, block local vars and other stuff.

The difference to non-LTO is that in non-LTO you only need to be sure you
create same decls in the same order.  With LTO we need to be sure to keep all
references streamed in the same order.  I suppose we could avoid some of it by
streaming DECL_UIDs and merging them same way as we do symbol_table->order but
that will still have fun effects wrt merging.
> 
> >This is not
> >the case with LTO,
> 
> I don't see how LTO does behave differently here.
> 
>  so ATM we do not have same codegen with lto and
> >-g/-g0.  I
> >guess it is something we can start shooting for once early debug is in.
> >> 
> >> That said - improve remove_unused_locals instead please?

I looked into remove_unused_locals and in fact it is removing those decls
aready to some degree, it just keeps all TYPE_DECLs when debug info is on.  I
will extend it to skip redundant typedefs.

Honza


Re: [hsa merge 08/10] HSAIL BRIG description header file

2016-01-16 Thread Jakub Jelinek
On Fri, Jan 15, 2016 at 06:23:05PM +0100, Martin Jambor wrote:
>   BRIG_KIND_OPERAND_REGISTER = 0x300a,
>   BRIG_KIND_OPERAND_STRING = 0x300b,
>   BRIG_KIND_OPERAND_WAVESIZE = 0x3009c,
>   BRIG_KIND_OPERAND_END = 0x300d

The above looks weird, I'd have expected BRIG_KIND_OPERAND_WAVESIZE
to be 0x300c instead.  Bug in the standard?
As typedef uint16_t BrigKind16_t;, I'm afraid this doesn't even fit
into the data type.  Note the original brig header you've posted
had this fixed.

Jakub


[PING][PATCH][DJGPP][libgfortran] Do not use S_ISVTX for DJGPP in libfortran/intrinsic/chmod.c

2016-01-16 Thread Andris Pavenis

Patch avoids using S_ISVTX if it is not defined.

https://gcc.gnu.org/ml/gcc-patches/2015-11/msg01899.html

Initial version of patch avoided it additionally for DJGPP 
(https://gcc.gnu.org/ml/gcc-patches/2015-11/msg01880.html)


Andris



Re: [PATCH v2] libstdc++: Make certain exceptions transaction_safe.

2016-01-16 Thread David Edelsohn
This patch broke bootstrap on AIX.  Not all targets support TM.  This
patch makes libstdc++ unconditionally refer to TM symbols.

Please fix.

- David


Re: [PATCH v2] libstdc++: Make certain exceptions transaction_safe.

2016-01-16 Thread Jonathan Wakely

What are the errors?

I can build libstdc++ on gcc111.

Does this patch help?


diff --git a/libstdc++-v3/src/c++11/cow-stdexcept.cc 
b/libstdc++-v3/src/c++11/cow-stdexcept.cc
index afc3f6c..8a1b65a 100644
--- a/libstdc++-v3/src/c++11/cow-stdexcept.cc
+++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc
@@ -27,6 +27,7 @@
 //
 
 // Enable hooks for support for the Transactional Memory TS (N4514).
+#if __cpp_transactional_memory >= 201505L
 #define _GLIBCXX_TM_TS_INTERNAL
 void
 _txnal_cow_string_C1_for_exceptions(void* that, const char* s, void* exc);
@@ -40,6 +41,7 @@ void*
 _txnal_logic_error_get_msg(void* e);
 void*
 _txnal_runtime_error_get_msg(void* e);
+#endif
 
 // All exception classes still use the classic COW std::string.
 #define _GLIBCXX_USE_CXX11_ABI 0
@@ -167,6 +169,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
+#if __cpp_transactional_memory >= 201505L
 // Support for the Transactional Memory TS (N4514).
 //
 // logic_error and runtime_error both carry a message in the form of a COW
@@ -440,3 +443,4 @@ CTORDTOR(14overflow_error, std::overflow_error, 
runtime_error)
 CTORDTOR(15underflow_error, std::underflow_error, runtime_error)
 
 }
+#endif


Re: [PATCH v2] libstdc++: Make certain exceptions transaction_safe.

2016-01-16 Thread David Edelsohn
stage1 libstdc++ builds just fine.  the problem is stage2 configure
fails due to missing ITM_xxx symbols when configure tries to compile
and run conftest programs.

Thanks, David


On Sat, Jan 16, 2016 at 7:43 AM, Jonathan Wakely  wrote:
> What are the errors?
>
> I can build libstdc++ on gcc111.
>
> Does this patch help?
>
>


Re: [PATCH v2] libstdc++: Make certain exceptions transaction_safe.

2016-01-16 Thread Jakub Jelinek
On Sat, Jan 16, 2016 at 07:47:33AM -0500, David Edelsohn wrote:
> stage1 libstdc++ builds just fine.  the problem is stage2 configure
> fails due to missing ITM_xxx symbols when configure tries to compile
> and run conftest programs.

On x86_64-linux, the _ITM_xxx symbols are undef weak ones and thus it is
fine to load libstdc++ without libitm and libstdc++ doesn't depend on
libitm.

So, is AIX defining __GXX_WEAK__ or not?  Perhaps some other macro or
configure check needs to be used to determine if undefined weak symbols
work the way libstdc++ needs them to.

#if __GXX_WEAK__
// Declare all libitm symbols we rely on, but make them weak so that we do
// not depend on libitm.
extern void* _ZGTtnaX (size_t sz) __attribute__((weak));
extern void _ZGTtdlPv (void* ptr) __attribute__((weak));
extern uint8_t _ITM_RU1(const uint8_t *p)
  ITM_REGPARM __attribute__((weak));
extern uint32_t _ITM_RU4(const uint32_t *p)
  ITM_REGPARM __attribute__((weak));
extern uint64_t _ITM_RU8(const uint64_t *p)
  ITM_REGPARM __attribute__((weak));
extern void _ITM_memcpyRtWn(void *, const void *, size_t)
  ITM_REGPARM __attribute__((weak));
extern void _ITM_memcpyRnWt(void *, const void *, size_t)
  ITM_REGPARM __attribute__((weak));
extern void _ITM_addUserCommitAction(void (*)(void *), uint64_t, void *)
  ITM_REGPARM __attribute__((weak));

#else
// If there is no support for weak symbols, create dummies.  The exceptions
// will not be declared transaction_safe in this case.
void* _ZGTtnaX (size_t) { return NULL; }
void _ZGTtdlPv (void*) { }
uint8_t _ITM_RU1(const uint8_t *) { return 0; }
uint32_t _ITM_RU4(const uint32_t *) { return 0; }
uint64_t _ITM_RU8(const uint64_t *) { return 0; }
void _ITM_memcpyRtWn(void *, const void *, size_t) { }
void _ITM_memcpyRnWt(void *, const void *, size_t) { }
void _ITM_addUserCommitAction(void (*)(void *), uint64_t, void *) { };
#endif

Jakub


Re: [PATCH v2] libstdc++: Make certain exceptions transaction_safe.

2016-01-16 Thread Jonathan Wakely

On 16/01/16 14:35 +0100, Jakub Jelinek wrote:

On Sat, Jan 16, 2016 at 07:47:33AM -0500, David Edelsohn wrote:

stage1 libstdc++ builds just fine.  the problem is stage2 configure
fails due to missing ITM_xxx symbols when configure tries to compile
and run conftest programs.


On x86_64-linux, the _ITM_xxx symbols are undef weak ones and thus it is
fine to load libstdc++ without libitm and libstdc++ doesn't depend on
libitm.

So, is AIX defining __GXX_WEAK__ or not?  Perhaps some other macro or
configure check needs to be used to determine if undefined weak symbols
work the way libstdc++ needs them to.

#if __GXX_WEAK__
// Declare all libitm symbols we rely on, but make them weak so that we do
// not depend on libitm.
extern void* _ZGTtnaX (size_t sz) __attribute__((weak));
extern void _ZGTtdlPv (void* ptr) __attribute__((weak));
extern uint8_t _ITM_RU1(const uint8_t *p)
 ITM_REGPARM __attribute__((weak));
extern uint32_t _ITM_RU4(const uint32_t *p)
 ITM_REGPARM __attribute__((weak));
extern uint64_t _ITM_RU8(const uint64_t *p)
 ITM_REGPARM __attribute__((weak));
extern void _ITM_memcpyRtWn(void *, const void *, size_t)
 ITM_REGPARM __attribute__((weak));
extern void _ITM_memcpyRnWt(void *, const void *, size_t)
 ITM_REGPARM __attribute__((weak));
extern void _ITM_addUserCommitAction(void (*)(void *), uint64_t, void *)
 ITM_REGPARM __attribute__((weak));

#else
// If there is no support for weak symbols, create dummies.  The exceptions
// will not be declared transaction_safe in this case.
void* _ZGTtnaX (size_t) { return NULL; }
void _ZGTtdlPv (void*) { }
uint8_t _ITM_RU1(const uint8_t *) { return 0; }
uint32_t _ITM_RU4(const uint32_t *) { return 0; }
uint64_t _ITM_RU8(const uint64_t *) { return 0; }
void _ITM_memcpyRtWn(void *, const void *, size_t) { }
void _ITM_memcpyRnWt(void *, const void *, size_t) { }
void _ITM_addUserCommitAction(void (*)(void *), uint64_t, void *) { };
#endif


I think it's better to just drop that whole section of the file if TM
isn't supported, as this patch does.

Bootstraps OK on AIX, still testing on GNU/Linux.


commit 16819a03a27de6911140c8e1a249611dc232b30d
Author: Jonathan Wakely 
Date:   Sat Jan 16 13:07:02 2016 +

Fix bootstrap for targets without TM support

	PR libstdc++/69312
	* include/bits/c++config: Adjust whitespace.
	* libsupc++/eh_exception.cc: Check feature-test macro for TM support.
	* src/c++11/cow-stdexcept.cc: Likewise.

diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 387a7bb..81d757e 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -490,11 +490,11 @@ namespace std
   && _GLIBCXX_USE_DUAL_ABI && __cpp_transactional_memory >= 201505L	\
   &&  !_GLIBCXX_FULLY_DYNAMIC_STRING && __GXX_WEAK__ 			\
   && _GLIBCXX_USE_ALLOCATOR_NEW
-#define _GLIBCXX_TXN_SAFE transaction_safe
-#define _GLIBCXX_TXN_SAFE_DYN transaction_safe_dynamic
+# define _GLIBCXX_TXN_SAFE transaction_safe
+# define _GLIBCXX_TXN_SAFE_DYN transaction_safe_dynamic
 #else
-#define _GLIBCXX_TXN_SAFE
-#define _GLIBCXX_TXN_SAFE_DYN
+# define _GLIBCXX_TXN_SAFE
+# define _GLIBCXX_TXN_SAFE_DYN
 #endif
 
 #else // !__cplusplus
diff --git a/libstdc++-v3/libsupc++/eh_exception.cc b/libstdc++-v3/libsupc++/eh_exception.cc
index 32f9df7..f1a6ffb 100644
--- a/libstdc++-v3/libsupc++/eh_exception.cc
+++ b/libstdc++-v3/libsupc++/eh_exception.cc
@@ -51,6 +51,7 @@ std::bad_exception::what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT
   return "std::bad_exception";
 }
 
+#if __cpp_transactional_memory >= 201505L
 // Transactional clones for the destructors and what().
 // what() is effectively transaction_pure, but we do not want to annotate it
 // as such; thus, we call exactly the respective nontransactional function.
@@ -84,3 +85,4 @@ _ZGTtNKSt13bad_exception4whatEv(
 }
 
 }
+#endif
diff --git a/libstdc++-v3/src/c++11/cow-stdexcept.cc b/libstdc++-v3/src/c++11/cow-stdexcept.cc
index afc3f6c..7211ebe 100644
--- a/libstdc++-v3/src/c++11/cow-stdexcept.cc
+++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc
@@ -26,6 +26,7 @@
 // ISO C++ 14882: 19.1  Exception classes
 //
 
+#if __cpp_transactional_memory >= 201505L
 // Enable hooks for support for the Transactional Memory TS (N4514).
 #define _GLIBCXX_TM_TS_INTERNAL
 void
@@ -40,6 +41,7 @@ void*
 _txnal_logic_error_get_msg(void* e);
 void*
 _txnal_runtime_error_get_msg(void* e);
+#endif
 
 // All exception classes still use the classic COW std::string.
 #define _GLIBCXX_USE_CXX11_ABI 0
@@ -167,6 +169,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
+#if __cpp_transactional_memory >= 201505L
 // Support for the Transactional Memory TS (N4514).
 //
 // logic_error and runtime_error both carry a message in the form of a COW
@@ -440,3 +443,4 @@ CTORDTOR(14overflow_error, std::overflow_error, runtime_error)
 CTORDTOR(15underflow_error, std::underflow_error, runtime_error)
 
 }
+#endif


[PATCH] s390: Add -fsplit-stack support

2016-01-16 Thread Marcin Kościelnicki
libgcc/ChangeLog:

* config.host: Use t-stack and t-stack-s390 for s390*-*-linux.
* config/s390/morestack.S: New file.
* config/s390/t-stack-s390: New file.
* generic-morestack.c (__splitstack_find): Add s390-specific code.

gcc/ChangeLog:

* common/config/s390/s390-common.c (s390_supports_split_stack):
New function.
(TARGET_SUPPORTS_SPLIT_STACK): New macro.
* config/s390/s390-protos.h: Add s390_expand_split_stack_prologue.
* config/s390/s390.c (struct machine_function): New field
split_stack_varargs_pointer.
(s390_register_info): Mark r12 as clobbered if it'll be used as temp
in s390_emit_prologue.
(s390_emit_prologue): Use r12 as temp if r1 is taken by split-stack
vararg pointer.
(morestack_ref): New global.
(SPLIT_STACK_AVAILABLE): New macro.
(s390_expand_split_stack_prologue): New function.
(s390_expand_split_stack_call): New function.
(s390_live_on_entry): New function.
(s390_va_start): Use split-stack vararg pointer if appropriate.
(s390_reorg): Lower the split-stack pseudo-insns.
(s390_asm_file_end): Emit the split-stack note sections.
(TARGET_EXTRA_LIVE_ON_ENTRY): New macro.
* config/s390/s390.md: (UNSPEC_STACK_CHECK): New unspec.
(UNSPECV_SPLIT_STACK_CALL): New unspec.
(UNSPECV_SPLIT_STACK_SIBCALL): New unspec.
(UNSPECV_SPLIT_STACK_MARKER): New unspec.
(split_stack_prologue): New expand.
(split_stack_call_*): New insn.
(split_stack_cond_call_*): New insn.
(split_stack_space_check): New expand.
(split_stack_sibcall_*): New insn.
(split_stack_cond_sibcall_*): New insn.
(split_stack_marker): New insn.
---
Support for !TARGET_CPU_ZARCH removed and sorried.  I've also cleaned up
the 31-bit versions of morestack.S routines to more closely mirror their
64-bit counterparts, since I can now use the newer opcodes.

I'm also submitting a new version of the gold patch, which has support for
old CPUs likewise removed.

 gcc/ChangeLog|  33 ++
 gcc/common/config/s390/s390-common.c |  14 +
 gcc/config/s390/s390-protos.h|   1 +
 gcc/config/s390/s390.c   | 371 -
 gcc/config/s390/s390.md  | 109 +++
 libgcc/ChangeLog |   7 +
 libgcc/config.host   |   4 +-
 libgcc/config/s390/morestack.S   | 609 +++
 libgcc/config/s390/t-stack-s390  |   2 +
 libgcc/generic-morestack.c   |   4 +
 10 files changed, 1148 insertions(+), 6 deletions(-)
 create mode 100644 libgcc/config/s390/morestack.S
 create mode 100644 libgcc/config/s390/t-stack-s390

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c881d52..71f6f38 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,38 @@
 2016-01-16  Marcin Kościelnicki  
 
+   * common/config/s390/s390-common.c (s390_supports_split_stack):
+   New function.
+   (TARGET_SUPPORTS_SPLIT_STACK): New macro.
+   * config/s390/s390-protos.h: Add s390_expand_split_stack_prologue.
+   * config/s390/s390.c (struct machine_function): New field
+   split_stack_varargs_pointer.
+   (s390_register_info): Mark r12 as clobbered if it'll be used as temp
+   in s390_emit_prologue.
+   (s390_emit_prologue): Use r12 as temp if r1 is taken by split-stack
+   vararg pointer.
+   (morestack_ref): New global.
+   (SPLIT_STACK_AVAILABLE): New macro.
+   (s390_expand_split_stack_prologue): New function.
+   (s390_expand_split_stack_call): New function.
+   (s390_live_on_entry): New function.
+   (s390_va_start): Use split-stack vararg pointer if appropriate.
+   (s390_reorg): Lower the split-stack pseudo-insns.
+   (s390_asm_file_end): Emit the split-stack note sections.
+   (TARGET_EXTRA_LIVE_ON_ENTRY): New macro.
+   * config/s390/s390.md: (UNSPEC_STACK_CHECK): New unspec.
+   (UNSPECV_SPLIT_STACK_CALL): New unspec.
+   (UNSPECV_SPLIT_STACK_SIBCALL): New unspec.
+   (UNSPECV_SPLIT_STACK_MARKER): New unspec.
+   (split_stack_prologue): New expand.
+   (split_stack_call_*): New insn.
+   (split_stack_cond_call_*): New insn.
+   (split_stack_space_check): New expand.
+   (split_stack_sibcall_*): New insn.
+   (split_stack_cond_sibcall_*): New insn.
+   (split_stack_marker): New insn.
+
+2016-01-02  Marcin Kościelnicki  
+
* cfgrtl.c (rtl_tidy_fallthru_edge): Bail for unconditional jumps
with side effects.
 
diff --git a/gcc/common/config/s390/s390-common.c 
b/gcc/common/config/s390/s390-common.c
index 4519c21..1e497e6 100644
--- a/gcc/common/config/s390/s390-common.c
+++ b/gcc/common/config/s390/s390-common.c
@@ -105,6 +105,17 @@ s390_handle_option (struct gcc_options *opts 
ATTRIBUTE_UNUSED,
 }
 }
 
+/* -fsplit-stack uses a field in the TCB, available wit

Re: [PATCH v2] libstdc++: Make certain exceptions transaction_safe.

2016-01-16 Thread Jonathan Wakely

On 16/01/16 13:41 +, Jonathan Wakely wrote:

On 16/01/16 14:35 +0100, Jakub Jelinek wrote:

On Sat, Jan 16, 2016 at 07:47:33AM -0500, David Edelsohn wrote:

stage1 libstdc++ builds just fine.  the problem is stage2 configure
fails due to missing ITM_xxx symbols when configure tries to compile
and run conftest programs.


On x86_64-linux, the _ITM_xxx symbols are undef weak ones and thus it is
fine to load libstdc++ without libitm and libstdc++ doesn't depend on
libitm.

So, is AIX defining __GXX_WEAK__ or not?  Perhaps some other macro or
configure check needs to be used to determine if undefined weak symbols
work the way libstdc++ needs them to.

#if __GXX_WEAK__
// Declare all libitm symbols we rely on, but make them weak so that we do
// not depend on libitm.
extern void* _ZGTtnaX (size_t sz) __attribute__((weak));
extern void _ZGTtdlPv (void* ptr) __attribute__((weak));
extern uint8_t _ITM_RU1(const uint8_t *p)
ITM_REGPARM __attribute__((weak));
extern uint32_t _ITM_RU4(const uint32_t *p)
ITM_REGPARM __attribute__((weak));
extern uint64_t _ITM_RU8(const uint64_t *p)
ITM_REGPARM __attribute__((weak));
extern void _ITM_memcpyRtWn(void *, const void *, size_t)
ITM_REGPARM __attribute__((weak));
extern void _ITM_memcpyRnWt(void *, const void *, size_t)
ITM_REGPARM __attribute__((weak));
extern void _ITM_addUserCommitAction(void (*)(void *), uint64_t, void *)
ITM_REGPARM __attribute__((weak));

#else
// If there is no support for weak symbols, create dummies.  The exceptions
// will not be declared transaction_safe in this case.
void* _ZGTtnaX (size_t) { return NULL; }
void _ZGTtdlPv (void*) { }
uint8_t _ITM_RU1(const uint8_t *) { return 0; }
uint32_t _ITM_RU4(const uint32_t *) { return 0; }
uint64_t _ITM_RU8(const uint64_t *) { return 0; }
void _ITM_memcpyRtWn(void *, const void *, size_t) { }
void _ITM_memcpyRnWt(void *, const void *, size_t) { }
void _ITM_addUserCommitAction(void (*)(void *), uint64_t, void *) { };
#endif


I think it's better to just drop that whole section of the file if TM
isn't supported, as this patch does.

Bootstraps OK on AIX, still testing on GNU/Linux.


Doh, it causes libitm.c++/libstdc++-safeexc.C to FAIL, because TM
isn't enabled when building libstdc++ ... that's the whole point of
the complicated preprocessor conditions!



Re: [RFC][PATCH, ARM 7/8] ARMv8-M Security Extension's cmse_nonsecure_call: use __gnu_cmse_nonsecure_call]

2016-01-16 Thread Senthil Kumar Selvaraj
User-agent: mu4e 0.9.13; emacs 24.5.1

Hi,

Apologies for the bad posting style (I don't have the
original email handy), but shouldn't _gnu_cmse_nonsecure_call be defined
with the .global directive in the below hunk (to make it visible when linking)?

diff --git a/libgcc/config/arm/cmse_nonsecure_call.S b/libgcc/config/arm/cm=
se_nonsecure_call.S
new file mode 100644
index ..bdc140f5bbe87c6599db225b1b9=
b7bbc7d606710
--- /dev/null
+++ b/libgcc/config/arm/cmse_nonsecure_call.S
@@ -0,0 +1,87 @@
+.syntax unified
+.thumb
+__gnu_cmse_nonsecure_call:

Right now, it ends up as a local symbol, and compiling and linking a
program with cmse_nonsecure_call (say cmse-11.c), results in a linker
error - the linker doesn't find the symbol even if it is present in
libgcc.a. I found the problem that way - dumping symbols for my variant
of libgcc.a and grepping showed the symbol to be available but local.

Regards
Senthil


Re: [PATCH v2] libstdc++: Make certain exceptions transaction_safe.

2016-01-16 Thread Torvald Riegel
On Sat, 2016-01-16 at 10:57 +0100, Dominique d'Humières wrote:
> > Addressed these, fixed a problem with using GLIBCXX_WEAK_DEFINITION
> > (which is only set on Darwin despite the generic-sounding name -- so
> > just use __attribute__((weak)) directly), and also updated
> > testsuite_abi.cc so that it knows about CXXABI_1.3.10.
> >
> > Approved by Jonathan Wakely.  Committed as r232454.
> This breaks bootstrap on darwin, see 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69310.

Can you (or anyone else with access to Darwin) let me know what Darwin
actually supports that would be similar in effect to the alias we use
right now?  I suppose a weak alias would work as well because we define
the C1 constructor anyway?  If so, what's the proper macros / configury
check to use for these?

Is there any documentation for what darwin supports and needs in this
space?



Re: [PATCH v2] libstdc++: Make certain exceptions transaction_safe.

2016-01-16 Thread Torvald Riegel
On Sat, 2016-01-16 at 14:35 +0100, Jakub Jelinek wrote:
> On Sat, Jan 16, 2016 at 07:47:33AM -0500, David Edelsohn wrote:
> > stage1 libstdc++ builds just fine.  the problem is stage2 configure
> > fails due to missing ITM_xxx symbols when configure tries to compile
> > and run conftest programs.
> 
> On x86_64-linux, the _ITM_xxx symbols are undef weak ones and thus it is
> fine to load libstdc++ without libitm and libstdc++ doesn't depend on
> libitm.
> 
> So, is AIX defining __GXX_WEAK__ or not?  Perhaps some other macro or
> configure check needs to be used to determine if undefined weak symbols
> work the way libstdc++ needs them to.

David, if you can tell me what AIX supports and whether it defines
__GXX_WEAK__ with the semantics we assume here, I can see what a fix
would be.  As Jakub says, the point of all what's below is to actually
make it work when there's no TM support.

Also, knowing the actual error that AIX fails with would be helpful.  I
have no access to AIX, so can't check.  Thanks.

> #if __GXX_WEAK__
> // Declare all libitm symbols we rely on, but make them weak so that we do
> // not depend on libitm.
> extern void* _ZGTtnaX (size_t sz) __attribute__((weak));
> extern void _ZGTtdlPv (void* ptr) __attribute__((weak));
> extern uint8_t _ITM_RU1(const uint8_t *p)
>   ITM_REGPARM __attribute__((weak));
> extern uint32_t _ITM_RU4(const uint32_t *p)
>   ITM_REGPARM __attribute__((weak));
> extern uint64_t _ITM_RU8(const uint64_t *p)
>   ITM_REGPARM __attribute__((weak));
> extern void _ITM_memcpyRtWn(void *, const void *, size_t)
>   ITM_REGPARM __attribute__((weak));
> extern void _ITM_memcpyRnWt(void *, const void *, size_t)
>   ITM_REGPARM __attribute__((weak));
> extern void _ITM_addUserCommitAction(void (*)(void *), uint64_t, void *)
>   ITM_REGPARM __attribute__((weak));
> 
> #else
> // If there is no support for weak symbols, create dummies.  The exceptions
> // will not be declared transaction_safe in this case.
> void* _ZGTtnaX (size_t) { return NULL; }
> void _ZGTtdlPv (void*) { }
> uint8_t _ITM_RU1(const uint8_t *) { return 0; }
> uint32_t _ITM_RU4(const uint32_t *) { return 0; }
> uint64_t _ITM_RU8(const uint64_t *) { return 0; }
> void _ITM_memcpyRtWn(void *, const void *, size_t) { }
> void _ITM_memcpyRnWt(void *, const void *, size_t) { }
> void _ITM_addUserCommitAction(void (*)(void *), uint64_t, void *) { };
> #endif
> 
>   Jakub





Re: [PATCH v2] libstdc++: Make certain exceptions transaction_safe.

2016-01-16 Thread David Edelsohn
Torvald,

The error is a link failure in stage2 configure due to the missing
_ITM_xxx and related symbols.  I don't have the failed build any more.
Maybe Jonathan can reply with the specific failures.

There is an AIX system in the GNU Compile Farm: gcc111.

- David

On Sat, Jan 16, 2016 at 3:12 PM, Torvald Riegel  wrote:
> On Sat, 2016-01-16 at 14:35 +0100, Jakub Jelinek wrote:
>> On Sat, Jan 16, 2016 at 07:47:33AM -0500, David Edelsohn wrote:
>> > stage1 libstdc++ builds just fine.  the problem is stage2 configure
>> > fails due to missing ITM_xxx symbols when configure tries to compile
>> > and run conftest programs.
>>
>> On x86_64-linux, the _ITM_xxx symbols are undef weak ones and thus it is
>> fine to load libstdc++ without libitm and libstdc++ doesn't depend on
>> libitm.
>>
>> So, is AIX defining __GXX_WEAK__ or not?  Perhaps some other macro or
>> configure check needs to be used to determine if undefined weak symbols
>> work the way libstdc++ needs them to.
>
> David, if you can tell me what AIX supports and whether it defines
> __GXX_WEAK__ with the semantics we assume here, I can see what a fix
> would be.  As Jakub says, the point of all what's below is to actually
> make it work when there's no TM support.
>
> Also, knowing the actual error that AIX fails with would be helpful.  I
> have no access to AIX, so can't check.  Thanks.
>
>> #if __GXX_WEAK__
>> // Declare all libitm symbols we rely on, but make them weak so that we do
>> // not depend on libitm.
>> extern void* _ZGTtnaX (size_t sz) __attribute__((weak));
>> extern void _ZGTtdlPv (void* ptr) __attribute__((weak));
>> extern uint8_t _ITM_RU1(const uint8_t *p)
>>   ITM_REGPARM __attribute__((weak));
>> extern uint32_t _ITM_RU4(const uint32_t *p)
>>   ITM_REGPARM __attribute__((weak));
>> extern uint64_t _ITM_RU8(const uint64_t *p)
>>   ITM_REGPARM __attribute__((weak));
>> extern void _ITM_memcpyRtWn(void *, const void *, size_t)
>>   ITM_REGPARM __attribute__((weak));
>> extern void _ITM_memcpyRnWt(void *, const void *, size_t)
>>   ITM_REGPARM __attribute__((weak));
>> extern void _ITM_addUserCommitAction(void (*)(void *), uint64_t, void *)
>>   ITM_REGPARM __attribute__((weak));
>>
>> #else
>> // If there is no support for weak symbols, create dummies.  The exceptions
>> // will not be declared transaction_safe in this case.
>> void* _ZGTtnaX (size_t) { return NULL; }
>> void _ZGTtdlPv (void*) { }
>> uint8_t _ITM_RU1(const uint8_t *) { return 0; }
>> uint32_t _ITM_RU4(const uint32_t *) { return 0; }
>> uint64_t _ITM_RU8(const uint64_t *) { return 0; }
>> void _ITM_memcpyRtWn(void *, const void *, size_t) { }
>> void _ITM_memcpyRnWt(void *, const void *, size_t) { }
>> void _ITM_addUserCommitAction(void (*)(void *), uint64_t, void *) { };
>> #endif
>>
>>   Jakub
>
>
>


Re: [PATCH v2] libstdc++: Make certain exceptions transaction_safe.

2016-01-16 Thread David Edelsohn
On Sat, Jan 16, 2016 at 8:35 AM, Jakub Jelinek  wrote:
> On Sat, Jan 16, 2016 at 07:47:33AM -0500, David Edelsohn wrote:
>> stage1 libstdc++ builds just fine.  the problem is stage2 configure
>> fails due to missing ITM_xxx symbols when configure tries to compile
>> and run conftest programs.
>
> On x86_64-linux, the _ITM_xxx symbols are undef weak ones and thus it is
> fine to load libstdc++ without libitm and libstdc++ doesn't depend on
> libitm.
>
> So, is AIX defining __GXX_WEAK__ or not?  Perhaps some other macro or
> configure check needs to be used to determine if undefined weak symbols
> work the way libstdc++ needs them to.

__GXX_WEAK__ appears to be defined by gcc/c-family/c-cppbuiltin.c
based on  SUPPORTS_ONE_ONLY.  gcc/defaults.h defines SUPPORTS_ONE_ONLY
if the target supports MAKE_DECL_ONE_ONLY and link-once semantics.
AIX weak correctly supports link-once semantics.  AIX also supports
the definition of __GXX_WEAK__ in gcc/doc/cpp.texi, namely collapsing
symbols with vague linkage in multiple translation units.

libstdc++/src/c++11/cow-stdexcept.cc appears to be using __GXX_WEAK__
and __attribute__ ((weak)) for references to symbols that may not be
defined at link time or run time.  AIX does not allow undefined symbol
errors by default.  And the libstdc++ inference about the semantics of
__GXX_WEAK__ are different than the documentation.

AIX supports MAKE_DECL_ONE_ONLY and the documented meaning of
__GXX_WEAK__.  AIX does not support extension of the meaning to
additional SVR4 semantics not specified in the documentation.

Thanks, David


[PATCH][committed] libitm: Ensure proxy privatization safety.

2016-01-16 Thread Torvald Riegel
This patch fixes privatization safety support by additionally ensuring
proxy privatization safety.  It fixes a correctness bugs, but in a
simple way for now, which will lead to less scalability with higher
thread counts.  I plan to finish an optimization once I have enough time
for this.

Tested on x86_64-linux.  Committed as r232469

* method-gl.cc (gl_wt_dispatch::trycommit): Ensure proxy privatization
safety.
* method-ml.cc (ml_wt_dispatch::trycommit): Likewise.
* libitm/testsuite/libitm.c/priv-1.c: New.

commit fded025d03371aa320eb7e0cb6bd3d772e387fdc
Author: Torvald Riegel 
Date:   Fri Nov 27 22:59:07 2015 +0100

libitm: Ensure proxy privatization safety.

	* method-gl.cc (gl_wt_dispatch::trycommit): Ensure proxy privatization
	safety.
	* method-ml.cc (ml_wt_dispatch::trycommit): Likewise.
	* libitm/testsuite/libitm.c/priv-1.c: New.

diff --git a/libitm/method-gl.cc b/libitm/method-gl.cc
index b2e2bca..b51c802 100644
--- a/libitm/method-gl.cc
+++ b/libitm/method-gl.cc
@@ -291,12 +291,18 @@ public:
 // See begin_or_restart() for why we need release memory order here.
 	v = gl_mg::clear_locked(v) + 1;
 	o_gl_mg.orec.store(v, memory_order_release);
-
-	// Need to ensure privatization safety. Every other transaction must
-	// have a snapshot time that is at least as high as our commit time
-	// (i.e., our commit must be visible to them).
-	priv_time = v;
   }
+
+// Need to ensure privatization safety. Every other transaction must have
+// a snapshot time that is at least as high as our commit time (i.e., our
+// commit must be visible to them).  Because of proxy privatization, we
+// must ensure that even if we are a read-only transaction.  See
+// ml_wt_dispatch::trycommit() for details: We can't get quite the same
+// set of problems because we just use one orec and thus, for example,
+// there cannot be concurrent writers -- but we can still get pending
+// loads to privatized data when not ensuring privatization safety, which
+// is problematic if the program unmaps the privatized memory.
+priv_time = v;
 return true;
   }
 
diff --git a/libitm/method-ml.cc b/libitm/method-ml.cc
index 723643a..c1a6771 100644
--- a/libitm/method-ml.cc
+++ b/libitm/method-ml.cc
@@ -513,6 +513,21 @@ public:
 if (!tx->writelog.size())
   {
 tx->readlog.clear();
+// We still need to ensure privatization safety, unfortunately.  While
+// we cannot have privatized anything by ourselves (because we are not
+// an update transaction), we can have observed the commits of
+// another update transaction that privatized something.  Because any
+// commit happens before ensuring privatization, our snapshot and
+// commit can thus have happened before ensuring privatization safety
+// for this commit/snapshot time.  Therefore, before we can return to
+// nontransactional code that might use the privatized data, we must
+// ensure privatization safety for our snapshot time.
+// This still seems to be better than not allowing use of the
+// snapshot time before privatization safety has been ensured because
+// we at least can run transactions such as this one, and in the
+// meantime the transaction producing this commit time might have
+// finished ensuring privatization safety for it.
+priv_time = tx->shared_state.load(memory_order_relaxed);
 return true;
   }
 
diff --git a/libitm/testsuite/libitm.c/priv-1.c b/libitm/testsuite/libitm.c/priv-1.c
new file mode 100644
index 000..635d523
--- /dev/null
+++ b/libitm/testsuite/libitm.c/priv-1.c
@@ -0,0 +1,116 @@
+/* Quick stress test for proxy privatization.  */
+
+/* We need to use a TM method that has to enforce privatization safety
+   explicitly.  */
+/* { dg-set-target-env-var ITM_DEFAULT_METHOD "ml_wt" } */
+
+#include 
+#include 
+#include 
+
+/* Make them likely to be mapped to different orecs.  */
+#define ALIGN __attribute__((aligned (256)))
+/* Don't make these static to work around PR 68591.  */
+int x ALIGN;
+int *ptr ALIGN;
+int *priv_ptr ALIGN;
+int priv_value ALIGN;
+int barrier ALIGN = 0;
+const int iters = 100;
+
+static void arrive_and_wait (int expected_value)
+{
+  int now = __atomic_add_fetch (&barrier, 1, __ATOMIC_ACQ_REL);
+  while (now < expected_value)
+__atomic_load (&barrier, &now, __ATOMIC_ACQUIRE);
+}
+
+static void __attribute__((transaction_pure,noinline)) delay (int i)
+{
+  for (volatile int v = 0; v < i; v++);
+}
+
+/* This tries to catch a case in which proxy privatization safety is not
+   ensured by privatization_user.  Specifically, it's access to the value
+   of it's transactional snapshot of ptr must read from an uncommitted write
+   by writer; thus, writer must still be active but must have read ptr before
+   proxy can privatize *ptr by assigning to ptr.
+   We try to make this int

[Committed, testsuite] Move gcc.dg/parloops-exit-first-loop-alt-*.c to gcc.dg/autopar

2016-01-16 Thread Tom de Vries

Hi,

I've moved the gcc.dg/parloops-exit-first-loop-alt-*.c tests to 
gcc.dg/autopar.


Committed to trunk.

Thanks,
- Tom
Move gcc.dg/parloops-exit-first-loop-alt-*.c to gcc.dg/autopar

2016-01-16  Tom de Vries  

	* gcc.dg/parloops-exit-first-loop-alt.c: Move ...
	* gcc.dg/autopar/parloops-exit-first-loop-alt.c: ... here.  Remove
	redundant dg-require-effective-target pthread.
	* gcc.dg/parloops-exit-first-loop-alt-2.c: Same.
	* gcc.dg/parloops-exit-first-loop-alt-3.c: Same.
	* gcc.dg/parloops-exit-first-loop-alt-4.c: Same.
	* gcc.dg/parloops-exit-first-loop-alt-5.c: Same.
	* gcc.dg/parloops-exit-first-loop-alt-6.c: Same.
	* gcc.dg/parloops-exit-first-loop-alt-7.c: Same.
	* gcc.dg/parloops-exit-first-loop-alt-pr66652.c: Same.

---
 .../autopar/parloops-exit-first-loop-alt-2.c   | 21 +
 .../autopar/parloops-exit-first-loop-alt-3.c   | 20 +
 .../autopar/parloops-exit-first-loop-alt-4.c   | 22 ++
 .../autopar/parloops-exit-first-loop-alt-5.c   | 16 +
 .../autopar/parloops-exit-first-loop-alt-6.c   | 16 +
 .../autopar/parloops-exit-first-loop-alt-7.c   | 16 +
 .../autopar/parloops-exit-first-loop-alt-pr66652.c | 25 +
 .../gcc.dg/autopar/parloops-exit-first-loop-alt.c  | 17 ++
 .../gcc.dg/parloops-exit-first-loop-alt-2.c| 22 --
 .../gcc.dg/parloops-exit-first-loop-alt-3.c| 21 -
 .../gcc.dg/parloops-exit-first-loop-alt-4.c| 23 ---
 .../gcc.dg/parloops-exit-first-loop-alt-5.c| 17 --
 .../gcc.dg/parloops-exit-first-loop-alt-6.c| 17 --
 .../gcc.dg/parloops-exit-first-loop-alt-7.c| 17 --
 .../gcc.dg/parloops-exit-first-loop-alt-pr66652.c  | 26 --
 .../gcc.dg/parloops-exit-first-loop-alt.c  | 18 ---
 16 files changed, 153 insertions(+), 161 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/autopar/parloops-exit-first-loop-alt-2.c b/gcc/testsuite/gcc.dg/autopar/parloops-exit-first-loop-alt-2.c
new file mode 100644
index 000..f988455
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/autopar/parloops-exit-first-loop-alt-2.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=2 -fdump-tree-parloops-details" } */
+
+/* Constant bound, vector addition.  */
+
+#define N 1000
+
+unsigned int a[N];
+unsigned int b[N];
+unsigned int c[N];
+
+void
+f (void)
+{
+  int i;
+
+for (i = 0; i < N; ++i)
+  c[i] = a[i] + b[i];
+}
+
+/* { dg-final { scan-tree-dump-times "alternative exit-first loop transform succeeded" 1 "parloops" } } */
diff --git a/gcc/testsuite/gcc.dg/autopar/parloops-exit-first-loop-alt-3.c b/gcc/testsuite/gcc.dg/autopar/parloops-exit-first-loop-alt-3.c
new file mode 100644
index 000..8bba352
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/autopar/parloops-exit-first-loop-alt-3.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=2 -fdump-tree-parloops-details" } */
+
+/* Variable bound, reduction.  */
+
+unsigned int *a;
+
+unsigned int
+f (unsigned int n, unsigned int *__restrict__ a)
+{
+  int i;
+  unsigned int sum = 1;
+
+  for (i = 0; i < n; ++i)
+sum += a[i];
+
+  return sum;
+}
+
+/* { dg-final { scan-tree-dump-times "alternative exit-first loop transform succeeded" 1 "parloops" } } */
diff --git a/gcc/testsuite/gcc.dg/autopar/parloops-exit-first-loop-alt-4.c b/gcc/testsuite/gcc.dg/autopar/parloops-exit-first-loop-alt-4.c
new file mode 100644
index 000..ccb07bc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/autopar/parloops-exit-first-loop-alt-4.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=2 -fdump-tree-parloops-details" } */
+
+/* Constant bound, reduction.  */
+
+#define N 4000
+
+unsigned int *a;
+
+unsigned int
+f (void)
+{
+  int i;
+  unsigned int sum = 1;
+
+  for (i = 0; i < N; ++i)
+sum += a[i];
+
+  return sum;
+}
+
+/* { dg-final { scan-tree-dump-times "alternative exit-first loop transform succeeded" 1 "parloops" } } */
diff --git a/gcc/testsuite/gcc.dg/autopar/parloops-exit-first-loop-alt-5.c b/gcc/testsuite/gcc.dg/autopar/parloops-exit-first-loop-alt-5.c
new file mode 100644
index 000..68367b1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/autopar/parloops-exit-first-loop-alt-5.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=2 -fdump-tree-parloops-details" } */
+
+/* Variable bound, vector addition, unsigned loop counter, unsigned bound.  */
+
+void
+f (unsigned int n, unsigned int *__restrict__ a, unsigned int *__restrict__ b,
+   unsigned int *__restrict__ c)
+{
+  unsigned int i;
+
+  for (i = 0; i < n; ++i)
+c[i] = a[i] + b[i];
+}
+
+/* { dg-final { scan-tree-dump-times "alternative exit-first loop transform succeeded" 1 "parloops" } } */
diff --git a/gcc/testsuite/gcc.dg/autopar/parloops-exit-first-loop-alt-6.c b

[testsuite, committed] Add goacc/kernels-alias-ipa-pta-4.c

2016-01-16 Thread Tom de Vries

Hi,

this is an additional test, similar to goacc/kernels-alias-ipa-pta.c but 
with scalars instead of arrays.


Committed to trunk.

Thanks,
- Tom
Add goacc/kernels-alias-ipa-pta-4.c

2016-01-16  Tom de Vries  

	* c-c++-common/goacc/kernels-alias-ipa-pta-4.c: New test.

---
 .../c-c++-common/goacc/kernels-alias-ipa-pta-4.c| 21 +
 1 file changed, 21 insertions(+)

diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-alias-ipa-pta-4.c b/gcc/testsuite/c-c++-common/goacc/kernels-alias-ipa-pta-4.c
new file mode 100644
index 000..20b21dc
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-alias-ipa-pta-4.c
@@ -0,0 +1,21 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fipa-pta -fdump-tree-optimized" } */
+
+void
+foo (void)
+{
+  unsigned int a;
+  unsigned int b;
+  unsigned int c;
+
+#pragma acc kernels pcopyout (a, b, c)
+  {
+a = 0;
+b = 1;
+c = a;
+  }
+}
+
+/* { dg-final { scan-tree-dump-times "(?n)= 0;$" 2 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "(?n)= 1;$" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "(?n)= \\*_\[0-9\];$" 0 "optimized" } } */


[committed] Release_defs in expand_omp_atomic_fetch_op

2016-01-16 Thread Tom de Vries

Hi,

this patch adds a missing 'release_defs (stmt)' in 
expand_omp_atomic_fetch_op.


This is a merge of this ( 
https://gcc.gnu.org/ml/gcc-patches/2015-11/msg00447.html ) patch from 
the gomp-4_0-branch.


Bootstrapped and reg-tested on x86_64.

Committed to trunk.

Thanks,
- Tom
Release_defs in expand_omp_atomic_fetch_op

2015-11-05  Tom de Vries  

	* omp-low.c (expand_omp_atomic_fetch_op):  Release defs of update stmt.

---
 gcc/omp-low.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 6df01a4..b391ee0 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -12020,10 +12020,14 @@ expand_omp_atomic_fetch_op (basic_block load_bb,
   gcc_assert (gimple_code (gsi_stmt (gsi)) == GIMPLE_OMP_ATOMIC_STORE);
   gsi_remove (&gsi, true);
   gsi = gsi_last_bb (store_bb);
+  stmt = gsi_stmt (gsi);
   gsi_remove (&gsi, true);
 
   if (gimple_in_ssa_p (cfun))
-update_ssa (TODO_update_ssa_no_phi);
+{
+  release_defs (stmt);
+  update_ssa (TODO_update_ssa_no_phi);
+}
 
   return true;
 }


[Committed] Move pass_expand_omp_ssa out of pass_parallelize_loops

2016-01-16 Thread Tom de Vries

[ was: Re: [PIING][PATCH, 9/16] Add pass_parallelize_loops_oacc_kernels ]

On 14/12/15 16:22, Richard Biener wrote:

Can the pass not just use a pass parameter to switch between oacc/non-oacc?


It can, but given PR68874 ('Allow pass groups to be cloned'), if we 
clone pass_parallelize_loops we can no longer use it as a pass group, 
and that means that we no longer can have pass_expand_omp_ssa inside 
pass_parallelize_loops.


This patch moves pass_expand_omp_ssa out of pass_parallelize_loops.

Bootstrapped and reg-tested on x86_64.

Committed to trunk.

Thanks,
- Tom
Move pass_expand_omp_ssa out of pass_parallelize_loops

2016-01-16  Tom de Vries  

	* passes.def: Move pass_expand_omp_ssa out of pass_parallelize_loops.

---
 gcc/passes.def | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/gcc/passes.def b/gcc/passes.def
index c593851..392a9bc 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -273,9 +273,7 @@ along with GCC; see the file COPYING3.  If not see
 	  POP_INSERT_PASSES ()
 	  NEXT_PASS (pass_iv_canon);
 	  NEXT_PASS (pass_parallelize_loops);
-	  PUSH_INSERT_PASSES_WITHIN (pass_parallelize_loops)
-	  NEXT_PASS (pass_expand_omp_ssa);
-	  POP_INSERT_PASSES ()
+	  NEXT_PASS (pass_expand_omp_ssa);
 	  NEXT_PASS (pass_ch_vect);
 	  NEXT_PASS (pass_if_conversion);
 	  /* pass_vectorize must immediately follow pass_if_conversion.


[PATCH] libstdc++: Fix static_assert.

2016-01-16 Thread Torvald Riegel
This adds a missing string argument to a call to static_assert, thus not
making it depend on c++1z extensions.  This fixes the build breakage on
mingw introduced in 232454.

Tested on x86_64-linux.  OK?
commit 7659ab483954a15c8143f6b1b9d135159a2ecc67
Author: Torvald Riegel 
Date:   Sat Jan 16 23:40:26 2016 +0100

libstdc++: Fix static_assert.

	* src/c++11/cow-stdexcept.cc (txnal_read_ptr): Fix static_assert.

diff --git a/libstdc++-v3/src/c++11/cow-stdexcept.cc b/libstdc++-v3/src/c++11/cow-stdexcept.cc
index afc3f6c..375ab8b 100644
--- a/libstdc++-v3/src/c++11/cow-stdexcept.cc
+++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc
@@ -278,8 +278,8 @@ _txnal_cow_string_C1_for_exceptions(void* that, const char* s, void *exc)
 static void* txnal_read_ptr(void* const * ptr)
 {
   static_assert(sizeof(uint64_t) == sizeof(void*)
-		|| sizeof(uint32_t) == sizeof(void*));
-  // FIXME make a true compile-time choice to prevent warnings.
+		|| sizeof(uint32_t) == sizeof(void*),
+		"Pointers are neither 32 nor 64 bit wide");
 #if __UINTPTR_MAX__ == __UINT64_MAX__
   return (void*)_ITM_RU8((const uint64_t*)ptr);
 #else


Re: version typeinfo for 128bit types

2016-01-16 Thread H.J. Lu
On Mon, Apr 14, 2014 at 2:39 AM, Marc Glisse  wrote:
> Hello,
>
> this is a follow-up for this patch:
> http://gcc.gnu.org/ml/gcc-patches/2014-04/msg00618.html
>
> once committed, g++ will generate typeinfo for __float128, and it needs
> versioning. While there, I noticed that __int128 has "typeinfo" but not
> "typeinfo name", so I am adding it. I manually checked that the new symbols
> were exactly the 12 I expected, with the new version number.
>
> I did not test the gnu-versioned-namespace version.
>
> I manually updated baseline for x86_64. It is awfully inconvenient to do. I
> was expecting "make new-abi-baseline" to generate it for me, but it gives me
> plenty of extra symbols compared to the current one. Some random examples:
>
> FUNC:_ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_ERKS6_PKS3_@@GLIBCXX_3.4
> FUNC:_ZSt8distanceIPKcENSt15iterator_traitsIT_E15difference_typeES3_S3_@@GLIBCXX_3.4
> FUNC:_ZSt19__iterator_categoryIPKmENSt15iterator_traitsIT_E17iterator_categoryERKS3_@@GLIBCXX_3.4
> FUNC:_ZSt13__check_facetISt7codecvtIwc11__mbstate_tEERKT_PS4_@@GLIBCXX_3.4
> FUNC:_ZSt13__check_facetISt7num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcRKT_PS7_@@GLIBCXX_3.4
> FUNC:_ZNSt9exceptionC1Ev@@GLIBCXX_3.4
> FUNC:_ZNSt8iteratorISt18input_iterator_tagclPcRcEC1Ev@@GLIBCXX_3.4
> FUNC:_ZNSt8ios_base4setfESt13_Ios_FmtflagsS0_@@GLIBCXX_3.4
> FUNC:_ZNSt7complexIfEC1Eff@@GLIBCXX_3.4
> FUNC:_ZNSt6chrono13duration_castINS_8durationIlSt5ratioILl1ELl10lS2_ILl1ELl1NSt9enable_ifIXsrNS_13__is_durationIT_EE5valueES8_E4typeERKNS1_IT0_T1_EE@@GLIBCXX_3.4
> FUNC:_ZNSt20bad_array_new_lengthC2Ev@@CXXABI_1.3.8
> FUNC:_ZNSt14numeric_limitsIdE8infinityEv@@GLIBCXX_3.4
> FUNC:_ZN10__cxxabiv117__class_type_info16__dyncast_resultC1Ei@@CXXABI_1.3
>
> etc.
>
>
> Bootstrap+testsuite on x86_64-linux-gnu.
>
> 2014-04-14  Marc Glisse  
>
> PR libstdc++/43622
> * config/abi/pre/gnu.ver (CXXABI_1.3.9): New version, new symbols.
> * config/abi/pre/gnu-versioned-namespace.ver: New symbols.
> * config/abi/post/x86_64-linux-gnu/baseline_symbols.txt: Likewise.
>

I checked this long overdue patch into trunk and will backport
it to GCC 5.

H.J.
---
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 4f16875..9690193 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,8 @@
+2016-01-16  H.J. Lu  
+
+ * config/abi/post/x86_64-linux-gnu/x32/baseline_symbols.txt: Add
+ __int128 symbols.
+
 2016-01-15  Jonathan Wakely  

  PR libstdc++/69293
diff --git 
a/libstdc++-v3/config/abi/post/x86_64-linux-gnu/x32/baseline_symbols.txt
b/libstdc++-v3/config/abi/post/x86_64-linux-gnu/x32/baseline_symbols.txt
index 67b1f3e..6bc4a4b 100644
--- a/libstdc++-v3/config/abi/post/x86_64-linux-gnu/x32/baseline_symbols.txt
+++ b/libstdc++-v3/config/abi/post/x86_64-linux-gnu/x32/baseline_symbols.txt
@@ -4618,6 +4618,8 @@ OBJECT:2:_ZTSi@@CXXABI_1.3
 OBJECT:2:_ZTSj@@CXXABI_1.3
 OBJECT:2:_ZTSl@@CXXABI_1.3
 OBJECT:2:_ZTSm@@CXXABI_1.3
+OBJECT:2:_ZTSn@@CXXABI_1.3.9
+OBJECT:2:_ZTSo@@CXXABI_1.3.9
 OBJECT:2:_ZTSs@@CXXABI_1.3
 OBJECT:2:_ZTSt@@CXXABI_1.3
 OBJECT:2:_ZTSv@@CXXABI_1.3
@@ -4711,6 +4713,8 @@ OBJECT:3:_ZTSPi@@CXXABI_1.3
 OBJECT:3:_ZTSPj@@CXXABI_1.3
 OBJECT:3:_ZTSPl@@CXXABI_1.3
 OBJECT:3:_ZTSPm@@CXXABI_1.3
+OBJECT:3:_ZTSPn@@CXXABI_1.3.9
+OBJECT:3:_ZTSPo@@CXXABI_1.3.9
 OBJECT:3:_ZTSPs@@CXXABI_1.3
 OBJECT:3:_ZTSPt@@CXXABI_1.3
 OBJECT:3:_ZTSPv@@CXXABI_1.3
@@ -5116,6 +5120,8 @@ OBJECT:4:_ZTSPKi@@CXXABI_1.3
 OBJECT:4:_ZTSPKj@@CXXABI_1.3
 OBJECT:4:_ZTSPKl@@CXXABI_1.3
 OBJECT:4:_ZTSPKm@@CXXABI_1.3
+OBJECT:4:_ZTSPKn@@CXXABI_1.3.9
+OBJECT:4:_ZTSPKo@@CXXABI_1.3.9
 OBJECT:4:_ZTSPKs@@CXXABI_1.3
 OBJECT:4:_ZTSPKt@@CXXABI_1.3
 OBJECT:4:_ZTSPKv@@CXXABI_1.3


Re: [PATCH v2] libstdc++: Make certain exceptions transaction_safe.

2016-01-16 Thread H.J. Lu
On Thu, Jan 7, 2016 at 8:47 AM, Torvald Riegel  wrote:
> The attached patch makes some exceptions transaction-safe, as require by
> the Transactional Memory TS.  I believe I addressed all feedback for the
> previous version of this patch (in particular, there are now more safety
> checks for preconditions for this implementation (eg, that the new
> allocator is used), all exceptions declared by the TM TS are now
> supported (with the exception of tx_exception -- should I add that in a
> follow-up patch?), and there is a test for the new functionality (as
> part of libitm's testsuite)).
>
> There are two things that complicate such support.  First, it seems
> better to not rely on -fgnu-tm of libstdc++ code for now (or at least we
> tried to avoid this so far).  Therefore, the transactional clones in
> this patch are all manually instrumented (ie, the functions are C
> functions with names matching the mangled names of the respective C++
> functions, and the _ZGTt prefix signaling that they are txnal clones).
>
> Second, exceptions still use a COW string internally, which cannot be
> made transaction-safe with just compiler support because of the
> reference counting implementation inside of COW strings, which uses
> atomics.  One would need something custom for that nonetheless.
>
> Thus, the patch adds txnal clones as required.  They are new exported
> symbols, but not visible to nontransactional code.  The only changes to
> headers is transaction_safe[_dynamic] annotations where required by the
> TS, and a few friend declarations.  The annotations are only enabled if
> a user compiles with -fgnu-tm.  IOW, the changes are pretty much
> invisible when not using the TM TS.
>
> There are also commented-out calls to _ITM_setAssociatedException in the
> code, which exist to show how we plan to support transaction
> cancellation through exceptions (which needs some more libitm support
> and bugfixes on the compiler side).
>
> Tested on x86_64-linux and x86-linux.
>
> OK?
>
> 2016-01-07  Torvald Riegel  
>
> * include/bits/basic_string.h (basic_string): Declare friends.
> * include/bits/c++config (_GLIBCXX_TXN_SAFE,
> _GLIBCXX_TXN_SAFE_DYN, _GLIBCXX_USE_ALLOCATOR_NEW): New.
> * include/std/stdexcept (logic_error, domain_error, invalid_argument,
> length_error, out_of_range, runtime_error, range_error,
> underflow_error, overflow_error): Declare members as transaction-safe.
> (logic_error, runtime_error): Declare friend functions.
> * libsupc++/exception (exception, bad_exception): Declare members as
> transaction-safe.
> * src/c++11/cow-stdexcept.cc: Define transactional clones for the
> transaction-safe members of exceptions and helper functions.
> * libsupc++/eh_exception.cc: Adjust and define transactional clones.
> * config/abi/pre/gnu.ver (GLIBCXX_3.4.22) Add transactional clones.
> (CXXABI_1.3.10): New.
> * acinclude.m4 (GLIBCXX_CHECK_SIZE_T_MANGLING): New.
> (GLIBCXX_ENABLE_ALLOCATOR): Set ENABLE_ALLOCATOR_NEW.
> * configure.ac: Call GLIBCXX_CHECK_SIZE_T_MANGLING.
> * include/Makefile.am: Write ENABLE_ALLOCATOR_NEW to c++config.h.
> * include/Makefile.in: Regenerate.
> * config.h.in: Regenerate.
> * configure: Regenerate.
>

Don't you need to update baseline_symbols.txt?


-- 
H.J.


[PATCH] fix #69317 - [6 regression] wrong ABI version in -Wabi warnings

2016-01-16 Thread Martin Sebor

While adding an ABI warning in the patch for bug 69277 I noticed
that the ABI version printed by GCC 6.0 in some -Wabi diagnostics
is incorrect:  while 5.1.0 prints the versions of the ABI given
by the -Wabi=X and -fabi-version=Y options (i.e., it mentions
both X and Y), 6.0 prints the same version twice (just Y).

The attached patch fixes this and adds tests to verify that the
referenced versions are as expected (it uses ABIs 2 and 3 but
tests exercising the other ABI changes should be added as well).

Martin
gcc/cp/ChangeLog:
2016-01-16  Martin Sebor  

	PR c++/69317
	* mangle.c (mangle_decl): Reference the correct (saved) version
	of the ABI in -Wabi diagnostics.

gcc/testsuite/ChangeLog:
2016-01-16  Martin Sebor  

	PR c++/69317
	* g++.dg/abi/Wabi-2-2.C: New test.
	* g++.dg/abi/Wabi-2-3.C: New test.
	* g++.dg/abi/Wabi-3-2.C: New test.
	* g++.dg/abi/Wabi-3-3.C: New test.

Index: gcc/cp/mangle.c
===
--- gcc/cp/mangle.c	(revision 232296)
+++ gcc/cp/mangle.c	(working copy)
@@ -3657,13 +3669,13 @@ mangle_decl (const tree decl)
 	warning_at (DECL_SOURCE_LOCATION (G.entity), OPT_Wabi,
 			"the mangled name of %qD changed between "
 			"-fabi-version=%d (%D) and -fabi-version=%d (%D)",
-			G.entity, warn_abi_version, id2,
-			flag_abi_version, id);
+			G.entity, save_ver, id2,
+			warn_abi_version, id);
 	  else
 	warning_at (DECL_SOURCE_LOCATION (G.entity), OPT_Wabi,
 			"the mangled name of %qD changes between "
 			"-fabi-version=%d (%D) and -fabi-version=%d (%D)",
-			G.entity, flag_abi_version, id,
+			G.entity, save_ver, id,
 			warn_abi_version, id2);
 	}
 
Index: gcc/testsuite/g++.dg/abi/Wabi-2-2.C
===
--- gcc/testsuite/g++.dg/abi/Wabi-2-2.C	(revision 0)
+++ gcc/testsuite/g++.dg/abi/Wabi-2-2.C	(working copy)
@@ -0,0 +1,14 @@
+// Verify that no diagnostic is issued when the version specified
+// via -Wabi= matches the version specified by -fabi-version=.
+
+// { dg-options "-Werror -Wabi=2 -fabi-version=2" }
+// { dg-do compile }
+
+// The mangling of templates with a non-type template parameter
+// of reference type changed in ABI version 3: 
+extern int N;
+template  struct S { };
+
+// Expect no diagnostic.
+void foo (S) { }
+
Index: gcc/testsuite/g++.dg/abi/Wabi-2-3.C
===
--- gcc/testsuite/g++.dg/abi/Wabi-2-3.C	(revision 0)
+++ gcc/testsuite/g++.dg/abi/Wabi-2-3.C	(working copy)
@@ -0,0 +1,16 @@
+// PR c++/69317 - [6 regression] wrong ABI version in -Wabi warnings 
+// Exercise that the correct ABI versions are referenced in the -Wabi
+// diagnostic.  See also the equivalent Wabi-3-2.C test.
+
+// { dg-options "-Wabi=2 -fabi-version=3" }
+// { dg-do compile }
+
+// The mangling of templates with a non-type template parameter
+// of reference type changed in ABI version 3: 
+extern int N;
+template  struct S { };
+
+// Expect the diagnostic to reference the ABI version specified via
+// -fabi-version=3 and the ABI version specified via -Wabi=2.
+void foo (S) { }   // { dg-warning "the mangled name of .void foo\\(S\\). changed between -fabi-version=3 \\(_Z3foo1SILZ1NEE\\) and -fabi-version=2 \\(_Z3foo1SIL_Z1NEE\\)" }
+
Index: gcc/testsuite/g++.dg/abi/Wabi-3-2.C
===
--- gcc/testsuite/g++.dg/abi/Wabi-3-2.C	(revision 0)
+++ gcc/testsuite/g++.dg/abi/Wabi-3-2.C	(working copy)
@@ -0,0 +1,16 @@
+// PR c++/69317 - [6 regression] wrong ABI version in -Wabi warnings 
+// Exercise that the correct ABI versions are referenced in the -Wabi
+// diagnostic.  See also the equivalent Wabi-2-3.C test.
+
+// { dg-options "-Wabi=3 -fabi-version=2" }
+// { dg-do compile }
+
+// The mangling of templates with a non-type template parameter
+// of reference type changed in ABI version 3: 
+extern int N;
+template  struct S { };
+
+// Expect the diagnostic to reference the ABI version specified via
+// -fabi-version=2 and the ABI version specified via -Wabi=3.
+void foo (S) { }   // { dg-warning "the mangled name of .void foo\\(S\\). changed between -fabi-version=2 \\(_Z3foo1SIL_Z1NEE\\) and -fabi-version=3 \\(_Z3foo1SILZ1NEE\\)" }
+
Index: gcc/testsuite/g++.dg/abi/Wabi-3-3.C
===
--- gcc/testsuite/g++.dg/abi/Wabi-3-3.C	(revision 0)
+++ gcc/testsuite/g++.dg/abi/Wabi-3-3.C	(working copy)
@@ -0,0 +1,14 @@
+// Verify that no diagnostic is issued when the version specified
+// via -Wabi= matches the version specified by -fabi-version=.
+
+// { dg-options "-Werror -Wabi=3 -fabi-version=3" }
+// { dg-do compile }
+
+// The mangling of templates with a non-type template parameter
+// of reference type changed in ABI version 3: 
+extern int N;
+template  struct S { };
+
+// Expect no diagnostic.
+void foo (S) { }
+


[doc, 6/n] invoke.texi: split debugging options into programmer vs developer sections

2016-01-16 Thread Sandra Loosemore
This is the last planned part of my series to try to make it easier for 
users to find information about command-line options (although as I've 
been going through this chapter I've been finding places that need 
copy-editing or technical corrections, which I'll handle separately). 
In this part, I've split the options relating to debugging GCC itself 
into a new section, separate from the one about producing debuggable code.


Here's the list of options remaining in the "Debugging Options" section:

@gccoptlist{-g  -g@var{level}  -gcoff  -gdwarf-@var{version} @gol
-ggdb  -grecord-gcc-switches  -gno-record-gcc-switches @gol
-gstabs  -gstabs+  -gstrict-dwarf  -gno-strict-dwarf @gol
-gvms  -gxcoff  -gxcoff+ -gz@r{[}=@var{type}@r{]} @gol
-fdebug-prefix-map=@var{old}=@var{new} -fdebug-types-section @gol
-feliminate-dwarf2-dups -fno-eliminate-unused-debug-types @gol
-femit-struct-debug-baseonly -femit-struct-debug-reduced @gol
-femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]} @gol
-feliminate-unused-debug-symbols -femit-class-debug-always @gol
-fno-merge-debug-strings -fno-dwarf2-cfi-asm @gol
-fvar-tracking -fvar-tracking-assignments}

And here's the list in the new "GCC Developer Options" section:

@gccoptlist{-d@var{letters}  -dumpspecs  -dumpmachine  -dumpversion @gol
-fchecking -fdbg-cnt-list -fdbg-cnt=@var{counter-value-list} @gol
-fdisable-ipa-@var{pass_name} @gol
-fdisable-rtl-@var{pass_name} @gol
-fdisable-rtl-@var{pass-name}=@var{range-list} @gol
-fdisable-tree-@var{pass_name} @gol
-fdisable-tree-@var{pass-name}=@var{range-list} @gol
-fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links @gol
-fdump-translation-unit@r{[}-@var{n}@r{]} @gol
-fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol
-fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline @gol
-fdump-passes @gol
-fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename} @gol
-fdump-statistics @gol
-fdump-tree-all @gol
-fdump-tree-original@r{[}-@var{n}@r{]}  @gol
-fdump-tree-optimized@r{[}-@var{n}@r{]} @gol
-fdump-tree-cfg -fdump-tree-alias @gol
-fdump-tree-ch @gol
-fdump-tree-ssa@r{[}-@var{n}@r{]} -fdump-tree-pre@r{[}-@var{n}@r{]} @gol
-fdump-tree-ccp@r{[}-@var{n}@r{]} -fdump-tree-dce@r{[}-@var{n}@r{]} @gol
-fdump-tree-gimple@r{[}-raw@r{]} @gol
-fdump-tree-dom@r{[}-@var{n}@r{]} @gol
-fdump-tree-dse@r{[}-@var{n}@r{]} @gol
-fdump-tree-phiprop@r{[}-@var{n}@r{]} @gol
-fdump-tree-phiopt@r{[}-@var{n}@r{]} @gol
-fdump-tree-backprop@r{[}-@var{n}@r{]} @gol
-fdump-tree-forwprop@r{[}-@var{n}@r{]} @gol
-fdump-tree-nrv -fdump-tree-vect @gol
-fdump-tree-sink @gol
-fdump-tree-sra@r{[}-@var{n}@r{]} @gol
-fdump-tree-forwprop@r{[}-@var{n}@r{]} @gol
-fdump-tree-fre@r{[}-@var{n}@r{]} @gol
-fdump-tree-vtable-verify @gol
-fdump-tree-vrp@r{[}-@var{n}@r{]} @gol
-fdump-tree-split-paths@r{[}-@var{n}@r{]} @gol
-fdump-tree-storeccp@r{[}-@var{n}@r{]} @gol
-fdump-final-insns=@var{file} @gol
-fcompare-debug@r{[}=@var{opts}@r{]}  -fcompare-debug-second @gol
-fenable-@var{kind}-@var{pass} @gol
-fenable-@var{kind}-@var{pass}=@var{range-list} @gol
-fira-verbose=@var{n} @gol
-flto-report -flto-report-wpa -fmem-report-wpa @gol
-fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report @gol
-fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]} @gol
-fprofile-report @gol
-frandom-seed=@var{string} -fsched-verbose=@var{n} @gol
-fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose @gol
-fstats  -fstack-usage  -ftime-report @gol
-fvar-tracking-assignments-toggle -gtoggle @gol
-print-file-name=@var{library}  -print-libgcc-file-name @gol
-print-multi-directory  -print-multi-lib  -print-multi-os-directory @gol
-print-prog-name=@var{program}  -print-search-dirs  -Q @gol
-print-sysroot -print-sysroot-headers-suffix @gol
-save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}}

I've generally not touched the option descriptions, just moved them 
around.  The exception is that I incorporated some of the material from 
the -g description into the section introduction, and also added a 
pointer to -Og to the discussion about the interaction between -O and -g 
(having previously run into PR62225 myself).


I'll commit this in a couple days unless I hear complaints meanwhile.

-Sandra

2016-01-16  Sandra Loosemore 

	gcc/
	* doc/invoke.texi (Invoking GCC): Add new section to menu.
	(Option Summary): Update to reflect new section and moved options.
	(C++ Dialect Options): Move -fstats to new section.
	(Debugging Options): Move all dump, statistics, and other GCC
	developer options to new section.  Rewrite section introduction
	and re-order remaining options to put the more basic ones first.
	(Optimization Options): Move -fira-verbose and -flto-report* to
	new section.
	(Developer Options): New section incorporating moved options.
	* doc/cppopts.texi (-dM): Update cross-reference.
Index: gcc/doc/invoke.texi
===
--- gcc/doc/invoke.texi	(revision 232475)
+++ gcc/doc/invoke.texi	(working copy)
@@ -138,7 +138,7 @@

Re: [PATCH] [ARC] Add basic support for double load and store instructions

2016-01-16 Thread Joern Wolfgang Rennecke



On 15/01/16 12:40, Claudiu Zissulescu wrote:

(arc_save_restore): Use double load/store instruction.
(arc_expand_movmem): Likewise.
 


>if (n_pieces >= (unsigned int) (optimize_size ? 3 : 15))
>  return false;
> -  if (piece > 4)
> +  if (TARGET_LL64 && (piece != 8) && (align >= 4))
> +piece = 8;
> +  else if (piece > 4)
>  piece = 4;
>dst_addr = force_offsettable (XEXP (operands[0], 0), size, 0);

That bit doesn't make sense to me.
Assume the alignment is 8.  Thus, piece becomes 8 too.  Then the
above conditional gets processed, and it sets piece to 4.
I think instead of "(piece != 8) && (align >= 4)" it should be:
"(piece >= 8)"

* config/arc/arc.md (*movdi_insn): Emit ldd/std instructions.


> -  "&& reload_completed && optimize"
> -  [(set (match_dup 2) (match_dup 3)) (set (match_dup 4) (match_dup 5))]
> -  "arc_split_move (operands);"
> +  "reload_completed"
> +  [(match_dup 2)]
> +  "operands[2] = arc_split_move (operands);"

arc_split_move uses, inter alia,  operands[2]..operands[[5].
Thus, it is not save to stop mentioning these in the pattern.


(*movdf_insn): Likewise.

Likewise.

When you say 'basic support', I suppose you have a plan to re-visit this 
later to get the register allocator to use

register pairs, and stop regrename breaking them up?