Re: [PATCH 5/5] add libcc1

2014-10-28 Thread Jakub Jelinek
On Tue, Oct 28, 2014 at 01:05:00AM +0100, Dominique Dhumieres wrote:
> > This patch has now been committed.
> 
> It breaks bootstap on x86_64-apple-darwin14:
> 
> ...
> make[3]: Entering directory `/opt/gcc/p_build/libcc1'
> make  all-am
> make[4]: Entering directory `/opt/gcc/p_build/libcc1'
> make[4]: *** No rule to make target `../libiberty/pic/libiberty.a', needed by 
> `libcc1.la'.  Stop.
> make[4]: Leaving directory `/opt/gcc/p_build/libcc1'
> make[3]: *** [all] Error 2
> make[3]: Leaving directory `/opt/gcc/p_build/libcc1'
> make[2]: *** [all-stage1-libcc1] Error 2
> make[2]: Leaving directory `/opt/gcc/p_build'
> make[1]: *** [stage1-bubble] Error 2
> make[1]: Leaving directory `/opt/gcc/p_build'
> make: *** [all] Error 2

There are other issues related to --with-build-config=bootstrap-{a,ub}san
in there too, my current WIP patch is but didn't get to test it yet.

--- libcc1/Makefile.am.jj   2014-10-27 19:41:13.0 +0100
+++ libcc1/Makefile.am  2014-10-28 09:07:57.443711725 +0100
@@ -24,8 +24,17 @@ AM_CPPFLAGS = -I $(srcdir)/../include -I
-I $(srcdir)/../libcpp/include
 WERROR_FLAG = -Werror
 AM_CXXFLAGS = $(WARN_FLAGS) $(WERROR_FLAG) $(visibility)
-libiberty = ../libiberty/pic/libiberty.a
-
+override CXXFLAGS := $(filter-out -fsanitize=address,$(CXXFLAGS))
+override LDFLAGS := $(filter-out -fsanitize=address,$(LDFLAGS))
+# Can be simplified when libiberty becomes a normal convenience library.
+libiberty_normal = ../libiberty/libiberty.a
+libiberty_noasan = ../libiberty/noasan/libiberty.a
+libiberty_pic = ../libiberty/pic/libiberty.a
+Wc=-Wc,
+libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \
+   $(if $(wildcard $(libiberty_pic)),$(Wc)$(libiberty_pic), \
+   $(Wc)$(libiberty_normal)))
+libiberty_dep = $(patsubst $(Wc)%,%,$(libiberty))
 
 plugindir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/plugin
 cc1libdir = $(libdir)/$(libsuffix)
@@ -49,7 +58,16 @@ shared_source = callbacks.cc callbacks.h
 libcc1plugin_la_LDFLAGS = -module -export-symbols $(srcdir)/libcc1plugin.sym
 libcc1plugin_la_SOURCES = plugin.cc $(shared_source)
 libcc1plugin_la_LIBADD = $(libiberty)
+libcc1plugin_la_DEPENDENCIES = $(libiberty_dep)
+libcc1plugin_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
+   $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+   $(CXXFLAGS) $(libcc1plugin_la_LDFLAGS) $(LTLDFLAGS) -o $@
 
+LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
 libcc1_la_LDFLAGS = -module -export-symbols $(srcdir)/libcc1.sym
 libcc1_la_SOURCES = findcomp.cc libcc1.cc names.cc names.hh $(shared_source)
 libcc1_la_LIBADD = $(libiberty)
+libcc1_la_DEPENDENCIES = $(libiberty_dep)
+libcc1_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
+   $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+   $(CXXFLAGS) $(libcc1_la_LDFLAGS) $(LTLDFLAGS) -o $@
--- libcc1/Makefile.in.jj   2014-10-27 19:41:13.0 +0100
+++ libcc1/Makefile.in  2014-10-28 09:08:01.689922599 +0100
@@ -81,20 +81,12 @@ am__base_list = \
   sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
 am__installdirs = "$(DESTDIR)$(cc1libdir)" "$(DESTDIR)$(plugindir)"
 LTLIBRARIES = $(cc1lib_LTLIBRARIES) $(plugin_LTLIBRARIES)
-libcc1_la_DEPENDENCIES = $(libiberty)
 am__objects_1 = callbacks.lo connection.lo marshall.lo
 am_libcc1_la_OBJECTS = findcomp.lo libcc1.lo names.lo $(am__objects_1)
 libcc1_la_OBJECTS = $(am_libcc1_la_OBJECTS)
-libcc1_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
-   $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
-   $(CXXFLAGS) $(libcc1_la_LDFLAGS) $(LDFLAGS) -o $@
 @ENABLE_PLUGIN_TRUE@am_libcc1_la_rpath = -rpath $(cc1libdir)
-libcc1plugin_la_DEPENDENCIES = $(libiberty)
 am_libcc1plugin_la_OBJECTS = plugin.lo $(am__objects_1)
 libcc1plugin_la_OBJECTS = $(am_libcc1plugin_la_OBJECTS)
-libcc1plugin_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
-   $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
-   $(CXXFLAGS) $(libcc1plugin_la_LDFLAGS) $(LDFLAGS) -o $@
 @ENABLE_PLUGIN_TRUE@am_libcc1plugin_la_rpath = -rpath $(plugindir)
 DEFAULT_INCLUDES = -I.@am__isrc@
 depcomp = $(SHELL) $(top_srcdir)/../depcomp
@@ -259,7 +251,16 @@ AM_CPPFLAGS = -I $(srcdir)/../include -I
 
 WERROR_FLAG = -Werror
 AM_CXXFLAGS = $(WARN_FLAGS) $(WERROR_FLAG) $(visibility)
-libiberty = ../libiberty/pic/libiberty.a
+# Can be simplified when libiberty becomes a normal convenience library.
+libiberty_normal = ../libiberty/libiberty.a
+libiberty_noasan = ../libiberty/noasan/libiberty.a
+libiberty_pic = ../libiberty/pic/libiberty.a
+Wc = -Wc,
+libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \
+   $(if $(wildcard $(libiberty_pic)),$(Wc)$(libiberty_pic), \
+   $(Wc)$(libiberty_normal)))
+
+libiberty_dep = $(patsubst $(Wc)%,%,$(libiberty))
 plugindir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/plugin
 cc1libdir = $(libdir)/$(libsuffix)
 @ENABLE_PLUGIN_TRUE@plugin_LTLIBRARIES = libcc1plugin

Re: [PATCH 5/5] add libcc1

2014-10-28 Thread Uros Bizjak
> This patch has now been committed.

Also breaks bootstap on x86_64-linux-gnu, CentOS 5.11:

gmake[4]: Entering directory `/home/uros/gcc-build/libcc1'
/bin/sh ./libtool --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I.
-I../../gcc-svn/trunk/libcc1  -I ../../gcc-svn/trunk/libcc1/../include
-I ../../gcc-svn/trunk/libcc1/../libgcc -I .././gcc
-I../../gcc-svn/trunk/libcc1/../gcc -I
../../gcc-svn/trunk/libcc1/../gcc/c -I
../../gcc-svn/trunk/libcc1/../gcc/c-family -I
../../gcc-svn/trunk/libcc1/../libcpp/include  -W -Wall -Werror -Werror
-fvisibility=hidden -g -MT plugin.lo -MD -MP -MF .deps/plugin.Tpo -c
-o plugin.lo ../../gcc-svn/trunk/libcc1/plugin.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I.
-I../../gcc-svn/trunk/libcc1 -I ../../gcc-svn/trunk/libcc1/../include
-I ../../gcc-svn/trunk/libcc1/../libgcc -I .././gcc
-I../../gcc-svn/trunk/libcc1/../gcc -I
../../gcc-svn/trunk/libcc1/../gcc/c -I
../../gcc-svn/trunk/libcc1/../gcc/c-family -I
../../gcc-svn/trunk/libcc1/../libcpp/include -W -Wall -Werror -Werror
-fvisibility=hidden -g -MT plugin.lo -MD -MP -MF .deps/plugin.Tpo -c
../../gcc-svn/trunk/libcc1/plugin.cc  -fPIC -DPIC -o .libs/plugin.o
cc1plus: warnings being treated as errors
../../gcc-svn/trunk/libcc1/../gcc/hash-table.h: In instantiation of
‘hash_table, xcallocator, true>’:
../../gcc-svn/trunk/libcc1/plugin.cc:171:   instantiated from here
../../gcc-svn/trunk/libcc1/../gcc/hash-table.h:1161: warning: lowering
visibility of ‘void gt_ggc_mx(hash_table::value>*) [with T = T, Descriptor =
pointer_hash, Allocator = xcallocator]’ to match its type
../../gcc-svn/trunk/libcc1/../gcc/hash-table.h:1162: warning: lowering
visibility of ‘void gt_pch_nx(hash_table::value>*) [with T = T, Descriptor =
pointer_hash, Allocator = xcallocator]’ to match its type
../../gcc-svn/trunk/libcc1/../gcc/hash-table.h:1166: warning: lowering
visibility of ‘void gt_pch_nx(hash_map*, void (*)(void*,
void*), void*) [with T = T, U = U, V = V, Descriptor =
pointer_hash, Allocator = xcallocator]’ to match its type
../../gcc-svn/trunk/libcc1/../gcc/hash-table.h:1169: warning: lowering
visibility of ‘void gt_pch_nx(hash_set*, void (*)(void*, void*),
void*) [with T = T, U = U, Descriptor = pointer_hash,
Allocator = xcallocator]’ to match its type
../../gcc-svn/trunk/libcc1/../gcc/hash-table.h:1171: warning: lowering
visibility of ‘void gt_pch_nx(hash_table::value>*, void (*)(void*, void*), void*) [with
T = T, Descriptor = pointer_hash, Allocator = xcallocator]’
to match its type
gmake[4]: *** [plugin.lo] Error 1
gmake[4]: Leaving directory `/home/uros/gcc-build/libcc1'
gmake[3]: *** [all] Error 2
gmake[3]: Leaving directory `/home/uros/gcc-build/libcc1'
gmake[2]: *** [all-stage1-libcc1] Error 2
gmake[2]: Leaving directory `/home/uros/gcc-build'
gmake[1]: *** [stage1-bubble] Error 2
gmake[1]: Leaving directory `/home/uros/gcc-build'
gmake: *** [all] Error 2

Uros.


Re: genmatch infinite loop during bootstrap on AIX

2014-10-28 Thread Richard Biener
On Mon, 27 Oct 2014, David Edelsohn wrote:

> Richi,
> 
> The bootstrap with an empty match.pd seems to be succeeding.  I don't
> know if you have disabled optimizations in other passes that now are
> implemented in genmatch.  Regular testing of AIX is important to
> discover bootstrap issues early and avoid more release blocking
> issues.

Yes, the patterns implemented in match.pd have been removed from
fold-const.c.  So this will definitely affect some testcases
with respect to constant expressions no longer being constant
for example.

I didn't even expect that bootstrap succeeds - that it does is
good news.

> AIX and PPC64 Linux (Big Endian) use basically the same ABI, but PPC64
> Linux defaults to 64 bit and AIX defaults to 32 bit, so it's not
> testing exactly the same code paths.

Ah, I'm trying --with-cpu=default32 then while waiting for cfarm
access.

Thanks,
Richard.


Re: [PATCH 5/5] add libcc1

2014-10-28 Thread Phil Muldoon
On 28/10/14 08:13, Jakub Jelinek wrote:
> On Tue, Oct 28, 2014 at 01:05:00AM +0100, Dominique Dhumieres wrote:
>>> This patch has now been committed.
>> It breaks bootstap on x86_64-apple-darwin14:
>>
>> ...
>> make[3]: Entering directory `/opt/gcc/p_build/libcc1'
>> make  all-am
>> make[4]: Entering directory `/opt/gcc/p_build/libcc1'
>> make[4]: *** No rule to make target `../libiberty/pic/libiberty.a', needed 
>> by `libcc1.la'.  Stop.
>> make[4]: Leaving directory `/opt/gcc/p_build/libcc1'
>> make[3]: *** [all] Error 2
>> make[3]: Leaving directory `/opt/gcc/p_build/libcc1'
>> make[2]: *** [all-stage1-libcc1] Error 2
>> make[2]: Leaving directory `/opt/gcc/p_build'
>> make[1]: *** [stage1-bubble] Error 2
>> make[1]: Leaving directory `/opt/gcc/p_build'
>> make: *** [all] Error 2
> There are other issues related to --with-build-config=bootstrap-{a,ub}san
> in there too, my current WIP patch is but didn't get to test it yet.

Apologies.  I am investigating the issue, though I am not entirely sure of why 
the issue with libiberty occurs.

Cheers

Phil



Re: [PATCH 5/5] add libcc1

2014-10-28 Thread Christophe Lyon
On 28 October 2014 09:43, Phil Muldoon  wrote:
> On 28/10/14 08:13, Jakub Jelinek wrote:
>> On Tue, Oct 28, 2014 at 01:05:00AM +0100, Dominique Dhumieres wrote:
 This patch has now been committed.
>>> It breaks bootstap on x86_64-apple-darwin14:
>>>
>>> ...
>>> make[3]: Entering directory `/opt/gcc/p_build/libcc1'
>>> make  all-am
>>> make[4]: Entering directory `/opt/gcc/p_build/libcc1'
>>> make[4]: *** No rule to make target `../libiberty/pic/libiberty.a', needed 
>>> by `libcc1.la'.  Stop.
>>> make[4]: Leaving directory `/opt/gcc/p_build/libcc1'
>>> make[3]: *** [all] Error 2
>>> make[3]: Leaving directory `/opt/gcc/p_build/libcc1'
>>> make[2]: *** [all-stage1-libcc1] Error 2
>>> make[2]: Leaving directory `/opt/gcc/p_build'
>>> make[1]: *** [stage1-bubble] Error 2
>>> make[1]: Leaving directory `/opt/gcc/p_build'
>>> make: *** [all] Error 2
>> There are other issues related to --with-build-config=bootstrap-{a,ub}san
>> in there too, my current WIP patch is but didn't get to test it yet.
>
> Apologies.  I am investigating the issue, though I am not entirely sure of 
> why the issue with libiberty occurs.
>

I also breaks the build of cross compilers for arm* and aarch64*
targets (host RHEL5/x86_64):
cc1plus: warnings being treated as errors
/tmp/76611_16.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libcc1/../gcc/hash-table.h:
In instantiation of ‘hash_table, xcallocator,
true>’:
/tmp/76611_16.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libcc1/plugin.cc:171:
  instantiated from here
/tmp/76611_16.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libcc1/../gcc/hash-table.h:1161:
warning: lowering visibility of ‘void gt_ggc_mx(hash_table::value>*) [with T = T, Descriptor =
pointer_hash, Allocator = xcallocator]’ to match its type
/tmp/76611_16.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libcc1/../gcc/hash-table.h:1162:
warning: lowering visibility of ‘void gt_pch_nx(hash_table::value>*) [with T = T, Descriptor =
pointer_hash, Allocator = xcallocator]’ to match its type
/tmp/76611_16.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libcc1/../gcc/hash-table.h:1166:
warning: lowering visibility of ‘void gt_pch_nx(hash_map*,
void (*)(void*, void*), void*) [with T = T, U = U, V = V, Descriptor =
pointer_hash, Allocator = xcallocator]’ to match its type
/tmp/76611_16.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libcc1/../gcc/hash-table.h:1169:
warning: lowering visibility of ‘void gt_pch_nx(hash_set*, void
(*)(void*, void*), void*) [with T = T, U = U, Descriptor =
pointer_hash, Allocator = xcallocator]’ to match its type
/tmp/76611_16.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libcc1/../gcc/hash-table.h:1171:
warning: lowering visibility of ‘void gt_pch_nx(hash_table::value>*, void (*)(void*, void*),
void*) [with T = T, Descriptor = pointer_hash, Allocator =
xcallocator]’ to match its type
make[3]: *** [plugin.lo] Error 1

> Cheers
>
> Phil
>


[PATCH v5] Enable -fsanitize-recover for KASan

2014-10-28 Thread Yury Gribov

Hi all,

On 10/23/2014 11:11 AM, Yury Gribov wrote:

This patch enables -fsanitize-recover for KASan by default. This causes
KASan to continue execution after error in case of inline
instrumentation. This feature is needed because
- reports during early bootstrap won't even be printed
- needed to run all tests w/o rebooting machine for every test
- needed for interactive work on desktop


This is the third version of patch which renames -fsanitize-recover to
-fubsan-recover and introduces -fasan-recover (enabled by default for
KASan). It also moves flag handling to finish_options per Jakub's
request.


A new version of patch based upon Jakub's recent changes to
-fsanitize-recover=.  I've renamed __asan_report_recover_load* to
__asan_report_load*_noabort to match UBSan's style.

Note that currently -fsanitize=kernel-address
-fno-sanitize-recover=kernel-address won't work as expected because we
miss __asan_load*_abort family of functions in libasan.


A new version of patch with full support for __asan_report_loadX_noabort 
and __asan_loadX_noabort based upon recent discussion with KASan folks.


Bootstrapped and regtested on x64.

-Y

>From ee93b44c0b87da5346476c2554697168d07c6600 Mon Sep 17 00:00:00 2001
From: Yury Gribov 
Date: Wed, 22 Oct 2014 17:24:55 +0400
Subject: [PATCH] Enable -fsanitize-recover for KASan.

2014-10-23  Yury Gribov  

gcc/
	* asan.c (report_error_func): Add noabort path.
	(check_func): Ditto.  Formatting.
	(asan_expand_check_ifn): Handle noabort path.
	* common.opt (flag_sanitize_recover): Add SANITIZE_KERNEL_ADDRESS
	to default value.
	* doc/invoke.texi (-fsanitize-recover=): Mention KASan.
	* opts.c (finish_options): Reword comment.
	* sanitizer.def: Add noabort ASan builtins.

gcc/testsuite/
	* c-c++-common/asan/kasan-recover-1.c: New test.
	* c-c++-common/asan/kasan-recover-2.c: New test.
---
 gcc/asan.c|   81 ++---
 gcc/common.opt|2 +-
 gcc/doc/invoke.texi   |8 +-
 gcc/opts.c|4 +-
 gcc/sanitizer.def |   62 
 gcc/testsuite/c-c++-common/asan/kasan-recover-1.c |   12 +++
 gcc/testsuite/c-c++-common/asan/kasan-recover-2.c |   12 +++
 7 files changed, 150 insertions(+), 31 deletions(-)
 create mode 100644 gcc/testsuite/c-c++-common/asan/kasan-recover-1.c
 create mode 100644 gcc/testsuite/c-c++-common/asan/kasan-recover-2.c

diff --git a/gcc/asan.c b/gcc/asan.c
index 97f0b4c..93536ad 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -1344,44 +1344,72 @@ asan_protect_global (tree decl)
IS_STORE is either 1 (for a store) or 0 (for a load).  */
 
 static tree
-report_error_func (bool is_store, HOST_WIDE_INT size_in_bytes, int *nargs)
-{
-  static enum built_in_function report[2][6]
-= { { BUILT_IN_ASAN_REPORT_LOAD1, BUILT_IN_ASAN_REPORT_LOAD2,
-	  BUILT_IN_ASAN_REPORT_LOAD4, BUILT_IN_ASAN_REPORT_LOAD8,
-	  BUILT_IN_ASAN_REPORT_LOAD16, BUILT_IN_ASAN_REPORT_LOAD_N },
-	{ BUILT_IN_ASAN_REPORT_STORE1, BUILT_IN_ASAN_REPORT_STORE2,
-	  BUILT_IN_ASAN_REPORT_STORE4, BUILT_IN_ASAN_REPORT_STORE8,
-	  BUILT_IN_ASAN_REPORT_STORE16, BUILT_IN_ASAN_REPORT_STORE_N } };
+report_error_func (bool is_store, bool recover_p, HOST_WIDE_INT size_in_bytes,
+		   int *nargs)
+{
+  static enum built_in_function report[2][2][6]
+= { { { BUILT_IN_ASAN_REPORT_LOAD1, BUILT_IN_ASAN_REPORT_LOAD2,
+	BUILT_IN_ASAN_REPORT_LOAD4, BUILT_IN_ASAN_REPORT_LOAD8,
+	BUILT_IN_ASAN_REPORT_LOAD16, BUILT_IN_ASAN_REPORT_LOAD_N },
+	  { BUILT_IN_ASAN_REPORT_STORE1, BUILT_IN_ASAN_REPORT_STORE2,
+	BUILT_IN_ASAN_REPORT_STORE4, BUILT_IN_ASAN_REPORT_STORE8,
+	BUILT_IN_ASAN_REPORT_STORE16, BUILT_IN_ASAN_REPORT_STORE_N } },
+	{ { BUILT_IN_ASAN_REPORT_LOAD1_NOABORT,
+	BUILT_IN_ASAN_REPORT_LOAD2_NOABORT,
+	BUILT_IN_ASAN_REPORT_LOAD4_NOABORT,
+	BUILT_IN_ASAN_REPORT_LOAD8_NOABORT,
+	BUILT_IN_ASAN_REPORT_LOAD16_NOABORT,
+	BUILT_IN_ASAN_REPORT_LOAD_N_NOABORT },
+	  { BUILT_IN_ASAN_REPORT_STORE1_NOABORT,
+	BUILT_IN_ASAN_REPORT_STORE2_NOABORT,
+	BUILT_IN_ASAN_REPORT_STORE4_NOABORT,
+	BUILT_IN_ASAN_REPORT_STORE8_NOABORT,
+	BUILT_IN_ASAN_REPORT_STORE16_NOABORT,
+	BUILT_IN_ASAN_REPORT_STORE_N_NOABORT } } };
   if (size_in_bytes == -1)
 {
   *nargs = 2;
-  return builtin_decl_implicit (report[is_store][5]);
+  return builtin_decl_implicit (report[recover_p][is_store][5]);
 }
   *nargs = 1;
-  return builtin_decl_implicit (report[is_store][exact_log2 (size_in_bytes)]);
+  int size_log2 = exact_log2 (size_in_bytes);
+  return builtin_decl_implicit (report[recover_p][is_store][size_log2]);
 }
 
 /* Construct a function tree for __asan_{load,store}{1,2,4,8,16,_n}.
IS_STORE is either 1 (for a store) or 0 (for a load).  */
 
 static tree
-check_func (bool is_store, int size_in_bytes, int *nargs)
-{
-  static enum built_in_function check[2][6]
-= { { BUILT_

Re: [PATCH 5/5] add libcc1

2014-10-28 Thread Phil Muldoon
On 28/10/14 08:36, Uros Bizjak wrote:
>> This patch has now been committed.
> Also breaks bootstap on x86_64-linux-gnu, CentOS 5.11:
>
> gmake[4]: Entering directory `/home/uros/gcc-build/libcc1'
> /bin/sh ./libtool --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I.
> -I../../gcc-svn/trunk/libcc1  -I ../../gcc-svn/trunk/libcc1/../include
> -I ../../gcc-svn/trunk/libcc1/../libgcc -I .././gcc
> -I../../gcc-svn/trunk/libcc1/../gcc -I

Weird, I bootstrapped my build on x8664 Fedora 20 and saw no issues.  Can you 
please
provide me your build/configure parameters?

Cheers

Phil


RE: [AArch64] [BE] [2/2] Make large opaque integer modes endianness-safe.

2014-10-28 Thread David Sherwood
Hi,

Sorry to bother you again, but if someone has time could they take
a look at this change please?

Thanks!
David.

-Original Message-
From: David Sherwood [mailto:david.sherw...@arm.com] 
Sent: 13 October 2014 11:02
To: gcc-patches@gcc.gnu.org
Subject: [AArch64] [BE] [2/2] Make large opaque integer modes endianness-safe.

Hi,

This is the second patch of the work to fix:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59810

and removes the CANNOT_CHANGE_MODE_CLASS macro, which now permits subregs of
vector registers to work correctly on aarch64_be.

NOTE: This patch depends upon the following:
[AArch64] [BE] [1/2] Make large opaque integer modes endianness-safe.
[AArch64] [BE] Fix vector load/stores to not use ld1/st1

Thanks,
David.

ChangeLog:

gcc/:
2014-13-10  David Sherwood  

* config/aarch64/aarch64.h (CLEAR_INSN_CACHE): Removed.
* config/aarch64/aarch64.c (aarch64_cannot_change_mode_class): Removed.
* config/aarch64/aarch64-protos.h (aarch64_cannot_change_mode_class):
Removed.






RE: [AArch64] [BE] [1/2] Make large opaque integer modes endianness-safe.

2014-10-28 Thread David Sherwood
Hi,

Sorry to bother you again. Could someone take a look at this change
please if they have time?

Thanks!
David.

-Original Message-
From: David Sherwood [mailto:david.sherw...@arm.com] 
Sent: 10 October 2014 15:48
To: gcc-patches@gcc.gnu.org
Subject: [AArch64] [BE] [1/2] Make large opaque integer modes endianness-safe.

Hi,

I have a fix (originally written by Tejas Belagod) for the following bug:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59810

Could someone take a look please?

Thanks!
David Sherwood.

ChangeLog:

gcc/:
2014-10-10  David Sherwood  

* config/aarch64/aarch64-protos.h (aarch64_simd_attr_length_rglist,
aarch64_reverse_mask): New decls.
* config/aarch64/iterators.md (UNSPEC_REV_REGLIST): New enum.
* config/aarch64/iterators.md (insn_count): New mode_attr.
* config/aarch64/aarch64-simd.md (vec_store_lanes(o/c/x)i,
vec_load_lanes(o/c/x)i): Fixed to work for Big Endian. 
* config/aarch64/aarch64-simd.md (aarch64_rev_reglist,
aarch64_simd_(ld/st)(2/3/4)): Added.
* config/aarch64/aarch64.c (aarch64_simd_attr_length_rglist,
aarch64_reverse_mask): Added.





Re: [PATCH 5/5] add libcc1

2014-10-28 Thread Jakub Jelinek
On Tue, Oct 28, 2014 at 08:43:35AM +, Phil Muldoon wrote:
> On 28/10/14 08:13, Jakub Jelinek wrote:
> > On Tue, Oct 28, 2014 at 01:05:00AM +0100, Dominique Dhumieres wrote:
> >>> This patch has now been committed.
> >> It breaks bootstap on x86_64-apple-darwin14:
> >>
> >> ...
> >> make[3]: Entering directory `/opt/gcc/p_build/libcc1'
> >> make  all-am
> >> make[4]: Entering directory `/opt/gcc/p_build/libcc1'
> >> make[4]: *** No rule to make target `../libiberty/pic/libiberty.a', needed 
> >> by `libcc1.la'.  Stop.
> >> make[4]: Leaving directory `/opt/gcc/p_build/libcc1'
> >> make[3]: *** [all] Error 2
> >> make[3]: Leaving directory `/opt/gcc/p_build/libcc1'
> >> make[2]: *** [all-stage1-libcc1] Error 2
> >> make[2]: Leaving directory `/opt/gcc/p_build'
> >> make[1]: *** [stage1-bubble] Error 2
> >> make[1]: Leaving directory `/opt/gcc/p_build'
> >> make: *** [all] Error 2
> > There are other issues related to --with-build-config=bootstrap-{a,ub}san
> > in there too, my current WIP patch is but didn't get to test it yet.
> 
> Apologies.  I am investigating the issue, though I am not entirely sure of 
> why the issue with libiberty occurs.

I think I have the libiberty issues solved in my patch, just hit another
issue (visibility related) in my -fsanitize=vptr patch which I've been
bootstrapping it with, so had to fix that and am now trying again.

The thing with libiberty is that we have one to 3 versions of libiberty,
e.g. on targets where there is no pic support or where -fpic is on by
default libiberty doesn't build the pic/ version, and the noasan/ version
is built for --with-build-config=bootstrap-asan builds, so that one can
choose libiberty instrumented -fsanitize=address (the normal one or pic if
the latter exists) and pic non-instrumented one (for use in lto-plugin and
supposedly libcc1 too), anything that can be loaded into some other program
than gcc should not be asan instrumented, because it requires the executable
to be linked that way too (e.g. linker or gdb).

Jakub


Re: [PATCH 5/5] add libcc1

2014-10-28 Thread Uros Bizjak
On Tue, Oct 28, 2014 at 9:50 AM, Phil Muldoon  wrote:
> On 28/10/14 08:36, Uros Bizjak wrote:
>>> This patch has now been committed.
>> Also breaks bootstap on x86_64-linux-gnu, CentOS 5.11:
>>
>> gmake[4]: Entering directory `/home/uros/gcc-build/libcc1'
>> /bin/sh ./libtool --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I.
>> -I../../gcc-svn/trunk/libcc1  -I ../../gcc-svn/trunk/libcc1/../include
>> -I ../../gcc-svn/trunk/libcc1/../libgcc -I .././gcc
>> -I../../gcc-svn/trunk/libcc1/../gcc -I
>
> Weird, I bootstrapped my build on x8664 Fedora 20 and saw no issues.  Can you 
> please
> provide me your build/configure parameters?

This failure is in stage1 due to -Werror in combination with default
CentOS gcc-4.1.x compiler:

gcc version 4.1.2 20080704 (Red Hat 4.1.2-55)

Stage1 libraries should not be compiled with -Werror, since the
default system compiler can have issues with warnings.

Uros.


Re: [PATCHv2] Don't expand string/memory builtins if ASan is enabled.

2014-10-28 Thread Maxim Ostapenko



The code which identifies interceptors seems to be duplicated in
expand_builtin.  What about factoring this out to some is_asan_intercepted()
in asan.h?

I agree.


Fixed  this.


BTW, when you handle a builtin, but set *intercepted_p to false, is the
point just that you don't instrument e.g. scalar accesses to that memory
region afterwards?  I mean:
memcpy (p, "abc", 3);
p[0] = 'd';
you don't really have to instrument p[0] store, because supposedly memcpy
call has already verified p[0] through p[2] is writable.

Jakub



Yes, in this case p[0] store is not instrumented we use either 
intercepted_p builtin or not intercepted_p one. But access with some 
offset e.g. to p[1] will be instrumented in both cases. I'll probably 
fix this next time.


As Yury mentioned, I've also added a test case for pr63638 in this patch.

Tested on x86_64-unknown-inux-gnu.

-Maxim
gcc/ChangeLog:

2014-10-28  Max Ostapenko  

	* asan.h (is_asan_intercepted): New function.
	* asan.c (asan_mem_ref_hasher::hash): Remove MEM_REF access size from
	hash value construction.  Call iterative_hash_expr instead of explicit
	hash building.
	(asan_mem_ref_hasher::equal): Change condition.
	(has_mem_ref_been_instrumented): Likewise.
	(update_mem_ref_hash_table): Likewise.
	(maybe_update_mem_ref_hash_table): New function.
	(instrument_strlen_call): Removed.
	(get_mem_refs_of_builtin_call): Handle new parameter.
	(instrument_builtin_call): Call maybe_update_mem_ref_hash_table instead
	of instrument_mem_region_access if intercepted_p is true.
	(instrument_mem_region_access): Instrument only base with len instead of
	base and end with 1.
	(build_check_stmt): Remove start_instrumented and end_instrumented
	parameters.
	(enum asan_check_flags): Remove ASAN_CHECK_START_INSTRUMENTED and
	ASAN_CHECK_END_INSTRUMENTED.  Change ASAN_CHECK_LAST.
	(asan_expand_check_ifn): Remove start_instrumented and end_instrumented.
	* builtins.c (expand_builtin): Include asan.h.  Don't expand string/memory
	builtin functions that have interceptors if ASan is enabled.

gcc/testsuite/ChangeLog:

2014-10-28  Max Ostapenko  

	* c-c++-common/asan/no-redundant-instrumentation-1.c: Updated test.
	* c-c++-common/asan/no-redundant-instrumentation-4.c: Likewise.
	* c-c++-common/asan/no-redundant-instrumentation-5.c: Likewise.
	* c-c++-common/asan/no-redundant-instrumentation-6.c: Likewise.
	* c-c++-common/asan/no-redundant-instrumentation-7.c: Likewise.
	* c-c++-common/asan/no-redundant-instrumentation-8.c: Likewise.
	* c-c++-common/asan/no-redundant-instrumentation-2.c: Removed.
	* c-c++-common/asan/no-redundant-instrumentation-9.c: Likewise.
	* c-c++-common/asan/no-redundant-instrumentation-10.c: New test.
	* c-c++-common/asan/no-redundant-instrumentation-11.c: Likewise.
	* c-c++-common/asan/pr63638.c: Likewise.

diff --git a/gcc/asan.c b/gcc/asan.c
index d50e9e0..878fe48 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -264,9 +264,7 @@ enum asan_check_flags
   ASAN_CHECK_STORE = 1 << 0,
   ASAN_CHECK_SCALAR_ACCESS = 1 << 1,
   ASAN_CHECK_NON_ZERO_LEN = 1 << 2,
-  ASAN_CHECK_START_INSTRUMENTED = 1 << 3,
-  ASAN_CHECK_END_INSTRUMENTED = 1 << 4,
-  ASAN_CHECK_LAST
+  ASAN_CHECK_LAST = 1 << 3
 };
 
 /* Hashtable support for memory references used by gimple
@@ -363,10 +361,7 @@ struct asan_mem_ref_hasher
 inline hashval_t
 asan_mem_ref_hasher::hash (const asan_mem_ref *mem_ref)
 {
-  inchash::hash hstate;
-  inchash::add_expr (mem_ref->start, hstate);
-  hstate.add_wide_int (mem_ref->access_size);
-  return hstate.end ();
+  return iterative_hash_expr (mem_ref->start, 0);
 }
 
 /* Compare two memory references.  We accept the length of either
@@ -376,8 +371,7 @@ inline bool
 asan_mem_ref_hasher::equal (const asan_mem_ref *m1,
 			const asan_mem_ref *m2)
 {
-  return (m1->access_size == m2->access_size
-	  && operand_equal_p (m1->start, m2->start, 0));
+  return operand_equal_p (m1->start, m2->start, 0);
 }
 
 static hash_table *asan_mem_ref_ht;
@@ -428,7 +422,8 @@ has_mem_ref_been_instrumented (tree ref, HOST_WIDE_INT access_size)
   asan_mem_ref r;
   asan_mem_ref_init (&r, ref, access_size);
 
-  return (get_mem_ref_hash_table ()->find (&r) != NULL);
+  asan_mem_ref *saved_ref = get_mem_ref_hash_table ()->find (&r);
+  return saved_ref && saved_ref->access_size >= access_size;
 }
 
 /* Return true iff the memory reference REF has been instrumented.  */
@@ -445,19 +440,11 @@ has_mem_ref_been_instrumented (const asan_mem_ref *ref)
 static bool
 has_mem_ref_been_instrumented (const asan_mem_ref *ref, tree len)
 {
-  /* First let's see if the address of the beginning of REF has been
- instrumented.  */
-  if (!has_mem_ref_been_instrumented (ref))
-return false;
+  HOST_WIDE_INT size_in_bytes
+= tree_fits_shwi_p (len) ? tree_to_shwi (len) : -1;
 
-  if (len != 0)
-{
-  /* Let's see if the end of the region has been instrumented.  */
-  if (!has_mem_ref_been_instrumented (asan_mem_ref_get_end (ref, len),
-	  ref->access_size))
-	return false;
- 

Re: [PATCH v5] Enable -fsanitize-recover for KASan

2014-10-28 Thread Jakub Jelinek
On Tue, Oct 28, 2014 at 11:46:31AM +0300, Yury Gribov wrote:
> 2014-10-23  Yury Gribov  
> 
> gcc/
>   * asan.c (report_error_func): Add noabort path.
>   (check_func): Ditto.  Formatting.
>   (asan_expand_check_ifn): Handle noabort path.
>   * common.opt (flag_sanitize_recover): Add SANITIZE_KERNEL_ADDRESS
>   to default value.
>   * doc/invoke.texi (-fsanitize-recover=): Mention KASan.
>   * opts.c (finish_options): Reword comment.
>   * sanitizer.def: Add noabort ASan builtins.
> 
> gcc/testsuite/
>   * c-c++-common/asan/kasan-recover-1.c: New test.
>   * c-c++-common/asan/kasan-recover-2.c: New test.

Are the __asan_{load,store,report}*_noabort entrypoints going to be added
into libasan too?

> --- a/gcc/common.opt
> +++ b/gcc/common.opt
> @@ -213,7 +213,7 @@ unsigned int flag_sanitize
>  
>  ; What sanitizers should recover from errors
>  Variable
> -unsigned int flag_sanitize_recover = SANITIZE_UNDEFINED | SANITIZE_NONDEFAULT
> +unsigned int flag_sanitize_recover = SANITIZE_UNDEFINED | 
> SANITIZE_NONDEFAULT | SANITIZE_KERNEL_ADDRESS

I wonder whether we can break lines here, if e.g. \ at the end of line would
work.  If not, it is ok this way.

> --- /dev/null
> +++ b/gcc/testsuite/c-c++-common/asan/kasan-recover-1.c
> @@ -0,0 +1,12 @@
> +/* { dg-do compile } */
> +/* { dg-options "-fno-sanitize=address -fsanitize=kernel-address --param 
> asan-instrumentation-with-call-threshold=100 -save-temps" } */

Why -save-temps and cleanup-saved-temps?  Do you for some reason want to
avoid integrated preprocessing?  I mean, this is a dg-do compile test,
so for scanning assembly you don't really need -save-temps.

> --- /dev/null
> +++ b/gcc/testsuite/c-c++-common/asan/kasan-recover-2.c
> @@ -0,0 +1,12 @@
> +/* { dg-do compile } */
> +/* { dg-options "-fno-sanitize=address -fsanitize=kernel-address 
> -save-temps" } */

Likewise.

> +
> +void
> +foo (int *p)
> +{
> +  *p = 0;
> +}
> +
> +/* { dg-final { scan-assembler "__asan_store4_noabort" } } */
> +/* { dg-final { cleanup-saved-temps } } */
> +

Otherwise LGTM.

Jakub


Re: [PATCHv2] Don't expand string/memory builtins if ASan is enabled.

2014-10-28 Thread Jakub Jelinek
On Tue, Oct 28, 2014 at 12:21:25PM +0400, Maxim Ostapenko wrote:
> 2014-10-28  Max Ostapenko  
> 
>   * asan.h (is_asan_intercepted): New function.

I'd call it asan_intercepted_p instead.

Can you please check if:
void foo (char *p)
{
  volatile int zero = 0;
  memcpy (p, "abc", zero);
  p[0] = 'd';
}
does not remove instrumentation from p[0] store (i.e. the builtin store
length might (and this case actually is) zero, so no checking is done for
any byte.

Ditto for explicit s/zero)/0)/, and for s/zero)/2)/ check if the
instrumentation is removed.

If that works properly, the patch is ok with the routine name change.  Thanks.

Jakub


Re: [PATCH 5/5] add libcc1

2014-10-28 Thread Jakub Jelinek
On Tue, Oct 28, 2014 at 09:36:45AM +0100, Uros Bizjak wrote:
> > This patch has now been committed.
> 
> Also breaks bootstap on x86_64-linux-gnu, CentOS 5.11:

For -Werror, I'd think that should fix that, WARN_FLAGS should
already contain -Werror during stage2/stage3 unless --disable-werror.
Untested though.

--- libcc1/Makefile.am  2014-10-28 09:07:57.443711725 +0100
+++ libcc1/Makefile.am  2014-10-28 10:32:09.712135034 +0100
@@ -22,8 +22,7 @@ AM_CPPFLAGS = -I $(srcdir)/../include -I
-I $(gcc_build_dir) -I$(srcdir)/../gcc \
-I $(srcdir)/../gcc/c -I $(srcdir)/../gcc/c-family \
-I $(srcdir)/../libcpp/include
-WERROR_FLAG = -Werror
-AM_CXXFLAGS = $(WARN_FLAGS) $(WERROR_FLAG) $(visibility)
+AM_CXXFLAGS = $(WARN_FLAGS) $(visibility)
 override CXXFLAGS := $(filter-out -fsanitize=address,$(CXXFLAGS))
 override LDFLAGS := $(filter-out -fsanitize=address,$(LDFLAGS))
 # Can be simplified when libiberty becomes a normal convenience library.
--- libcc1/Makefile.in  2014-10-28 09:08:01.689922599 +0100
+++ libcc1/Makefile.in  2014-10-28 10:32:21.376918921 +0100
@@ -249,8 +249,7 @@ AM_CPPFLAGS = -I $(srcdir)/../include -I
-I $(srcdir)/../gcc/c -I $(srcdir)/../gcc/c-family \
-I $(srcdir)/../libcpp/include
 
-WERROR_FLAG = -Werror
-AM_CXXFLAGS = $(WARN_FLAGS) $(WERROR_FLAG) $(visibility)
+AM_CXXFLAGS = $(WARN_FLAGS) $(visibility)
 # Can be simplified when libiberty becomes a normal convenience library.
 libiberty_normal = ../libiberty/libiberty.a
 libiberty_noasan = ../libiberty/noasan/libiberty.a


Jakub


Re: [patch] Flatten cgraph.h.

2014-10-28 Thread Richard Biener
On Mon, Oct 27, 2014 at 10:32 PM, Andrew MacLeod  wrote:
> No so much preamble for this one since cgraph.h is already representative of
> only things in cgraph.c.   So this is mostly shuffling of include files.
>
> One short 'interesting' patch, and a couple of longer boring mechanical
> ones.
>
> symbol_table::initialize() was moved to cgraph.c.  The use of TDI_cgraph to
> initialize the dump file was the only reason dumpfile.h was a
> pre-requirement for cgraph,h, thus the dependency was removed.
>
> ipa-inline.h, ipa-prop.h, ipa-reference.h, and ipa-utils.h all included
> cgraph.h and one or 2 other files, so I simply flattened them and copied
> their include list to all places that included them.   lto-streamer.h
> included cgraph.h and a bunch of stuff, so I simply removed cgraph.h from it
> and pushed it through to all the other places that included lto-streamer and
> into the eventual source file .  I then removed all duplicate includes in
> all those affected files.
>
> At this point, no .h file includes cgraph.h any more.
>
> gcc-plugin.h has a few of cgraph.h's includes added to help avoid some
> plugin breakage, but depending on their uses, there are some ordering issues
> that could be beyond my control.
>
> Bootstraps with no new regressions on  x86_64-unknown-linux-gnu, and is
> currently running through a full set of targets from config-list.mk.
> Assuming no issues, OK for mainline?

Ok.

Thanks,
Richard.

> Andrew
>


Re: [PATCH 5/5] add libcc1

2014-10-28 Thread Uros Bizjak
On Tue, Oct 28, 2014 at 10:35 AM, Jakub Jelinek  wrote:
> On Tue, Oct 28, 2014 at 09:36:45AM +0100, Uros Bizjak wrote:
>> > This patch has now been committed.
>>
>> Also breaks bootstap on x86_64-linux-gnu, CentOS 5.11:
>
> For -Werror, I'd think that should fix that, WARN_FLAGS should
> already contain -Werror during stage2/stage3 unless --disable-werror.
> Untested though.

No, it still fails, although with one -Werror less in the compile flags:

gmake[4]: Entering directory `/home/uros/gcc-build/libcc1'
/bin/sh ./libtool --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I.
-I../../gcc-svn/trunk/libcc1  -I ../../gcc-svn/trunk/libcc1/../include
-I ../../gcc-svn/trunk/libcc1/../libgcc -I .././gcc
-I../../gcc-svn/trunk/libcc1/../gcc -I
../../gcc-svn/trunk/libcc1/../gcc/c -I
../../gcc-svn/trunk/libcc1/../gcc/c-family -I
../../gcc-svn/trunk/libcc1/../libcpp/include  -W -Wall -Werror
-fvisibility=hidden -g -MT plugin.lo -MD -MP -MF .deps/plugin.Tpo -c
-o plugin.lo ../../gcc-svn/trunk/libcc1/plugin.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I.
-I../../gcc-svn/trunk/libcc1 -I ../../gcc-svn/trunk/libcc1/../include
-I ../../gcc-svn/trunk/libcc1/../libgcc -I .././gcc
-I../../gcc-svn/trunk/libcc1/../gcc -I
../../gcc-svn/trunk/libcc1/../gcc/c -I
../../gcc-svn/trunk/libcc1/../gcc/c-family -I
../../gcc-svn/trunk/libcc1/../libcpp/include -W -Wall -Werror
-fvisibility=hidden -g -MT plugin.lo -MD -MP -MF .deps/plugin.Tpo -c
../../gcc-svn/trunk/libcc1/plugin.cc  -fPIC -DPIC -o .libs/plugin.o
cc1plus: warnings being treated as errors
../../gcc-svn/trunk/libcc1/../gcc/hash-table.h: In instantiation of
‘hash_table, xcallocator, true>’:
../../gcc-svn/trunk/libcc1/plugin.cc:171:   instantiated from here
../../gcc-svn/trunk/libcc1/../gcc/hash-table.h:1161: warning: lowering
visibility of ‘void gt_ggc_mx(hash_table::value>*) [with T = T, Descriptor =
pointer_hash, Allocator = xcallocator]’ to match its type
../../gcc-svn/trunk/libcc1/../gcc/hash-table.h:1162: warning: lowering
visibility of ‘void gt_pch_nx(hash_table::value>*) [with T = T, Descriptor =
pointer_hash, Allocator = xcallocator]’ to match its type
../../gcc-svn/trunk/libcc1/../gcc/hash-table.h:1166: warning: lowering
visibility of ‘void gt_pch_nx(hash_map*, void (*)(void*,
void*), void*) [with T = T, U = U, V = V, Descriptor =
pointer_hash, Allocator = xcallocator]’ to match its type
../../gcc-svn/trunk/libcc1/../gcc/hash-table.h:1169: warning: lowering
visibility of ‘void gt_pch_nx(hash_set*, void (*)(void*, void*),
void*) [with T = T, U = U, Descriptor = pointer_hash,
Allocator = xcallocator]’ to match its type
../../gcc-svn/trunk/libcc1/../gcc/hash-table.h:1171: warning: lowering
visibility of ‘void gt_pch_nx(hash_table::value>*, void (*)(void*, void*), void*) [with
T = T, Descriptor = pointer_hash, Allocator = xcallocator]’
to match its type
gmake[4]: *** [plugin.lo] Error 1
gmake[4]: Leaving directory `/home/uros/gcc-build/libcc1'
gmake[3]: *** [all] Error 2
gmake[3]: Leaving directory `/home/uros/gcc-build/libcc1'
gmake[2]: *** [all-stage1-libcc1] Error 2
gmake[2]: Leaving directory `/home/uros/gcc-build'
gmake[1]: *** [stage1-bubble] Error 2
gmake[1]: Leaving directory `/home/uros/gcc-build'
gmake: *** [all] Error 2

I wonder if at this point just compiled gcc/xg++ and not system
compiler should be used?

Uros.


[match-and-simplify] Merge from trunk

2014-10-28 Thread Richard Biener

Committed.

Richard.

2014-10-28  Richard Biener  

Merge from trunk r216632 through r216771.

Brings back third merge piece.



Re: [PATCH v5] Enable -fsanitize-recover for KASan

2014-10-28 Thread Yury Gribov

On 10/28/2014 12:26 PM, Jakub Jelinek wrote:

On Tue, Oct 28, 2014 at 11:46:31AM +0300, Yury Gribov wrote:

2014-10-23  Yury Gribov  

gcc/
* asan.c (report_error_func): Add noabort path.
(check_func): Ditto.  Formatting.
(asan_expand_check_ifn): Handle noabort path.
* common.opt (flag_sanitize_recover): Add SANITIZE_KERNEL_ADDRESS
to default value.
* doc/invoke.texi (-fsanitize-recover=): Mention KASan.
* opts.c (finish_options): Reword comment.
* sanitizer.def: Add noabort ASan builtins.

gcc/testsuite/
* c-c++-common/asan/kasan-recover-1.c: New test.
* c-c++-common/asan/kasan-recover-2.c: New test.


Are the __asan_{load,store,report}*_noabort entrypoints going to be added
into libasan too?


Probably not, ASan team has declined recovery mode in userspace ASan 
since the beginning of days.  It's even mentioned in their FAQ at 
https://code.google.com/p/address-sanitizer/wiki/AddressSanitizer


-Y


Re: [match-and-simplify] error checking on user defined oper in for

2014-10-28 Thread Richard Biener
On Sat, Oct 25, 2014 at 8:16 PM, Prathamesh Kulkarni
 wrote:
> Currently this is accepted:
> (for plus (mult div)
>   ...)
> which is incorrect. This patch puts more error-checks on the user-defined
> operator in for-pattern.

Nicely spotted issue.  But I prefer to fix it simpler like with the following
which I applied.

Richard.

2014-10-28  Richard Biener  

* genmatch.c (parser::parse_for): Properly check for already
defined operators.


> * genmatch.c
>   (insert_operator): New function.
>   (parse_for): Call insert_operator.
>
> Thanks,
> Prathamesh


p2
Description: Binary data


Re: [match-and-simplify] reject conditional convert and commutative ops in result operand

2014-10-28 Thread Richard Biener
On Mon, Oct 27, 2014 at 3:32 PM, Prathamesh Kulkarni
 wrote:
> I suppose we should reject conditional convert and commutative ops in
> result operand ? since it would create 1-n mapping from match ->
> result.

Yeah.  Same is true for parsing of :type syntax for the match part.
Now that we have a class parser I think it would be better to simply
record whether we are parsing ->match or ->result and issue the
diagnostic at parsing time.

Can you adjust the patch accordingly?

Thanks,
Richard.

> * genmatch.c
>   (fatal_at): New overloaded function with source_location as first parameter.
>   (has_opt_convert_or_commutative_ops): New function.
>   (lower): Call has_opt_convert_or_commutative_ops.
>
> Thanks,
> Prathamesh


Re: [match-and-simplify] error checking on user defined oper in for

2014-10-28 Thread Prathamesh Kulkarni
On Tue, Oct 28, 2014 at 3:45 PM, Richard Biener
 wrote:
> On Sat, Oct 25, 2014 at 8:16 PM, Prathamesh Kulkarni
>  wrote:
>> Currently this is accepted:
>> (for plus (mult div)
>>   ...)
>> which is incorrect. This patch puts more error-checks on the user-defined
>> operator in for-pattern.
>
> Nicely spotted issue.  But I prefer to fix it simpler like with the following
> which I applied.
Won't using get_operator() lookup the hash-table twice for a valid
user-defined operator ?
I thought it would be be better instead to write another function
(insert_operator) to insert operator into hash-table, that does one
lookup.

Thanks,
Prathamesh.
>
> Richard.
>
> 2014-10-28  Richard Biener  
>
> * genmatch.c (parser::parse_for): Properly check for already
> defined operators.
>
>
>> * genmatch.c
>>   (insert_operator): New function.
>>   (parse_for): Call insert_operator.
>>
>> Thanks,
>> Prathamesh


Re: [match-and-simplify] error checking on user defined oper in for

2014-10-28 Thread Richard Biener
On Tue, Oct 28, 2014 at 11:27 AM, Prathamesh Kulkarni
 wrote:
> On Tue, Oct 28, 2014 at 3:45 PM, Richard Biener
>  wrote:
>> On Sat, Oct 25, 2014 at 8:16 PM, Prathamesh Kulkarni
>>  wrote:
>>> Currently this is accepted:
>>> (for plus (mult div)
>>>   ...)
>>> which is incorrect. This patch puts more error-checks on the user-defined
>>> operator in for-pattern.
>>
>> Nicely spotted issue.  But I prefer to fix it simpler like with the following
>> which I applied.
> Won't using get_operator() lookup the hash-table twice for a valid
> user-defined operator ?

Sure - but who cares for a generator program.

> I thought it would be be better instead to write another function
> (insert_operator) to insert operator into hash-table, that does one
> lookup.

Well - I'd prefer easy maintainance for the code over optimization ;)
Which means less lines of code == better.

Thanks,
Richard.

> Thanks,
> Prathamesh.
>>
>> Richard.
>>
>> 2014-10-28  Richard Biener  
>>
>> * genmatch.c (parser::parse_for): Properly check for already
>> defined operators.
>>
>>
>>> * genmatch.c
>>>   (insert_operator): New function.
>>>   (parse_for): Call insert_operator.
>>>
>>> Thanks,
>>> Prathamesh


Re: [PATCH 5/5] add libcc1

2014-10-28 Thread Phil Muldoon
On 28/10/14 09:57, Uros Bizjak wrote:
> On Tue, Oct 28, 2014 at 10:35 AM, Jakub Jelinek  wrote:
>> On Tue, Oct 28, 2014 at 09:36:45AM +0100, Uros Bizjak wrote:
 This patch has now been committed.
>>>
>>> Also breaks bootstap on x86_64-linux-gnu, CentOS 5.11:
>>
>> For -Werror, I'd think that should fix that, WARN_FLAGS should
>> already contain -Werror during stage2/stage3 unless --disable-werror.
>> Untested though.
>
> No, it still fails, although with one -Werror less in the compile flags:

Does removing it from configure.ac and regenerating configure work?

I don't have access to a system compiler of the version you have, so I
am unable to test.

Cheers

Phil

--

Index: Makefile.am
===
--- Makefile.am(revision 216776)
+++ Makefile.am(working copy)
@@ -22,8 +22,7 @@
 -I $(gcc_build_dir) -I$(srcdir)/../gcc \
 -I $(srcdir)/../gcc/c -I $(srcdir)/../gcc/c-family \
 -I $(srcdir)/../libcpp/include
-WERROR_FLAG = -Werror
-AM_CXXFLAGS = $(WARN_FLAGS) $(WERROR_FLAG) $(visibility)
+AM_CXXFLAGS = $(WARN_FLAGS) $(visibility)
 libiberty = ../libiberty/pic/libiberty.a
 
 
Index: Makefile.in
===
--- Makefile.in(revision 216776)
+++ Makefile.in(working copy)
@@ -257,8 +257,7 @@
 -I $(srcdir)/../gcc/c -I $(srcdir)/../gcc/c-family \
 -I $(srcdir)/../libcpp/include
 
-WERROR_FLAG = -Werror
-AM_CXXFLAGS = $(WARN_FLAGS) $(WERROR_FLAG) $(visibility)
+AM_CXXFLAGS = $(WARN_FLAGS) $(visibility)
 libiberty = ../libiberty/pic/libiberty.a
 plugindir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/plugin
 cc1libdir = $(libdir)/$(libsuffix)

Index: configure
===
--- configure(revision 216776)
+++ configure(working copy)
@@ -14342,7 +14342,7 @@
   done
 CFLAGS="$save_CFLAGS"
 
-WARN_FLAGS="$WARN_FLAGS -Werror"
+WARN_FLAGS="$WARN_FLAGS"
 
 
 libsuffix=

Index: configure.ac
===
--- configure.ac(revision 216776)
+++ configure.ac(working copy)
@@ -52,7 +52,7 @@
 AC_SUBST(gcc_version)
 
 ACX_PROG_CC_WARNING_OPTS([-W -Wall], [WARN_FLAGS])
-WARN_FLAGS="$WARN_FLAGS -Werror"
+WARN_FLAGS="$WARN_FLAGS"
 AC_SUBST(WARN_FLAGS)
 
 libsuffix=




Re: [PATCH 5/5] add libcc1

2014-10-28 Thread Uros Bizjak
On Tue, Oct 28, 2014 at 11:35 AM, Phil Muldoon  wrote:

> This patch has now been committed.

 Also breaks bootstap on x86_64-linux-gnu, CentOS 5.11:
>>>
>>> For -Werror, I'd think that should fix that, WARN_FLAGS should
>>> already contain -Werror during stage2/stage3 unless --disable-werror.
>>> Untested though.
>>
>> No, it still fails, although with one -Werror less in the compile flags:
>
> Does removing it from configure.ac and regenerating configure work?
>
> I don't have access to a system compiler of the version you have, so I
> am unable to test.

Yes, this patch allows bootstrap to pass stage1, although with a new warning:

*** Warning: Linking the shared library libcc1.la against the
*** static library ../libiberty/pic/libiberty.a is not portable!

Thanks,
Uros.


Re: [PATCH 5/5] add libcc1

2014-10-28 Thread Phil Muldoon
On 28/10/14 10:51, Uros Bizjak wrote:
> On Tue, Oct 28, 2014 at 11:35 AM, Phil Muldoon  wrote:
>
>> This patch has now been committed.
> Also breaks bootstap on x86_64-linux-gnu, CentOS 5.11:
 For -Werror, I'd think that should fix that, WARN_FLAGS should
 already contain -Werror during stage2/stage3 unless --disable-werror.
 Untested though.
>>> No, it still fails, although with one -Werror less in the compile flags:
>> Does removing it from configure.ac and regenerating configure work?
>>
>> I don't have access to a system compiler of the version you have, so I
>> am unable to test.
> Yes, this patch allows bootstrap to pass stage1, although with a new warning:
>
> *** Warning: Linking the shared library libcc1.la against the
> *** static library ../libiberty/pic/libiberty.a is not portable!
>
> Thanks,
> Uros.

Yeah there is a separate issue with the way we link libiberty in Makefile.am.  
I am investigating and attempting to fix this right now.

Cheers

Phil



[gomp4] Rationalise thread-local variables in libgomp OpenACC support

2014-10-28 Thread Julian Brown
Hi,

This patch rationalises TLS support by moving all thread-local
variables into a single structure. Because this meant interfering with
how per-thread/per-device initialisation was done, I took the
opportunity to tidy up a couple of other bits along the way. Highlights
are:

- TLS support is now optional, with the possibility of falling back to
  pthread primitives (pthread_{get,set}specific). All thread-specific
  data is now stored in a "goacc_thread" structure, and any additional
  data needed by a backend is now pointed to from that structure also.
  New hooks have been added to create and destroy such target-specific
  per-thread data.

- Support for multiple offload devices of the same type has been moved
  into the generic part of libgomp, and can now (in principle) be
  reused by OpenMP also. Because of this, the splay tree mapping host
  memory addresses to addresses on the target device is now stored in
  the same place for OpenMP and OpenACC, whereas beforehand the
  map for the latter was stored in an off-side associative list, which
  was a bit of an ugly niggle.

- The explicit lists of "contexts" (in oacc-init.c) and PTX device info
  (in the NVPTX plugin) have been removed, in favour of linking the
  associated data directly with the entity that it concerns: as
  mentioned above, the memory map is part of the device descriptor
  (since there is now one of those per device instance), and the extra
  info needed for a PTX device over a generic device is simply linked
  by a pointer from the latter.

Additionally, headers have been rearranged a little so that plugins no
longer need to include "oacc-int.h" (and in fact cannot do so), and some
code which is now dead has been removed.

No regressions on a build from the gomp4 branch that has been
additionally patched to support the PTX backend.

OK to apply?

Thanks,

Julian

ChangeLog

libgomp/
* env.c (oacc-int.h): Include.
* libgomp-plugin.h (GOMP_PLUGIN_async_unmap_vars): Don't declare
here.
* libgomp.map (PLUGIN_1.0): Add GOMP_PLUGIN_acc_thread symbol.
* oacc-async.c (oacc-int.h): Include.
(acc_async_test, acc_async_test_all, acc_wait, acc_wait_async)
(acc_wait_all, acc_wait_all_async): Use base_dev not ACC_dev.
* oacc-cuda.c (oacc-int.h): Include.
(acc_get_current_cuda_device, acc_get_current_cuda_context)
(acc_get_cuda_stream): Use base_dev not ACC_dev.
(acc_set_cuda_stream): Call ACC_lazy_initialize, use base_dev not
ACC_dev.
* oacc-host.c (oacc-plugin.h, oacc-int.h): Include one or the
other, depending on HOST_NONSHM_PLUGIN setting.
(openacc_create_thread_data, openacc_destroy_thread_data): New.
(host_dispatch): Initialize create_thread_data_func,
destroy_thread_data_func hooks.
* oacc-init.c (oacc-int.h): Include.
(acc_device_lock): Make static.
(ACC_dev, ACC_handle, handle_num, struct ACC_context, ACC_contexts)
(_ACC_contexts): Remove.
(base_dev, goacc_threads, goacc_thread_lock, goacc_cleanup_key):
Add.
(goacc_tls_data, goacc_tls_key): Define one or the other, depending
on HAVE_TLS setting.
(dispatchers): Add comment.
(ACC_register): Only register 0th device.
(close_handle): Remove.
(_acc_init): Add comment. Don't use ACC_dev.
(goacc_new_thread, goacc_destroy_thread): New.
(lazy_open): Update comment. Remove code relating to contexts and
memory maps. Create thread-specific data if necessary.
(acc_init): Use base_dev not ACC_dev.
(_acc_shutdown): Don't call close_handle. Use base_dev not ACC_dev.
Free target-specific TLS data and close devices that are open at
the time of shutdown.
(lazy_init): Add comment. Use base_dev not ACC_dev.
(lazy_init_and_open): Add comment. Use base_dev not ACC_dev.
(acc_get_num_devices, acc_get_device_type, acc_get_device_num): Use
base_dev not ACC_dev.
(acc_set_device_num): Likewise. If switching device number,
de-associate previous device number from the current thread, but do
not close the device.
(acc_on_device): Check type for device for current thread, not
ACC_dev.
(ACC_runtime_initialize): Initialize goacc_tls_key,
goacc_cleanup_key, base_dev, goacc_threads, goacc_thread_lock. Don't
initialize ACC_contexts.
(saved_bound_dev): Remove.
(ACC_save_and_set_bind, ACC_restore_bind): Use goacc_thread.
(ACC_lazy_initialize): Use base_dev, goacc_thread instead of
ACC_dev, ACC_memmap.
* oacc-int.h (struct ACC_dispatch_t): Don't declare here.
(struct goacc_thread): New.
(goacc_tls_data): Define for HAVE_TLS.
(goacc_tls_key): Define for !HAVE_TLS.
(goacc_thread): New (versions with and without HAVE_TLS).
(ACC_mem_open, ACC_mem_close, ACC_resolve_device, ACC_dev)
(ACC_handle, struct memmap_t, ACC_memmap): Remove.
(base_dev): Add extern declaration.
* oacc-mem.c (oacc-int.h, assert.h): Include.
(ACC_memmap, ACC_mem_open, ACC_mem_close): Remove.
(lookup_host): Ch

[PATCH] Fix PR63665

2014-10-28 Thread Richard Biener

The following fixes folding of x + CST != CST with -fwrapv.  Even
with -fwrapv overflow is signalled by int_const_binop with
TREE_OVERFLOW but of course we cannot do any undefined overflow
optimizations when overflow wraps.

bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2014-10-28  Richard Biener  

PR middle-end/63665
* fold-const.c (fold_comparison): Properly guard simplifying
against INT_MAX/INT_MIN with !TYPE_OVERFLOW_WRAPS.

* gcc.dg/pr63665.c: New testcase.

Index: gcc/fold-const.c
===
--- gcc/fold-const.c(revision 216771)
+++ gcc/fold-const.c(working copy)
@@ -8751,7 +8770,8 @@ fold_comparison (location_t loc, enum tr
 
   /* If the constant operation overflowed this can be
 simplified as a comparison against INT_MAX/INT_MIN.  */
-  if (TREE_OVERFLOW (new_const))
+  if (TREE_OVERFLOW (new_const)
+ && !TYPE_OVERFLOW_WRAPS (TREE_TYPE (arg0)))
{
  int const1_sgn = tree_int_cst_sgn (const1);
  enum tree_code code2 = code;
Index: gcc/testsuite/gcc.dg/pr63665.c
===
--- gcc/testsuite/gcc.dg/pr63665.c  (revision 0)
+++ gcc/testsuite/gcc.dg/pr63665.c  (working copy)
@@ -0,0 +1,18 @@
+/* { dg-do run } */
+/* { dg-require-effective-target int32plus } */
+/* { dg-options "-O -fno-tree-ccp -fno-tree-fre -fno-tree-copy-prop -fwrapv" } 
*/
+
+static inline int
+test5 (int x)
+{
+  int y = 0x8000;
+  return x + y;
+}
+
+int
+main ()
+{
+  if (test5 (0x8000) != 0)
+__builtin_abort ();
+  return 0;
+}


RE: [Patch] Add MIPS flag to avoid use of ldc1/sdc1/ldxc1/sdxc1

2014-10-28 Thread Matthew Fortune
> >> >   Do you have an objection to allowing an option to disable these
> >> instructions (despite the reason for wanting to do so)?
> >>
> >> Yes this seems like a bad workaround for broken code.
> >>
> > Well, we work around broken hardware all the time.  What would you
> suggest that Steve do instead?
> 
> We work around broken hardware all the time yes but that is something
> which is hard to change.  Software is easier to fix.  That does not
> mean in the compiler.  The compiler team should not get themselves in
> the business of working around broken software that depends on
> undefined behavior (this undefined behavior is very obvious and easier
> to fix in the source of the problem).  Report the bug to Google.

I'm mostly in agreement with Andrew on this. I'd like to understand more
about the use-case and what happens for other architectures (only ARM
and x86 are really relevant here I guess). I believe x86 will just
happily load/store doubles to 4-byte aligned addresses but I'm not sure
for ARM. If ARM has to take unaligned access faults for this then I
think MIPS simply has to do the same.

Unless the application is allocating thousands of small chunks of data
and the padding is significant in the overall memory usage then I'd have
thought the allocator could be fixed relatively easily. I'd also expect
that to be generally a performance win for the application on all
architectures.

'If' we were to make a change to the compiler then I would make it a
little more generic/focus on the actual issue which relates to alignment.
I'm not sure what I would call the option but its effect would be for
the compiler to not rely on any greater than 'X' alignment and disable
the use of any load/store instructions which need larger alignment.

That still feels like a bad feature though.

Matthew


Re: [PATCH 5/5] add libcc1

2014-10-28 Thread Phil Muldoon
On 28/10/14 10:51, Uros Bizjak wrote:
> On Tue, Oct 28, 2014 at 11:35 AM, Phil Muldoon  wrote:
>
>> This patch has now been committed.
>
> Also breaks bootstap on x86_64-linux-gnu, CentOS 5.11:

 For -Werror, I'd think that should fix that, WARN_FLAGS should
 already contain -Werror during stage2/stage3 unless --disable-werror.
 Untested though.
>>>
>>> No, it still fails, although with one -Werror less in the compile flags:
>>
>> Does removing it from configure.ac and regenerating configure work?
>>
>> I don't have access to a system compiler of the version you have, so I
>> am unable to test.
>
> Yes, this patch allows bootstrap to pass stage1, although with a new warning:
>
> *** Warning: Linking the shared library libcc1.la against the
> *** static library ../libiberty/pic/libiberty.a is not portable!
>
> Thanks,
> Uros.

I think I have a solution.  Though my automake fu is very weak.  Does
this patch work for you?  I'm really not sure how to deal with the
three possible versions of libiberty any other way.

Cheers

Phil

--



Index: Makefile.in
===
--- Makefile.in(revision 216776)
+++ Makefile.in(working copy)
@@ -81,7 +81,8 @@
   sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
 am__installdirs = "$(DESTDIR)$(cc1libdir)" "$(DESTDIR)$(plugindir)"
 LTLIBRARIES = $(cc1lib_LTLIBRARIES) $(plugin_LTLIBRARIES)
-libcc1_la_DEPENDENCIES = $(libiberty)
+libcc1_la_DEPENDENCIES = $(if $(wildcard $(libiberty_noasan)),, $(if \
+$(wildcard $(libiberty_pic)),,$(libiberty)))
 am__objects_1 = callbacks.lo connection.lo marshall.lo
 am_libcc1_la_OBJECTS = findcomp.lo libcc1.lo names.lo $(am__objects_1)
 libcc1_la_OBJECTS = $(am_libcc1_la_OBJECTS)
@@ -89,7 +90,8 @@
 $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
 $(CXXFLAGS) $(libcc1_la_LDFLAGS) $(LDFLAGS) -o $@
 @ENABLE_PLUGIN_TRUE@am_libcc1_la_rpath = -rpath $(cc1libdir)
-libcc1plugin_la_DEPENDENCIES = $(libiberty)
+libcc1plugin_la_DEPENDENCIES = $(if $(wildcard $(libiberty_noasan)),, \
+$(if $(wildcard $(libiberty_pic)),,$(libiberty)))
 am_libcc1plugin_la_OBJECTS = plugin.lo $(am__objects_1)
 libcc1plugin_la_OBJECTS = $(am_libcc1plugin_la_OBJECTS)
 libcc1plugin_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
@@ -257,9 +259,10 @@
 -I $(srcdir)/../gcc/c -I $(srcdir)/../gcc/c-family \
 -I $(srcdir)/../libcpp/include
 
-WERROR_FLAG = -Werror
-AM_CXXFLAGS = $(WARN_FLAGS) $(WERROR_FLAG) $(visibility)
-libiberty = ../libiberty/pic/libiberty.a
+AM_CXXFLAGS = $(WARN_FLAGS) $(visibility)
+libiberty = ../libiberty/libiberty.a
+libiberty_noasan = ../libiberty/noasan/libiberty.a
+libiberty_pic = ../libiberty/pic/libiberty.a
 plugindir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/plugin
 cc1libdir = $(libdir)/$(libsuffix)
 @ENABLE_PLUGIN_TRUE@plugin_LTLIBRARIES = libcc1plugin.la
@@ -270,10 +273,16 @@
 
 libcc1plugin_la_LDFLAGS = -module -export-symbols $(srcdir)/libcc1plugin.sym
 libcc1plugin_la_SOURCES = plugin.cc $(shared_source)
-libcc1plugin_la_LIBADD = $(libiberty)
+libcc1plugin_la_LIBADD = \
+$(if $(wildcard $(libiberty_noasan)),, \
+$(if $(wildcard $(libiberty_pic)),,$(libiberty)))
+
 libcc1_la_LDFLAGS = -module -export-symbols $(srcdir)/libcc1.sym
 libcc1_la_SOURCES = findcomp.cc libcc1.cc names.cc names.hh $(shared_source)
-libcc1_la_LIBADD = $(libiberty)
+libcc1_la_LIBADD = \
+$(if $(wildcard $(libiberty_noasan)),, \
+$(if $(wildcard $(libiberty_pic)),,$(libiberty)))
+
 all: $(BUILT_SOURCES) cc1plugin-config.h
 $(MAKE) $(AM_MAKEFLAGS) all-am
 
Index: Makefile.am
===
--- Makefile.am(revision 216776)
+++ Makefile.am(working copy)
@@ -22,10 +22,11 @@
 -I $(gcc_build_dir) -I$(srcdir)/../gcc \
 -I $(srcdir)/../gcc/c -I $(srcdir)/../gcc/c-family \
 -I $(srcdir)/../libcpp/include
-WERROR_FLAG = -Werror
-AM_CXXFLAGS = $(WARN_FLAGS) $(WERROR_FLAG) $(visibility)
-libiberty = ../libiberty/pic/libiberty.a
+AM_CXXFLAGS = $(WARN_FLAGS) $(visibility)
 
+libiberty = ../libiberty/libiberty.a
+libiberty_noasan = ../libiberty/noasan/libiberty.a
+libiberty_pic = ../libiberty/pic/libiberty.a
 
 plugindir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/plugin
 cc1libdir = $(libdir)/$(libsuffix)
@@ -48,8 +49,13 @@
 
 libcc1plugin_la_LDFLAGS = -module -export-symbols $(srcdir)/libcc1plugin.sym
 libcc1plugin_la_SOURCES = plugin.cc $(shared_source)
-libcc1plugin_la_LIBADD = $(libiberty)
+libcc1plugin_la_LIBADD = \
+$(if $(wildcard $(libiberty_noasan)),, \
+$(if $(wildcard $(libiberty_pic)),,$(libiberty)))
 
 libcc1_la_LDFLAGS = -module -export-symbols $(srcdir)/libcc1.sym
 libcc1_la_SOURCES = findcomp.cc libcc1.cc names.cc names.hh $(shared_source)
-libcc1_la_LIBADD = $(libiberty)
+libcc1_la_LIBADD = \
+$(if $(wildcard $(libiberty_noasan)),, \
+$(if $(wildcard $(libiberty_pic)),,$(libiberty)))
+



[Ping] [PATCH] Add arm_cortex_m7_tune.

2014-10-28 Thread Hale Wang
Ping?
https://gcc.gnu.org/ml/gcc-patches/2014-10/msg02025.html

Thanks
Hale Wang

> -Original Message-
> From: Hale Wang [mailto:hale.w...@arm.com]
> Sent: Tuesday, October 21, 2014 5:57 PM
> To: Hale Wang; gcc-patches@gcc.gnu.org
> Subject: RE: [PATCH] Add arm_cortex_m7_tune.
> 
> Attach the patch.
> 
> > -Original Message-
> > From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches-
> > ow...@gcc.gnu.org] On Behalf Of Hale Wang
> > Sent: Tuesday, October 21, 2014 5:49 PM
> > To: gcc-patches@gcc.gnu.org
> > Subject: [PATCH] Add arm_cortex_m7_tune.
> >
> > Hi,
> >
> > This patch is used to tune the gcc for Cortex-M7.
> >
> > The performance of Dhrystone can be improved by 1%.
> > The performance of Coremark can be improved by 2.3%.
> >
> > Patch also attached for convenience.
> >
> > Is it ok for trunk?
> >
> > Thanks and Best Regards,
> > Hale Wang
> >
> > gcc/ChangeLog
> > 2014-10-11  Hale Wang  
> >
> > * config/arm/arm.c: Add cortex-m7 tune.
> > * config/arm/arm-cores.def: Use cortex-m7 tune.
> >
> > diff --git a/gcc/config/arm/arm-cores.def
> > b/gcc/config/arm/arm-cores.def index 56ec7fd..3b34173 100644
> > --- a/gcc/config/arm/arm-cores.def
> > +++ b/gcc/config/arm/arm-cores.def
> > @@ -149,7 +149,7 @@ ARM_CORE("cortex-r4",
> > cortexr4, cortexr4,  7R,  FL_LDSCHED, cortex)
> > ARM_CORE("cortex-r4f",cortexr4f, cortexr4f,
> > 7R,  FL_LDSCHED, cortex)
> > ARM_CORE("cortex-r5",  cortexr5, cortexr5,
> > 7R,  FL_LDSCHED | FL_ARM_DIV, cortex)
> > ARM_CORE("cortex-r7",  cortexr7, cortexr7,
> > 7R,  FL_LDSCHED | FL_ARM_DIV, cortex)
> > -ARM_CORE("cortex-m7",   cortexm7, cortexm7,
> > 7EM, FL_LDSCHED, v7m)
> > +ARM_CORE("cortex-m7",  cortexm7, cortexm7,
> > 7EM, FL_LDSCHED, cortex_m7)
> > ARM_CORE("cortex-m4",   cortexm4, cortexm4,
> > 7EM, FL_LDSCHED, v7m)
> > ARM_CORE("cortex-m3",   cortexm3, cortexm3,
> > 7M,  FL_LDSCHED, v7m)
> > ARM_CORE("marvell-pj4", marvell_pj4,
marvell_pj4,
> > 7A,  FL_LDSCHED, 9e)
> > diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index
> > 93b989d..834b13a 100644
> > --- a/gcc/config/arm/arm.c
> > +++ b/gcc/config/arm/arm.c
> > @@ -2003,6 +2003,27 @@ const struct tune_params arm_v7m_tune =
> >8
> > /* Maximum insns to inline memset.  */ };
> >
> > +/* Cortex-M7 tuning.  */
> > +
> > +const struct tune_params arm_cortex_m7_tune = {
> > +  arm_9e_rtx_costs,
> > +  &v7m_extra_costs,
> > +  NULL,
> > /* Sched adj cost.  */
> > +  0,
> > /* Constant limit.  */
> > +  0,
> > /* Max cond insns.  */
> > +  ARM_PREFETCH_NOT_BENEFICIAL,
> > +  true,
> > /* Prefer constant pool.  */
> > +  arm_cortex_m_branch_cost,
> > +  false,
> > /* Prefer LDRD/STRD.  */
> > +  {true, true},
> > /* Prefer non short circuit.  */
> > +  &arm_default_vec_cost,/* Vectorizer costs.
*/
> > +  false,/* Prefer Neon for
64-bits
> > bitops.  */
> > +  false, false, /* Prefer 32-bit
encodings.
> > */
> > +  false,
> > /* Prefer Neon for stringops.  */
> > +  8
> > /* Maximum insns to inline memset.  */
> > +};
> > +
> > /* The arm_v6m_tune is duplicated from arm_cortex_tune, rather than
> > arm_v6t2_tune. It is used for cortex-m0, cortex-m1 and
cortex-m0plus.
> > */
> > const struct tune_params arm_v6m_tune =
> >
> >
> >


cortex-m7-tune-2.patch
Description: Binary data


Re: FW: [AArch64] [BE] [1/2] Make large opaque integer modes endianness-safe.

2014-10-28 Thread Alan Lawrence
When you say a patch by Alan Hayward that's "coming soon", I take it you mean 
this one?  https://gcc.gnu.org/ml/gcc-patches/2014-10/msg00952.html

Just so that we know it has now arrived :).

--Alan

David Sherwood wrote:

Hi,

I forgot to mention that this patch needs was tested in combination with another
patch by Alan Hayward (coming soon) and observed the following:

x86_64: No regressions.
aarch64: No regressions.
aarch64_be: Lots of vector tests now fixed. No new regressions.

Regards,
David.




[Ping] [PATCH] Small multiplier support in Cortex-M0/1/+

2014-10-28 Thread Hale Wang
Ping?
https://gcc.gnu.org/ml/gcc-patches/2014-10/msg02027.html

Thanks,
Hale Wang

> -Original Message-
> From: Hale Wang [mailto:hale.w...@arm.com]
> Sent: Tuesday, October 21, 2014 6:02 PM
> To: 'gcc-patches@gcc.gnu.org'
> Subject: Small multiplier support in Cortex-M0/1/+
> 
> Hi,
> 
> Some configurations of the Cortex-M0 and Cortex-M1 come with a high
> latency multiplier. This patch adds support for such configurations.
> 
> Small multiplier means using add/sub/shift instructions to replace the mul
> instruction for the MCU that has no fast multiplier.
> 
> The following strategies are adopted in this patch:
> 1. Define new CPUs as -mcpu=cortex-m0.small-multiply,cortex-m0plus.small-
> multiply,cortex-m1.small-multiply to support small multiplier.
> 2. -Os means size is preferred. A threshold of 5 is set which means it
will
> prevent spliting if ending up with more than 5 instructions. As for
non-OS,
> there will be no such a limit.
> 
> Some test cases are also added in the testsuite to verify this function.
> 
> Is it ok for trunk?
> 
> Thanks and Best Regards,
> Hale Wang
> 
> gcc/ChangeLog:
> 
> 2014-08-29  Hale Wang  
> 
>   * config/arm/arm-cores.def: Add support for
>   -mcpu=cortex-m0.small-multiply,cortex-m0plus.small-multiply,
>   cortex-m1.small-multiply.
>   * config/arm/arm-tables.opt: Regenerate.
>   * config/arm/arm-tune.md: Regenerate.
>   * config/arm/arm.c: Update the rtx-costs for MUL.
>   * config/arm/bpabi.h: Handle
>   -mcpu=cortex-m0.small-multiply,cortex-m0plus.small-multiply,
>   cortex-m1.small-multiply.
>   * doc/invoke.texi: Document
>   -mcpu=cortex-m0.small-multiply,cortex-m0plus.small-multiply,
>   cortex-m1.small-multiply.
>   * testsuite/gcc.target/arm/small-multiply-m0-1.c: New test case.
>   * testsuite/gcc.target/arm/small-multiply-m0-2.c: Likewise.
>   * testsuite/gcc.target/arm/small-multiply-m0-3.c: Likewise.
>   * testsuite/gcc.target/arm/small-multiply-m0plus-1.c: Likewise.
>   * testsuite/gcc.target/arm/small-multiply-m0plus-2.c: Likewise.
>   * testsuite/gcc.target/arm/small-multiply-m0plus-3.c: Likewise.
>   * testsuite/gcc.target/arm/small-multiply-m1-1.c: Likewise.
>   * testsuite/gcc.target/arm/small-multiply-m1-2.c: Likewise.
>   * testsuite/gcc.target/arm/small-multiply-m1-3.c: Likewise.
> 
> ==
> =
> diff --git a/gcc/config/arm/arm-cores.def b/gcc/config/arm/arm-cores.def
> index a830a83..af4b373 100644
> --- a/gcc/config/arm/arm-cores.def
> +++ b/gcc/config/arm/arm-cores.def
> @@ -137,6 +137,11 @@ ARM_CORE("cortex-m1",cortexm1,
> cortexm1, 6M, FL_LDSCHED, v6m)
>  ARM_CORE("cortex-m0",cortexm0, cortexm0, 6M,
> FL_LDSCHED, v6m)
>  ARM_CORE("cortex-m0plus",cortexm0plus, cortexm0plus, 6M,
> FL_LDSCHED, v6m)
> 
> +/* V6M Architecture Processors for small-multiply implementations.  */
> +ARM_CORE("cortex-m1.small-multiply", cortexm1smallmultiply,
> cortexm1, 6M, FL_LDSCHED | FL_SMALLMUL, v6m)
> +ARM_CORE("cortex-m0.small-multiply", cortexm0smallmultiply,
> cortexm0, 6M, FL_LDSCHED | FL_SMALLMUL, v6m)
> +ARM_CORE("cortex-m0plus.small-multiply",cortexm0plussmallmultiply,
> +cortexm0plus,6M, FL_LDSCHED | FL_SMALLMUL, v6m)
> +
>  /* V7 Architecture Processors */
>  ARM_CORE("generic-armv7-a",  genericv7a, genericv7a,
>   7A,  FL_LDSCHED, cortex)
>  ARM_CORE("cortex-a5",cortexa5, cortexa5, 7A,
> FL_LDSCHED, cortex_a5)
> diff --git a/gcc/config/arm/arm-tables.opt b/gcc/config/arm/arm-tables.opt
> index bc046a0..bd65bd2 100644
> --- a/gcc/config/arm/arm-tables.opt
> +++ b/gcc/config/arm/arm-tables.opt
> @@ -241,6 +241,15 @@ EnumValue
>  Enum(processor_type) String(cortex-m0plus) Value(cortexm0plus)
> 
>  EnumValue
> +Enum(processor_type) String(cortex-m1.small-multiply)
> +Value(cortexm1smallmultiply)
> +
> +EnumValue
> +Enum(processor_type) String(cortex-m0.small-multiply)
> +Value(cortexm0smallmultiply)
> +
> +EnumValue
> +Enum(processor_type) String(cortex-m0plus.small-multiply)
> +Value(cortexm0plussmallmultiply)
> +
> +EnumValue
>  Enum(processor_type) String(generic-armv7-a) Value(genericv7a)
> 
>  EnumValue
> diff --git a/gcc/config/arm/arm-tune.md b/gcc/config/arm/arm-tune.md
> index 954cab8..8b5c778 100644
> --- a/gcc/config/arm/arm-tune.md
> +++ b/gcc/config/arm/arm-tune.md
> @@ -25,6 +25,7 @@
>   arm1176jzs,arm1176jzfs,mpcorenovfp,
>   mpcore,arm1156t2s,arm1156t2fs,
>   cortexm1,cortexm0,cortexm0plus,
> +
>   cortexm1smallmultiply,cortexm0smallmultiply,cortexm0plussmallmul
> tiply,
>   genericv7a,cortexa5,cortexa7,
>   cortexa8,cortexa9,cortexa12,
>   cortexa15,cortexr4,cortexr4f,
> diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index
> 93b989d..5062c85 100644
> --- a/gcc/config/arm/arm.c
> +++ b/gcc/config/arm/arm.c
> @@ -751,6 +751,8 @@ static int thumb_call_reg_n

[PING][PATCH, AARCH64] Add support for -mlong-calls option

2014-10-28 Thread Yangfei (Felix)
> +  c_register_pragma (0, "long_calls_off", aarch64_pr_long_calls_off);
> \
> +} while (0)
> +
>  #define FUNCTION_ARG_PADDING(MODE, TYPE) \
>(aarch64_pad_arg_upward (MODE, TYPE) ? upward : downward)


Hi,
I added four testcases to ensure that this patch tested properly. 
Reg-tested with aarch64-linux-gnu-gcc on qemu. 
OK for the trunk?  


Index: gcc/ChangeLog
===
--- gcc/ChangeLog   (revision 216558)
+++ gcc/ChangeLog   (working copy)
@@ -1,3 +1,26 @@
+2014-10-28  Felix Yang  
+   Haijian Zhang  
+
+   * config/aarch64/aarch64.opt (mlong-calls): New option.
+   * config/aarch64/aarch64.h (REGISTER_TARGET_PRAGMAS): Define.
+   * config/aarch64/aarch64.c (aarch64_set_default_type_attributes,
+   aarch64_attribute_table, aarch64_comp_type_attributes,
+   aarch64_decl_is_long_call_p, aarch64_function_in_section_p,
+   aarch64_pr_long_calls, aarch64_pr_no_long_calls,
+   aarch64_pr_long_calls_off): New functions.
+   (TARGET_SET_DEFAULT_TYPE_ATTRIBUTES): Define as
+   aarch64_set_default_type_attributes.
+   (TARGET_ATTRIBUTE_TABLE): Define as aarch64_attribute_table.
+   (TARGET_COMP_TYPE_ATTRIBUTES): Define as aarch64_comp_type_attribute.
+   (aarch64_pragma_enum): New enum.
+   (aarch64_attribute_table): New attribute table.
+   * config/aarch64/aarch64-protos.h (aarch64_pr_long_calls,
+   aarch64_pr_no_long_calls, aarch64_pr_long_calls_off): New declarations.
+   * config/aarch64/aarch64.md (sibcall, sibcall_value): Modified to
+   generate indirect call for sibling call when needed.
+   * config/aarch64/predicate.md (aarch64_call_insn_operand): Modified to
+   exclude a symbol_ref for an indirect call.
+
 2014-10-22  Richard Sandiford  
 
* lra.c (lra): Remove call to recog_init.
Index: gcc/testsuite/gcc.target/aarch64/long-calls-1.c
===
--- gcc/testsuite/gcc.target/aarch64/long-calls-1.c (revision 0)
+++ gcc/testsuite/gcc.target/aarch64/long-calls-1.c (revision 0)
@@ -0,0 +1,133 @@
+/* Check that long calls to different sections are not optimized to "bl".  */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* This test expects that short calls are the default.  */
+/* { dg-skip-if "-mlong-calls in use" { "*-*-*" } { "-mlong-calls" } { "" } } 
*/
+
+#define section(S) __attribute__((section(S)))
+#define weak __attribute__((weak))
+#define noinline __attribute__((noinline))
+#define long_call __attribute__((long_call))
+#define short_call __attribute__((short_call))
+
+#define REMOTE_CALL(ID, TARGET_ATTRS, CALL_ATTRS)  \
+  const char *TARGET_ATTRS ID (void);  \
+  const char *CALL_ATTRS call_##ID (void) { return ID () + 1; }
+
+#define EXTERN_CALL(ID, TARGET_ATTRS, CALL_ATTRS)  \
+  const char *TARGET_ATTRS noinline ID (void) { return #ID; }  \
+  const char *CALL_ATTRS call_##ID (void) { return ID () + 1; }
\
+  const char *CALL_ATTRS sibcall_##ID (void) { return ID (); }
+
+#define STATIC_CALL(ID, TARGET_ATTRS, CALL_ATTRS)  \
+  static const char *TARGET_ATTRS noinline ID (void) { return #ID; }   \
+  const char *CALL_ATTRS call_##ID (void) { return ID () + 1; }
\
+  const char *CALL_ATTRS sibcall_##ID (void) { return ID (); }
+
+#define DO_TESTS_SECTION(ID, TEST, TARGET_ATTRS)   \
+  TEST (ID##1, TARGET_ATTRS, ) \
+  TEST (ID##2, TARGET_ATTRS section (".test.a"), section (".test.b"))  \
+  TEST (ID##3, TARGET_ATTRS section (".test.c"), section (".test.c"))
+
+#define DO_TESTS_CALL_ATTR(ID, TEST, TARGET_ATTRS) \
+  DO_TESTS_SECTION (ID##n, TEST, TARGET_ATTRS) \
+  DO_TESTS_SECTION (ID##l, TEST, TARGET_ATTRS long_call)   \
+  DO_TESTS_SECTION (ID##s, TEST, TARGET_ATTRS short_call)
+
+DO_TESTS_CALL_ATTR (remote_, REMOTE_CALL,)
+DO_TESTS_CALL_ATTR (strong_, EXTERN_CALL,)
+DO_TESTS_CALL_ATTR (weak_, EXTERN_CALL, weak)
+DO_TESTS_CALL_ATTR (static_, STATIC_CALL,)
+
+
+/* Calls to remote_* should honor the call type attribute,
+   with "short" being the default.
+
+   In the regular expressions below:
+   
+   * We allow both "b" and "bl" in some cases to allow for the
+ possibility of sibling calls.  */
+
+/* { dg-final { scan-assembler "\tbl\tremote_n1\n" } } */
+/* { dg-final { scan-assembler "\tbl\tremote_n2\n" } } */
+/* { dg-final { scan-assembler "\tbl\tremote_n3\n" } } */
+
+/* { dg-final { scan-assembler-not "\tbl\tremote_l1\n" } } */
+/* { dg-final { scan-assembler-not "\tbl\tremote_l2\n" } } */
+/* { dg-final { scan-assembler-not "\tbl\tremote_l3\n" } } */
+
+/* { dg-final { scan-assembler "\tbl\tremote_s1\n" } } */
+/* { dg-final { scan-assembler "\tbl\tremote_s2\n" } } */
+/* { dg-final

Re: [PATCH x86] Increase PARAM_MAX_COMPLETELY_PEELED_INSNS when branch is costly

2014-10-28 Thread Evgeny Stupachenko
make check for gcc passed

On Mon, Oct 27, 2014 at 11:10 AM, Evgeny Stupachenko  wrote:
> The results are the same for Silvermont.
> There are no significant changes on Haswell.
> So I agree with Richard, let's enable this x86 wide.
>
> Bootstrap/ passed.
> Make check in progress.
> Is it ok?
>
> 2014-10-25  Evgeny Stupachenko  
> * config/i386/i386.c (ix86_option_override_internal): Increase
> PARAM_MAX_COMPLETELY_PEELED_INSNS.
>
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index 6337aa5..5ac10eb 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -4081,6 +4081,12 @@ ix86_option_override_internal (bool main_args_p,
>  opts->x_param_values,
>  opts_set->x_param_values);
>
> +  /* Extend full peel max insns parameter for x86.  */
> +  maybe_set_param_value (PARAM_MAX_COMPLETELY_PEELED_INSNS,
> +120,
> +opts->x_param_values,
> +opts_set->x_param_values);
> +
>/* Enable sw prefetching at -O3 for CPUS that prefetching is helpful.  */
>if (opts->x_flag_prefetch_loop_arrays < 0
>&& HAVE_prefetch
>
> On Mon, Oct 13, 2014 at 4:23 PM, Jan Hubicka  wrote:
>>> On Fri, Oct 10, 2014 at 5:40 PM, Evgeny Stupachenko  
>>> wrote:
>>> > Hi,
>>> >
>>> > The patch increase PARAM_MAX_COMPLETELY_PEELED_INSNS for CPUs with
>>> > high branch cost.
>>> > Bootstrap and make check are in progress.
>>> > The patch boosts (up to 2,5 times improve) several benchmarks compiled
>>> > with "-Ofast" on Silvermont
>>> > Spec2000:
>>> > +5% gain on 173.applu
>>> > +1% gain on 255.vortex
>>> >
>>> > Is it ok for trunk when pass bootstrap and make check?
>>>
>>> This is only a 20% increase - from 100 to 120.  I would instead suggest
>>> to explore doing this change unconditionally if it helps that much.
>>
>> Agreed, I think the value of 100 was set decade ago by Zdenek and me 
>> completely
>> artifically. I do not recall any serious tuning of this flag.
>>
>> Note that I plan to update
>> https://gcc.gnu.org/ml/gcc-patches/2013-11/msg02270.html to current tree so
>> PARAM_MAX_COMPLETELY_PEELED_INSNS will be used at gimple level rather than 
>> tree
>> changing its meaning somewhat.
>>
>> Perhaps I could try to find time this or next week to update the patch so we 
>> do
>> not need to do the tuning twice.
>>
>> Honza
>>
>>>
>>> Richard.
>>>
>>> > Thanks,
>>> > Evgeny
>>> >
>>> > 2014-10-10  Evgeny Stupachenko  
>>> > * config/i386/i386.c (ix86_option_override_internal): Increase
>>> > PARAM_MAX_COMPLETELY_PEELED_INSNS for CPUs with high branch cost.
>>> > * config/i386/i386.h (TARGET_HIGH_BRANCH_COST): New.
>>> > * config/i386/x86-tune.def (X86_TUNE_HIGH_BRANCH_COST): Indicates
>>> > CPUs with high branch cost.
>>> >
>>> > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
>>> > index 6337aa5..5ac10eb 100644
>>> > --- a/gcc/config/i386/i386.c
>>> > +++ b/gcc/config/i386/i386.c
>>> > @@ -4081,6 +4081,14 @@ ix86_option_override_internal (bool main_args_p,
>>> >  opts->x_param_values,
>>> >  opts_set->x_param_values);
>>> >
>>> > +  /* Extend full peel max insns parameter for CPUs with high branch 
>>> > cost.  */
>>> > +  if (TARGET_HIGH_BRANCH_COST)
>>> > +maybe_set_param_value (PARAM_MAX_COMPLETELY_PEELED_INSNS,
>>> > +  120,
>>> > +  opts->x_param_values,
>>> > +  opts_set->x_param_values);
>>> > +
>>> > +
>>> >/* Enable sw prefetching at -O3 for CPUS that prefetching is helpful.  
>>> > */
>>> >if (opts->x_flag_prefetch_loop_arrays < 0
>>> >&& HAVE_prefetch
>>> > diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
>>> > index 2c64162..da0c57b 100644
>>> > --- a/gcc/config/i386/i386.h
>>> > +++ b/gcc/config/i386/i386.h
>>> > @@ -415,6 +415,7 @@ extern unsigned char 
>>> > ix86_tune_features[X86_TUNE_LAST];
>>> >  #define TARGET_INTER_UNIT_CONVERSIONS \
>>> > ix86_tune_features[X86_TUNE_INTER_UNIT_CONVERSIONS]
>>> >  #define TARGET_FOUR_JUMP_LIMIT 
>>> > ix86_tune_features[X86_TUNE_FOUR_JUMP_LIMIT]
>>> > +#define TARGET_HIGH_BRANCH_COST
>>> > ix86_tune_features[X86_TUNE_HIGH_BRANCH_COST]
>>> >  #define TARGET_SCHEDULE
>>> > ix86_tune_features[X86_TUNE_SCHEDULE]
>>> >  #define TARGET_USE_BT  ix86_tune_features[X86_TUNE_USE_BT]
>>> >  #define TARGET_USE_INCDEC  ix86_tune_features[X86_TUNE_USE_INCDEC]
>>> > diff --git a/gcc/config/i386/x86-tune.def b/gcc/config/i386/x86-tune.def
>>> > index b6b210e..04d8bf8 100644
>>> > --- a/gcc/config/i386/x86-tune.def
>>> > +++ b/gcc/config/i386/x86-tune.def
>>> > @@ -208,6 +208,11 @@ DEF_TUNE (X86_TUNE_FOUR_JUMP_LIMIT, 
>>> > "four_jump_limit",
>>> >m_PPRO | m_P4_NOCONA | m_BONNELL | m_SILVERMONT | m_INTEL |
>>> >   m_ATHLON_K8 | m_AMDFAM10)
>>> >
>>> > +/* X86_TUNE_

Re: [PATCH] Add zero-overhead looping for xtensa backend

2014-10-28 Thread Yangfei (Felix)
> On Thu, Oct 23, 2014 at 11:51 PM, Yangfei (Felix) 
> wrote:
> > Thanks for the explanation. I think I am clear about what you are thinking 
> > now.
> > That's an interesting question. I am not sure about reason why GCC's reload
> cannot handle a doloop_end insn.
> > I guess maybe the doloop_end pattern is special? I mean it's a branch insn 
> > in a
> parallel form.
> 
> 
> No it is not special.  Just jump are never handled by reload.  I thought this 
> was
> documented somewhere also.  Basically the main issue with jumps is where
> does the reload value go which side of the jump?
> 
> Thanks,
> Andrew
> 


Hi Sterling,
  How do you think about this issue? 
  As c6x/bfin port handles this the same way, is it OK for the patch to be 
applied? 
  Thanks. 


Re: [PATCH 5/5] add libcc1

2014-10-28 Thread Jakub Jelinek
On Tue, Oct 28, 2014 at 11:47:31AM +, Phil Muldoon wrote:
> I think I have a solution.  Though my automake fu is very weak.  Does
> this patch work for you?  I'm really not sure how to deal with the
> three possible versions of libiberty any other way.

That is insufficient,
a) you don't filter away -fsanitize=address, which would make it
unusable in gdb
b) without the -Wc, stuff, you get the ugly libtool warnings
c) the LTLDFLAGS mess is needed for libtool not eating the -Wc, stuff

I've in the mean time successfully bootstrapped/regtested my patch on
i686-linux (--with-build-config=bootstrap-ubsan), that was build without
ada, on x86_64-linux the build failed because of some recent ada vs.
bootstrap-ubsan incompatibilities unrelated to libcc1 (but libcc1 built
fine).

So I'm proposing my patch (which is modeled after lto-plugin changes by
myself and others), with the -Werror stuff handled separately as follow-up.
Ok for trunk?

2014-10-28  Jakub Jelinek  

* Makefile.am (CXXFLAGS, LDFLAGS): Filter out -fsanitize=address.
(libiberty_normal, libiberty_noasan, libiberty_pic, libiberty_dep):
New variables.
(libiberty): Set to -Wc, followed by the first existing noasan/,
pic/ or . libiberty.a.
(libcc1plugin_la_DEPENDENCIES, libcc1plugin_la_LINK,
libcc1_la_DEPENDENCIES, libcc1_la_LINK, LTLDFLAGS): New variables.
* Makefile.in: Regenerated.

--- libcc1/Makefile.am.jj   2014-10-27 19:41:13.0 +0100
+++ libcc1/Makefile.am  2014-10-28 09:07:57.443711725 +0100
@@ -24,8 +24,17 @@ AM_CPPFLAGS = -I $(srcdir)/../include -I
-I $(srcdir)/../libcpp/include
 WERROR_FLAG = -Werror
 AM_CXXFLAGS = $(WARN_FLAGS) $(WERROR_FLAG) $(visibility)
-libiberty = ../libiberty/pic/libiberty.a
-
+override CXXFLAGS := $(filter-out -fsanitize=address,$(CXXFLAGS))
+override LDFLAGS := $(filter-out -fsanitize=address,$(LDFLAGS))
+# Can be simplified when libiberty becomes a normal convenience library.
+libiberty_normal = ../libiberty/libiberty.a
+libiberty_noasan = ../libiberty/noasan/libiberty.a
+libiberty_pic = ../libiberty/pic/libiberty.a
+Wc=-Wc,
+libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \
+   $(if $(wildcard $(libiberty_pic)),$(Wc)$(libiberty_pic), \
+   $(Wc)$(libiberty_normal)))
+libiberty_dep = $(patsubst $(Wc)%,%,$(libiberty))
 
 plugindir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/plugin
 cc1libdir = $(libdir)/$(libsuffix)
@@ -49,7 +58,16 @@ shared_source = callbacks.cc callbacks.h
 libcc1plugin_la_LDFLAGS = -module -export-symbols $(srcdir)/libcc1plugin.sym
 libcc1plugin_la_SOURCES = plugin.cc $(shared_source)
 libcc1plugin_la_LIBADD = $(libiberty)
+libcc1plugin_la_DEPENDENCIES = $(libiberty_dep)
+libcc1plugin_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
+   $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+   $(CXXFLAGS) $(libcc1plugin_la_LDFLAGS) $(LTLDFLAGS) -o $@
 
+LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
 libcc1_la_LDFLAGS = -module -export-symbols $(srcdir)/libcc1.sym
 libcc1_la_SOURCES = findcomp.cc libcc1.cc names.cc names.hh $(shared_source)
 libcc1_la_LIBADD = $(libiberty)
+libcc1_la_DEPENDENCIES = $(libiberty_dep)
+libcc1_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
+   $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+   $(CXXFLAGS) $(libcc1_la_LDFLAGS) $(LTLDFLAGS) -o $@
--- libcc1/Makefile.in.jj   2014-10-27 19:41:13.0 +0100
+++ libcc1/Makefile.in  2014-10-28 09:08:01.689922599 +0100
@@ -81,20 +81,12 @@ am__base_list = \
   sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
 am__installdirs = "$(DESTDIR)$(cc1libdir)" "$(DESTDIR)$(plugindir)"
 LTLIBRARIES = $(cc1lib_LTLIBRARIES) $(plugin_LTLIBRARIES)
-libcc1_la_DEPENDENCIES = $(libiberty)
 am__objects_1 = callbacks.lo connection.lo marshall.lo
 am_libcc1_la_OBJECTS = findcomp.lo libcc1.lo names.lo $(am__objects_1)
 libcc1_la_OBJECTS = $(am_libcc1_la_OBJECTS)
-libcc1_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
-   $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
-   $(CXXFLAGS) $(libcc1_la_LDFLAGS) $(LDFLAGS) -o $@
 @ENABLE_PLUGIN_TRUE@am_libcc1_la_rpath = -rpath $(cc1libdir)
-libcc1plugin_la_DEPENDENCIES = $(libiberty)
 am_libcc1plugin_la_OBJECTS = plugin.lo $(am__objects_1)
 libcc1plugin_la_OBJECTS = $(am_libcc1plugin_la_OBJECTS)
-libcc1plugin_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
-   $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
-   $(CXXFLAGS) $(libcc1plugin_la_LDFLAGS) $(LDFLAGS) -o $@
 @ENABLE_PLUGIN_TRUE@am_libcc1plugin_la_rpath = -rpath $(plugindir)
 DEFAULT_INCLUDES = -I.@am__isrc@
 depcomp = $(SHELL) $(top_srcdir)/../depcomp
@@ -259,7 +251,16 @@ AM_CPPFLAGS = -I $(srcdir)/../include -I
 
 WERROR_FLAG = -Werror
 AM_CXXFLAGS = $(WARN_FLAGS) $(WERROR_FLAG) $(visibility)
-libiberty = ../libiberty/pic/libiberty.a
+# Can be simplified when libiberty becomes a normal convenience library.
+libiberty_norm

Fix libcc1 bootstrap and linking issues

2014-10-28 Thread Phil Muldoon

Hi

A few issues came to light this morning on some systems with
bootstrapping and libiberty linking issues.  We erroneously specified
-Werror in stage one builds.  This patch removes that flag.  We also
unconditionally linked with the PIC version of libiberty.  This patch
adds a conditional if to Makefile.am.

The conditional if I am not terribly sure of.  But it is the only way
I can think of to conditionally test for one version of libiberty over
another.  I pretty much just took the if code from the
lto_plugin/Makefile.am

What do you think?

Cheers

Phil

--

2014-10-28  Phil Muldoon 

* configure.ac: Remove -Werror.
* configure: Regenerate.
* Makefile.am: Remove -Werror. Link correct libiberty.
* Makefile.in: Regenerate.

Index: Makefile.am
===
--- Makefile.am(revision 216776)
+++ Makefile.am(working copy)
@@ -22,10 +22,11 @@
 -I $(gcc_build_dir) -I$(srcdir)/../gcc \
 -I $(srcdir)/../gcc/c -I $(srcdir)/../gcc/c-family \
 -I $(srcdir)/../libcpp/include
-WERROR_FLAG = -Werror
-AM_CXXFLAGS = $(WARN_FLAGS) $(WERROR_FLAG) $(visibility)
-libiberty = ../libiberty/pic/libiberty.a
+AM_CXXFLAGS = $(WARN_FLAGS) $(visibility)
 
+libiberty = ../libiberty/libiberty.a
+libiberty_noasan = ../libiberty/noasan/libiberty.a
+libiberty_pic = ../libiberty/pic/libiberty.a
 
 plugindir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/plugin
 cc1libdir = $(libdir)/$(libsuffix)
@@ -48,8 +49,13 @@
 
 libcc1plugin_la_LDFLAGS = -module -export-symbols $(srcdir)/libcc1plugin.sym
 libcc1plugin_la_SOURCES = plugin.cc $(shared_source)
-libcc1plugin_la_LIBADD = $(libiberty)
+libcc1plugin_la_LIBADD = \
+$(if $(wildcard $(libiberty_noasan)),, \
+$(if $(wildcard $(libiberty_pic)),,$(libiberty)))
 
 libcc1_la_LDFLAGS = -module -export-symbols $(srcdir)/libcc1.sym
 libcc1_la_SOURCES = findcomp.cc libcc1.cc names.cc names.hh $(shared_source)
-libcc1_la_LIBADD = $(libiberty)
+libcc1_la_LIBADD = \
+$(if $(wildcard $(libiberty_noasan)),, \
+$(if $(wildcard $(libiberty_pic)),,$(libiberty)))
+
Index: Makefile.in
===
--- Makefile.in(revision 216776)
+++ Makefile.in(working copy)
@@ -81,7 +81,8 @@
   sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
 am__installdirs = "$(DESTDIR)$(cc1libdir)" "$(DESTDIR)$(plugindir)"
 LTLIBRARIES = $(cc1lib_LTLIBRARIES) $(plugin_LTLIBRARIES)
-libcc1_la_DEPENDENCIES = $(libiberty)
+libcc1_la_DEPENDENCIES = $(if $(wildcard $(libiberty_noasan)),, $(if \
+$(wildcard $(libiberty_pic)),,$(libiberty)))
 am__objects_1 = callbacks.lo connection.lo marshall.lo
 am_libcc1_la_OBJECTS = findcomp.lo libcc1.lo names.lo $(am__objects_1)
 libcc1_la_OBJECTS = $(am_libcc1_la_OBJECTS)
@@ -89,7 +90,8 @@
 $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
 $(CXXFLAGS) $(libcc1_la_LDFLAGS) $(LDFLAGS) -o $@
 @ENABLE_PLUGIN_TRUE@am_libcc1_la_rpath = -rpath $(cc1libdir)
-libcc1plugin_la_DEPENDENCIES = $(libiberty)
+libcc1plugin_la_DEPENDENCIES = $(if $(wildcard $(libiberty_noasan)),, \
+$(if $(wildcard $(libiberty_pic)),,$(libiberty)))
 am_libcc1plugin_la_OBJECTS = plugin.lo $(am__objects_1)
 libcc1plugin_la_OBJECTS = $(am_libcc1plugin_la_OBJECTS)
 libcc1plugin_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
@@ -257,9 +259,10 @@
 -I $(srcdir)/../gcc/c -I $(srcdir)/../gcc/c-family \
 -I $(srcdir)/../libcpp/include
 
-WERROR_FLAG = -Werror
-AM_CXXFLAGS = $(WARN_FLAGS) $(WERROR_FLAG) $(visibility)
-libiberty = ../libiberty/pic/libiberty.a
+AM_CXXFLAGS = $(WARN_FLAGS) $(visibility)
+libiberty = ../libiberty/libiberty.a
+libiberty_noasan = ../libiberty/noasan/libiberty.a
+libiberty_pic = ../libiberty/pic/libiberty.a
 plugindir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/plugin
 cc1libdir = $(libdir)/$(libsuffix)
 @ENABLE_PLUGIN_TRUE@plugin_LTLIBRARIES = libcc1plugin.la
@@ -270,10 +273,16 @@
 
 libcc1plugin_la_LDFLAGS = -module -export-symbols $(srcdir)/libcc1plugin.sym
 libcc1plugin_la_SOURCES = plugin.cc $(shared_source)
-libcc1plugin_la_LIBADD = $(libiberty)
+libcc1plugin_la_LIBADD = \
+$(if $(wildcard $(libiberty_noasan)),, \
+$(if $(wildcard $(libiberty_pic)),,$(libiberty)))
+
 libcc1_la_LDFLAGS = -module -export-symbols $(srcdir)/libcc1.sym
 libcc1_la_SOURCES = findcomp.cc libcc1.cc names.cc names.hh $(shared_source)
-libcc1_la_LIBADD = $(libiberty)
+libcc1_la_LIBADD = \
+$(if $(wildcard $(libiberty_noasan)),, \
+$(if $(wildcard $(libiberty_pic)),,$(libiberty)))
+
 all: $(BUILT_SOURCES) cc1plugin-config.h
 $(MAKE) $(AM_MAKEFLAGS) all-am
 
Index: configure
===
--- configure(revision 216776)
+++ configure(working copy)
@@ -14342,7 +14342,7 @@
   done
 CFLAGS="$save_CFLAGS"
 
-WARN_FLAGS="$WARN_FLAGS -Werror"
+WARN_FLAGS="$WARN_FLAGS"
 
 
 libsuffix=
Index: configure.ac
==

Re: [match-and-simplify] reject conditional convert and commutative ops in result operand

2014-10-28 Thread Prathamesh Kulkarni
On Tue, Oct 28, 2014 at 3:50 PM, Richard Biener
 wrote:
> On Mon, Oct 27, 2014 at 3:32 PM, Prathamesh Kulkarni
>  wrote:
>> I suppose we should reject conditional convert and commutative ops in
>> result operand ? since it would create 1-n mapping from match ->
>> result.
>
> Yeah.  Same is true for parsing of :type syntax for the match part.
> Now that we have a class parser I think it would be better to simply
> record whether we are parsing ->match or ->result and issue the
> diagnostic at parsing time.
>
> Can you adjust the patch accordingly?
Is the following version okay ?

* genmatch.c
  (parser): Add new member parsing_match_operand.
  (parser::parse_operation): Check for conditional convert in result operand.
  (parser::parse_expr): Check for commutative operator in result operand.
 Check for :type in match operand.
  (parser::parse_simplify): Set/unset parsing_match_operand.

Thanks,
Prathamesh

>
> Thanks,
> Richard.
>
>> * genmatch.c
>>   (fatal_at): New overloaded function with source_location as first 
>> parameter.
>>   (has_opt_convert_or_commutative_ops): New function.
>>   (lower): Call has_opt_convert_or_commutative_ops.
>>
>> Thanks,
>> Prathamesh
Index: gcc/genmatch.c
===
--- gcc/genmatch.c	(revision 216776)
+++ gcc/genmatch.c	(working copy)
@@ -2453,6 +2453,7 @@
 public:
   vec simplifiers;
   vec user_predicates;
+  bool parsing_match_operand;
 };
 
 /* Lexing helpers.  */
@@ -2598,6 +2599,9 @@
 	;
   else
 	fatal_at (id_tok, "non-convert operator conditionalized");
+
+  if (!parsing_match_operand)
+	fatal_at (id_tok, "conditional convert can only be used in match expression");
   eat_token (CPP_QUERY);
 }
   else if (strcmp  (id, "convert1") == 0
@@ -2652,11 +2656,20 @@
 	{
 	  const char *s = get_ident ();
 	  if (s[0] == 'c' && !s[1])
-	is_commutative = true;
+	{
+	  if (!parsing_match_operand)
+		fatal_at (token, "flag :c can only be used in match expression");
+	  is_commutative = true;
+	}
 	  else if (s[1] != '\0')
-	expr_type = s;
+	{
+	  if (parsing_match_operand)
+		fatal_at (token, "':type' can only be used in result expression");
+	  expr_type = s;
+	}
 	  else
 	fatal_at (token, "flag %s not recognized", s);
+	  
 	  token = peek ();
 	}
   else
@@ -2809,6 +2822,7 @@
 {
   /* Reset the capture map.  */
   capture_ids = new std::map;
+  parsing_match_operand = true;
 
   const cpp_token *loc = peek ();
   struct operand *match = parse_op ();
@@ -2818,6 +2832,7 @@
   && is_a  (as_a  (match)->operation))
 fatal_at (loc, "outermost expression cannot be a predicate");
 
+  parsing_match_operand = false; 
   const cpp_token *token = peek ();
 
   /* If this if is immediately closed then it is part of a predicate


[PATCH] Fix up sign extension in bswap

2014-10-28 Thread Jakub Jelinek
On Tue, Oct 21, 2014 at 10:28:40AM +0100, Thomas Preud'homme wrote:
> --- a/gcc/tree-ssa-math-opts.c
> +++ b/gcc/tree-ssa-math-opts.c
> @@ -1916,7 +1916,8 @@ find_bswap_or_nop_1 (gimple stmt, struct 
> symbolic_number *n, int limit)
>   if (!TYPE_UNSIGNED (n->type) && type_size > old_type_size
>   && HEAD_MARKER (n->n, old_type_size))
> for (i = 0; i < type_size - old_type_size; i++)
> - n->n |= MARKER_BYTE_UNKNOWN << (type_size - 1 - i);
> + n->n |= MARKER_BYTE_UNKNOWN
> + << ((type_size - 1 - i) * BITS_PER_MARKER);
>  
>   if (type_size < 64 / BITS_PER_MARKER)
> {

As my last bootstrap-ubsan bootstrap revealed, this is still wrong.
Here is a fix (other spots where MARKER_BYTE_UNKNOWN is shifted up
are correct).  Bootstrapped/regtested on i686-linux, ok for trunk?

Thomas, you know the code better, can you from the fix figure out
a testcase that current trunk miscompiles or doesn't optimize
because of this bug?

2014-10-28  Jakub Jelinek  

* tree-ssa-math-opts.c (find_bswap_or_nop_1): Use uint64_t
type for the left shift in CASE_CONVERT case.

--- gcc/tree-ssa-math-opts.c.jj 2014-10-27 19:41:14.0 +0100
+++ gcc/tree-ssa-math-opts.c2014-10-27 23:43:41.956495361 +0100
@@ -1926,7 +1926,7 @@ find_bswap_or_nop_1 (gimple stmt, struct
if (!TYPE_UNSIGNED (n->type) && type_size > old_type_size
&& HEAD_MARKER (n->n, old_type_size))
  for (i = 0; i < type_size - old_type_size; i++)
-   n->n |= MARKER_BYTE_UNKNOWN
+   n->n |= (uint64_t) MARKER_BYTE_UNKNOWN
<< ((type_size - 1 - i) * BITS_PER_MARKER);
 
if (type_size < 64 / BITS_PER_MARKER)


Jakub


Re: [Patch] Add MIPS flag to avoid use of ldc1/sdc1/ldxc1/sdxc1

2014-10-28 Thread Ramana Radhakrishnan
On Tue, Oct 28, 2014 at 11:46 AM, Matthew Fortune
 wrote:
>> >> >   Do you have an objection to allowing an option to disable these
>> >> instructions (despite the reason for wanting to do so)?
>> >>
>> >> Yes this seems like a bad workaround for broken code.
>> >>
>> > Well, we work around broken hardware all the time.  What would you
>> suggest that Steve do instead?
>>
>> We work around broken hardware all the time yes but that is something
>> which is hard to change.  Software is easier to fix.  That does not
>> mean in the compiler.  The compiler team should not get themselves in
>> the business of working around broken software that depends on
>> undefined behavior (this undefined behavior is very obvious and easier
>> to fix in the source of the problem).  Report the bug to Google.
>
> I'm mostly in agreement with Andrew on this. I'd like to understand more
> about the use-case and what happens for other architectures (only ARM
> and x86 are really relevant here I guess). I believe x86 will just
> happily load/store doubles to 4-byte aligned addresses but I'm not sure
> for ARM. If ARM has to take unaligned access faults for this then I
> think MIPS simply has to do the same.

On AArch32 (ARM) the equivalent general purpose instructions (ldrd /
strd , vldr / vstr, vpush / vpop, vldm / vstm) require only 4 byte
alignment in the architecture. The only case where we may have a
problem is with ldrexd / strexd instructions which are used for
atomics but I'm not sure if that is under question / discussion here.
This is really an application "design / portability" issue rather than
anything else. So, there's no need to take alignment faults on AArch32
in this situation. Oh and before someone asks AArch64 is not a strict
alignment target and so the compiler is free to emit unaligned
accesses unless it is told not to do so.

regards
Ramana


[patch,avr,4.9] Fix PR63633 ICEs for expanders colliding hard-regs

2014-10-28 Thread Georg-Johann Lay
Middle-end might come up with hard registers as operands for expanders which 
clobber respective hard regs.  This patch uses freshly created pseudos for 
respective expander operands and emits pseudo <-> hard move insn.


Ok for 4.9.2?

It's not yet for trunk because avr trunk backend is currently broken.

Johann

gcc/
PR63633
* config/avr/avr-protos.h (regmask): New inline function.
(avr_fix_inputs, avr_emit3_fix_outputs): New protos.
* config/avr/avr.c (avr_fix_operands, avr_move_fixed_operands)
(avr_fix_inputs, avr_emit3_fix_outputs): New functions.
* config/avr/avr-fixed.md (mulqq3_nomul, muluqq3_nomul)
(mul3, mul3, 3, 3)
(3, round3): Fix input operands.
* config/avr/avr-dimode.md (add3, sub3)
(3, 3, cbranch4)
(3, mulsidi3): Fix input operands.
* config/avr/avr.md (mulqi3_call, mulhi3_call, mulsi3, mulpsi3)
(mulusi3, mulssi3, mulohisi3, mulhisi3)
(usmulhisi3, mulhi3_highpart, mulsqipsi3)
(fmul, fmuls, fmulsu): Fix operands.  Turn insn into expander as
needed.

gcc/testsuite/
PR63633
* gcc.target/avr/torture/pr63633-ice-mult.c: New test.
Index: testsuite/gcc.target/avr/torture/pr63633-ice-mult.c
===
--- testsuite/gcc.target/avr/torture/pr63633-ice-mult.c	(revision 0)
+++ testsuite/gcc.target/avr/torture/pr63633-ice-mult.c	(revision 0)
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+
+void ice_mult32 (int x)
+{
+  register long reg __asm ("22");
+  __asm volatile (" " :: "r" (reg = 0x12345 * x));
+}
+
+void ice_mult24 (int x)
+{
+  register __int24 reg __asm ("20");
+  __asm volatile (" " :: "r" (reg = 0x12345 * x));
+}
+
+void ice_sh24 (__int24 x)
+{
+  register __int24 reg __asm ("20");
+  __asm volatile (" " :: "r" (reg = x << 3));
+}
+
+void ice_sh24b (__int24 x)
+{
+  register __int24 reg __asm ("20");
+  __asm volatile (" " :: "r" (reg = x << 22));
+}
+
+void ice_s16s16 (int x)
+{
+  register long reg __asm ("20");
+  __asm volatile (" " :: "r" (reg = (long) x*x));
+}
+
+void ice_u16s16 (int x)
+{
+  register long reg __asm ("20");
+  __asm volatile (" " :: "r" (reg = (long) x*0x1234u));
+}
Index: config/avr/avr-fixed.md
===
--- config/avr/avr-fixed.md	(revision 215212)
+++ config/avr/avr-fixed.md	(working copy)
@@ -231,7 +231,11 @@ (define_expand "mulqq3_nomul"
   (clobber (reg:HI 24))])
(set (match_operand:QQ 0 "register_operand" "")
 (reg:QQ 23))]
-  "!AVR_HAVE_MUL")
+  "!AVR_HAVE_MUL"
+  {
+avr_fix_inputs (operands, 1 << 2, regmask (QQmode, 24));
+  })
+
 
 (define_expand "muluqq3_nomul"
   [(set (reg:UQQ 22)
@@ -246,7 +250,10 @@ (define_expand "muluqq3_nomul"
   (clobber (reg:HI 22))])
(set (match_operand:UQQ 0 "register_operand" "")
 (reg:UQQ 25))]
-  "!AVR_HAVE_MUL")
+  "!AVR_HAVE_MUL"
+  {
+avr_fix_inputs (operands, 1 << 2, regmask (UQQmode, 22));
+  })
 
 (define_insn "*mulqq3.call"
   [(set (reg:QQ 23)
@@ -274,7 +281,10 @@ (define_expand "mul3"
   (clobber (reg:HI 22))])
(set (match_operand:ALL2QA 0 "register_operand" "")
 (reg:ALL2QA 24))]
-  "AVR_HAVE_MUL")
+  "AVR_HAVE_MUL"
+  {
+avr_fix_inputs (operands, 1 << 2, regmask (mode, 18));
+  })
 
 ;; "*mulhq3.call"  "*muluhq3.call"
 ;; "*mulha3.call"  "*muluha3.call"
@@ -302,7 +312,10 @@ (define_expand "mul3"
 (reg:ALL4A 20)))
(set (match_operand:ALL4A 0 "register_operand" "")
 (reg:ALL4A 24))]
-  "AVR_HAVE_MUL")
+  "AVR_HAVE_MUL"
+  {
+avr_fix_inputs (operands, 1 << 2, regmask (mode, 16));
+  })
 
 ;; "*mulsa3.call" "*mulusa3.call"
 (define_insn "*mul3.call"
@@ -330,7 +343,12 @@ (define_expand "3"
 (reg:ALL1Q 22)))
   (clobber (reg:QI 25))])
(set (match_operand:ALL1Q 0 "register_operand" "")
-(reg:ALL1Q 24))])
+(reg:ALL1Q 24))]
+  ""
+  {
+avr_fix_inputs (operands, 1 << 2, regmask (mode, 25));
+  })
+
 
 ;; "*divqq3.call" "*udivuqq3.call"
 (define_insn "*3.call"
@@ -356,7 +374,11 @@ (define_expand "3"
   (clobber (reg:HI 26))
   (clobber (reg:QI 21))])
(set (match_operand:ALL2QA 0 "register_operand" "")
-(reg:ALL2QA 24))])
+(reg:ALL2QA 24))]
+  ""
+  {
+avr_fix_inputs (operands, 1 << 2, regmask (mode, 26));
+  })
 
 ;; "*divhq3.call" "*udivuhq3.call"
 ;; "*divha3.call" "*udivuha3.call"
@@ -385,7 +407,11 @@ (define_expand "3"
   (clobber (reg:HI 26))
   (clobber (reg:HI 30))])
(set (match_operand:ALL4A 0 "register_operand" "")
-(reg:ALL4A 22))])
+(reg:ALL4A 22))]
+  ""
+  {
+avr_fix_inputs (operands, 1 << 2, regmask (mode, 24));
+  })
 
 ;; "*divsa3.call" "*udivusa3.call"
 (define_insn "*3.call"
@@ -435,6 +461,7 @@ (define_expand "round3"
 
 operands[3] = gen_rtx_REG (mode, regno_out[(size_t) GET

Re: Fix libcc1 bootstrap and linking issues

2014-10-28 Thread Jakub Jelinek
On Tue, Oct 28, 2014 at 12:24:39PM +, Phil Muldoon wrote:
> 2014-10-28  Phil Muldoon 
> 
> * configure.ac: Remove -Werror.
> * configure: Regenerate.
> * Makefile.am: Remove -Werror. Link correct libiberty.
> * Makefile.in: Regenerate.

As for -Werror, doesn't your patch completely remove -Werror from the flags?
Looking around, we have config/warnings.m4 which contains
ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual])
macro used by several libraries, which supposedly enables -Werror when
requested.

Jakub


(Withdrawn) Fix libcc1 bootstrap and linking issues

2014-10-28 Thread Phil Muldoon
On 28/10/14 12:24, Phil Muldoon wrote:
> Hi
>
> A few issues came to light this morning on some systems with
> bootstrapping and libiberty linking issues.  We erroneously specified
> -Werror in stage one builds.  This patch removes that flag.  We also
> unconditionally linked with the PIC version of libiberty.  This patch
> adds a conditional if to Makefile.am.
>
>
Turns out Jakub had a patch out already, and it is a better patch than my 
attempt.  So withdrawing this one.

Cheers

Phil


Re: Fix libcc1 bootstrap and linking issues

2014-10-28 Thread Phil Muldoon
On 28/10/14 12:34, Jakub Jelinek wrote:
> On Tue, Oct 28, 2014 at 12:24:39PM +, Phil Muldoon wrote:
>> 2014-10-28  Phil Muldoon 
>>
>> * configure.ac: Remove -Werror.
>> * configure: Regenerate.
>> * Makefile.am: Remove -Werror. Link correct libiberty.
>> * Makefile.in: Regenerate.
>
> As for -Werror, doesn't your patch completely remove -Werror from the flags?
> Looking around, we have config/warnings.m4 which contains
> ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual])
> macro used by several libraries, which supposedly enables -Werror when
> requested.
>
> Jakub

Yeah Uros was reporting that the -Werror flag in configure.ac was also
conflicting. auto-* tools are definetly not my strong point, and I did
not write these build configurations.  Anyway, this is somewhat moot
as your patch is earlier and better than mine, so we'll go with that.
Thanks for taking a look at the issue and coming up with a fix.

Cheers

Phil




Re: [PATCH] -fsanitize=vptr instrumentation (take 2)

2014-10-28 Thread Jakub Jelinek
On Mon, Oct 27, 2014 at 05:16:05PM +0100, Jakub Jelinek wrote:
> Here is an updated patch, ok if bootstrap/testing passes (so far just
> checked with
> make -j16 -k check RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} asan.exp 
> tsan.exp ubsan.exp'
> )?

Updated patch that passed bootstrap/regtest on i686-linux.
Only minor changes: ensure during the cp_walk_tree we don't walk same trees
more than once (with SAVE_EXPR resulted in huge compile times), tiny test
cleanups, and making sure __ubsan_vptr_type_cache decl has normal visibility
and is not considered local in shared libraries.

2014-10-28  Jakub Jelinek  

* flag-types.h (enum sanitize_code): Add SANITIZE_VPTR,
include SANITIZE_VPTR in SANITIZE_UNDEFINED.
* opts.c (common_handle_option): Add -fsanitize=vptr.
* sanitizer.def (BUILT_IN_UBSAN_HANDLE_DYNAMIC_TYPE_CACHE_MISS,
BUILT_IN_UBSAN_HANDLE_DYNAMIC_TYPE_CACHE_MISS_ABORT): New.
* ubsan.h (enum ubsan_null_ckind): Add UBSAN_DOWNCAST_POINTER,
UBSAN_DOWNCAST_REFERENCE, UBSAN_UPCAST and UBSAN_CAST_TO_VBASE.
cp/
* config-lang.in (gtfiles): Add cp/cp-ubsan.c.
* cp-gimplify.c (cp_genericize_r): Call
cp_ubsan_maybe_instrument_member_call for member calls and
cp_ubsan_maybe_instrument_member_access for member accesses.
(struct cp_ubsan_check_member_access_data): New type.
(cp_ubsan_check_member_access_r): New function.
(cp_genericize_tree): Call cp_walk_tree with
cp_ubsan_check_member_access_r callback for -fsanitize=vptr.
* cp-tree.h (cp_ubsan_maybe_instrument_member_call,
cp_ubsan_maybe_instrument_member_access,
cp_ubsan_maybe_instrument_downcast,
cp_ubsan_maybe_instrument_cast_to_vbase,
cp_ubsan_fixup_downcast_instrumentation): New prototypes.
* cp-ubsan.c: New file.
* Make-lang.in (CXX_AND_OBJCXX_OBJS): Add cp/cp-ubsan.o.
* constexpr.c (cxx_eval_call_expression): Handle 4 argument
BUILT_IN_UBSAN_HANDLE_DYNAMIC_TYPE_CACHE_MISS{,_ABORT}.
* typeck.c (build_class_member_access_expr): Provide locus
for COMPONENT_REFs.
(build_static_cast_1): Instrument downcasts.
* class.c (build_base_path): For -fsanitize=vptr and !fixed_type_p
add ubsan instrumentation for virtual_access.
gcc/testsuite/
* g++.dg/ubsan/vptr-1.C: New test.
* g++.dg/ubsan/vptr-2.C: New test.
* g++.dg/ubsan/vptr-3.C: New test.
* g++.dg/ubsan/vptr-4.C: New test.
* g++.dg/ubsan/vptr-5.C: New test.
* g++.dg/ubsan/vptr-6.C: New test.
* g++.dg/ubsan/vptr-7.C: New test.
* g++.dg/ubsan/vptr-8.C: New test.
* g++.dg/ubsan/vptr-9.C: New test.
libsanitizer/
* ubsan/ubsan_handlers.cc (__ubsan::TypeCheckKinds): Cherry pick
upstream r219642.

--- gcc/opts.c.jj   2014-10-25 20:46:06.443427738 +0200
+++ gcc/opts.c  2014-10-27 10:48:06.855097104 +0100
@@ -1575,6 +1575,7 @@ common_handle_option (struct gcc_options
sizeof "returns-nonnull-attribute" - 1 },
  { "object-size", SANITIZE_OBJECT_SIZE,
sizeof "object-size" - 1 },
+ { "vptr", SANITIZE_VPTR, sizeof "vptr" - 1 },
  { NULL, 0, 0 }
};
const char *comma;
--- gcc/ubsan.h.jj  2014-10-25 20:46:06.460427425 +0200
+++ gcc/ubsan.h 2014-10-27 12:09:47.738576202 +0100
@@ -28,7 +28,11 @@ enum ubsan_null_ckind {
   UBSAN_REF_BINDING,
   UBSAN_MEMBER_ACCESS,
   UBSAN_MEMBER_CALL,
-  UBSAN_CTOR_CALL
+  UBSAN_CTOR_CALL,
+  UBSAN_DOWNCAST_POINTER,
+  UBSAN_DOWNCAST_REFERENCE,
+  UBSAN_UPCAST,
+  UBSAN_CAST_TO_VBASE
 };
 
 /* This controls how ubsan prints types.  Used in ubsan_type_descriptor.  */
--- gcc/sanitizer.def.jj2014-10-25 20:46:06.374429010 +0200
+++ gcc/sanitizer.def   2014-10-27 13:54:41.087270591 +0100
@@ -433,3 +433,11 @@ DEF_SANITIZER_BUILTIN(BUILT_IN_UBSAN_HAN
  "__ubsan_handle_nonnull_return_abort",
  BT_FN_VOID_PTR,
  ATTR_COLD_NORETURN_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_UBSAN_HANDLE_DYNAMIC_TYPE_CACHE_MISS,
+ "__ubsan_handle_dynamic_type_cache_miss",
+ BT_FN_VOID_PTR_PTR_PTR,
+ ATTR_COLD_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_UBSAN_HANDLE_DYNAMIC_TYPE_CACHE_MISS_ABORT,
+ "__ubsan_handle_dynamic_type_cache_miss_abort",
+ BT_FN_VOID_PTR_PTR_PTR,
+ ATTR_COLD_NOTHROW_LEAF_LIST)
--- gcc/cp/cp-tree.h.jj 2014-10-25 20:46:05.433446353 +0200
+++ gcc/cp/cp-tree.h2014-10-27 12:41:59.263503080 +0100
@@ -6333,6 +6333,13 @@ extern vec cx_error_context
 /* In c-family/cilk.c */
 extern bool cilk_valid_spawn(tree);
 
+/* In cp-ubsan.c */
+extern void cp_ubsan_maybe_instrument_member_call (tree);
+extern void cp_ubsan_maybe_instrument_member_access (tree);
+extern tree cp_u

Re: [patch,avr,4.9] Fix PR63633 ICEs for expanders colliding hard-regs

2014-10-28 Thread Georg-Johann Lay

Am 10/28/2014 01:34 PM, schrieb Georg-Johann Lay:

Middle-end might come up with hard registers as operands for expanders which
clobber respective hard regs.  This patch uses freshly created pseudos for
respective expander operands and emits pseudo <-> hard move insn.

Ok for 4.9.2?


p.s.: testsuite passes without new regressions



It's not yet for trunk because avr trunk backend is currently broken.

Johann

gcc/
 PR63633
 * config/avr/avr-protos.h (regmask): New inline function.
 (avr_fix_inputs, avr_emit3_fix_outputs): New protos.
 * config/avr/avr.c (avr_fix_operands, avr_move_fixed_operands)
 (avr_fix_inputs, avr_emit3_fix_outputs): New functions.
 * config/avr/avr-fixed.md (mulqq3_nomul, muluqq3_nomul)
 (mul3, mul3, 3, 3)
 (3, round3): Fix input operands.
 * config/avr/avr-dimode.md (add3, sub3)
 (3, 3, cbranch4)
 (3, mulsidi3): Fix input operands.
 * config/avr/avr.md (mulqi3_call, mulhi3_call, mulsi3, mulpsi3)
 (mulusi3, mulssi3, mulohisi3, mulhisi3)
 (usmulhisi3, mulhi3_highpart, mulsqipsi3)
 (fmul, fmuls, fmulsu): Fix operands.  Turn insn into expander as
 needed.

gcc/testsuite/
 PR63633
 * gcc.target/avr/torture/pr63633-ice-mult.c: New test.




Re: [PATCH] Fix up sign extension in bswap

2014-10-28 Thread Richard Biener
On Tue, 28 Oct 2014, Jakub Jelinek wrote:

> On Tue, Oct 21, 2014 at 10:28:40AM +0100, Thomas Preud'homme wrote:
> > --- a/gcc/tree-ssa-math-opts.c
> > +++ b/gcc/tree-ssa-math-opts.c
> > @@ -1916,7 +1916,8 @@ find_bswap_or_nop_1 (gimple stmt, struct 
> > symbolic_number *n, int limit)
> > if (!TYPE_UNSIGNED (n->type) && type_size > old_type_size
> > && HEAD_MARKER (n->n, old_type_size))
> >   for (i = 0; i < type_size - old_type_size; i++)
> > -   n->n |= MARKER_BYTE_UNKNOWN << (type_size - 1 - i);
> > +   n->n |= MARKER_BYTE_UNKNOWN
> > +   << ((type_size - 1 - i) * BITS_PER_MARKER);
> >  
> > if (type_size < 64 / BITS_PER_MARKER)
> >   {
> 
> As my last bootstrap-ubsan bootstrap revealed, this is still wrong.
> Here is a fix (other spots where MARKER_BYTE_UNKNOWN is shifted up
> are correct).  Bootstrapped/regtested on i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> Thomas, you know the code better, can you from the fix figure out
> a testcase that current trunk miscompiles or doesn't optimize
> because of this bug?
> 
> 2014-10-28  Jakub Jelinek  
> 
>   * tree-ssa-math-opts.c (find_bswap_or_nop_1): Use uint64_t
>   type for the left shift in CASE_CONVERT case.
> 
> --- gcc/tree-ssa-math-opts.c.jj   2014-10-27 19:41:14.0 +0100
> +++ gcc/tree-ssa-math-opts.c  2014-10-27 23:43:41.956495361 +0100
> @@ -1926,7 +1926,7 @@ find_bswap_or_nop_1 (gimple stmt, struct
>   if (!TYPE_UNSIGNED (n->type) && type_size > old_type_size
>   && HEAD_MARKER (n->n, old_type_size))
> for (i = 0; i < type_size - old_type_size; i++)
> - n->n |= MARKER_BYTE_UNKNOWN
> + n->n |= (uint64_t) MARKER_BYTE_UNKNOWN
>   << ((type_size - 1 - i) * BITS_PER_MARKER);
>  
>   if (type_size < 64 / BITS_PER_MARKER)
> 
> 
>   Jakub
> 
> 

-- 
Richard Biener 
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend"orffer


[PATCH] Fix PR63665

2014-10-28 Thread Richard Biener

It seems that SLP vectorization can somehow generate out-of-bound
masks for VEC_PERM.  The following fixes that (the ICE reproduces
on x86_64 with the added assert).

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Richard.

2014-10-28  Richard Biener  

PR tree-optimization/63665
* tree-vect-slp.c (vect_get_mask_element): Properly handle
accessing out-of-bound elements.

Index: gcc/tree-vect-slp.c
===
--- gcc/tree-vect-slp.c (revision 216771)
+++ gcc/tree-vect-slp.c (working copy)
@@ -2890,7 +2890,7 @@ vect_get_mask_element (gimple stmt, int
 }
 
   /* The mask requires the next vector.  */
-  if (*current_mask_element >= mask_nunits * 2)
+  while (*current_mask_element >= mask_nunits * 2)
 {
   if (*needs_first_vector || *mask_fixed)
 {
@@ -3041,6 +3041,7 @@ vect_transform_slp_perm_load (slp_tree n
  &number_of_mask_fixes, &mask_fixed,
  &needs_first_vector))
return false;
+ gcc_assert (current_mask_element < 2 * nunits);
  mask[index++] = current_mask_element;
 
   if (index == nunits)


Re: [PATCH, x86, 63534] Fix '-p' profile for 32 bit PIC mode

2014-10-28 Thread Evgeny Stupachenko
Thank you, Jakub.

The following patch passed bootstrap, gcc make check and spec2000 with
"-p -m32 -fPIC".
Is it ok?

ChangeLog:

2014-10-28  Evgeny Stupachenko  

gcc/testsuite
* gcc.target/i386/mcount_pic.c: New.

gcc/
* config/i386/i386.c (ix86_init_pic_reg): Emit SET_GOT to
REAL_PIC_OFFSET_TABLE_REGNUM for mcount profiling.
(ix86_save_reg): Save REAL_PIC_OFFSET_TABLE_REGNUM when profiling
using mcount in 32bit PIC mode.
(ix86_elim_set_got): New.
(ix86_expand_prologue): For the mcount profiling emit new SET_GOT
in PROLOGUE, delete initial if possible.

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 6235c4f..3332f36 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -6190,8 +6190,15 @@ ix86_init_pic_reg (void)
 }
   else
 {
-  rtx insn = emit_insn (gen_set_got (pic_offset_table_rtx));
+  /*  If there is future mcount call in the function it is more profitable
+ to emit SET_GOT into ABI defined REAL_PIC_OFFSET_TABLE_REGNUM.  */
+  rtx reg = crtl->profile
+   ? gen_rtx_REG (Pmode, REAL_PIC_OFFSET_TABLE_REGNUM)
+   : pic_offset_table_rtx;
+  rtx insn = emit_insn (gen_set_got (reg));
   RTX_FRAME_RELATED_P (insn) = 1;
+  if (crtl->profile)
+emit_move_insn (pic_offset_table_rtx, reg);
   add_reg_note (insn, REG_CFA_FLUSH_QUEUE, NULL_RTX);
 }

@@ -9471,15 +9478,23 @@ ix86_select_alt_pic_regnum (void)
 static bool
 ix86_save_reg (unsigned int regno, bool maybe_eh_return)
 {
-  if (pic_offset_table_rtx
-  && !ix86_use_pseudo_pic_reg ()
-  && regno == REAL_PIC_OFFSET_TABLE_REGNUM
-  && (df_regs_ever_live_p (REAL_PIC_OFFSET_TABLE_REGNUM)
- || crtl->profile
- || crtl->calls_eh_return
- || crtl->uses_const_pool
- || cfun->has_nonlocal_label))
-return ix86_select_alt_pic_regnum () == INVALID_REGNUM;
+  if (regno == REAL_PIC_OFFSET_TABLE_REGNUM
+  && pic_offset_table_rtx)
+{
+  if (ix86_use_pseudo_pic_reg ())
+   {
+ /* REAL_PIC_OFFSET_TABLE_REGNUM used by call to
+ _mcount in prologue.  */
+ if (!TARGET_64BIT && flag_pic && crtl->profile)
+   return true;
+   }
+  else if (df_regs_ever_live_p (REAL_PIC_OFFSET_TABLE_REGNUM)
+  || crtl->profile
+  || crtl->calls_eh_return
+  || crtl->uses_const_pool
+  || cfun->has_nonlocal_label)
+return ix86_select_alt_pic_regnum () == INVALID_REGNUM;
+}

   if (crtl->calls_eh_return && maybe_eh_return)
 {
@@ -10818,6 +10833,36 @@ ix86_finalize_stack_realign_flags (void)
   crtl->stack_realign_finalized = true;
 }

+/* Delete first SET_GOT allocated to reg.  */
+
+static void
+ix86_elim_set_got (rtx reg)
+{
+  basic_block bb;
+  FOR_EACH_BB_FN (bb, cfun)
+{
+  rtx_insn *c_insn;
+  FOR_BB_INSNS (bb, c_insn)
+   {
+ if (GET_CODE (c_insn) == INSN)
+   {
+ rtx pat = PATTERN (c_insn);
+ if (GET_CODE (pat) == PARALLEL)
+   {
+ rtx vec = XVECEXP (pat, 0, 0);
+ if (GET_CODE (vec) == SET
+&& XINT (XEXP (vec, 1), 1) == UNSPEC_SET_GOT
+&& REGNO (XEXP (vec, 0)) == REGNO (reg))
+   {
+ delete_insn (c_insn);
+ return;
+   }
+   }
+   }
+   }
+}
+}
+
 /* Expand the prologue into a bunch of separate insns.  */

 void
@@ -11271,6 +11316,20 @@ ix86_expand_prologue (void)
   if (!sse_registers_saved)
 ix86_emit_save_sse_regs_using_mov (frame.sse_reg_save_offset);

+  /* For the mcount profiling on 32 bit PIC mode we need to emit SET_GOT
+ in PROLOGUE.  */
+  if (!TARGET_64BIT && pic_offset_table_rtx && crtl->profile && !flag_fentry)
+{
+  rtx pic = gen_rtx_REG (Pmode, REAL_PIC_OFFSET_TABLE_REGNUM);
+  insn = emit_insn (gen_set_got (pic));
+  RTX_FRAME_RELATED_P (insn) = 1;
+  add_reg_note (insn, REG_CFA_FLUSH_QUEUE, NULL_RTX);
+  emit_insn (gen_prologue_use (pic));
+  /* Deleting already emmitted SET_GOT if exist and allocated to
+REAL_PIC_OFFSET_TABLE_REGNUM.  */
+  ix86_elim_set_got (pic);
+}
+
   if (crtl->drap_reg && !crtl->stack_realign_needed)
 {
   /* vDRAP is setup but after reload it turns out stack realign
diff --git a/gcc/testsuite/gcc.target/i386/mcount_pic.c
b/gcc/testsuite/gcc.target/i386/mcount_pic.c
new file mode 100644
index 000..1297265
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/mcount_pic.c
@@ -0,0 +1,12 @@
+/* Test check correct mcount generation.  */
+/* { dg-do run } */
+/* { dg-require-effective-target ia32 } */
+/* { dg-options "-O2 -fpic -p -save-temps" } */
+
+int main()
+{
+  return 0;
+}
+
+/* { dg-final { scan-assembler "mcount" } } */
+/* { dg-final { scan-assembler "get_pc_thunk" } } */


On Fri, Oct 24, 2014 at 7:50 PM, Jak

Re: [PATCH 5/5] add libcc1

2014-10-28 Thread Joseph S. Myers
I'm seeing a different bootstrap failure from those already discussed:

In file included from 
/scratch/jmyers/fsf/gcc-mainline/libcc1/../gcc/gcc-plugin.h:28:0,
 from 
/scratch/jmyers/fsf/gcc-mainline/libcc1/plugin.cc:34:
/scratch/jmyers/fsf/gcc-mainline/libcc1/../gcc/system.h:653:17: fatal error: 
gmp.h: No such file or directory

It appears the build is ignoring the --with-gmp option passed to 
configure.  Since  is included in system.h, if you include system.h 
you have to pass the right -I option corresponding to --with-gmp / 
--with-gmp-include.  (There are several other such configure options for 
MPFR, MPC, CLooG, ISL, libiconv at least - whether they are relevant 
depends on whether your code ends up including the relevant headers.)

-- 
Joseph S. Myers
jos...@codesourcery.com


[gomp4] Remove goacc_parse_device_num

2014-10-28 Thread Julian Brown
Hi,

This patch removes the goacc_parse_device_num function in libgomp's
env.c since it is redundant with parse_int. I also added some bounds
checking for the device number in oacc-init.c (the behaviour is left as
"implementation defined" in the OpenACC 2.0 spec, so I chose to raise
an error for an out-of-range device number).

OK for gomp4 branch?

Thanks,

Julian

ChangeLog

libgomp/
* env.c (goacc_parse_device_num): Remove.
(initialize_env): Use parse_int instead of goacc_parse_device_num.
* oacc-init.c (lazy_open): Add bounds check for device number.commit 1dacb833b33d179553723faecf4b32e89efc69a9
Author: Julian Brown 
Date:   Tue Oct 28 06:03:47 2014 -0700

ACC_DEVICE_NUM tweaks

diff --git a/libgomp/env.c b/libgomp/env.c
index 8b22e6f..02bce0c 100644
--- a/libgomp/env.c
+++ b/libgomp/env.c
@@ -1016,27 +1016,6 @@ parse_affinity (bool ignore)
   return false;
 }
 
-
-static void
-goacc_parse_device_num (void)
-{
-  const char *env = getenv ("ACC_DEVICE_NUM");
-  int default_num = -1;
-  
-  if (env && *env != '\0')
-{
-  char *end;
-  default_num = strtol (env, &end, 0);
-  
-  if (*end || default_num < 0)
-default_num = 0;
-}
-  else
-default_num = 0;
-  
-  goacc_device_num = default_num;
-}
-
 static void
 goacc_parse_device_type (void)
 {
@@ -1310,7 +1289,9 @@ initialize_env (void)
   handle_omp_display_env (stacksize, wait_policy);
   
   /* Look for OpenACC-specific environment variables.  */
-  goacc_parse_device_num ();
+  if (!parse_int ("ACC_DEVICE_NUM", &goacc_device_num, true))
+goacc_device_num = 0;
+
   goacc_parse_device_type ();
 
   /* Initialize OpenACC-specific internal state.  */
diff --git a/libgomp/oacc-init.c b/libgomp/oacc-init.c
index 489ac14..24e911b 100644
--- a/libgomp/oacc-init.c
+++ b/libgomp/oacc-init.c
@@ -249,6 +249,9 @@ lazy_open (int ord)
   if (ord < 0)
 ord = goacc_device_num;
 
+  if (ord >= base_dev->get_num_devices_func ())
+gomp_fatal ("device %u does not exist", ord);
+
   if (!thr)
 thr = goacc_new_thread ();
   


[PATCH][7/n] Merge from match-and-simplify, SSA propagators

2014-10-28 Thread Richard Biener

The following hooks the machinery into SSA propagators via
gimple_fold_stmt_to_constant[_1].  Unfortunately how SSA
propagators work doesn't allow us to walk SSA edges here
so to compensate for that shortcoming I am following
single-use SSA edges when substitute_and_fold calls fold_stmt
(as explained previously that doesn't necessarily fold all
stmts that are worth folding).

SCCVN on the other hand could deal fine with walking SSA
edges, but that's for another day (and maybe only next stage1).

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

(yeah, I hope that any of these patches make the AIX bootstrap
issue go latent again... - meanwhile trying to debug them
at the known failure point)

Richard.

2014-10-28  Richard Biener  

* gimple-fold.h (follow_single_use_edges): Declare.
* gimple-fold.c (follow_single_use_edges): New function.
(gimple_fold_stmt_to_constant_1): Dispatch to gimple_simplify.
* tree-ssa-propagate.c
(substitute_and_fold_dom_walker::before_dom_children): Allow
following single-use edges when folding stmts we propagated into.

Index: gcc/gimple-fold.h
===
--- gcc/gimple-fold.h   
(svn+ssh://rgue...@gcc.gnu.org/svn/gcc/trunk/gcc/gimple-fold.h) (revision 
216771)
+++ gcc/gimple-fold.h   (.../gcc/gimple-fold.h) (working copy)
@@ -33,6 +33,7 @@ extern tree maybe_fold_and_comparisons (
 extern tree maybe_fold_or_comparisons (enum tree_code, tree, tree,
   enum tree_code, tree, tree);
 extern tree no_follow_ssa_edges (tree);
+extern tree follow_single_use_edges (tree);
 extern tree gimple_fold_stmt_to_constant_1 (gimple, tree (*) (tree));
 extern tree gimple_fold_stmt_to_constant (gimple, tree (*) (tree));
 extern tree fold_const_aggregate_ref_1 (tree, tree (*) (tree));
Index: gcc/gimple-fold.c
===
--- gcc/gimple-fold.c   
(svn+ssh://rgue...@gcc.gnu.org/svn/gcc/trunk/gcc/gimple-fold.c) (revision 
216771)
+++ gcc/gimple-fold.c   (.../gcc/gimple-fold.c) (working copy)
@@ -65,6 +65,8 @@ along with GCC; see the file COPYING3.
 #include "output.h"
 #include "tree-eh.h"
 #include "gimple-match.h"
+#include "tree-phinodes.h"
+#include "ssa-iterators.h"
 
 /* Return true when DECL can be referenced from current unit.
FROM_DECL (if non-null) specify constructor of variable DECL was taken from.
@@ -3241,6 +3243,17 @@ no_follow_ssa_edges (tree)
   return NULL_TREE;
 }
 
+/* Valueization callback that ends up following single-use SSA edges only.  */
+
+tree
+follow_single_use_edges (tree val)
+{
+  if (TREE_CODE (val) == SSA_NAME
+  && !has_single_use (val))
+return NULL_TREE;
+  return val;
+}
+
 /* Fold the statement pointed to by GSI.  In some cases, this function may
replace the whole statement with a new one.  Returns true iff folding
makes any changes.
@@ -4371,6 +4384,30 @@ maybe_fold_or_comparisons (enum tree_cod
 tree
 gimple_fold_stmt_to_constant_1 (gimple stmt, tree (*valueize) (tree))
 {
+  code_helper rcode;
+  tree ops[3] = {};
+  /* ???  The SSA propagators do not correctly deal with following SSA use-def
+ edges if there are intermediate VARYING defs.  For this reason
+ do not follow SSA edges here even though SCCVN can technically
+ just deal fine with that.  */
+  if (gimple_simplify (stmt, &rcode, ops, NULL, no_follow_ssa_edges)
+  && rcode.is_tree_code ()
+  && (TREE_CODE_LENGTH ((tree_code) rcode) == 0
+ || ((tree_code) rcode) == ADDR_EXPR)
+  && is_gimple_val (ops[0]))
+{
+  tree res = ops[0];
+  if (dump_file && dump_flags & TDF_DETAILS)
+   {
+ fprintf (dump_file, "Match-and-simplified ");
+ print_gimple_expr (dump_file, stmt, 0, TDF_SLIM);
+ fprintf (dump_file, " to ");
+ print_generic_expr (dump_file, res, 0);
+ fprintf (dump_file, "\n");
+   }
+  return res;
+}
+
   location_t loc = gimple_location (stmt);
   switch (gimple_code (stmt))
 {
Index: gcc/tree-ssa-propagate.c
===
--- gcc/tree-ssa-propagate.c
(svn+ssh://rgue...@gcc.gnu.org/svn/gcc/trunk/gcc/tree-ssa-propagate.c)  
(revision 216771)
+++ gcc/tree-ssa-propagate.c(.../gcc/tree-ssa-propagate.c)  (working copy)
@@ -1150,7 +1150,7 @@ substitute_and_fold_dom_walker::before_d
 
   /* If we made a replacement, fold the statement.  */
   if (did_replace)
-   fold_stmt (&i);
+   fold_stmt (&i, follow_single_use_edges);
 
   /* Now cleanup.  */
   if (did_replace)


Re: [match-and-simplify] reject conditional convert and commutative ops in result operand

2014-10-28 Thread Richard Biener
On Tue, Oct 28, 2014 at 1:26 PM, Prathamesh Kulkarni
 wrote:
> On Tue, Oct 28, 2014 at 3:50 PM, Richard Biener
>  wrote:
>> On Mon, Oct 27, 2014 at 3:32 PM, Prathamesh Kulkarni
>>  wrote:
>>> I suppose we should reject conditional convert and commutative ops in
>>> result operand ? since it would create 1-n mapping from match ->
>>> result.
>>
>> Yeah.  Same is true for parsing of :type syntax for the match part.
>> Now that we have a class parser I think it would be better to simply
>> record whether we are parsing ->match or ->result and issue the
>> diagnostic at parsing time.
>>
>> Can you adjust the patch accordingly?
> Is the following version okay ?

Yes, applied.

Thanks,
Richard.

> * genmatch.c
>   (parser): Add new member parsing_match_operand.
>   (parser::parse_operation): Check for conditional convert in result operand.
>   (parser::parse_expr): Check for commutative operator in result operand.
>  Check for :type in match operand.
>   (parser::parse_simplify): Set/unset parsing_match_operand.
>
> Thanks,
> Prathamesh
>
>>
>> Thanks,
>> Richard.
>>
>>> * genmatch.c
>>>   (fatal_at): New overloaded function with source_location as first 
>>> parameter.
>>>   (has_opt_convert_or_commutative_ops): New function.
>>>   (lower): Call has_opt_convert_or_commutative_ops.
>>>
>>> Thanks,
>>> Prathamesh


Re: [PATCH, x86, 63534] Fix '-p' profile for 32 bit PIC mode

2014-10-28 Thread Jakub Jelinek
On Tue, Oct 28, 2014 at 04:10:12PM +0300, Evgeny Stupachenko wrote:
> Thank you, Jakub.
> 
> The following patch passed bootstrap, gcc make check and spec2000 with
> "-p -m32 -fPIC".
> Is it ok?
> 
> ChangeLog:
> 
> 2014-10-28  Evgeny Stupachenko  
> 
> gcc/testsuite
> * gcc.target/i386/mcount_pic.c: New.
> 
> gcc/

Please mention
PR target/63534
in the ChangeLog entry.

> @@ -10818,6 +10833,36 @@ ix86_finalize_stack_realign_flags (void)
>crtl->stack_realign_finalized = true;
>  }
> 
> +/* Delete first SET_GOT allocated to reg.  */
> +
> +static void
> +ix86_elim_set_got (rtx reg)
> +{
> +  basic_block bb;
> +  FOR_EACH_BB_FN (bb, cfun)
> +{
> +  rtx_insn *c_insn;
> +  FOR_BB_INSNS (bb, c_insn)
> +   {
> + if (GET_CODE (c_insn) == INSN)
> +   {
> + rtx pat = PATTERN (c_insn);
> + if (GET_CODE (pat) == PARALLEL)
> +   {
> + rtx vec = XVECEXP (pat, 0, 0);
> + if (GET_CODE (vec) == SET
> +&& XINT (XEXP (vec, 1), 1) == UNSPEC_SET_GOT
> +&& REGNO (XEXP (vec, 0)) == REGNO (reg))
> +   {
> + delete_insn (c_insn);
> + return;
> +   }
> +   }
> +   }
> +   }
> +}
> +}
> +

This is unsafe.  What I meant is to just remove set_got insn
that is at the beginning of the first basic block (successor of
entry bb), perhaps after some notes.  You can perhaps generalize
that a little bit and look at other insns in the first bb, as long
as no NONDEBUG_INSN_P insn preceeding satisfy
modified_in_p (reg, c_insn) or reg_referenced_p (reg, PATTERN (c_insn))
or so.  But certainly stop at the end of the first bb or at any
real insn that might clobber/set %ebx or use it.

Also, instead of GET_CODE (c_insn) == INSN please use
NONJUMP_INSN_P (c_insn).

> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/mcount_pic.c
> @@ -0,0 +1,12 @@
> +/* Test check correct mcount generation.  */
> +/* { dg-do run } */
> +/* { dg-require-effective-target ia32 } */
> +/* { dg-options "-O2 -fpic -p -save-temps" } */
> +
> +int main()
> +{
> +  return 0;
> +}
> +
> +/* { dg-final { scan-assembler "mcount" } } */
> +/* { dg-final { scan-assembler "get_pc_thunk" } } */

Missing cleanup-save-temps.  Is _mcount the name of the profiling routine
on all i?86 targets?

Jakub


Re: support operator list

2014-10-28 Thread Richard Biener
On Sun, Oct 26, 2014 at 7:40 AM, Prathamesh Kulkarni
 wrote:
> Fixed a silly mistake in match-bitwise.pd (I had put ')' at wrong place).
> This patch also checks if operator-list is used outside for-pattern
> (in parser::parse_operation).

With recent discussion on how to use operator-lists - thus

(for (oplist1 oplist2 ...)
  (simplify (oplist1 @0 @1)...

it shouldn't be necessary to have an is_oper_list member in user_id
as all user_ids are operator-lists this way (just temporarily defined
in for scope eventually).

- if (arity == -1)
-   arity = idb->nargs;
- else if (idb->nargs == -1)
-   ;
- else if (idb->nargs != arity)
-   fatal_at (token, "operator '%s' with arity %d does not match "
- "others with arity %d", oper, idb->nargs, arity);
+ vec substitutes = vNULL;
+ if (idb->kind == id_base::USER)
+   substitutes = (as_a (idb))->substitutes;
+ else
+   substitutes.safe_push (idb);

- op->substitutes.safe_push (idb);
+ for (unsigned si = 0; si < substitutes.length (); ++si)
+   if (!add_substitute (op, substitutes[si], arity))
+ fatal_at (token, "operator '%s' with arity %d does not match "
+  "others with arity %d", oper, idb->nargs, arity);

an operator-list user_id should have a proper arity computed.  With
the syntax change this probably will look differently anyway.

+void
+parser::parse_operator_list ()
+{
+  const char *id = get_ident ();
+  user_id *op = new user_id (id, true);
+  vec user_id_tokens = vNULL;
+
+  id_base **slot = operators->find_slot_with_hash (op, op->hashval, INSERT);
+  if (*slot)
+fatal ("operator %s already defined", id);

use get_operator (id) != NULL, otherwise same issue as with the
other already defined check we just fixed.

+  id_base *p = get_operator (oper);
+  if (p == 0)
+   fatal_at (token, "%s is not defined", oper);

I'd say "no such operator '%s'"

+  flatten_substitutes (ids, op->substitutes);

huh, so you support

(define_operator_list list1 a b)
(define_operator_list list2 list1 c)

?  Well, ok.  Any reason to not splice in during parsing?  I also
miss a check for matching arity and computing arity of the
operator list.  That's all be best done here I think, in the loop
parsing the identifiers.

@@ -23,7 +26,7 @@
binary operation result instead of to the operands.  This allows
to combine successive conversions and bitwise binary operations.  */
 /* We combine the above two cases by using a conditional convert.  */
-(for bitop (bit_and bit_ior bit_xor)
+(for bitop (bitwise_ops)

as discussed this will change to

(for (bitwise_ops)

instead.  Btw - I'm not sure that using

(define_operator_list bitwise_ors bit_ior bit_xor)
(define_operator_list bitwise_ops bit_and bitwise_ors)

will improve readability.  I'd like to see it mostly for comparisons
and math builtin variants.  For example we have the well-known
term comparison_class, so

(define_operator_list comparison_class lt le eq ne ge gt unordered
ordered unlt unle ungt unge uneq ltgt)

or rather shorter, 'cc' instead of 'comparison_class'.

Thanks,
Richard.

> * genmatch.c
> (user_id): Add new member is_oper_list.
> (user_id::user_id): Add new default argument.
> (parser::parse_operator_list): New member function in parser.
> (add_substitute): New function.
> (flatten_substitutes): Likewise.
> (parser::parse_for): Call add_substitute.
> (parser::parse_pattern): Call parser::parse_operator_list.
> (parser::parse_operation): Put check for operator-list.
>
> * match-bitwise.pd
> (bitwise_ors): New operator-list.
> (bitwise_ops): Likewise.
> Use bitwise_ors and bitwise_ops in patterns.
>
> * match-comparison.pd
>  (eq_ops): New operator-list.
>  (cmp_ops): Likewise.
>  Use cmp_ops and eq_ops in patterns.
>
> Thanks,
> Prathamesh
>
>
>
> On Sat, Oct 25, 2014 at 10:44 PM, Prathamesh Kulkarni
>  wrote:
>> Hi,
>> This patch adds support for operator-lists, and uses
>> them in match-bitwise.pd and match-comparison.pd
>>
>> * genmatch.c
>> (parser::parse_operator_list): New member function in parser.
>> (add_substitute): New function.
>> (flatten_substitutes): Likewise.
>> (parser::parse_for): Call add_substitute.
>> (parser::parse_pattern): Call parser::parse_operator_list.
>>
>> * match-bitwise.pd
>> (bitwise_ors): New operator-list.
>> (bitwise_ops): Likewise.
>> Use bitwise_ors and bitwise_ops in patterns.
>>
>> * match-comparison.pd
>>  (eq_ops): New operator-list.
>>  (cmp_ops): Likewise.
>>  Use cmp_ops and eq_ops in patterns.
>>
>> Thanks,
>> Prathamesh


Re: [gofrontend-dev] [PATCH 7/9] Gccgo port to s390[x] -- part I

2014-10-28 Thread Dominik Vogt
On Thu, Oct 16, 2014 at 04:45:03PM -0700, Ian Lance Taylor wrote:
> On Tue, Sep 9, 2014 at 6:02 AM, Dominik Vogt  wrote:
> > +case 8:
> > +  return (is_unsigned) ? "uint8" : "int8";
> 
> No need to parenthesize is_unsigned here and in the following lines.

That's just my way of coding.  I always put conditions into
parentheses, but I don't care whether they are removed here.

> > +#if 1 /*!!!todo: identifier may not be unique???*/
> > +#endif
> 
> I'm not sure what the #if 1 is about.  Just put a FIXME comment--see
> other examples in the code base.

That's an accident.

> > +  static unsigned int art_i = 0;
> >
> > +  if (is_nested == false)
> > +art_i = 0;
> 
> Don't use a static variable.  Instead, pass down an int*.  It can be
> NULL for the case where !is_nested.

Done.

>  (Also, in code like this, write
> !is_nested rather than is_nested == false).

Okay.

> > +   layout_type (type);
> Is this really necessary?

It seems so.  Without it, -fdump-go-specs triggers a core dump when
processing the s390x headers.  A file like this generates the core:

  typedef struct S T;

> +   decl_align_unit = precision_to_units (DECL_ALIGN (field));
> You can just use DECL_ALIGN_UNIT.
> > + type_align_unit = precision_to_units (TYPE_ALIGN (type));
> You can just use TYPE_ALIGN_UNIT.

Okay.

> > +   snprintf (buf, sizeof buf, "%u", sz_units);
> 
> This doesn't look right--shouldn't it be
> sz_units / TYPE_ALIGN_UNITS (type)
> ?  Using sz_units only looks right if go_get_uinttype_for_precision
> returns byte.

The generated size is correct because sz_units is always in bytes,
and the code generates a *byte* array.  However, the alignment may
be wrong.  Given a C union

  union { uint8_t c; uint64_t ll; } u;

with size 8 and alignment 8, the generated Go struct is

  _u struct { c [8]byte; }

The alignment of this struct is 1 and the size is 8.  I've added an
alignment field at the end of the struct like this:

  _u struct { c [8]byte; Godump__align [0]uint64; }

and added more tests.

> > +  (  !htab_find_slot (container->type_hash, IDENTIFIER_POINTER (id),
> 
> Don't use these leading spaces after parens, just let emacs format
> your code even if looks awkward.

Okay.

--

The attached patch contains all the discussed changes.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany
>From 5e1556d67febf91e066953a7c795f7855b8f841e Mon Sep 17 00:00:00 2001
From: Dominik Vogt 
Date: Fri, 5 Sep 2014 07:30:56 +0100
Subject: [PATCH] godump: Support bitfields and unions in go_format_type.

1) Fix handling of arrays with zero elements.

2) Support bitfields and unions in go_format_type.

Bitfields are replaced by byte arrays with synthetic names that cover the space
occupied by the bitfield and any padding after it.

Unions are represented by a struct with a single field that has the name of the
first field of the original record (or "Godump_" if the first field has no
name).  This field is a byte array with the size of the largest field of the
original union.  If alignment of the union does not match the size of the byte
array, an array of integers with the alignment of the union and zero elements is
added at the end of the record to enforce proper alignment (name
"Godump__align").

Placement of the fields of a record is derived using the internal placement
algorithm in stor.layout.c.  In some cases byte arrays of proper size are
inserted into records to get the alignment right.  Also, if the representation
of a record in Go does not have the proper alignment after all fields have been
converted to Go, an array of integers with the alignment of the recordn and
zero elements is added at the end of the record (name "Godump__align").

When translating a VAR_DECL, a type that is aliased with typedef (or a struct
or union) is used literally, if possible, and not resolved to builtin types.

Packed records are (still) not supported.

3) Add godump testsuite.
---
 gcc/godump.c| 361 +---
 gcc/testsuite/gcc.misc-tests/godump-1.c | 482 
 gcc/testsuite/gcc.misc-tests/godump.exp |  36 +++
 3 files changed, 785 insertions(+), 94 deletions(-)
 create mode 100644 gcc/testsuite/gcc.misc-tests/godump-1.c
 create mode 100644 gcc/testsuite/gcc.misc-tests/godump.exp

diff --git a/gcc/godump.c b/gcc/godump.c
index 7566f4d..a124291 100644
--- a/gcc/godump.c
+++ b/gcc/godump.c
@@ -37,6 +37,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "obstack.h"
 #include "debug.h"
 #include "wide-int-print.h"
+#include "stor-layout.h"
+#include "defaults.h"
 
 /* We dump this information from the debug hooks.  This gives us a
stable and maintainable API to hook into.  In order to work
@@ -73,6 +75,14 @@ struct macro_hash_value
   char *value;
 };
 
+/* Returns the number of units necessary to represent an integer with the given
+   PRECISION (in bits).  */
+static inline unsigned int
+precision_to_units (unsigned int precis

Re: [debug-early] emit locals early patchset

2014-10-28 Thread Michael Matz
Hi,

On Mon, 27 Oct 2014, Aldy Hernandez wrote:

> Here I use a new tree bit (BLOCK_DIE) to store the DIE<->block 
> relationship. This will have to be adapted and streamed for LTO.

You might consider using an on-the-side tree->hash map.  Saves memory when 
not generating debug info (there can be many BLOCKs).

> Kind words greatly appreciated.  Basically I'm looking for feedback and
> positive reinforcement that this is all eventually useful :).

I think that goes exactly in the right direction, FWIW.


Ciao,
Michael.


[match-and-simplify] Merge from trunk

2014-10-28 Thread Richard Biener

2014-10-28  Richard Biener  

Merge from trunk r216772 through r216799.

Brings back next merge piece.


Re: [wwwdocs] Add porting_to.html, describe gnu11 changes

2014-10-28 Thread Marek Polacek
Ping?

On Wed, Oct 22, 2014 at 07:16:31PM +0200, Marek Polacek wrote:
> On Wed, Oct 22, 2014 at 09:56:08AM -0700, Mike Stump wrote:
> > On Oct 22, 2014, at 8:29 AM, Marek Polacek  wrote:
> > > The following adds the porting_to.html document for GCC 5 and
> > > documents issues arising from moving the default to gnu11.
> > 
> > So, one way for a person to port a large project, would be just to select 
> > gnu89 as the target language for the project.  Should be a one line change, 
> > if their project is structured well.  Seems like we should mention that at 
> > the top.
> 
> Good point.  I've added something like that.
>  
> > I think we should leave out headers with empty contents.  For example, Java 
> > issues.  Don’t expect there to be any, so, no need to have the header.
> 
> I've dropped those, thanks.
> 
> Another suggestions are welcome!
> 
> --- porting_to.html.mp2014-10-22 17:25:42.122367884 +0200
> +++ porting_to.html   2014-10-22 19:12:49.809720491 +0200
> @@ -0,0 +1,214 @@
> +
> +
> +
> +Porting to GCC 5
> +
> +
> +
> +Porting to GCC 5
> +
> +
> +The GCC 5 release series differs from previous GCC releases in
> +a number of ways. Some of
> +these are a result of bug fixing, and some old behaviors have been
> +intentionally changed in order to support new standards, or relaxed
> +in standards-conforming ways to facilitate compilation or run-time
> +performance.  Some of these changes are not visible to the naked eye
> +and will not cause problems when updating from older versions.
> +
> +
> +
> +However, some of these changes are visible, and can cause grief to
> +users porting to GCC 5. This document is an effort to identify major
> +issues and provide clear solutions in a quick and easily searched
> +manner. Additions and suggestions for improvement are welcome.
> +
> +
> +C language issues
> +
> +Default standard is now GNU11
> +
> +GCC defaults to -std=gnu11 instead of 
> -std=gnu89.
> +This brings several changes that the users should be aware of.  The following
> +paragraphs describe some of these changes and suggest how to deal with them.
> +
> +Some users might prefer to stay with gnu89, in which case we suggest to use
> +the -std=gnu89 command-line option, perhaps by putting it in
> +override CFLAGS or similarly in the Makefile.
> +
> +Different semantics for inline functions
> +While -std=gnu89 employs the GNU89 inline semantics,
> +-std=gnu11 uses the C99 inline semantics.  The C99 inline 
> semantics
> +requires that if a function with external linkage is declared with
> +inline function specifier, it also has to be defined in the same
> +translation unit.  Consequently, GCC now warns if it sees a TU such as the
> +following:
> +
> +
> +  inline int foo (void);
> +
> +
> +This example now gives the following diagnostic:
> +
> +
> +f.c:1:12: warning: inline function 
> 'foo' declared but never defined
> +   inline int foo (void);
> +  ^
> +
> +
> +Furthermore, there is a difference between extern inline and
> +inline:
> +
> +  C99 inline: no externally visible function is generated;
> +  if the function is referenced in this TU, external definition has to
> +  exist in another TU;
> +  C99 extern inline: externally visible function is 
> generated;
> +  
> +  GNU89 inline: same as C99 extern inline;
> +  GNU89 extern inline: same as C99 inline.
> +
> +
> +In other words, ISO C99 requires that exactly one C source file has the
> +callable copy of the inline function.  Consider the following program:
> +
> +
> +  inline int
> +  foo (void)
> +  {
> +return 42;
> +  }
> +
> +  int
> +  main (void)
> +  {
> +return foo ();
> +  }
> +
> +
> +The program above will not link with the C99 inline semantics, because 
> there
> +is not an out-of-line function foo generated.  To fix this, add 
> the
> +following declaration:
> +
> +
> +  extern inline int foo (void);
> +
> +
> +This declaration ensures that an externally visible function be emitted.
> +To enforce the GNU89 inline semantics, you can either use the
> +-fgnu89-inline command-line option, or mark a function with the
> +gnu_inline attribute.
> +
> +Some warnings are enabled by default
> +
> +The C99 mode enables some warnings by default.  For instance, GCC warns
> +about missing declarations of functions:
> +
> +
> +  int
> +  foo (void)
> +  {
> +return bar ();
> +  }
> +
> +
> +This example now gives the following diagnostic:
> +
> +
> +w.c:4:10: warning: implicit declaration 
> of function 'bar' [-Wimplicit-function-declaration]
> +   return bar ();
> +  ^
> +
> +
> +To suppress this warning add the proper declaration:
> +
> +
> +  int bar (void);
> +
> +
> +or use -Wno-implicit-function-declaration.
> +
> +Another warning that is now turned on by default is the warning about
> +implicit int, as in the following snippet:
> +
> +
> +  foo (u)
> +  {
> +return u;
> +  }
> +
> +
> +This example now gives the following diagnostic:
> +
> +
> +q.c:1:1: warning: return type defaults

Re: The nvptx port [7/11+] Inform the port about call arguments

2014-10-28 Thread Bernd Schmidt

On 10/22/2014 08:12 PM, Jeff Law wrote:

Yea, let's keep your approach.  Just wanted to explore a bit since the
PA seems to have a variety of similar characteristics.


Here's an updated version of the patch. I experimented a little with ptx 
calling conventions and ran into an arg that had to be moved with 
memcpy, which exposed an ordering problem - all call_args were added to 
the memcpy call. So the invocation of the hook had to be moved downwards 
a bit, and the calculation of the return value needs to happen after it 
(since nvptx_function_value needs to know whether we are actually trying 
to construct a call at the moment).


Bootstrapped and tested on x86_64-linux, ok?


Bernd

	gcc/
	* target.def (call_args, end_call_args): New hooks.
	* hooks.c (hook_void_rtx_tree): New empty function.
	* hooks.h (hook_void_rtx_tree): Declare.
	* doc/tm.texi.in (TARGET_CALL_ARGS, TARGET_END_CALL_ARGS): Add.
	* doc/tm.texi: Regenerate.
	* calls.c (expand_call): Slightly rearrange the code.  Use the two new
	hooks.
	(expand_library_call_value_1): Use the two new hooks.


Index: gcc/doc/tm.texi
===
--- gcc/doc/tm.texi.orig
+++ gcc/doc/tm.texi
@@ -4960,6 +4960,29 @@ except the last are treated as named.
 You need not define this hook if it always returns @code{false}.
 @end deftypefn
 
+@deftypefn {Target Hook} void TARGET_CALL_ARGS (rtx, @var{tree})
+While generating RTL for a function call, this target hook is invoked once
+for each argument passed to the function, either a register returned by
+@code{TARGET_FUNCTION_ARG} or a memory location.  It is called just
+before the point where argument registers are stored.  The type of the
+function to be called is also passed as the second argument; it is
+@code{NULL_TREE} for libcalls.  The @code{TARGET_END_CALL_ARGS} hook is
+invoked just after the code to copy the return reg has been emitted.
+This functionality can be used to perform special setup of call argument
+registers if a target needs it.
+For functions without arguments, the hook is called once with @code{pc_rtx}
+passed instead of an argument register.
+Most ports do not need to implement anything for this hook.
+@end deftypefn
+
+@deftypefn {Target Hook} void TARGET_END_CALL_ARGS (void)
+This target hook is invoked while generating RTL for a function call,
+just after the point where the return reg is copied into a pseudo.  It
+signals that all the call argument and return registers for the just
+emitted call are now no longer in use.
+Most ports do not need to implement anything for this hook.
+@end deftypefn
+
 @deftypefn {Target Hook} bool TARGET_PRETEND_OUTGOING_VARARGS_NAMED (cumulative_args_t @var{ca})
 If you need to conditionally change ABIs so that one works with
 @code{TARGET_SETUP_INCOMING_VARARGS}, but the other works like neither
Index: gcc/doc/tm.texi.in
===
--- gcc/doc/tm.texi.in.orig
+++ gcc/doc/tm.texi.in
@@ -3856,6 +3856,10 @@ These machine description macros help im
 
 @hook TARGET_STRICT_ARGUMENT_NAMING
 
+@hook TARGET_CALL_ARGS
+
+@hook TARGET_END_CALL_ARGS
+
 @hook TARGET_PRETEND_OUTGOING_VARARGS_NAMED
 
 @node Trampolines
Index: gcc/hooks.c
===
--- gcc/hooks.c.orig
+++ gcc/hooks.c
@@ -245,6 +245,11 @@ hook_void_tree (tree a ATTRIBUTE_UNUSED)
 }
 
 void
+hook_void_rtx_tree (rtx, tree)
+{
+}
+
+void
 hook_void_constcharptr (const char *a ATTRIBUTE_UNUSED)
 {
 }
Index: gcc/hooks.h
===
--- gcc/hooks.h.orig
+++ gcc/hooks.h
@@ -71,6 +71,7 @@ extern void hook_void_constcharptr (cons
 extern void hook_void_rtx_insn_int (rtx_insn *, int);
 extern void hook_void_FILEptr_constcharptr (FILE *, const char *);
 extern bool hook_bool_FILEptr_rtx_false (FILE *, rtx);
+extern void hook_void_rtx_tree (rtx, tree);
 extern void hook_void_tree (tree);
 extern void hook_void_tree_treeptr (tree, tree *);
 extern void hook_void_int_int (int, int);
Index: gcc/target.def
===
--- gcc/target.def.orig
+++ gcc/target.def
@@ -3816,6 +3816,33 @@ not generate any instructions in this ca
  default_setup_incoming_varargs)
 
 DEFHOOK
+(call_args,
+ "While generating RTL for a function call, this target hook is invoked once\n\
+for each argument passed to the function, either a register returned by\n\
+@code{TARGET_FUNCTION_ARG} or a memory location.  It is called just\n\
+before the point where argument registers are stored.  The type of the\n\
+function to be called is also passed as the second argument; it is\n\
+@code{NULL_TREE} for libcalls.  The @code{TARGET_END_CALL_ARGS} hook is\n\
+invoked just after the code to copy the return reg has been emitted.\n\
+This functionality can be used to perform special setup of call argument

Re: [debug-early] emit locals early patchset

2014-10-28 Thread Richard Biener
On Tue, Oct 28, 2014 at 1:00 AM, Aldy Hernandez  wrote:
> Gentlemen!
>
> My apologies for the big patch.  In getting locals emitted early (parameters
> and locally scoped variables), I ran into many things which were in need of
> surgery, many of which couldn't happen without the other.  Consequently, I
> ended up fixing everything such that we are now back to no guality.exp
> failures for any language.
>
> [Curiously, I hadn't noticed locals were not being dumped early because they
> were being picked up by the late dwarf pass.  Fixing this oversight is what
> caused this entire patch.]
>
> There are a lot of changes here, and I would greatly appreciate feedback, so
> let me at least explain what's going on at a high level...
>
> 1. Changes to gen_subprogram_die() to handle early generation of locals, and
> amending location information on the second pass.  Everything else in this
> patch, basically stems from this change.
>
> 2. Changes to gen_variable_die() to handle multiple passes (early/late dwarf
> generation).
>
> A lot of this is complicated by the fact that old_die's are cached and keyed
> by `tree', but an abstract instance and an inline instance share trees,
> while dwarf2out_abstract_function() sets DECL_ABSTRACT_P behind the scenes.
>
> The current support (and my changes) maintain this shared and delicate
> design.  I wonder whether we could simplify a lot of this code by unsharing
> these trees, but this may be beyond the scope of this work. Richi perhaps
> you can comment?

I think that the abstract and inline instances are cases that are _only_
generated "early" - that is, they don't contain any locations or whatever
and thus do not need to ameded in the late dwarf pass.  So I'd simply
generate dwarf for them and not remember their DIEs.

But maybe I am missing something here ;)

They are also only a space optimization I think - the trees are there
in the inline instances and we can fully re-generate them from there.

Richard.

> 3. I've removed deferred_locations.  With multiple dwarf passes we can do
> without them.
>
> 4. I have commented a lot of dwarf2out.c throughout .  Dwarf generation is
> this big mystery, and my brain is small.  I've commented things as I've
> learned them.  Hopefully it can help those unfortunate souls who come after
> me.
>
> 5. Variable-lengthed array types need special treatment.  Even though they
> can be early dumped, location information may not be available until late
> dwarf.  I've modified gen_type_die*() and friends to work with
> variable-lengthed arrays.  Now we will early generate the
> DW_TAG_subrange_type, but fill in the location at late dwarf.
>
> 6. Handle dual passes through gen_lexical_block_die(), while handling
> inlining gracefully.
>
> Here I use a new tree bit (BLOCK_DIE) to store the DIE<->block relationship.
> This will have to be adapted and streamed for LTO.
>
> For that matter, LTO as a whole needs addressing, but I want to get the
> non-LTO version working before I dive into dwarf streaming, and removing all
> these ancillary data structures in dwarf2out.  Right now, LTO is working but
> only because everything gets recreated by the late dwarf pass, thus it's
> working as in mainline.
>
> Phew... that's basically it.
>
> Kind words greatly appreciated.  Basically I'm looking for feedback and
> positive reinforcement that this is all eventually useful :).
>
> Aldy
>
> p.s. Committed to branch.


Re: The nvptx port [10/11+] Target files

2014-10-28 Thread Bernd Schmidt

On 10/22/2014 08:01 PM, Jeff Law wrote:

Please make sure all the functions in nvptx.c have function comments.


Done, and replaced regno 4 with NVPTX_RETURN_REGNUM.


+const char *
+nvptx_output_call_insn (rtx insn, rtx result, rtx callee)

If possible, promote first argument to rtx_insn *.


Also done.


+/* Clean up subreg operands.  */

Which means what?  A little more descriptive here would be helpful.


Expanded.


I'm surprised there's not more hair around the address space issues.  I
expected more problems there.


I have patches that expose all the address spaces to the middle-end 
through a lower-as pass that runs early. The preliminary patches for 
that ran into some resistance and into general brokenness of our address 
space support, so I decided to rip all that out for the moment to get 
the basic port into the next version.


This new version also implements a way of providing realloc that was 
suggested in another thread. Calls to malloc and free are redirected to 
libgcc variants. I'm not a big fan of wasting extra space on every 
allocation (which is why I didn't originally consider this approach 
viable), but it seems we'll have to do it that way. There's a change to 
the libgcc build system: on ptx we need comments in the assembly to 
survive, so we can't use -xassembler-with-cpp. I've not found any files 
named "*.asm", so I've changed that suffix to mean plain assembler.



Bernd

	* configure.ac: Allow configuring lto for nvptx.
	* configure: Regenerate.

	gcc/
	* config/nvptx/nvptx.c: New file.
	* config/nvptx/nvptx.h: New file.
	* config/nvptx/nvptx-protos.h: New file.
	* config/nvptx/nvptx.md: New file.
	* config/nvptx/t-nvptx: New file.
	* config/nvptx/nvptx.opt: New file.
	* common/config/nvptx/nvptx-common.c: New file.
	* config.gcc: Handle nvptx-*-*.

	libgcc/
	* config.host: Handle nvptx-*-*.
	* shared-object.mk (as-flags-$o): Define.
	($(base)$(objext), $(base)_s$(objext)): Use it instead of
	-xassembler-with-cpp.
	* static-object.mk: Identical changes.
	* config/nvptx/t-nvptx: New file.
	* config/nvptx/crt0.s: New file.
	* config/nvptx/free.asm: New file.
	* config/nvptx/malloc.asm: New file.
	* config/nvptx/realloc.c: New file.


Index: gcc/common/config/nvptx/nvptx-common.c
===
--- /dev/null
+++ gcc/common/config/nvptx/nvptx-common.c
@@ -0,0 +1,38 @@
+/* NVPTX common hooks.
+   Copyright (C) 2014 Free Software Foundation, Inc.
+   Contributed by Bernd Schmidt 
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "diagnostic-core.h"
+#include "tm.h"
+#include "tm_p.h"
+#include "common/common-target.h"
+#include "common/common-target-def.h"
+#include "opts.h"
+#include "flags.h"
+
+#undef TARGET_HAVE_NAMED_SECTIONS
+#define TARGET_HAVE_NAMED_SECTIONS false
+
+#undef TARGET_DEFAULT_TARGET_FLAGS
+#define TARGET_DEFAULT_TARGET_FLAGS MASK_ABI64
+
+struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
Index: gcc/config.gcc
===
--- gcc/config.gcc.orig
+++ gcc/config.gcc
@@ -420,6 +420,9 @@ nios2-*-*)
 	cpu_type=nios2
 	extra_options="${extra_options} g.opt"
 	;;
+nvptx-*-*)
+	cpu_type=nvptx
+	;;
 powerpc*-*-*)
 	cpu_type=rs6000
 	extra_headers="ppc-asm.h altivec.h spe.h ppu_intrinsics.h paired.h spu2vmx.h vec_types.h si2vmx.h htmintrin.h htmxlintrin.h"
@@ -2148,6 +2151,10 @@ nios2-*-*)
 		;;
 esac
 	;;
+nvptx-*)
+	tm_file="${tm_file} newlib-stdint.h"
+	tmake_file="nvptx/t-nvptx"
+	;;
 pdp11-*-*)
 	tm_file="${tm_file} newlib-stdint.h"
 	use_gcc_stdint=wrap
Index: gcc/config/nvptx/nvptx.c
===
--- /dev/null
+++ gcc/config/nvptx/nvptx.c
@@ -0,0 +1,2118 @@
+/* Target code for NVPTX.
+   Copyright (C) 2014 Free Software Foundation, Inc.
+   Contributed by Bernd Schmidt 
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published
+   by the Free Software Foundation; either version 3, or (at your
+   option) any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied war

[AArch64, Docs, Patch] Add reference to ACLE in docs.

2014-10-28 Thread Tejas Belagod

Hi,

Here is patch that consolidates AArch64 and ARM Intrinsics sections in 
extend.texi into one ACLE section to avoid information repetition and 
adds reference to the ARM C Language Extension spec on infocenter.arm.com.


Built aarch64-none-elf and viewed gcc.info and associated HTML. OK for 
trunk?


Thanks,
Tejas.

2014-10-28  Tejas Belagod  

gcc/
* Makefile.in (TEXI_GCC_FILES): Remove arm-acle-intrinsics.texi,
arm-neon-intrinsics.texi, aarch64-acle-intrinsics.texi.
* doc/aarch64-acle-intrinsics.texi: Remove.
* doc/arm-acle-intrinsics.texi: Remove.
* doc/arm-neon-intrinsics.texi: Remove.
* doc/extend.texi: Consolidate sections AArch64 intrinsics,
ARM NEON Intrinsics, ARM ACLE Intrinsics into one ARM C Language
Extension section. Add references to public ACLE specification.

intrinsics-doc-2.txt.gz
Description: application/gzip


Re: [PATCH, x86, 63534] Fix '-p' profile for 32 bit PIC mode

2014-10-28 Thread Evgeny Stupachenko
Agree. Let't stop at first insn after entry block notes.
As for the test it looks like mcount is general i?86 name.

Bootstrap and make check are in progress.

2014-10-28  Evgeny Stupachenko  

gcc/testsuite
PR target/63534
* gcc.target/i386/mcount_pic.c: New.

gcc/
PR target/63534
* config/i386/i386.c (ix86_init_pic_reg): Emit SET_GOT to
REAL_PIC_OFFSET_TABLE_REGNUM for mcount profiling.
(ix86_save_reg): Save REAL_PIC_OFFSET_TABLE_REGNUM when profiling
using mcount in 32bit PIC mode.
(ix86_elim_entry_set_got): New.
(ix86_expand_prologue): For the mcount profiling emit new SET_GOT
in PROLOGUE, delete initial if possible.

2014-10-22  Evgeny Stupachenko  

PR rtl-optimization/63618
* gcc.target/i386/pr63618.c: New.

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 6235c4f..a38bc33 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -6190,8 +6190,15 @@ ix86_init_pic_reg (void)
 }
   else
 {
-  rtx insn = emit_insn (gen_set_got (pic_offset_table_rtx));
+  /*  If there is future mcount call in the function it is more profitable
+ to emit SET_GOT into ABI defined REAL_PIC_OFFSET_TABLE_REGNUM.  */
+  rtx reg = crtl->profile
+   ? gen_rtx_REG (Pmode, REAL_PIC_OFFSET_TABLE_REGNUM)
+   : pic_offset_table_rtx;
+  rtx insn = emit_insn (gen_set_got (reg));
   RTX_FRAME_RELATED_P (insn) = 1;
+  if (crtl->profile)
+emit_move_insn (pic_offset_table_rtx, reg);
   add_reg_note (insn, REG_CFA_FLUSH_QUEUE, NULL_RTX);
 }

@@ -9471,15 +9478,23 @@ ix86_select_alt_pic_regnum (void)
 static bool
 ix86_save_reg (unsigned int regno, bool maybe_eh_return)
 {
-  if (pic_offset_table_rtx
-  && !ix86_use_pseudo_pic_reg ()
-  && regno == REAL_PIC_OFFSET_TABLE_REGNUM
-  && (df_regs_ever_live_p (REAL_PIC_OFFSET_TABLE_REGNUM)
- || crtl->profile
- || crtl->calls_eh_return
- || crtl->uses_const_pool
- || cfun->has_nonlocal_label))
-return ix86_select_alt_pic_regnum () == INVALID_REGNUM;
+  if (regno == REAL_PIC_OFFSET_TABLE_REGNUM
+  && pic_offset_table_rtx)
+{
+  if (ix86_use_pseudo_pic_reg ())
+   {
+ /* REAL_PIC_OFFSET_TABLE_REGNUM used by call to
+ _mcount in prologue.  */
+ if (!TARGET_64BIT && flag_pic && crtl->profile)
+   return true;
+   }
+  else if (df_regs_ever_live_p (REAL_PIC_OFFSET_TABLE_REGNUM)
+  || crtl->profile
+  || crtl->calls_eh_return
+  || crtl->uses_const_pool
+  || cfun->has_nonlocal_label)
+return ix86_select_alt_pic_regnum () == INVALID_REGNUM;
+}

   if (crtl->calls_eh_return && maybe_eh_return)
 {
@@ -10818,6 +10833,30 @@ ix86_finalize_stack_realign_flags (void)
   crtl->stack_realign_finalized = true;
 }

+/* Delete SET_GOT right after entry block if it is allocated to reg.  */
+
+static void
+ix86_elim_entry_set_got (rtx reg)
+{
+  basic_block bb = ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb;
+  rtx_insn *c_insn;
+  FOR_BB_INSNS (bb, c_insn)
+if (GET_CODE (c_insn) != NOTE)
+  break;
+  if (NONJUMP_INSN_P (c_insn))
+{
+  rtx pat = PATTERN (c_insn);
+  if (GET_CODE (pat) == PARALLEL)
+   {
+ rtx vec = XVECEXP (pat, 0, 0);
+ if (GET_CODE (vec) == SET
+ && XINT (XEXP (vec, 1), 1) == UNSPEC_SET_GOT
+ && REGNO (XEXP (vec, 0)) == REGNO (reg))
+   delete_insn (c_insn);
+   }
+}
+}
+
 /* Expand the prologue into a bunch of separate insns.  */

 void
@@ -11271,6 +11310,20 @@ ix86_expand_prologue (void)
   if (!sse_registers_saved)
 ix86_emit_save_sse_regs_using_mov (frame.sse_reg_save_offset);

+  /* For the mcount profiling on 32 bit PIC mode we need to emit SET_GOT
+ in PROLOGUE.  */
+  if (!TARGET_64BIT && pic_offset_table_rtx && crtl->profile && !flag_fentry)
+{
+  rtx pic = gen_rtx_REG (Pmode, REAL_PIC_OFFSET_TABLE_REGNUM);
+  insn = emit_insn (gen_set_got (pic));
+  RTX_FRAME_RELATED_P (insn) = 1;
+  add_reg_note (insn, REG_CFA_FLUSH_QUEUE, NULL_RTX);
+  emit_insn (gen_prologue_use (pic));
+  /* Deleting already emmitted SET_GOT if exist and allocated to
+REAL_PIC_OFFSET_TABLE_REGNUM.  */
+  ix86_elim_entry_set_got (pic);
+}
+
   if (crtl->drap_reg && !crtl->stack_realign_needed)
 {
   /* vDRAP is setup but after reload it turns out stack realign
diff --git a/gcc/testsuite/gcc.target/i386/mcount_pic.c
b/gcc/testsuite/gcc.target/i386/mcount_pic.c
new file mode 100644
index 000..08ecd07
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/mcount_pic.c
@@ -0,0 +1,13 @@
+/* Test check correct mcount generation.  */
+/* { dg-do run } */
+/* { dg-require-effective-target ia32 } */
+/* { dg-options "-O2 -fpic -p -save-temps" } */
+
+int main ()
+{
+  return 0;
+}
+
+/* { dg-final { scan-assembler "mcount" } } */
+/* 

Re: [PATCH] Redesign jump threading profile updates

2014-10-28 Thread Renlin Li

On 01/10/14 21:04, Teresa Johnson wrote:

The block frequencies are very small in this case leading to rounding
errors when computing the edge frequency. The rounding error was then
propagated into the recomputed probabilities, leading to insanities in
the outgoing edge probabilities on the jump threading path. Eventually
during rtl expansion these insanities somehow caused an ICE.
That's exactly what I have observed while investigation this bug: 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61529


In this ICE while building glibc, we have frequency = 16, but we have 
even probabilities for 45 successors.
The count for each outgoing edge is rounding to 0. Later in the 
update_joiner_offpath_counts() function, the count for each edge is 
re-calculated to  be equal to e->src->count, thus the probability for 
each outgoing edge is 100% when probability is recomputed.


This patch fixed the bug. Thank you!



(Before this patch the probabilities weren't even being updated,
leading to insanities in other cases where they needed to be updated.)

Specifically, in this case we had a block with frequency = 1. It had
two outgoing edges each with probability 50%. Because the
EDGE_FREQUENCY computation uses a rounding divide, the outgoing edge
frequencies were both computed as 1. Later use of these block and edge
frequencies to recompute the probability lead to both outgoing edges
getting 100%.

To address this, in the routine freqs_to_counts_path can simply scale
up the frequencies when recording them in the count field. I added a
scale by REG_BR_PROB_BASE. The largest count possible would therefore
be REG_BR_PROB_BASE * BB_FREQ_MAX which is 1 * 1 = 100mil
which safely fits in gcov_type.

Here is the patch I am testing. Confirmed it fixes the reported issue.
Currently bootstrapping and testing on x86_64-unknown-linux-gnu. Ok
for trunk if it passes?

(The whitespace is getting messed up when I copy the patch in here -
the indentations do line up in the patch.)

Thanks,
Teresa

2014-10-01  Teresa Johnson  

 * tree-ssa-threadupdate.c (freqs_to_counts_path): Scale frequencies
 up when synthesizing counts to avoid rounding errors.

Index: tree-ssa-threadupdate.c
===
--- tree-ssa-threadupdate.c (revision 215739)
+++ tree-ssa-threadupdate.c (working copy)
@@ -979,7 +979,11 @@ freqs_to_counts_path (struct redirection_data *rd)
FOR_EACH_EDGE (ein, ei, e->dest->preds)
  {
gcc_assert (!ein->count);
-  ein->count = EDGE_FREQUENCY (ein);
+  /* Scale up the frequency by REG_BR_PROB_BASE, to avoid rounding
+ errors applying the probability when the frequencies are very
+ small.  */
+  ein->count = apply_probability (ein->src->frequency * REG_BR_PROB_BASE,
+  ein->probability);
  }

for (unsigned int i = 1; i < path->length (); i++)
@@ -987,11 +991,13 @@ freqs_to_counts_path (struct redirection_data *rd)
edge epath = (*path)[i]->e;
gcc_assert (!epath->count);
edge esucc;
+  /* Scale up the frequency by REG_BR_PROB_BASE, to avoid rounding
+ errors applying the edge probability when the frequencies are very
+ small.  */
+  epath->src->count = epath->src->frequency * REG_BR_PROB_BASE;
FOR_EACH_EDGE (esucc, ei, epath->src->succs)
-{
-  esucc->count = EDGE_FREQUENCY (esucc);
-}
-  epath->src->count = epath->src->frequency;
+esucc->count = apply_probability (esucc->src->count,
+  esucc->probability);
  }
  }


On Wed, Oct 1, 2014 at 8:29 AM, Teresa Johnson  wrote:

I got the preprocessed source. With the aarch64 cross-compiler I built
I am able to reproduce the ICE. Looking at it now.

Thanks,
Teresa

On Wed, Oct 1, 2014 at 8:25 AM, Christophe Lyon
 wrote:

On 1 October 2014 17:22, Sebastian Pop  wrote:

Christophe Lyon wrote:

Since this commit, I can see all my builds for arm*linux* and
aarch64*linux* fail while building glibc:

/tmp/3496222_18.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/bin/aarch64-none-linux-gnu-gcc
iso-2022-cn.c -c -std=gnu99 -fgnu89-inline  -O2 -Wall -Win
line -Wundef -Wwrite-strings -fmerge-all-constants -frounding-math -g
-Wstrict-prototypes   -fPIC-I../include
-I/tmp/3496222_18.tmpdir/aci-gcc-f
sf/builds/gcc-fsf-gccsrc/obj-aarch64-none-linux-gnu/glibc-1/iconvdata
-I/tmp/3496222_18.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64-none-linux
-gnu/glibc-1  -I../sysdeps/unix/sysv/linux/aarch64/nptl
-I../sysdeps/unix/sysv/linux/aarch64
-I../sysdeps/unix/sysv/linux/generic  -I../sysdeps/unix/s
ysv/linux/wordsize-64  -I../nptl/sysdeps/unix/sysv/linux
-I../nptl/sysdeps/pthread  -I../sysdeps/pthread
-I../sysdeps/unix/sysv/linux  -I../sysdeps/gn
u  -I../sysdeps/unix/inet  -I../nptl/sysdeps/unix/sysv
-I../sysdeps/unix/sysv  -I../nptl/sysdeps/unix  -I../sysdeps/unix
-I../sysdeps/posix  -I../sy

Re: [gomp4] [2/3] OpenACC 2.0 support for libgomp - new tests

2014-10-28 Thread Thomas Schwinge
Hi!

Committed in r216804:

commit 4f9566b3e2954218c0d9ce3c585e14e539f0c1af
Author: tschwinge 
Date:   Tue Oct 28 15:57:48 2014 +

libgomp: Don't refer to CUDA installation in /opt/nvidia/cuda-5.5/.

libgomp/
* testsuite/libgomp.oacc-c/c.exp (ld_library_path, ALWAYS_CFLAGS):
Don't refer to CUDA installation in /opt/nvidia/cuda-5.5/.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@216804 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog.gomp | 3 +++
 libgomp/testsuite/libgomp.oacc-c/c.exp | 6 --
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git libgomp/ChangeLog.gomp libgomp/ChangeLog.gomp
index fda1cbc..5879e20 100644
--- libgomp/ChangeLog.gomp
+++ libgomp/ChangeLog.gomp
@@ -1,5 +1,8 @@
 2014-10-28  Thomas Schwinge  
 
+   * testsuite/libgomp.oacc-c/c.exp (ld_library_path, ALWAYS_CFLAGS):
+   Don't refer to CUDA installation in /opt/nvidia/cuda-5.5/.
+
* oacc-init.c: Don't use 's SLIST_*.
* plugin-nvptx.c: Likewise.
 
diff --git libgomp/testsuite/libgomp.oacc-c/c.exp 
libgomp/testsuite/libgomp.oacc-c/c.exp
index 553c225..318f78e 100644
--- libgomp/testsuite/libgomp.oacc-c/c.exp
+++ libgomp/testsuite/libgomp.oacc-c/c.exp
@@ -31,7 +31,6 @@ set tests [lsort [find $srcdir/$subdir *.c]]
 
 set ld_library_path $always_ld_library_path
 append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
-append ld_library_path ":/opt/nvidia/cuda-5.5/lib64"
 set_ld_library_path_env_vars
 
 # Todo: get list of accelerators from configure options --enable-accelerator.
@@ -58,11 +57,6 @@ foreach accel $accels {
# Copy ptx file (TEMPORARY)
remote_download host $srcdir/libgomp.oacc-c/subr.ptx
 
-   # Where cuda.h lives
-   # Todo: get that from configure option --with-cuda-driver.
-   lappend ALWAYS_CFLAGS 
"additional_flags=-I/opt/nvidia/cuda-5.5/include"
-   lappend ALWAYS_CFLAGS 
"additional_flags=-L/opt/nvidia/cuda-5.5/lib64"
-
# Where timer.h lives
lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}"
set acc_mem_shared 0


Grüße,
 Thomas


pgpQ_3DtSwy3r.pgp
Description: PGP signature


Re: [gomp4] [1/3] OpenACC 2.0 support for libgomp - OpenACC runtime, NVidia PTX/CUDA plugin

2014-10-28 Thread Thomas Schwinge
Hi!

Following the noble goal of code re-use, we had been using 
for a standard C linked list implementation.  However, we found that
elderly (but still sufficient to build GCC) glibc releases contain a
variant of  that pre-dates a 2006 upstream glibc update to a
more recent upstream BSD version of that file, and so is missing certain
interfaces that we were using.  Instead of conditionally re-implementing
those, in r216803 I committed a patch to remove the LIST_* usage, and
instead do things manually:

commit ba8916f6bc1dd93d8b6dc92f3d84aec49b68dea9
Author: tschwinge 
Date:   Tue Oct 28 15:57:37 2014 +

libgomp: Don't use 's SLIST_*.

Some of the interfaces are "too new".

libgomp/
* oacc-init.c: Don't use 's SLIST_*.
* plugin-nvptx.c: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@216803 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog.gomp |   5 ++
 libgomp/oacc-init.c|  23 -
 libgomp/plugin-nvptx.c | 138 +
 3 files changed, 96 insertions(+), 70 deletions(-)

diff --git libgomp/ChangeLog.gomp libgomp/ChangeLog.gomp
index 5363068..fda1cbc 100644
--- libgomp/ChangeLog.gomp
+++ libgomp/ChangeLog.gomp
@@ -1,3 +1,8 @@
+2014-10-28  Thomas Schwinge  
+
+   * oacc-init.c: Don't use 's SLIST_*.
+   * plugin-nvptx.c: Likewise.
+
 2014-10-23  Thomas Schwinge  
 
* testsuite/libgomp.oacc-c/reduction-initial-1.c: New file.
diff --git libgomp/oacc-init.c libgomp/oacc-init.c
index f797f89..ffa9ad8 100644
--- libgomp/oacc-init.c
+++ libgomp/oacc-init.c
@@ -31,7 +31,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 gomp_mutex_t acc_device_lock;
@@ -55,11 +54,11 @@ static __thread int handle_num = -1;
 struct ACC_context {
   struct memmap_t *ACC_memmap;
   void *ACC_handle;
-  SLIST_ENTRY(ACC_context) next;
+
+  struct ACC_context *next;
 };
 
-static SLIST_HEAD(_ACC_contexts, ACC_context) _ACC_contexts;
-static struct _ACC_contexts *ACC_contexts;
+static struct ACC_context *ACC_contexts;
 
 static struct gomp_device_descr const *dispatchers[_ACC_device_hwm] = { 0 };
 
@@ -198,7 +197,7 @@ lazy_open (int ord)
   ACC_handle = ACC_dev->openacc.open_device_func (ord);
   handle_num = ord;
 
-  SLIST_FOREACH(acc_ctx, ACC_contexts, next)
+  for (acc_ctx = ACC_contexts; acc_ctx != NULL; acc_ctx = acc_ctx->next)
 {
   if (acc_ctx->ACC_handle == ACC_handle)
 {
@@ -220,7 +219,8 @@ lazy_open (int ord)
   if (!ACC_memmap->mem_map.is_initialized)
 gomp_init_tables (ACC_dev, &ACC_memmap->mem_map);
 
-  SLIST_INSERT_HEAD(ACC_contexts, acc_ctx, next);
+  acc_ctx->next = ACC_contexts;
+  ACC_contexts = acc_ctx;
 }
 
 /* OpenACC 2.0a (3.2.12, 3.2.13) doesn't specify whether the serialization of
@@ -259,12 +259,10 @@ _acc_shutdown (acc_device_t d)
 
   close_handle ();
 
-  while (SLIST_FIRST(ACC_contexts) != NULL)
+  while (ACC_contexts != NULL)
 {
-  struct ACC_context *c;
-
-  c = SLIST_FIRST(ACC_contexts);
-  SLIST_REMOVE_HEAD(ACC_contexts, next);
+  struct ACC_context *c = ACC_contexts;
+  ACC_contexts = ACC_contexts->next;
   free (c);
 }
 
@@ -467,8 +465,7 @@ ACC_runtime_initialize (void)
 {
   gomp_mutex_init (&acc_device_lock);
 
-  ACC_contexts = &_ACC_contexts;
-  SLIST_INIT (ACC_contexts);
+  ACC_contexts = NULL;
 }
 
 /* Compiler helper functions */
diff --git libgomp/plugin-nvptx.c libgomp/plugin-nvptx.c
index f193229..33f868a 100644
--- libgomp/plugin-nvptx.c
+++ libgomp/plugin-nvptx.c
@@ -40,7 +40,6 @@
 #include "libgomp-plugin.h"
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -149,11 +148,9 @@ struct PTX_stream
   void *h_prev;
   void *h_tail;
 
-  SLIST_ENTRY(PTX_stream) next;
+  struct PTX_stream *next;
 };
 
-SLIST_HEAD(PTX_streams, PTX_stream);
-
 /* Each thread may select a stream (also specific to a device/context).  */
 static __thread struct PTX_stream *current_stream;
 
@@ -293,7 +290,7 @@ struct PTX_device
   /* All non-null streams associated with this device (actually context),
  either created implicitly or passed in from the user (via
  acc_set_cuda_stream).  */
-  struct PTX_streams active_streams;
+  struct PTX_stream *active_streams;
   struct {
 struct PTX_stream **arr;
 int size;
@@ -306,12 +303,12 @@ struct PTX_device
   bool concur;
   int  mode;
   bool mkern;
-  SLIST_ENTRY(PTX_device) next;
+
+  struct PTX_device *next;
 };
 
 static __thread struct PTX_device *PTX_dev;
-static SLIST_HEAD(_PTX_devices, PTX_device) _PTX_devices;
-static struct _PTX_devices *PTX_devices;
+static struct PTX_device *PTX_devices;
 
 enum PTX_event_type
 {
@@ -327,12 +324,12 @@ struct PTX_event
   int type;
   void *addr;
   int ord;
-  SLIST_ENTRY(PTX_event) next;
+
+  struct PTX_event *next;
 };
 
 static gomp_mutex_t PTX_event_lock;
-static SLIST_HEAD(_PTX_events, PTX_event) _PTX_events;
-static struct _PTX_events *PTX_events;
+static struct PTX_event *PTX_

[PATCH, IPA ICF] Fix PR63664, PR63574 (segfault in ipa-icf pass)

2014-10-28 Thread Ilya Enkovich
Hi,

This patch fixes PR63664 and PR63574.  Problem is in NULL types for labels not 
handled by ICF properly.  I assume it is OK for labels to have NULL type and 
added check into ICF rather then fixed label generation.

Bootstrapped and checked on linux-x86_64.  OK for trunk?

Thanks,
Ilya
--
gcc/

2014-10-28  Ilya Enkovich  

PR ipa/63664
PR bootstrap/63574
* ipa-icf-gimple.c (func_checker::compatible_types_p): Allow NULL args.

gcc/testsuite/

2014-10-28  Ilya Enkovich  

PR ipa/63664
* gcc.dg/ipa/pr63664.C: New.


diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c
index 1369b74..afc0eeb 100644
--- a/gcc/ipa-icf-gimple.c
+++ b/gcc/ipa-icf-gimple.c
@@ -169,6 +169,11 @@ bool func_checker::compatible_types_p (tree t1, tree t2,
   bool compare_polymorphic,
   bool first_argument)
 {
+  if (!t1 && !t2)
+return true;
+  else if (!t1 || !t2)
+return false;
+
   if (TREE_CODE (t1) != TREE_CODE (t2))
 return return_false_with_msg ("different tree types");
 
diff --git a/gcc/testsuite/gcc.dg/ipa/pr63664.C 
b/gcc/testsuite/gcc.dg/ipa/pr63664.C
new file mode 100644
index 000..31d96d4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr63664.C
@@ -0,0 +1,43 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+class test {
+ public:
+  test (int val, int *p)
+{
+  int_val = *p;
+  bool_val = (val != int_val);
+}
+
+  ~test ()
+{
+  if (!bool_val)
+   return;
+}
+
+  int get_int_val () const { return int_val; }
+
+ private:
+  bool bool_val;
+  int int_val;
+};
+
+static int __attribute__ ((noinline))
+f1 (int i, int *p)
+{
+  test obj (i, p);
+  return obj.get_int_val ();
+}
+
+static int __attribute__ ((noinline))
+f2 (int i, int *p)
+{
+  test obj (i, p);
+  return obj.get_int_val ();
+}
+
+int
+f (int i, int *p)
+{
+  return f1 (i, p) + f2 (i, p);
+}


[gomp4] Don't put acc_notify_var in thread-local struct

2014-10-28 Thread Julian Brown
Hi,

This patch moves acc_notify_var out of gomp_task_icv and makes it
simply a global variable instead.

OK for gomp4 branch?

Thanks,

Julian

ChangeLog

libgomp/
* env.c (goacc_notify_var): New.
(initialize_env): Use above instead of
gomp_global_icv.acc_notify_var.
* error.c (gomp_vnotify): Use goacc_notify_var.
(gomp_notify): Fix formatting.
* libgomp.h (gomp_task_icv): Remove acc_notify_var field.
(goacc_notify_var): Add extern declaration.commit 5b18c3e134779ee562af11702d2ba2c4baa66370
Author: Julian Brown 
Date:   Tue Oct 28 06:45:41 2014 -0700

acc_notify_var tweaks

diff --git a/libgomp/env.c b/libgomp/env.c
index 02bce0c..03206dd 100644
--- a/libgomp/env.c
+++ b/libgomp/env.c
@@ -79,6 +79,7 @@ unsigned long gomp_bind_var_list_len;
 void **gomp_places_list;
 unsigned long gomp_places_list_len;
 
+int goacc_notify_var;
 int goacc_device_num;
 char* goacc_device_type;
 
@@ -1196,7 +1197,7 @@ initialize_env (void)
   gomp_global_icv.thread_limit_var
 	= thread_limit_var > INT_MAX ? UINT_MAX : thread_limit_var;
 }
-  parse_int ("GCC_ACC_NOTIFY", &gomp_global_icv.acc_notify_var, true);
+  parse_int ("GCC_ACC_NOTIFY", &goacc_notify_var, true);
 #ifndef HAVE_SYNC_BUILTINS
   gomp_mutex_init (&gomp_managed_threads_lock);
 #endif
diff --git a/libgomp/error.c b/libgomp/error.c
index 5f400cc..320b4d2 100644
--- a/libgomp/error.c
+++ b/libgomp/error.c
@@ -76,13 +76,12 @@ gomp_fatal (const char *fmt, ...)
 void
 gomp_vnotify (const char *msg, va_list list)
 {
-  struct gomp_task_icv *icv = gomp_icv (false);
-  if (icv->acc_notify_var)
+  if (goacc_notify_var)
 vfprintf (stderr, msg, list);
 }
 
 void
-gomp_notify(const char *msg, ...)
+gomp_notify (const char *msg, ...)
 {
   va_list list;
   
diff --git a/libgomp/libgomp.h b/libgomp/libgomp.h
index 8b7327d..206b293 100644
--- a/libgomp/libgomp.h
+++ b/libgomp/libgomp.h
@@ -238,7 +238,6 @@ struct gomp_task_icv
   bool dyn_var;
   bool nest_var;
   char bind_var;
-  int acc_notify_var;
   /* Internal ICV.  */
   struct target_mem_desc *target_data;
 };
@@ -257,6 +256,7 @@ extern unsigned long gomp_bind_var_list_len;
 extern void **gomp_places_list;
 extern unsigned long gomp_places_list_len;
 
+extern int goacc_notify_var;
 extern int goacc_device_num;
 extern char* goacc_device_type;
 


[PATCH, Pointer Bounds Checker 40/x] Support in IPA ICF

2014-10-28 Thread Ilya Enkovich
Hi,

After recent merge with trunk I found that new IPA pass ICF requires few 
modifications for instrumented code:
 - instrumentation thunk existence means we cannot merge function into another 
one and should generate thunk instead
 - thunk generation should set with_bounds flag for instrumented funnctions
 - when DECL_INITIAL is cleaned for symbol, need_bounds_init should also be 
reset


Merge also required some minor changes in other patches due to changes 
includes, etc.  Nothing important to repost.

With these changes I get clean bootstrap and make check on linux-x86_64.  Also 
have clean runs of instrumented (run in NOP mode) and not isntrumented SPEC2000 
and SPEC2006.

I also tried to bootstrap it for Darwin but unfortunately trunk fails to 
bootstrap there even with patches from PR63534 applied.  Error is the same for 
mpx branch.

Thanks,
Ilya
--
2014-10-28  Ilya Enkovich  

* cgraphunit.c (cgraph_node::expand_thunk): Set with_bounds flag
for created call statement.
* ipa-icf.c (sem_function::merge): Do not merge when instrumentation
thunk still exists.
(sem_variable::merge): Reset need_bounds_init flag.


diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index f203f6d..c29e9aa 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1585,6 +1585,7 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool 
force_gimple_thunk)
   call = gimple_build_call_vec (build_fold_addr_expr_loc (0, alias), 
vargs);
   callees->call_stmt = call;
   gimple_call_set_from_thunk (call, true);
+  gimple_call_set_with_bounds (call, instrumentation_clone);
   if (restmp)
{
   gimple_call_set_lhs (call, restmp);
diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index e8c32c7..0ccda45 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -562,7 +562,8 @@ sem_function::merge (sem_item *alias_item)
   redirect_callers
= (!original_discardable
   && alias->get_availability () > AVAIL_INTERPOSABLE
-  && original->get_availability () > AVAIL_INTERPOSABLE);
+  && original->get_availability () > AVAIL_INTERPOSABLE
+  && !alias->instrumented_version);
 }
   else
 {
@@ -1177,6 +1178,7 @@ sem_variable::merge (sem_item *alias_item)
   alias->analyzed = false;
 
   DECL_INITIAL (alias->decl) = NULL;
+  alias->need_bounds_init = false;
   alias->remove_all_references ();
 
   varpool_node::create_alias (alias_var->decl, decl);


[gomp4] Remove redundant get_caps hook invocations

2014-10-28 Thread Julian Brown
Hi,

This patch causes the get_caps hook to be called only once during
device initialisation, and caches the result in the device's
"capabilities" field.

OK for gomp4 branch?

Thanks,

Julian

ChangeLog

libgomp/
* target.c (gomp_load_plugin_for_device): Only call get_caps once.
(gomp_find_available_plugins): ...and don't call it again here.commit 271ee70eec93866e312c7b9363cb0e736b6361d3
Author: Julian Brown 
Date:   Tue Oct 28 07:14:19 2014 -0700

Remove redundant get_caps calls.

diff --git a/libgomp/target.c b/libgomp/target.c
index 73a186b..615ba6b 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -1036,9 +1036,10 @@ gomp_load_plugin_for_device (struct gomp_device_descr *device,
   DLSYM (device_free);
   DLSYM (device_dev2host);
   DLSYM (device_host2dev);
-  if (device->get_caps_func () & TARGET_CAP_OPENMP_400)
+  device->capabilities = device->get_caps_func ();
+  if (device->capabilities & TARGET_CAP_OPENMP_400)
 DLSYM (device_run);
-  if (device->get_caps_func () & TARGET_CAP_OPENACC_200)
+  if (device->capabilities & TARGET_CAP_OPENACC_200)
 {
   optional_present = optional_total = 0;
   DLSYM_OPT (openacc.exec, openacc_parallel);
@@ -1167,7 +1168,6 @@ gomp_find_available_plugins (void)
 	  devicep->mem_map.is_initialized = false;
 	  devicep->type = devicep->get_type_func ();
 	  devicep->name = devicep->get_name_func ();
-	  devicep->capabilities = devicep->get_caps_func ();
 	  gomp_mutex_init (&devicep->mem_map.lock);
 	  devicep->ord = i;
 	  devicep->target_data = NULL;


[gomp4] Remove stray debugging code

2014-10-28 Thread Julian Brown
Hi,

This patch removes some debugging code leftover from development. It's
probably not helpful to keep it around now.

OK for gomp4 branch?

Thanks,

Julian

ChangeLog

libgomp/
* oacc-host.c (DEBUG): Remove undefine.
* plugin-nvptx.c (DEBUG, DISABLE_ASYNC): Remove comment-out macro
definitions.
* target.c (dump_mappings): Remove debugging function.commit 13794d26fc95225268e05abf9912ab6eba3c7b3f
Author: Julian Brown 
Date:   Tue Oct 28 06:49:19 2014 -0700

Remove stray debugging code

diff --git a/libgomp/oacc-host.c b/libgomp/oacc-host.c
index 6fe8f6c..fc3e77c 100644
--- a/libgomp/oacc-host.c
+++ b/libgomp/oacc-host.c
@@ -45,8 +45,6 @@
 #include 
 #include 
 
-#undef DEBUG
-
 #ifdef HOST_NONSHM_PLUGIN
 #define STATIC
 #define GOMP(X) GOMP_PLUGIN_##X
diff --git a/libgomp/plugin-nvptx.c b/libgomp/plugin-nvptx.c
index c5bdf73..8d040fe 100644
--- a/libgomp/plugin-nvptx.c
+++ b/libgomp/plugin-nvptx.c
@@ -30,9 +30,6 @@
is not clear as to what that state might be.  Or how one might
propagate it from one thread to another.  */
 
-//#define DEBUG
-//#define DISABLE_ASYNC
-
 #include "openacc.h"
 #include "config.h"
 #include "libgomp.h"
diff --git a/libgomp/target.c b/libgomp/target.c
index bce8ca6..73a186b 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -110,34 +110,6 @@ resolve_device (int device_id)
   return &devices[device_id];
 }
 
-__attribute__((used)) static void
-dump_mappings (FILE *f, splay_tree_node node)
-{
-  int i;
-  
-  splay_tree_key k = &node->key;
-  
-  if (!k)
-return;
-  
-  fprintf (f, "key %p: host_start %p, host_end %p, tgt_offset %p, refcount %d, "
-	   "copy_from %s\n", k, (void *) k->host_start,
-	   (void *) k->host_end, (void *) k->tgt_offset, (int) k->refcount,
-	   k->copy_from ? "true" : "false");
-  fprintf (f, "tgt->refcount %d, tgt->tgt_start %p, tgt->tgt_end %p, "
-	   "tgt->to_free %p, tgt->prev %p, tgt->list_count %d, "
-	   "tgt->device_descr %p\n", (int) k->tgt->refcount,
-	   (void *) k->tgt->tgt_start, (void *) k->tgt->tgt_end,
-	   k->tgt->to_free, k->tgt->prev, (int) k->tgt->list_count,
-	   k->tgt->device_descr);
-
-  for (i = 0; i < k->tgt->list_count; i++)
-fprintf (f, "item %d: %p\n", i, k->tgt->list[i]);
-  
-  dump_mappings (f, node->left);
-  dump_mappings (f, node->right);
-}
-
 /* Handle the case where splay_tree_lookup found oldn for newn.
Helper function of gomp_map_vars.  */
 


[gomp4] Remove gomp_map_vars mem_map argument

2014-10-28 Thread Julian Brown
Hi,

This patch removes the now-redundant gomp_memory_mapping argument from
gomp_map_vars, introduced when OpenACC kept the structure in question
in a different place from OpenMP. Both now keep the memory map in the
gomp_device_descr structure, so there's no need to pass both that and
the memory map to the function explicitly.

OK for gomp4 branch?

Thanks,

Julian

ChangeLog

libgomp/
* target.c (gomp_map_vars): Remove MM argument.
(GOMP_target, GOMP_target_data): Update calls to gomp_map_vars.
* oacc-mem.c (acc_map_data, present_create_copy): Update calls to
gomp_map_vars.
* oacc-parallel.c (GOACC_parallel, GOACC_data_start): Likewise.
* target.h (gomp_map_vars): Update prototype.commit 3afc4e592a6d8a796ec0c44bb8dc808b1392fd29
Author: Julian Brown 
Date:   Tue Oct 28 09:17:01 2014 -0700

Remove gomp_map_vars mem_map argument

diff --git a/libgomp/oacc-mem.c b/libgomp/oacc-mem.c
index d812f72..582a1e0 100644
--- a/libgomp/oacc-mem.c
+++ b/libgomp/oacc-mem.c
@@ -257,7 +257,7 @@ acc_map_data (void *h, void *d, size_t s)
   if (d != h)
 gomp_fatal ("cannot map data on shared-memory system");
 
-  tgt = gomp_map_vars (NULL, NULL, 0, NULL, NULL, NULL, NULL, true, false);
+  tgt = gomp_map_vars (NULL, 0, NULL, NULL, NULL, NULL, true, false);
 }
   else
 {
@@ -275,9 +275,8 @@ acc_map_data (void *h, void *d, size_t s)
 	gomp_fatal ("device address [%p, +%d] is already mapped", (void *)d,
 		(int)s);
 
-  tgt = gomp_map_vars ((struct gomp_device_descr *) acc_dev,
-			   &acc_dev->mem_map, mapnum, &hostaddrs,
-			   &devaddrs, &sizes, &kinds, true, false);
+  tgt = gomp_map_vars (acc_dev, mapnum, &hostaddrs, &devaddrs, &sizes,
+			   &kinds, true, false);
 }
 
   tgt->prev = acc_dev->openacc.data_environ;
@@ -383,9 +382,8 @@ present_create_copy (unsigned f, void *h, size_t s)
   else
 kinds = GOMP_MAP_ALLOC;
 
-  tgt = gomp_map_vars ((struct gomp_device_descr *) acc_dev,
-			   &acc_dev->mem_map, mapnum, &hostaddrs,
-			   NULL, &s, &kinds, true, false);
+  tgt = gomp_map_vars (acc_dev, mapnum, &hostaddrs, NULL, &s, &kinds, true,
+			   false);
 
   gomp_mutex_lock (&acc_dev->mem_map.lock);
 
diff --git a/libgomp/oacc-parallel.c b/libgomp/oacc-parallel.c
index b787df7..1639244 100644
--- a/libgomp/oacc-parallel.c
+++ b/libgomp/oacc-parallel.c
@@ -173,9 +173,8 @@ GOACC_parallel (int device, void (*fn) (void *), const void *openmp_target,
   else
 tgt_fn = (void (*)) fn;
 
-  tgt = gomp_map_vars ((struct gomp_device_descr *) acc_dev,
-		   &acc_dev->mem_map, mapnum, hostaddrs,
-		   NULL, sizes, kinds, true, false);
+  tgt = gomp_map_vars (acc_dev, mapnum, hostaddrs, NULL, sizes, kinds, true,
+		   false);
 
   devaddrs = alloca (sizeof (void *) * mapnum);
   for (i = 0; i < mapnum; i++)
@@ -217,7 +216,7 @@ GOACC_data_start (int device, const void *openmp_target, size_t mapnum,
   if ((acc_dev->capabilities & TARGET_CAP_SHARED_MEM)
   || !if_clause_condition_value)
 {
-  tgt = gomp_map_vars (NULL, NULL, 0, NULL, NULL, NULL, NULL, true, false);
+  tgt = gomp_map_vars (NULL, 0, NULL, NULL, NULL, NULL, true, false);
   tgt->prev = thr->mapped_data;
   thr->mapped_data = tgt;
 
@@ -225,9 +224,8 @@ GOACC_data_start (int device, const void *openmp_target, size_t mapnum,
 }
 
   gomp_notify ("  %s: prepare mappings\n", __FUNCTION__);
-  tgt = gomp_map_vars ((struct gomp_device_descr *) acc_dev,
-		   &acc_dev->mem_map, mapnum, hostaddrs,
-		   NULL, sizes, kinds, true, false);
+  tgt = gomp_map_vars (acc_dev, mapnum, hostaddrs, NULL, sizes, kinds, true,
+		   false);
   gomp_notify ("  %s: mappings prepared\n", __FUNCTION__);
   tgt->prev = thr->mapped_data;
   thr->mapped_data = tgt;
diff --git a/libgomp/target.c b/libgomp/target.c
index 615ba6b..507488e 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -134,14 +134,14 @@ get_kind (bool is_openacc, void *kinds, int idx)
 }
 
 attribute_hidden struct target_mem_desc *
-gomp_map_vars (struct gomp_device_descr *devicep,
-	   struct gomp_memory_mapping *mm, size_t mapnum,
-	   void **hostaddrs, void **devaddrs, size_t *sizes,
-	   void *kinds, bool is_openacc, bool is_target)
+gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum,
+	   void **hostaddrs, void **devaddrs, size_t *sizes, void *kinds,
+	   bool is_openacc, bool is_target)
 {
   size_t i, tgt_align, tgt_size, not_found_cnt = 0;
   const int rshift = is_openacc ? 8 : 3;
   const int typemask = is_openacc ? 0xff : 0x7;
+  struct gomp_memory_mapping *mm = &devicep->mem_map;
   struct splay_tree_key_s cur_node;
   struct target_mem_desc *tgt
 = gomp_malloc (sizeof (*tgt) + sizeof (tgt->list[0]) * mapnum);
@@ -861,8 +861,8 @@ GOMP_target (int device, void (*fn) (void *), const void *openmp_target,
   gomp_mutex_unlock (&mm->lock);
 
   struct target_mem_desc *tgt_vars
-= gomp_map_vars (devicep, &devicep->mem_map, mapnum, ho

Re: [gomp4] Remove gomp_map_vars mem_map argument

2014-10-28 Thread Julian Brown
On Tue, 28 Oct 2014 16:52:22 +
Julian Brown  wrote:

> Hi,
> 
> This patch removes the now-redundant gomp_memory_mapping argument from
> gomp_map_vars, introduced when OpenACC kept the structure in question
> in a different place from OpenMP. Both now keep the memory map in the
> gomp_device_descr structure, so there's no need to pass both that and
> the memory map to the function explicitly.
> 
> OK for gomp4 branch?

Forgot to say: this patch and the previous three have been tested with
no regressions (alongside a version of Bernd's PTX support patches) on
the gomp4 branch (libgomp tests).

Julian


RE: [PATCHv2][MIPS] Implement O32 ABI extensions (GCC)

2014-10-28 Thread Matthew Fortune
Moore, Catherine  writes:
> Review comments are attached.  I will tackle the R6 patch next.
> Thanks,
> Catherine

Thanks Catherine. Depending on whether the fix to the following
hunk needs discussion I'll make the changes and commit.

>> static bool
>> mips_function_value_regno_p (const unsigned int regno)
>> {
>>   if (regno == GP_RETURN
>>   || regno == FP_RETURN
>>+  || regno == FP_RETURN + 2
>>   || (LONG_DOUBLE_TYPE_SIZE == 128
>>&& FP_RETURN != GP_RETURN
>>&& regno == FP_RETURN + 2))
>> return true;
>> 
>  Is this right? I'm  not following the intent of this modification.

The intent is to cover the complex return case where both FP_RETURN
and FP_RETURN+2 are used to return the real and imaginary parts of
_Complex float. The hunk which follows then deals with the
_Complex double case where the corresponding odd numbered registers
are also used for FP32. What I noticed when you first pointed me
at this code on IRC was that the new condition leads to the
pre-existing LONG_DOUBLE_TYPE_SIZE condition being redundant so
should be removed I think. I just want to re-read how these functions
are used to reassure myself this is all correct.

I'll also check on whether o32 or O32 is the consistent name and
change appropriately.

For the R6 patch. I will be rebasing and updating that patch following
submission of FPXX but the only significant fix it needs relates to
allowing the use of DSP with R6. That will affect the conditions on
a few patterns and some of the expand code. A general read through the
current patch on the list wouldn't be wasted though.

Thanks,
Matthew


Re: [gofrontend-dev] [PATCH 7/9] Gccgo port to s390[x] -- part I

2014-10-28 Thread Ian Taylor
On Tue, Oct 28, 2014 at 7:31 AM, Dominik Vogt  wrote:
>
> The attached patch contains all the discussed changes.

I made a few formatting changes.  I patched the test to work on x86,
by making the char types accept either int8 or uint8, and making the
long double tests accept any floating point size.

Approved and applied as attached.

Thanks.

Ian


gcc/:
2014-10-28  Dominik Vogt  

* godump.c (precision_to_units): New helper function.
(go_append_artificial_name): Ditto.
(go_append_decl_name): Ditto.
(go_append_bitfield): Ditto.
(go_get_uinttype_for_precision): Ditto.
(go_append_padding): Ditto.
(go_force_record_alignment): Ditto.
(go_format_type): Represent unions with an array of uints of the size
of the alignment in go.  This fixes the 'random' size of the union's
representation using just the first field.
(go_format_type): Add argument that indicates whether a record is
nested (used for generation of artificial go names).
(go_output_fndecl): Adapt to new go_format_type signature.
(go_output_typedef): Ditto.
(go_output_var): Ditto.
(go_output_var): Prefer to output type as alias (typedef).
(go_format_type): Bitfields in records are simulated as arrays of bytes
in go.

* godump.c (go_format_type): Fix handling of arrays with zero elements.


gcc/testsuite/:
2014-10-28  Dominik Vogt  

* gcc.misc-tests/godump.exp: New.
* gcc.misc-tests/godump-1.c: New.
Index: godump.c
===
--- godump.c(revision 216766)
+++ godump.c(working copy)
@@ -37,6 +37,8 @@ along with GCC; see the file COPYING3.
 #include "obstack.h"
 #include "debug.h"
 #include "wide-int-print.h"
+#include "stor-layout.h"
+#include "defaults.h"
 
 /* We dump this information from the debug hooks.  This gives us a
stable and maintainable API to hook into.  In order to work
@@ -73,6 +75,15 @@ struct macro_hash_value
   char *value;
 };
 
+/* Returns the number of units necessary to represent an integer with the given
+   PRECISION (in bits).  */
+
+static inline unsigned int
+precision_to_units (unsigned int precision)
+{
+  return (precision + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
+}
+
 /* Calculate the hash value for an entry in the macro hash table.  */
 
 static hashval_t
@@ -552,19 +563,132 @@ go_append_string (struct obstack *ob, tr
   obstack_grow (ob, IDENTIFIER_POINTER (id), IDENTIFIER_LENGTH (id));
 }
 
+/* Given an integer PRECISION in bits, returns a constant string that is the
+   matching go int or uint type (depending on the IS_UNSIGNED flag).  Returns a
+   NULL pointer if there is no matching go type.  */
+
+static const char *
+go_get_uinttype_for_precision (unsigned int precision, bool is_unsigned)
+{
+  switch (precision)
+{
+case 8:
+  return is_unsigned ? "uint8" : "int8";
+case 16:
+  return is_unsigned ? "uint16" : "int16";
+case 32:
+  return is_unsigned ? "uint32" : "int32";
+case 64:
+  return is_unsigned ? "uint64" : "int64";
+default:
+  return NULL;
+}
+}
+
+/* Append an artificial variable name with the suffix _INDEX to OB.  Returns
+   INDEX + 1.  */
+
+static unsigned int
+go_append_artificial_name (struct obstack *ob, unsigned int index)
+{
+  char buf[100];
+
+  /* FIXME: identifier may not be unique.  */
+  obstack_grow (ob, "Godump_", 7);
+  snprintf (buf, sizeof buf, "%u", index);
+  obstack_grow (ob, buf, strlen (buf));
+
+  return index + 1;
+}
+
+/* Append the variable name from DECL to OB.  If the name is in the
+   KEYWORD_HASH, prepend an '_'.  */
+
+static void
+go_append_decl_name (struct obstack *ob, tree decl, htab_t keyword_hash)
+{
+  const char *var_name;
+  void **slot;
+
+  /* Start variable name with an underscore if a keyword.  */
+  var_name = IDENTIFIER_POINTER (DECL_NAME (decl));
+  slot = htab_find_slot (keyword_hash, var_name, NO_INSERT);
+  if (slot != NULL)
+obstack_1grow (ob, '_');
+  go_append_string (ob, DECL_NAME (decl));
+}
+
+/* Appends a byte array with the necessary number of elements and the name
+   "Godump_INDEX_pad" to pad from FROM_OFFSET to TO_OFFSET to OB assuming that
+   the next field is automatically aligned to ALIGN_UNITS.  Returns INDEX + 1,
+   or INDEX if no padding had to be appended.  The resulting offset where the
+   next field is allocated is returned through RET_OFFSET.  */
+
+static unsigned int
+go_append_padding (struct obstack *ob, unsigned int from_offset,
+  unsigned int to_offset, unsigned int align_units,
+  unsigned int index, unsigned int *ret_offset)
+{
+  if (from_offset % align_units > 0)
+from_offset += align_units - (from_offset % align_units);
+  gcc_assert (to_offset >= from_offset);
+  if (to_offset > from_offset)
+{
+  char buf[100];
+
+  index = go_append_artificial_name (ob, index);
+  snprintf (buf,

Re: [debug-early] emit locals early patchset

2014-10-28 Thread Jason Merrill

On 10/27/2014 08:00 PM, Aldy Hernandez wrote:

2. Changes to gen_variable_die() to handle multiple passes (early/late
dwarf generation).

A lot of this is complicated by the fact that old_die's are cached and
keyed by `tree', but an abstract instance and an inline instance share
trees, while dwarf2out_abstract_function() sets DECL_ABSTRACT_P behind
the scenes.

The current support (and my changes) maintain this shared and delicate
design.  I wonder whether we could simplify a lot of this code by
unsharing these trees, but this may be beyond the scope of this work.


Copying all the trees in a function just for debug generation?  No, that 
sounds undesirable.



3. I've removed deferred_locations.  With multiple dwarf passes we can
do without them.


Yay!


Kind words greatly appreciated.  Basically I'm looking for feedback and 
positive reinforcement that this is all eventually useful


This all looks very good, just a few nitpicks:


- instance tree [that has DW_AT_inline] should not contain any
+ instance tree [has DW_AT_inline] should not contain any


This doesn't seem like an improvement.


+  /* Find and reuse a previously generated DW_TAG_subrange_type if
+available.  */


Let's expand this comment a bit to clarify how this works for 
multi-dimensional arrays.



- abstract instance (origin != NULL), in which case we need a new
+ inline instance (origin != NULL), in which case we need a new DIE


I think "concrete instance" is what you want here.


+ /* Even if we have locations, we need to recurse through
+the locals to make sure they also have locations.  */


Why?  What is adding a location to the function without doing the same 
for the locals?



+  current_function_has_inlines = 0;
+
+  /* The first time through decls_for_scope we will generate the
+DIEs for the locals.  The second time, we fill in the
+location info.  */
+  decls_for_scope (outer_scope, subr_die, 0);
+
   /* Emit a DW_TAG_variable DIE for a named return value.  */
   if (DECL_NAME (DECL_RESULT (decl)))
gen_decl_die (DECL_RESULT (decl), NULL, subr_die);

-  current_function_has_inlines = 0;
-  decls_for_scope (outer_scope, subr_die, 0);


Why does this need to be reordered?


+  /* If the compiler emitted a definition for the DECL declaration
+ and we already emitted a DIE for it, don't emit a second
+ DIE for it again. Allow re-declarations of DECLs that are
+ inside functions, though.  */
+  else if (old_die && !declaration && !local_scope_p (context_die))
+return;


What DECLs in functions need re-declaration?


-  if (decl && (DECL_ABSTRACT_P (decl) || declaration || old_die == NULL))
+  if (decl && (DECL_ABSTRACT_P (decl) || declaration || old_die == NULL
+  /* If we make it to a specialization, we have already
+ handled the declaration by virtue of early dwarf.
+ If so, make a new assocation if available, so late
+ dwarf can find it.  */
+  || (specialization_p && old_die && old_die->dumped_early)))
 equate_decl_number_to_die (decl, var_die);


Instead of old_die->dumped_early, I think it would make more sense to 
check early_dwarf_dumping; the reason we need to call 
equate_decl_number_to_die is because we're early-dumping the definition 
and we will need to find it again later.



+  else if (BLOCK_ABSTRACT_ORIGIN (stmt))
 {
+  /* If this is an inlined instance, create a new lexical die for
+anything below to attach DW_AT_abstract_origin to.  */
+  stmt_die = new_die (DW_TAG_lexical_block, context_die, stmt);
+}


What if we early dumped this block?


+  /* Variabled-lengthed types may be incomplete even if
+TREE_ASM_WRITTEN.


"variable-length", I think.

Jason



Re: [PATCH 5/5] add libcc1

2014-10-28 Thread Phil Muldoon
On 28/10/14 13:19, Joseph S. Myers wrote:
> I'm seeing a different bootstrap failure from those already discussed:
>
> In file included from
> /scratch/jmyers/fsf/gcc-mainline/libcc1/../gcc/gcc-plugin.h:28:0,
>  from
> /scratch/jmyers/fsf/gcc-mainline/libcc1/plugin.cc:34:
> /scratch/jmyers/fsf/gcc-mainline/libcc1/../gcc/system.h:653:17: fatal error: 
> gmp.h: No such file or directory
>
> It appears the build is ignoring the --with-gmp option passed to
> configure.  Since  is included in system.h, if you include system.h
> you have to pass the right -I option corresponding to --with-gmp /
> --with-gmp-include.  (There are several other such configure options for
> MPFR, MPC, CLooG, ISL, libiconv at least - whether they are relevant
> depends on whether your code ends up including the relevant headers.)

Joseph,

Hi, sorry for the troubles! I am having difficulty seeing this fail on
my system.  I built gmp from upstream, installed it, and pointed to
the install location with --with-gmp. Which stage does your build fail
at?

I am actually not totally sure how to respect the -with-gmp argument
in libcc1.  auto* tools are not my strongest skill. ;)

I notice gcc/configure.ac I think just exports the variables to
Makefile.in from the main configure script.  That what we should do in
this case?

Cheers

Phil




Re: [debug-early] emit locals early patchset

2014-10-28 Thread Aldy Hernandez

On 10/28/14 07:40, Michael Matz wrote:

Hi,

On Mon, 27 Oct 2014, Aldy Hernandez wrote:


Here I use a new tree bit (BLOCK_DIE) to store the DIE<->block
relationship. This will have to be adapted and streamed for LTO.


You might consider using an on-the-side tree->hash map.  Saves memory when
not generating debug info (there can be many BLOCKs).


This is a very good point.  I need to revisit all the data structures 
that will be affected by LTO, and will do so then.


FWIW, I'm going on vacation for a few weeks, so this project will come 
to a complete stop for a bit.  Unless anyone wants to contribute patches 
while I'm gone ;-).



Kind words greatly appreciated.  Basically I'm looking for feedback and
positive reinforcement that this is all eventually useful :).


I think that goes exactly in the right direction, FWIW.


Whoo hoo!  Thanks.

Aldy



libgo patch committed: Add consts for ioctl

2014-10-28 Thread Ian Taylor
This patch from Lynn Boger ensures that some ioctl constants are
available on more systems.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff -r ec3c929aae72 libgo/mksysinfo.sh
--- a/libgo/mksysinfo.shTue Oct 28 10:34:18 2014 -0700
+++ b/libgo/mksysinfo.shTue Oct 28 11:16:30 2014 -0700
@@ -174,6 +174,9 @@
 #ifdef TIOCGWINSZ
   TIOCGWINSZ_val = TIOCGWINSZ,
 #endif
+#ifdef TIOCSWINSZ
+  TIOCSWINSZ_val = TIOCSWINSZ,
+#endif
 #ifdef TIOCNOTTY
   TIOCNOTTY_val = TIOCNOTTY,
 #endif
@@ -192,6 +195,12 @@
 #ifdef TIOCSIG
   TIOCSIG_val = TIOCSIG,
 #endif
+#ifdef TCGETS
+  TCGETS_val = TCGETS,
+#endif
+#ifdef TCSETS
+  TCSETS_val = TCSETS,
+#endif
 };
 EOF
 
@@ -790,6 +799,11 @@
 echo 'const TIOCGWINSZ = _TIOCGWINSZ_val' >> ${OUT}
   fi
 fi
+if ! grep '^const TIOCSWINSZ' ${OUT} >/dev/null 2>&1; then
+  if grep '^const _TIOCSWINSZ_val' ${OUT} >/dev/null 2>&1; then
+echo 'const TIOCSWINSZ = _TIOCSWINSZ_val' >> ${OUT}
+  fi
+fi
 if ! grep '^const TIOCNOTTY' ${OUT} >/dev/null 2>&1; then
   if grep '^const _TIOCNOTTY_val' ${OUT} >/dev/null 2>&1; then
 echo 'const TIOCNOTTY = _TIOCNOTTY_val' >> ${OUT}
@@ -822,8 +836,18 @@
 fi
 
 # The ioctl flags for terminal control
-grep '^const _TC[GS]ET' gen-sysinfo.go | \
+grep '^const _TC[GS]ET' gen-sysinfo.go | grep -v _val | \
 sed -e 's/^\(const \)_\(TC[GS]ET[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
+if ! grep '^const TCGETS' ${OUT} >/dev/null 2>&1; then
+  if grep '^const _TCGETS_val' ${OUT} >/dev/null 2>&1; then
+echo 'const TCGETS = _TCGETS_val' >> ${OUT}
+  fi
+fi
+if ! grep '^const TCSETS' ${OUT} >/dev/null 2>&1; then
+  if grep '^const _TCSETS_val' ${OUT} >/dev/null 2>&1; then
+echo 'const TCSETS = _TCSETS_val' >> ${OUT}
+  fi
+fi
 
 # ioctl constants.  Might fall back to 0 if TIOCNXCL is missing, too, but
 # needs handling in syscalls.exec.go.


Re: [PATCH, x86, 63534] Fix '-p' profile for 32 bit PIC mode

2014-10-28 Thread Jakub Jelinek
On Tue, Oct 28, 2014 at 06:28:29PM +0300, Evgeny Stupachenko wrote:

> +/* Delete SET_GOT right after entry block if it is allocated to reg.  */
> +
> +static void
> +ix86_elim_entry_set_got (rtx reg)
> +{
> +  basic_block bb = ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb;
> +  rtx_insn *c_insn;
> +  FOR_BB_INSNS (bb, c_insn)
> +if (GET_CODE (c_insn) != NOTE)
> +  break;

This might result in -fcompare-debug failure, if there is
a DEBUG_INSN before the UNSPEC_SET_GOT.  Also, if the first bb
contains only NOTE insns, you'd crash.
I'd use instead:
  rtx_insn *c_insn = BB_HEAD (bb);
  if (!NONDEBUG_INSN_P (c_insn))
c_insn = next_nonnote_nondebug_insn (c_insn);
  if (c_insn && NONJUMP_INSN_P (c_insn))
or so.

> +  if (NONJUMP_INSN_P (c_insn))

> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/mcount_pic.c
> @@ -0,0 +1,13 @@
> +/* Test check correct mcount generation.  */
> +/* { dg-do run } */
> +/* { dg-require-effective-target ia32 } */
> +/* { dg-options "-O2 -fpic -p -save-temps" } */

Please put the PR also in the testcase comment.
And, -fpic needs to be guarded by { target fpic }, though
as get_pc_thunk will not appear in non-pic code, I think
you want /* { dg-do run { target fpic } } */.

Otherwise LGTM.

Jakub


[gimple-classes] Merge trunk r216157-r216746 into branch

2014-10-28 Thread David Malcolm
Merger of changes on trunk from r216157 (2014-10-13) to
r216746 (2014-10-27) into the dmalcolm/gimple-classes branch.

I committed this in two parts: the basic merger:
  1a7adffe0f7c9be5b48042c27bc6cddece467da9
resolving minor conflicts in these files:
gcc/builtins.h
gcc/tree-ssa-loop-ivcanon.c
gcc/value-prof.c
gcc/value-prof.h
then a followup that fixes the build:
  e74b2ecd78d21fc7bcc2f50dacc92819e0e69e6b

Successfully bootstrapped®rtested on x86_64-unknown-linux-gnu
(Fedora 20) - same results relative to an unpatched control bootstrap of
trunk's r216157.

Here's the latter commit:

gcc/ChangeLog.gimple-classes:
* auto-profile.c (autofdo::function_instance::find_icall_target_map):
Strengthen param "stmt" from gimple to gcall *.
(autofdo::autofdo_source_profile::update_inlined_ind_target):
Likewise.
(autofdo::afdo_indirect_call): Rename local gimple "stmt" to "gs",
reintroducing "stmt" as a gcall * via a dyn_cast once we've
established that we have a GIMPLE_CALL.
(autofdo::afdo_set_bb_count): Use a gphi_iterator for the phi
iteration, renaming it from "gsi" to "gpi", strengthening
local "phi" from gimple to gphi *.
(autofdo::afdo_propagate_circuit): Rename local gimple "phi_stmt"
to "def_stmt".  Reintroduce "phi_stmt" as a gphi * via a dyn_cast
once we know we have a GIMPLE_PHI.
(autofdo::afdo_vpt_for_early_inline): Strengthen local "stmt" from
gimple to gcall *, using a dyn_cast.
* gimple-fold.c (replace_stmt_with_simplification): Replace check
against GIMPLE_COND with a dyn_cast , introducing local
"cond_stmt".  Use "cond_stmt" in place of "stmt" for typesafety.
* gimple-iterator.h (gsi_next_nonvirtual_phi): Strengthen param
from gimple_stmt_iterator * to gphi_iterator *, and local "phi"
from gimple to gphi *.
* ipa-icf-gimple.c (ipa_icf_gimple::func_checker::parse_labels):
Replace check against GIMPLE_LABEL with a dyn_cast ,
introducing local "label_stmt".  Use it in place of "stmt" for
typesafety.
(ipa_icf_gimple::func_checker::compare_bb): Add checked casts
to appropriate gimple subclasses when invoking comparison methods
within the cases for GIMPLE_SWITCH, GIMPLE_RESX, GIMPLE_LABEL,
GIMPLE_RETURN, GIMPLE_ASM.
(ipa_icf_gimple::func_checker::compare_gimple_label): Strengthen
both params from gimple to const glabel *.
(ipa_icf_gimple::func_checker::compare_gimple_switch): Strengthen
both params from gimple to const gswitch *.
(ipa_icf_gimple::func_checker::compare_gimple_return): Strengthen
both params from gimple to const greturn *.
(ipa_icf_gimple::func_checker::compare_gimple_resx): Strengthen
both params from gimple to const gresx *.
(ipa_icf_gimple::func_checker::compare_gimple_asm): Strengthen
both params from gimple to const gasm *.
* ipa-icf-gimple.h (ipa_icf_gimple::func_checker::compare_gimple_label):
Strengthen both params from gimple to const glabel *.
(ipa_icf_gimple::func_checker::compare_gimple_switch): Strengthen
both params from gimple to const gswitch *.
(ipa_icf_gimple::func_checker::compare_gimple_return): Strengthen
both params from gimple to const greturn *.
(ipa_icf_gimple::func_checker::compare_gimple_resx): Strengthen
both params from gimple to const gresx *.
(ipa_icf_gimple::func_checker::compare_gimple_asm): Strengthen
both params from gimple to const gasm *.
* ipa-icf.c (ipa_icf_gimple::sem_function::compare_phi_node):
Strengthen locals "si1" and "si2" from gimple_stmt_iterator to
gphi_iterator, and locals "phi1" and "phi2" from gimple to gphi *.
* tree-ssa-forwprop.c (fold_all_stmts): Replace check against
GIMPLE_COND with a dyn_cast , introducing local
"cond_stmt".  Use "cond_stmt" in place of "stmt" for typesafety.
* tree-ssa-reassoc.c (branch_fixup): Strengthen local "phi" from
gimple to gphi *.
---
 gcc/ChangeLog.gimple-classes | 60 
 gcc/auto-profile.c   | 43 ++-
 gcc/gimple-fold.c| 12 -
 gcc/gimple-iterator.h|  8 +++---
 gcc/ipa-icf-gimple.c | 37 +++
 gcc/ipa-icf-gimple.h | 21 
 gcc/ipa-icf.c|  8 +++---
 gcc/tree-ssa-forwprop.c  |  8 +++---
 gcc/tree-ssa-reassoc.c   |  2 +-
 9 files changed, 136 insertions(+), 63 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index aec5065..133965c 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,3 +1,63 @@
+2014-10-28  David Malcolm  
+
+   * auto-profile.c (autofdo::function_instance::find_icall_target_ma

Re: [gimple-classes] Merge trunk r216157-r216746 into branch

2014-10-28 Thread David Malcolm
On Tue, 2014-10-28 at 14:47 -0400, David Malcolm wrote:
> Merger of changes on trunk from r216157 (2014-10-13) to
> r216746 (2014-10-27) into the dmalcolm/gimple-classes branch.
 
[...]
> Successfully bootstrapped®rtested on x86_64-unknown-linux-gnu
> (Fedora 20) - same results relative to an unpatched control bootstrap of
> trunk's r216157.
  ^^^
This should have read r216746; sorry - i.e. the control build was the
version of trunk that I merged into the branch.

[...]



Re: [gomp4] Don't put acc_notify_var in thread-local struct

2014-10-28 Thread Thomas Schwinge
Hi Julian!

On Tue, 28 Oct 2014 16:37:29 +, Julian Brown  
wrote:
> This patch moves acc_notify_var out of gomp_task_icv and makes it
> simply a global variable instead.
> 
> OK for gomp4 branch?

Yes, thanks!

> libgomp/
> * env.c (goacc_notify_var): New.
> (initialize_env): Use above instead of
> gomp_global_icv.acc_notify_var.
> * error.c (gomp_vnotify): Use goacc_notify_var.
> (gomp_notify): Fix formatting.
> * libgomp.h (gomp_task_icv): Remove acc_notify_var field.
> (goacc_notify_var): Add extern declaration.


Grüße,
 Thomas


pgpYqkcpSsouA.pgp
Description: PGP signature


Re: [gomp4] Remove redundant get_caps hook invocations

2014-10-28 Thread Thomas Schwinge
Hi Julian!

On Tue, 28 Oct 2014 16:40:31 +, Julian Brown  
wrote:
> This patch causes the get_caps hook to be called only once during
> device initialisation, and caches the result in the device's
> "capabilities" field.
> 
> OK for gomp4 branch?

Yes, thanks!  I think such patches you can also apply without pre-commit
review, on a "obvious" basis.

> libgomp/
> * target.c (gomp_load_plugin_for_device): Only call get_caps once.
> (gomp_find_available_plugins): ...and don't call it again here.


Grüße,
 Thomas


pgpQ7qM5sO9Zv.pgp
Description: PGP signature


Re: [PATCH 2/n] OpenMP 4.0 offloading infrastructure: LTO streaming

2014-10-28 Thread Ilya Verbin
On 24 Oct 16:20, Jakub Jelinek wrote:
> Can't you do that when creating the cgraph or varpool nodes?
> I'd expect the attribute to be already present on the decls at those spots.

I cached "omp declare target" attribute in a symtab node.  Is this patch better?
OpenMP tests passed, make check in progress.

Thanks,
  -- Ilya


gcc/
* cgraph.c: Include context.h.
(cgraph_node::create): Set node->offloadable and g->have_offload if
decl have "omp declare target" attribute.
* cgraph.h (symtab_node): Add need_lto_streaming and offloadable flags.
* cgraphunit.c: Include lto-section-names.h.
(ipa_passes): Call ipa_write_summaries if there is something to write to
OFFLOAD_SECTION_NAME_PREFIX sections.
(symbol_table::compile): Set flag_generate_lto if there is something to
offload.
Replace flag_lto with flag_generate_lto before lto_streamer_hooks_init.
* context.c (gcc::context::context): Initialize have_offload with false.
* context.h (class context): Add have_offload flag.
* ipa-inline-analysis.c (inline_generate_summary): Do not exit under
flag_generate_lto.
(inline_free_summary): Always remove hooks.
* lto-cgraph.c (referenced_from_other_partition_p): Ignore references
from non-offloadable nodes while streaming a node into offload section.
(reachable_from_other_partition_p): Likewise.
(select_what_to_stream): New function.
(compute_ltrans_boundary): Do not call
lto_set_symtab_encoder_in_partition if the node should not be streamed.
* lto-section-names.h (OFFLOAD_SECTION_NAME_PREFIX): Define.
(section_name_prefix): Declare.
* lto-streamer.c (section_name_prefix): New variable.
(lto_get_section_name): Use section_name_prefix instead of
LTO_SECTION_NAME_PREFIX.
* lto-streamer.h (select_what_to_stream): Declare.
* omp-low.c: Include context.h.
(is_targetreg_ctx): New function.
(create_omp_child_function, check_omp_nesting_restrictions): Use it.
Replace usage of "omp declare target" attribute with a cgraph_node flag
offloadable.
(expand_omp_target): Set mark_force_output for the offloaded functions.
(lower_omp_critical): Set offloadable flag for omp critical symbol.
* passes.c (ipa_write_summaries): New argument offload_lto_mode.  Call
select_what_to_stream.  Do not call lto_set_symtab_encoder_in_partition
if the node should not be streamed out.
* tree-pass.h (ipa_write_summaries): New bool argument.
* varpool.c: Include context.h.
(varpool_node::get_create): Set node->offloadable and g->have_offload if
decl have "omp declare target" attribute.
gcc/lto/
* lto-object.c (lto_obj_add_section): Use section_name_prefix instead of
LTO_SECTION_NAME_PREFIX.
* lto-partition.c (lto_promote_cross_file_statics): Call
select_what_to_stream.
* lto.c (lto_section_with_id): Use section_name_prefix instead of
LTO_SECTION_NAME_PREFIX.
(read_cgraph_and_symbols): Read OFFLOAD_SECTION_NAME_PREFIX sections, if
being built as an offload compiler.

---

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 9a47ba2..27aad73 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -70,6 +70,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-dfa.h"
 #include "profile.h"
 #include "params.h"
+#include "context.h"
 
 /* FIXME: Only for PROP_loops, but cgraph shouldn't have to know about this.  
*/
 #include "tree-pass.h"
@@ -474,6 +475,13 @@ cgraph_node::create (tree decl)
   gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
 
   node->decl = decl;
+
+  if (lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl)))
+{
+  node->offloadable = 1;
+  g->have_offload = true;
+}
+
   node->register_symbol ();
 
   if (DECL_CONTEXT (decl) && TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL)
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 377adce..4988f2d 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -463,6 +463,13 @@ public:
   /* Set when init priority is set.  */
   unsigned in_init_priority_hash : 1;
 
+  /* Set when symbol needs to be streamed into LTO bytecode for LTO, or in case
+ of offloading, for separate compilation for a different target.  */
+  unsigned need_lto_streaming : 1;
+
+  /* Set when symbol can be streamed into bytecode for offloading.  */
+  unsigned offloadable : 1;
+
 
   /* Ordering of all symtab entries.  */
   int order;
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 3e76bf0..50ab2bc 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -218,6 +218,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-nested.h"
 #include "gimplify.h"
 #include "dbgcnt.h"
+#include "lto-section-names.h"
 
 /* Queue of cgraph nodes scheduled to be added into cgraph.  This is a
secondary queue used d

Re: [gomp4] Remove stray debugging code

2014-10-28 Thread Thomas Schwinge
Hi Julian!

On Tue, 28 Oct 2014 16:43:11 +, Julian Brown  
wrote:
> This patch removes some debugging code leftover from development. It's
> probably not helpful to keep it around now.

Agreed.  It remains available in the revision control system, but I've
found that typically you'll need your own, bespoke debugging code anyway.
Or, :-) use GDB's dprintf!)

> OK for gomp4 branch?

Yes, thanks!  (Again, "obvious".)

> libgomp/
> * oacc-host.c (DEBUG): Remove undefine.
> * plugin-nvptx.c (DEBUG, DISABLE_ASYNC): Remove comment-out macro
> definitions.
> * target.c (dump_mappings): Remove debugging function.


Grüße,
 Thomas


pgp5UzzDJ6gK2.pgp
Description: PGP signature


Re: [gomp4] Remove gomp_map_vars mem_map argument

2014-10-28 Thread Thomas Schwinge
Hi Julian!

On Tue, 28 Oct 2014 16:52:22 +, Julian Brown  
wrote:
> This patch removes the now-redundant gomp_memory_mapping argument from
> gomp_map_vars, introduced when OpenACC kept the structure in question
> in a different place from OpenMP. Both now keep the memory map in the
> gomp_device_descr structure, so there's no need to pass both that and
> the memory map to the function explicitly.

Makes sense.

> OK for gomp4 branch?

Yes, thanks!  (But I have not reviewed this code/change in detail.)

> libgomp/
> * target.c (gomp_map_vars): Remove MM argument.
> (GOMP_target, GOMP_target_data): Update calls to gomp_map_vars.
> * oacc-mem.c (acc_map_data, present_create_copy): Update calls to
> gomp_map_vars.
> * oacc-parallel.c (GOACC_parallel, GOACC_data_start): Likewise.
> * target.h (gomp_map_vars): Update prototype.


Grüße,
 Thomas


pgp0EdBuF4unl.pgp
Description: PGP signature


[gomp4] Synchronous mode? (was: [1/3] OpenACC 2.0 support for libgomp - OpenACC runtime, NVidia PTX/CUDA plugin)

2014-10-28 Thread Thomas Schwinge
Hi!

One remark here, not related to the patch itself:

On Tue, 14 Oct 2014 17:11:18 +0100, Julian Brown  
wrote:
> --- /dev/null
> +++ b/libgomp/plugin-nvptx.c

> +//#define DISABLE_ASYNC

> +#ifndef DISABLE_ASYNC
> +  [...]
> +#else
> +  r = cuCtxSynchronize ();
> +  if (r != CUDA_SUCCESS)
> +gomp_plugin_fatal ("cuCtxSynchronize error: %s", cuErrorMsg (r));
> +#endif

Earlier on, in discussion with Jim, we wondered whether it'd make sense
to expose the synchronous mode to the user (via an environment
variable?), which may help them when debugging?  This is not a priority
right now, but perhaps something to keep in mind for later on.


Grüße,
 Thomas


pgpbXGdParY9j.pgp
Description: PGP signature


Re: [gomp4] Remove goacc_parse_device_num

2014-10-28 Thread Thomas Schwinge
Hi Julian!

On Tue, 28 Oct 2014 13:19:18 +, Julian Brown  
wrote:
> This patch removes the goacc_parse_device_num function in libgomp's
> env.c since it is redundant with parse_int. I also added some bounds
> checking for the device number in oacc-init.c (the behaviour is left as
> "implementation defined" in the OpenACC 2.0 spec, so I chose to raise
> an error for an out-of-range device number).

I'd encourage to put such a comment into the source code, and/or into the
manual.

> OK for gomp4 branch?

Yes, thanks!

> libgomp/
> * env.c (goacc_parse_device_num): Remove.
> (initialize_env): Use parse_int instead of goacc_parse_device_num.
> * oacc-init.c (lazy_open): Add bounds check for device number.


Grüße,
 Thomas


pgpzbjXDZ5YMP.pgp
Description: PGP signature


[COMMITTED] longlong.h: Disable alpha umul_ppmm for old g++

2014-10-28 Thread Richard Henderson
I can't tell if this is fixed on mainline, because __builtin expansion
happens at a different time, or if it's still broken but hidden somehow.

But using gcc 4.8 as a bootstrap compiler for alphaev67-linux, we get a
"sorry: unexpected AST of kind MULT_HIGHPART".  It seems easiest to simply
disable this for pre-g++-5 to allow bootstrap to succeed.


r~


* longlong.h [__alpha] (umul_ppmm): Disable for c++.
---
 include/ChangeLog  | 4 
 include/longlong.h | 4 
 2 files changed, 8 insertions(+)

diff --git a/include/ChangeLog b/include/ChangeLog
index d2d1472..e482682 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,7 @@
+2014-10-28  Richard Henderson  
+
+   * longlong.h [__alpha] (umul_ppmm): Disable for c++.
+
 2014-10-28  Yury Gribov  
 
* libiberty.h (strtol, strtoul, strtoll, strtoull): New prototypes.
diff --git a/include/longlong.h b/include/longlong.h
index 42c68dd..8cd2c79 100644
--- a/include/longlong.h
+++ b/include/longlong.h
@@ -139,6 +139,9 @@ extern const UQItype __clz_tab[256] attribute_hidden;
 #endif /* __aarch64__ */
 
 #if defined (__alpha) && W_TYPE_SIZE == 64
+/* There is a bug in g++ before version 5 that
+   errors on __builtin_alpha_umulh.  */
+#if !defined(__cplusplus) || __GNUC__ >= 5
 #define umul_ppmm(ph, pl, m0, m1) \
   do { \
 UDItype __m0 = (m0), __m1 = (m1);  \
@@ -146,6 +149,7 @@ extern const UQItype __clz_tab[256] attribute_hidden;
 (pl) = __m0 * __m1;
\
   } while (0)
 #define UMUL_TIME 46
+#endif /* !c++ */
 #ifndef LONGLONG_STANDALONE
 #define udiv_qrnnd(q, r, n1, n0, d) \
   do { UDItype __r;\
-- 
1.9.3



RE: [Patch] Add MIPS flag to avoid use of ldc1/sdc1/ldxc1/sdxc1

2014-10-28 Thread Matthew Fortune
Matthew Fortune  writes:
> > >> >   Do you have an objection to allowing an option to disable these
> > >> instructions (despite the reason for wanting to do so)?
> > >>
> > >> Yes this seems like a bad workaround for broken code.
> > >>
> > > Well, we work around broken hardware all the time.  What would you
> > suggest that Steve do instead?
> >
> > We work around broken hardware all the time yes but that is something
> > which is hard to change.  Software is easier to fix.  That does not
> > mean in the compiler.  The compiler team should not get themselves in
> > the business of working around broken software that depends on
> > undefined behavior (this undefined behavior is very obvious and easier
> > to fix in the source of the problem).  Report the bug to Google.
> 
> I'm mostly in agreement with Andrew on this. I'd like to understand more
> about the use-case and what happens for other architectures (only ARM
> and x86 are really relevant here I guess). I believe x86 will just
> happily load/store doubles to 4-byte aligned addresses but I'm not sure
> for ARM. If ARM has to take unaligned access faults for this then I
> think MIPS simply has to do the same.
> 
> Unless the application is allocating thousands of small chunks of data
> and the padding is significant in the overall memory usage then I'd have
> thought the allocator could be fixed relatively easily. I'd also expect
> that to be generally a performance win for the application on all
> architectures.
> 
> 'If' we were to make a change to the compiler then I would make it a
> little more generic/focus on the actual issue which relates to alignment.
> I'm not sure what I would call the option but its effect would be for
> the compiler to not rely on any greater than 'X' alignment and disable
> the use of any load/store instructions which need larger alignment.
> 
> That still feels like a bad feature though.

Opinions aside there are actually some technical problems with this
feature. In particular we have to consider that the o32 ABI is about to
start its long awaited transition to use 64-bit floating-point registers.

We know that removing LDC1/SDC1 is possible for the original O32 FP32 ABI
as doubles just get handled with pairs of LWC1/SWC1.

Now if we consider O32 FP64 then it is not possible to use LWC1 to access
the upper-32-bits of doubles but we do have MTHC1/MFHC1 so the data would
have to move via GPRs which doubles the penalty in a way as GPR-FPR
transfers are generally slow. (I think the patch as it stands will fail
if used with O32 FP64 but I haven't looked in detail)

The bigger problem comes from the transitional ABI O32 FPXX. Firstly,
O32 FPXX on MIPS32r2 onwards... this will be OK as it has MTHC1/MFHC1 so
can use the same solution as O32 FP64. Next, O32 FPXX on MIPS II... this
is simply impossible, there is no way to load a double-precision FPR
given the constraints of the O32 FPXX ABI and the removal of LDC1/SDC1.

While the patch could be fixed to account for all of this we need to
determine if the case which won't work is the exact one which is needed
(and I believe it is). I.e. Android applications for MIPS are MIPS32r1
O32 FP32 NAN1985 currently and will transition from FP32 to FPXX to
enable the use of things like MSA. Since MIPS32r1 does not have
MTHC1/MFHC1 then this solution will not work.

We'll have to talk with the google engineers to explain the issues.

Matthew




RE: [Patch] Add MIPS flag to avoid use of ldc1/sdc1/ldxc1/sdxc1

2014-10-28 Thread Steve Ellcey
On Tue, 2014-10-28 at 14:06 -0700, Matthew Fortune wrote:

> While the patch could be fixed to account for all of this we need to
> determine if the case which won't work is the exact one which is needed
> (and I believe it is). I.e. Android applications for MIPS are MIPS32r1
> O32 FP32 NAN1985 currently and will transition from FP32 to FPXX to
> enable the use of things like MSA. Since MIPS32r1 does not have
> MTHC1/MFHC1 then this solution will not work.
> 
> We'll have to talk with the google engineers to explain the issues.
> 
> Matthew

FYI: I have emailed my Google contact to see if they could change their
allocator and included a reference to section 7.20.3 of the C standard.

Section 7.20.3 of C99 states: The pointer returned if the allocation
succeeds is suitably aligned so that it may be assigned to a pointer to
any type of object.

Steve Ellcey



libgo patch committed: Recognize PPC relocs

2014-10-28 Thread Ian Taylor
This patch to libgo recognizes PPC relocations in the debug/elf
package.  This is a backport of
https://codereview.appspot.com/125910043 which was applied to the PPC
development branch of the master Go repository.  For this patch
bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian
diff -r 30cebdd47f70 libgo/go/debug/elf/elf.go
--- a/libgo/go/debug/elf/elf.go Tue Oct 28 11:18:19 2014 -0700
+++ b/libgo/go/debug/elf/elf.go Tue Oct 28 15:53:31 2014 -0700
@@ -1162,6 +1162,184 @@
 func (i R_PPC) String() string   { return stringName(uint32(i), rppcStrings, 
false) }
 func (i R_PPC) GoString() string { return stringName(uint32(i), rppcStrings, 
true) }
 
+// Relocation types for PowerPC 64.
+type R_PPC64 int
+
+const (
+   R_PPC64_NONE   R_PPC64 = 0
+   R_PPC64_ADDR32 R_PPC64 = 1
+   R_PPC64_ADDR24 R_PPC64 = 2
+   R_PPC64_ADDR16 R_PPC64 = 3
+   R_PPC64_ADDR16_LO  R_PPC64 = 4
+   R_PPC64_ADDR16_HI  R_PPC64 = 5
+   R_PPC64_ADDR16_HA  R_PPC64 = 6
+   R_PPC64_ADDR14 R_PPC64 = 7
+   R_PPC64_ADDR14_BRTAKEN R_PPC64 = 8
+   R_PPC64_ADDR14_BRNTAKENR_PPC64 = 9
+   R_PPC64_REL24  R_PPC64 = 10
+   R_PPC64_REL14  R_PPC64 = 11
+   R_PPC64_REL14_BRTAKEN  R_PPC64 = 12
+   R_PPC64_REL14_BRNTAKEN R_PPC64 = 13
+   R_PPC64_GOT16  R_PPC64 = 14
+   R_PPC64_GOT16_LO   R_PPC64 = 15
+   R_PPC64_GOT16_HI   R_PPC64 = 16
+   R_PPC64_GOT16_HA   R_PPC64 = 17
+   R_PPC64_JMP_SLOT   R_PPC64 = 21
+   R_PPC64_REL32  R_PPC64 = 26
+   R_PPC64_ADDR64 R_PPC64 = 38
+   R_PPC64_ADDR16_HIGHER  R_PPC64 = 39
+   R_PPC64_ADDR16_HIGHERA R_PPC64 = 40
+   R_PPC64_ADDR16_HIGHEST R_PPC64 = 41
+   R_PPC64_ADDR16_HIGHESTAR_PPC64 = 42
+   R_PPC64_REL64  R_PPC64 = 44
+   R_PPC64_TOC16  R_PPC64 = 47
+   R_PPC64_TOC16_LO   R_PPC64 = 48
+   R_PPC64_TOC16_HI   R_PPC64 = 49
+   R_PPC64_TOC16_HA   R_PPC64 = 50
+   R_PPC64_TOCR_PPC64 = 51
+   R_PPC64_ADDR16_DS  R_PPC64 = 56
+   R_PPC64_ADDR16_LO_DS   R_PPC64 = 57
+   R_PPC64_GOT16_DS   R_PPC64 = 58
+   R_PPC64_GOT16_LO_DSR_PPC64 = 59
+   R_PPC64_TOC16_DS   R_PPC64 = 63
+   R_PPC64_TOC16_LO_DSR_PPC64 = 64
+   R_PPC64_TLSR_PPC64 = 67
+   R_PPC64_DTPMOD64   R_PPC64 = 68
+   R_PPC64_TPREL16R_PPC64 = 69
+   R_PPC64_TPREL16_LO R_PPC64 = 70
+   R_PPC64_TPREL16_HI R_PPC64 = 71
+   R_PPC64_TPREL16_HA R_PPC64 = 72
+   R_PPC64_TPREL64R_PPC64 = 73
+   R_PPC64_DTPREL16   R_PPC64 = 74
+   R_PPC64_DTPREL16_LOR_PPC64 = 75
+   R_PPC64_DTPREL16_HIR_PPC64 = 76
+   R_PPC64_DTPREL16_HAR_PPC64 = 77
+   R_PPC64_DTPREL64   R_PPC64 = 78
+   R_PPC64_GOT_TLSGD16R_PPC64 = 79
+   R_PPC64_GOT_TLSGD16_LO R_PPC64 = 80
+   R_PPC64_GOT_TLSGD16_HI R_PPC64 = 81
+   R_PPC64_GOT_TLSGD16_HA R_PPC64 = 82
+   R_PPC64_GOT_TLSLD16R_PPC64 = 83
+   R_PPC64_GOT_TLSLD16_LO R_PPC64 = 84
+   R_PPC64_GOT_TLSLD16_HI R_PPC64 = 85
+   R_PPC64_GOT_TLSLD16_HA R_PPC64 = 86
+   R_PPC64_GOT_TPREL16_DS R_PPC64 = 87
+   R_PPC64_GOT_TPREL16_LO_DS  R_PPC64 = 88
+   R_PPC64_GOT_TPREL16_HI R_PPC64 = 89
+   R_PPC64_GOT_TPREL16_HA R_PPC64 = 90
+   R_PPC64_GOT_DTPREL16_DSR_PPC64 = 91
+   R_PPC64_GOT_DTPREL16_LO_DS R_PPC64 = 92
+   R_PPC64_GOT_DTPREL16_HIR_PPC64 = 93
+   R_PPC64_GOT_DTPREL16_HAR_PPC64 = 94
+   R_PPC64_TPREL16_DS R_PPC64 = 95
+   R_PPC64_TPREL16_LO_DS  R_PPC64 = 96
+   R_PPC64_TPREL16_HIGHER R_PPC64 = 97
+   R_PPC64_TPREL16_HIGHERAR_PPC64 = 98
+   R_PPC64_TPREL16_HIGHESTR_PPC64 = 99
+   R_PPC64_TPREL16_HIGHESTA   R_PPC64 = 100
+   R_PPC64_DTPREL16_DSR_PPC64 = 101
+   R_PPC64_DTPREL16_LO_DS R_PPC64 = 102
+   R_PPC64_DTPREL16_HIGHERR_PPC64 = 103
+   R_PPC64_DTPREL16_HIGHERA   R_PPC64 = 104
+   R_PPC64_DTPREL16_HIGHEST   R_PPC64 = 105
+   R_PPC64_DTPREL16_HIGHESTA  R_PPC64 = 106
+   R_PPC64_TLSGD  R_PPC64 = 107
+   R_PPC64_TLSLD  R_PPC64 = 108
+   R_PPC64_REL16  R_PPC64 = 249
+   R_PPC64_REL16_LO   R_PPC64 = 250
+   R_PPC64_REL16_HI   R_PPC64 = 251
+   R_PPC64_REL16_HA   R_PPC64 = 252
+)
+
+var rppc64Strings = []intName{
+   {0, "R_PPC64_NONE"},
+   {1, "R_PPC64_ADDR32"},
+   {2, "R_PPC64_ADDR24"},
+   {3, "R_PPC64_ADDR16"},
+   {4, "R_PPC64_ADDR16_LO"},
+   {5, "R_PPC64_ADDR16_HI"},
+   {6, "R_PPC64_ADD

Re: PATCH: fix breakage from "[PATCH] Fix genmatch linking"

2014-10-28 Thread Paolo Bonzini
On 10/24/2014 06:32 AM, Hans-Peter Nilsson wrote:
> It seems "more correct" to just disable the config.cache sharing
> between the differently-configured build-subdirectories, as is
> already is done for host-libraries and target-libraries, even if
> that may slow down the builds.

Yes, please do.


Re: [AArch64, Docs, Patch] Add reference to ACLE in docs.

2014-10-28 Thread Joseph S. Myers
On Tue, 28 Oct 2014, Tejas Belagod wrote:

> Hi,
> 
> Here is patch that consolidates AArch64 and ARM Intrinsics sections in
> extend.texi into one ACLE section to avoid information repetition and adds
> reference to the ARM C Language Extension spec on infocenter.arm.com.

This seems to lose the information about which extensions are supported by 
GCC (given that not all of ACLE is supported; e.g. arm_acle.h has only the 
CRC intrinsics, while __fp16 isn't supported for AArch64 and the support 
for ARM corresponds to an older version of the specification).

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH 5/5] add libcc1

2014-10-28 Thread Joseph S. Myers
On Tue, 28 Oct 2014, Phil Muldoon wrote:

> Joseph,
> 
> Hi, sorry for the troubles! I am having difficulty seeing this fail on
> my system.  I built gmp from upstream, installed it, and pointed to
> the install location with --with-gmp. Which stage does your build fail
> at?

To get the failure you need not to have GMP installed somewhere the 
bootstrap compiler would otherwise find (e.g. uninstall your system GMP 
package before testing).  The failure is building stage 1.

> I am actually not totally sure how to respect the -with-gmp argument
> in libcc1.  auto* tools are not my strongest skill. ;)
> 
> I notice gcc/configure.ac I think just exports the variables to
> Makefile.in from the main configure script.  That what we should do in
> this case?

Toplevel passes GMPINC down to subdirectories.  I think you should

(a) copy

AC_ARG_VAR(GMPINC,[How to find GMP include files])

from gcc/configure.ac;

(b) copy

GMPINC = @GMPINC@

from gcc/Makefile.in;

(c) add $(GMPINC) to AM_CPPFLAGS.

-- 
Joseph S. Myers
jos...@codesourcery.com


[BUILDROBOT] Unused static function (was: RFA: AVR: add infrastructure for device packages)

2014-10-28 Thread Jan-Benedict Glaw
On Wed, 2014-10-08 18:50:32 +0100, Joern Rennecke  
wrote:
> Attached is the GCC patch for the basic device package infrastructure.
> OK to apply?

There's some fallout on config-list.mk builds:

g++ -c   -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -fno-exceptions 
-fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings 
-Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic 
-Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common 
 -DHAVE_CONFIG_H -I. -I. -I../../../gcc/gcc -I../../../gcc/gcc/. 
-I../../../gcc/gcc/../include -I../../../gcc/gcc/../libcpp/include 
-I/opt/cfarm/mpc/include  -I../../../gcc/gcc/../libdecnumber 
-I../../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber 
-I../../../gcc/gcc/../libbacktrace-I. -I. -I../../../gcc/gcc 
-I../../../gcc/gcc/. -I../../../gcc/gcc/../include 
-I../../../gcc/gcc/../libcpp/include -I/opt/cfarm/mpc/include  
-I../../../gcc/gcc/../libdecnumber -I../../../gcc/gcc/../libdecnumber/dpd 
-I../libdecnumber -I../../../gcc/gcc/../libbacktrace   
../../../gcc/gcc/config/avr/driver-avr.c
../../../gcc/gcc/config/avr/driver-avr.c:35:1: error: ‘void 
avr_set_current_device(const char*)’ defined but not used 
[-Werror=unused-function]
 avr_set_current_device (const char *name)
 ^
cc1plus: all warnings being treated as errors
make[2]: *** [driver-avr.o] Error 1

See build
http://toolchain.lug-owl.de/buildbot/show_build_details.php?id=370682

Is it planned to use that function later on? Or shall we just drop it?

MfG, JBG

-- 
  Jan-Benedict Glaw  jbg...@lug-owl.de  +49-172-7608481
Signature of:  Fortschritt bedeutet, einen Schritt so zu machen,
the second  :   daß man den nächsten auch noch machen kann.


signature.asc
Description: Digital signature


[PATCH] Add memory barriers to xbegin/xend/xabort

2014-10-28 Thread Andi Kleen
From: Andi Kleen 

xbegin/xend/xabort were missing memory barriers. This can
lead to memory operations being moved out of transactions, which would
cause unexpected races.

Always generate implicit memory barriers for these intrinsics.

The compat header versions always generated memory barriers,
so this also improves compatibility.

Passes test suite. Ok for release branches?

gcc/:

2014-10-28  Andi Kleen  

PR target/63672
* config/i386/i386.c (ix86_expand_builtin): Generate memory
barrier after abort.
* config/i386/i386.md (xbegin): Add memory barrier.
(xend): Rename to ...
(xend_1): New. Generate memory barrier and emit xend.
---
 gcc/config/i386/i386.c  |  1 +
 gcc/config/i386/i386.md | 18 +-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index ec3e056..ec0df40 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -36413,6 +36413,7 @@ addcarryx:
  return const0_rtx;
}
   emit_insn (gen_xabort (op0));
+  emit_insn (gen_memory_blockage ());
   return 0;
 
 default:
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 7ba07c3..3544e60 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -18530,6 +18530,9 @@
 
   emit_move_insn (operands[0], ax_reg);
 
+  operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
+  MEM_VOLATILE_P (operands[0]) = 1;
+
   DONE;
 })
 
@@ -18546,13 +18549,26 @@
   [(set_attr "type" "other")
(set_attr "length" "6")])
 
-(define_insn "xend"
+(define_insn "xend_1"
   [(unspec_volatile [(const_int 0)] UNSPECV_XEND)]
   "TARGET_RTM"
   "xend"
   [(set_attr "type" "other")
(set_attr "length" "3")])
 
+(define_expand "xend"
+  [(set (match_dup 0)
+   (unspec:BLK [(const_int 0)] UNSPECV_XEND))] /* or match_dup 0 ? */
+  "TARGET_RTM"
+{
+  emit_insn (gen_xend_1 ());
+
+  operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
+  MEM_VOLATILE_P (operands[0]) = 1;
+
+  DONE;
+})
+
 (define_insn "xabort"
   [(unspec_volatile [(match_operand:SI 0 "const_0_to_255_operand" "n")]
UNSPECV_XABORT)]
-- 
2.1.1



  1   2   >