Re: OpenACC: initialization with unsupported acc_device_t

2015-05-20 Thread Thomas Schwinge
Hi Julian!

On Thu, 7 May 2015 16:56:11 +0100, Julian Brown  wrote:
> On Tue, 5 May 2015 16:09:18 +0200
> Thomas Schwinge  wrote:
> > On Tue, 5 May 2015 08:43:48 -0400, John David Anglin
> >  wrote:
> > > On 2015-05-05 5:43 AM, Thomas Schwinge wrote:
> > > >> FAIL: libgomp.oacc-c/../libgomp.oacc-c-c++-common/lib-62.c
> > > >> >-DACC_DEVICE_TYPE_hos
> > > >> >t=1 -DACC_MEM_SHARED=1 output pattern test, is , should match
> > > >> >invalid size
> > > > With this one I'll need your help: please cite from libgomp.log
> > > > (or, from a manual run) the actual output message that you're
> > > > getting.
> > > There's no output message:
> > > # ./lib-62.exe
> > > Segmentation fault (core dumped)
> 
> > As this is a PA-RISC HP-UX system, I feel certain that you don't
> > actually have nvptx offloading available (so, the nvptx libgomp
> > plugin is not being built).  However, this test case, contains an
> > unconditional acc_init call for acc_device_nvidia, and I would then
> > guess that this situation is not (not anymore?) correctly handled
> > (abort with »offloading to [...] not possible«, or similar; see
> > libgomp.oacc-c-c++-common/lib-4.c) in libgomp -- Julian, could this be
> > due to your recent libgomp OpenACC initialization changes?  (When
> > working on this in a build that does have nvptx offloading
> > configured, I think you should be able to simulate the situation by
> > "hiding" (temporarily deleting, or similar) the nvptx libgomp
> > plugin?)
> 
> The attached patch contains (what I hope should be) a fix for this,
> tested by running the libgomp testsuite (with nvptx offloading), and by
> deleting the nvptx plugin, with the patch applied, and ensuring that
> lib-62.c no longer segfaults in that case.
> 
> The patch also tidies up a few other error paths around resolve_device,
> and de-duplicates some error message reporting code.
> 
> > Then, I don't know why libgomp.oacc-c-c++-common/lib-62.c contains
> > this explicit acc_init call with acc_device_nvidia -- generally, the
> > test cases should not contain such unconditional statements.  So,
> > let's then please remove this.  See
> > libgomp/testsuite/libgomp.oacc-c-c++-common/lib-66.c for a very
> > similar test case, which does this differently.
> 
> I've not touched this test though -- but I have tweaked
> libgomp.oacc-c-c++-common/lib-4.c that should now expect a slightly
> different error output.
> 
> OK for trunk?

Thanks, looks good to me -- Jakub?


Grüße,
 Thomas


> libgomp/
> * oacc-init.c (resolve_device): Add FAIL_IS_ERROR argument. Update
> function comment. Only call gomp_fatal if new argument is true.
> (acc_dev_num_out_of_range): New function.
> (acc_init_1, acc_shutdown_1): Update call to resolve_device. Call
> acc_dev_num_out_of_range as appropriate.
> (acc_get_num_devices, acc_set_device_type, acc_get_device_type)
> (acc_get_device_num, acc_set_device_num): Update calls to resolve_device.
> * testsuite/libgomp.oacc-c-c++-common/lib-4.c: Update expected test
> output.

> commit 221b5dea47cdb7611456ca3cf28d180d3ff1156a
> Author: Julian Brown 
> Date:   Thu May 7 08:39:16 2015 -0700
> 
> Clean up initialisation when no devices of a particular type are 
> available.
> 
> diff --git a/libgomp/oacc-init.c b/libgomp/oacc-init.c
> index f2c60ec..cd50521 100644
> --- a/libgomp/oacc-init.c
> +++ b/libgomp/oacc-init.c
> @@ -109,10 +109,12 @@ name_of_acc_device_t (enum acc_device_t type)
>  }
>  }
>  
> -/* ACC_DEVICE_LOCK should be held before calling this function.  */
> +/* ACC_DEVICE_LOCK must be held before calling this function.  If 
> FAIL_IS_ERROR
> +   is true, this function raises an error if there are no devices of type D,
> +   otherwise it returns NULL in that case.  */
>  
>  static struct gomp_device_descr *
> -resolve_device (acc_device_t d)
> +resolve_device (acc_device_t d, bool fail_is_error)
>  {
>acc_device_t d_arg = d;
>  
> @@ -130,7 +132,13 @@ resolve_device (acc_device_t d)
> && dispatchers[d]->get_num_devices_func () > 0)
>   goto found;
>  
> - gomp_fatal ("device type %s not supported", goacc_device_type);
> + if (fail_is_error)
> +   {
> + gomp_mutex_unlock (&acc_device_lock);
> + gomp_fatal ("device type %s not supported", goacc_device_type);
> +   }
> + else
> +   return NULL;
> }
>  
>   /* No default device specified, so start scanning for any non-host
> @@ -149,7 +157,13 @@ resolve_device (acc_device_t d)
> d = acc_device_host;
> goto found;
>   }
> -  gomp_fatal ("no device found");
> +  if (fail_is_error)
> +{
> +   gomp_mutex_unlock (&acc_device_lock);
> +   gomp_fatal ("no device found");
> + }
> +  else
> +return NULL;
>break;
>  
>  case acc_device_host:
> @@ -157,7 +171,12 @@ resolve_device (acc_device_t d)
>  
>  default:
>if (d > _ACC_device_hwm)
> - 

Re: [PATCH][DRIVER] Wrong C++ include paths when configuring with "--with-sysroot=/"

2015-05-20 Thread Yvan Roux
Hi,

On 8 May 2015 at 00:07, Joseph Myers  wrote:
> On Mon, 20 Apr 2015, Pavel Kopyl wrote:
>
>> Hi all,
>>
>>
>> To build a GCC-4.9.2 ARM cross-compiler for my setting I need to configure it
>> with  "--with-sysroot=/ --with-gxx-include-dir=/usr/include/c++/4.9.2".
>> But I found that gcc driver removes the leading slash from resulting paths:
>>
>> `gcc -print-prog-name=cc1plus` -v
>> ...
>> ignoring nonexistent directory "usr/include/c++/4.9.2"   <- HERE
>> ignoring nonexistent directory
>> "usr/include/c++/4.9.2/armv7l-tizen-linux-gnueabi"   <- AND HERE
>> ignoring nonexistent directory "usr/include/c++/4.9.2/backward" <- AND HERE
>> #include "..." search starts here:
>> #include <...> search starts here:
>> /usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/include
>> /usr/local/include
>> /usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/include-fixed
>> /usr/include
>>
>> It's also reproducible on trunk.
>>
>> Attached patch fixes this bug.
>
> You don't explain the rationale for this patch, in terms of the logical
> semantics of the various variables involved, and why, in terms of those
> logical semantics, this patch is the correct approach for fixing the
> observed problems.
>
> As I read the code, it's not the driver that removes the leading slash.
> Rather, it's the code in configure.ac:
>
> gcc_gxx_include_dir_add_sysroot=0
> if test "${with_sysroot+set}" = set; then
>   gcc_gxx_without_sysroot=`expr "${gcc_gxx_include_dir}" : 
> "${with_sysroot}"'\(.*\)'`
>   if test "${gcc_gxx_without_sysroot}"; then
> gcc_gxx_include_dir="${gcc_gxx_without_sysroot}"
> gcc_gxx_include_dir_add_sysroot=1
>   fi
> fi
>
> What I'd say is that this code is mishandling the case of a --with-sysroot
> path that ends with '/' (or, I suppose, '\', on hosts where that's a
> directory separator).  That is, it's producing a gcc_gxx_include_dir
> setting with no leading '/'.  I think it would be more appropriate for
> this configure.ac code to remove (sysroot minus trailing directory
> separator), so that the gcc_gxx_include_dir setting after this code still
> has a leading directory separator whether or not the --with-sysroot
> setting ended with such a separator.  Given such a configure.ac change, I
> wouldn't then expect changes elsewhere in the compiler to be needed.  But
> if that doesn't work to fix the bug, I think you need to elaborate further
> on the semantics of the various variables involved (in configure.ac and in
> the compiler).

There is this old patch submitted by Matthias on that same issue, if
its logic is the right one for you Joseph I can rebase/validate it
Joseph.

https://gcc.gnu.org/ml/gcc-patches/2012-02/msg00320.html

Cheers,
Yvan

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


Re: Add statistics to alias.c

2015-05-20 Thread Bernhard Reutner-Fischer
On May 21, 2015 12:13:19 AM GMT+02:00, Jan Hubicka  wrote:
>Hi,
>this patch extends statistics from tree-ssa-alias to also cover TBAA
>oracle.
>This is useful to keep track of aliasing effectivity.  For example the
>hack
>in alias.c putting globbing all pointers to one costs about 20% of all
>answers on firefox. I.e. from 15500978 disambiguations/23744267
>querries
>(with the hack removed) to 12932078 disambiguations/27256455 querries.
>
>Bootstrapped x86_64-linux, OK?

s/quaries/queries/
Thanks,



[patch, testsuite, ARM] don't try to execute simd.exp tests on targets without NEON

2015-05-20 Thread Sandra Loosemore
This is another patch aimed at fixing bugs relating to trying to execute 
NEON code on a target that doesn't support it revealed by my 
arm-none-eabi testing on a gazillion different multilibs.  Inspired by 
what vect.exp does and my other patch in this group to fix 
advsimd-intrinsics.exp, I've hacked simd.exp to test for NEON 
compilation and execution support and use set dg-do-what-default to 
either "compile" or "run" as appropriate, or skip the whole set of tests 
if neither is present.  And, I've removed the explicit "dg-do run" and 
arm_neon_ok test (which only tests for compilation support, not 
execution support) from all the individual test cases.


OK to commit?

-Sandra

2015-05-20  Sandra Loosemore  

	gcc/testsuite/
	* gcc.target/arm/simd/simd.exp: Skip all tests if no arm_neon_ok
	effective target support.  If no arm_neon_hw support, do not attempt
	to execute the tests; only compile them.
	* gcc.target/arm/simd/vextf32_1.c: Remove explicit "dg-do run"
	and "dg-require-effective-target arm_neon_ok".
	* gcc.target/arm/simd/vextp16_1.c: Likewise.
	* gcc.target/arm/simd/vextp64_1.c: Likewise.
	* gcc.target/arm/simd/vextp8_1.c: Likewise.
	* gcc.target/arm/simd/vextQf32_1.c: Likewise.
	* gcc.target/arm/simd/vextQp16_1.c: Likewise.
	* gcc.target/arm/simd/vextQp64_1.c: Likewise.
	* gcc.target/arm/simd/vextQp8_1.c: Likewise.
	* gcc.target/arm/simd/vextQs16_1.c: Likewise.
	* gcc.target/arm/simd/vextQs32_1.c: Likewise.
	* gcc.target/arm/simd/vextQs64_1.c: Likewise.
	* gcc.target/arm/simd/vextQs8_1.c: Likewise.
	* gcc.target/arm/simd/vextQu16_1.c: Likewise.
	* gcc.target/arm/simd/vextQu32_1.c: Likewise.
	* gcc.target/arm/simd/vextQu64_1.c: Likewise.
	* gcc.target/arm/simd/vextQu8_1.c: Likewise.
	* gcc.target/arm/simd/vexts16_1.c: Likewise.
	* gcc.target/arm/simd/vexts32_1.c: Likewise.
	* gcc.target/arm/simd/vexts64_1.c: Likewise.
	* gcc.target/arm/simd/vexts8_1.c: Likewise.
	* gcc.target/arm/simd/vextu16_1.c: Likewise.
	* gcc.target/arm/simd/vextu32_1.c: Likewise.
	* gcc.target/arm/simd/vextu64_1.c: Likewise.
	* gcc.target/arm/simd/vextu8_1.c: Likewise.
	* gcc.target/arm/simd/vrev16p8_1.c: Likewise.
	* gcc.target/arm/simd/vrev16qp8_1.c: Likewise.
	* gcc.target/arm/simd/vrev16qs8_1.c: Likewise.
	* gcc.target/arm/simd/vrev16qu8_1.c: Likewise.
	* gcc.target/arm/simd/vrev16s8_1.c: Likewise.
	* gcc.target/arm/simd/vrev16u8_1.c: Likewise.
	* gcc.target/arm/simd/vrev32p16_1.c: Likewise.
	* gcc.target/arm/simd/vrev32p8_1.c: Likewise.
	* gcc.target/arm/simd/vrev32qp16_1.c: Likewise.
	* gcc.target/arm/simd/vrev32qp8_1.c: Likewise.
	* gcc.target/arm/simd/vrev32qs16_1.c: Likewise.
	* gcc.target/arm/simd/vrev32qs8_1.c: Likewise.
	* gcc.target/arm/simd/vrev32qu16_1.c: Likewise.
	* gcc.target/arm/simd/vrev32qu8_1.c: Likewise.
	* gcc.target/arm/simd/vrev32s16_1.c: Likewise.
	* gcc.target/arm/simd/vrev32s8_1.c: Likewise.
	* gcc.target/arm/simd/vrev32u16_1.c: Likewise.
	* gcc.target/arm/simd/vrev32u8_1.c: Likewise.
	* gcc.target/arm/simd/vrev64f32_1.c: Likewise.
	* gcc.target/arm/simd/vrev64p16_1.c: Likewise.
	* gcc.target/arm/simd/vrev64p8_1.c: Likewise.
	* gcc.target/arm/simd/vrev64qf32_1.c: Likewise.
	* gcc.target/arm/simd/vrev64qp16_1.c: Likewise.
	* gcc.target/arm/simd/vrev64qp8_1.c: Likewise.
	* gcc.target/arm/simd/vrev64qs16_1.c: Likewise.
	* gcc.target/arm/simd/vrev64qs32_1.c: Likewise.
	* gcc.target/arm/simd/vrev64qs8_1.c: Likewise.
	* gcc.target/arm/simd/vrev64qu16_1.c: Likewise.
	* gcc.target/arm/simd/vrev64qu32_1.c: Likewise.
	* gcc.target/arm/simd/vrev64qu8_1.c: Likewise.
	* gcc.target/arm/simd/vrev64s16_1.c: Likewise.
	* gcc.target/arm/simd/vrev64s32_1.c: Likewise.
	* gcc.target/arm/simd/vrev64s8_1.c: Likewise.
	* gcc.target/arm/simd/vrev64u16_1.c: Likewise.
	* gcc.target/arm/simd/vrev64u32_1.c: Likewise.
	* gcc.target/arm/simd/vrev64u8_1.c: Likewise.
	* gcc.target/arm/simd/vtrnf32_1.c: Likewise.
	* gcc.target/arm/simd/vtrnp16_1.c: Likewise.
	* gcc.target/arm/simd/vtrnp8_1.c: Likewise.
	* gcc.target/arm/simd/vtrnqf32_1.c: Likewise.
	* gcc.target/arm/simd/vtrnqp16_1.c: Likewise.
	* gcc.target/arm/simd/vtrnqp8_1.c: Likewise.
	* gcc.target/arm/simd/vtrnqs16_1.c: Likewise.
	* gcc.target/arm/simd/vtrnqs32_1.c: Likewise.
	* gcc.target/arm/simd/vtrnqs8_1.c: Likewise.
	* gcc.target/arm/simd/vtrnqu16_1.c: Likewise.
	* gcc.target/arm/simd/vtrnqu32_1.c: Likewise.
	* gcc.target/arm/simd/vtrnqu8_1.c: Likewise.
	* gcc.target/arm/simd/vtrns16_1.c: Likewise.
	* gcc.target/arm/simd/vtrns32_1.c: Likewise.
	* gcc.target/arm/simd/vtrns8_1.c: Likewise.
	* gcc.target/arm/simd/vtrnu16_1.c: Likewise.
	* gcc.target/arm/simd/vtrnu32_1.c: Likewise.
	* gcc.target/arm/simd/vtrnu8_1.c: Likewise.
	* gcc.target/arm/simd/vuzpf32_1.c: Likewise.
	* gcc.target/arm/simd/vuzpp16_1.c: Likewise.
	* gcc.target/arm/simd/vuzpp8_1.c: Likewise.
	* gcc.target/arm/simd/vuzpqf32_1.c: Likewise.
	* gcc.target/arm/simd/vuzpqp16_1.c: Likewise.
	* gcc.target/arm/simd/vuzpqp8_1.c: Likewise.
	* gcc.target/arm/simd/vuzpqs16_1.c: Likewise.
	* gcc.target/arm/simd

Re: [PATCH 7/7] always define HAVE_peephole

2015-05-20 Thread Jeff Law

On 05/20/2015 08:09 PM, tbsaunde+...@tbsaunde.org wrote:

From: Trevor Saunders 

gcc/ChangeLog:

2015-05-20  Trevor Saunders  

* final.c (final_scan_insn): Don't check HAVE_peephole with the
preprocessor.
* output.h: Likewise.
* genconfig.c (main): Alwways define HAVE_peephole.
* genpeep.c: Don't emit checks of HAVE_peephole.

OK.
jeff



[RFA] Restore combine.c split point for multiply-accumulate instructions

2015-05-20 Thread Jeff Law


find_split_point will tend to favor splitting complex insns in such a 
way as to encourage multiply-add insns.  It does this by splitting an 
unrecognizable insn at the (plus (mult)).


Now that many MULTs are canonicalized as ASHIFT, that code to prefer the 
multiply-add is no longer triggering when it could/should.  This 
ultimately results in splitting at the ASHIFT rather than the containing 
PLUS and thus we generate distinct shift and add insns rather than a 
single shadd insn on the PA (and probably other architectures).


This patch will treat (plus (ashift)) just like (plus (mult)) which 
encourages creation of shift-add insns.


This has been bootstrapped and regression tested on 
x86-unknown-linux-gnu and with an hppa2.0w-hp-hpux11.00 cross compiler 
on the hppa.exp testsuite (full disclosure -- hppa.exp only has two 
tests, so it's far from extensive).


I've also verified this is one of the changes ultimately necessary to 
resolve the code generation regressions caused by Venkat's combine.c 
change on the PA across my 300+ testfiles for a PA cross compiler.


OK for the trunk?



Jeff



diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 490386e..250fa0a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,8 @@
 2015-05-20  Jeff Law  
 
+   * combine.c (find_split_point): Handle ASHIFT like MULT to encourage
+   multiply-accumulate/shift-add insn generation.
+
* config/pa/pa.c (pa_print_operand): New 'o' output modifier.
(pa_mem_shadd_constant_p): Renamed from pa_shadd_constant_p.
(pa_shadd_constant_p): Allow constants for shadd insns rather
diff --git a/gcc/combine.c b/gcc/combine.c
index a90849e..ab6de3a 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -5145,7 +5163,9 @@ find_split_point (rtx *loc, rtx_insn *insn, bool set_src)
   /* Split at a multiply-accumulate instruction.  However if this is
  the SET_SRC, we likely do not have such an instruction and it's
  worthless to try this split.  */
-  if (!set_src && GET_CODE (XEXP (x, 0)) == MULT)
+  if (!set_src
+ && (GET_CODE (XEXP (x, 0)) == MULT
+ || GET_CODE (XEXP (x, 0)) == ASHIFT))
 return loc;
 
 default:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f20a131..bac0973 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,7 @@
 2015-05-20  Jeff Law  
 
+   * gcc.target/hppa/shadd-2.c: New test.
+
* gcc.target/hppa/hppa.exp: New target test driver.
* gcc.target/hppa/shadd-1.c: New test.
 
diff --git a/gcc/testsuite/gcc.target/hppa/shadd-2.c 
b/gcc/testsuite/gcc.target/hppa/shadd-2.c
new file mode 100644
index 000..34708e5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/hppa/shadd-2.c
@@ -0,0 +1,49 @@
+/* { dg-do compile }  */
+/* { dg-options "-O2" }  */
+/* { dg-final { scan-assembler-times "sh.add" 2 } }  */
+
+typedef struct rtx_def *rtx;
+typedef const struct rtx_def *const_rtx;
+enum machine_mode
+{
+  VOIDmode, BLKmode, CCmode, CCGCmode, CCGOCmode, CCNOmode, CCAmode, CCCmode,
+CCOmode, CCSmode, CCZmode, CCFPmode, CCFPUmode, BImode, QImode, HImode,
+SImode, DImode, TImode, OImode, QQmode, HQmode, SQmode, DQmode, TQmode,
+UQQmode, UHQmode, USQmode, UDQmode, UTQmode, HAmode, SAmode, DAmode,
+TAmode, UHAmode, USAmode, UDAmode, UTAmode, SFmode, DFmode, XFmode,
+TFmode, SDmode, DDmode, TDmode, CQImode, CHImode, CSImode, CDImode,
+CTImode, COImode, SCmode, DCmode, XCmode, TCmode, V2QImode, V4QImode,
+V2HImode, V1SImode, V8QImode, V4HImode, V2SImode, V1DImode, V16QImode,
+V8HImode, V4SImode, V2DImode, V1TImode, V32QImode, V16HImode, V8SImode,
+V4DImode, V2TImode, V64QImode, V32HImode, V16SImode, V8DImode, V4TImode,
+V2SFmode, V4SFmode, V2DFmode, V8SFmode, V4DFmode, V2TFmode, V16SFmode,
+V8DFmode, V4TFmode, MAX_MACHINE_MODE, NUM_MACHINE_MODES = MAX_MACHINE_MODE
+};
+struct rtx_def
+{
+  __extension__ enum machine_mode mode:8;
+};
+struct target_regs
+{
+  unsigned char x_hard_regno_nregs[53][MAX_MACHINE_MODE];
+};
+extern void oof (void);
+extern int rhs_regno (rtx);
+
+extern struct target_regs default_target_regs;
+__inline__ unsigned int
+end_hard_regno (enum machine_mode mode, unsigned int regno)
+{
+  return regno +
+((&default_target_regs)->x_hard_regno_nregs)[regno][(int) mode];
+}
+
+void
+note_btr_set (rtx dest, const_rtx set
+ __attribute__ ((__unused__)), void *data)
+{
+  int regno, end_regno;
+  end_regno = end_hard_regno (((dest)->mode), (rhs_regno (dest)));
+  for (; regno < end_regno; regno++)
+oof ();
+}


[patch, testsuite, ARM] don't try to execute advsimd-intrinsics tests on hardware without NEON

2015-05-20 Thread Sandra Loosemore
ARM testing shares the AArch64 advsimd-intrinsics execution tests.  On 
ARM, though, the NEON support being tested is optional -- some arches 
are compatible with the NEON compilation options but hardware available 
for testing might or might not be able to execute those instructions. 
In arm-none-eabi testing of a long list of multilibs, I found that this 
problem caused some of the multilibs to get stuck for days because every 
one of these execution tests was wandering off into the weeds and timing 
out.


The vect.exp tests already handle this by setting dg-do-what-default to 
either "run" or "compile", depending on whether we have target hardware 
execution support (arm_neon_hw) for NEON, or only compilation support 
(arm_neon_ok).  So, I've adapted that logic for advsimd-intrinsics.exp 
too.


It also appeared that the main loop over the test cases was running them 
all twice with the torture options -- once using c-torture-execute and 
once using gcc-dg-runtest.  I deleted the former since it appears to 
ignore dg-do-what-default and always try to execute no matter what.  My 
dejagnu-fu isn't the strongest and this is pretty confusing to me 
am I missing something here?  Otherwise, OK to commit?


-Sandra

2015-05-20  Sandra Loosemore  

	gcc/testsuite/
	* gcc.target/aarch64/advsimd-intrinsics/advsimd-intrinsics.exp:
	Set dg-do-what-default to compile only on ARM targets without
	arm_neon_hw execution support.  Remove redundant c-torture-execute
	in loop over test cases.
Index: gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/advsimd-intrinsics.exp
===
--- gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/advsimd-intrinsics.exp	(revision 223468)
+++ gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/advsimd-intrinsics.exp	(working copy)
@@ -32,9 +32,20 @@ load_lib torture-options.exp
 
 dg-init
 
-if {[istarget arm*-*-*]
-&& ![check_effective_target_arm_neon_ok]} then {
-  return
+# The default action for a test is 'run'.  Save current default.
+global dg-do-what-default
+set save-dg-do-what-default ${dg-do-what-default}
+set dg-do-what-default run
+
+# For ARM, make sure that we have a target compatible with NEON, and do
+# not attempt to run execution tests if the hardware doesn't support it.
+if {[istarget arm*-*-*]} then {
+if {![check_effective_target_arm_neon_ok]} then {
+  return
+}
+if {![is-effective-target arm_neon_hw]} then {
+set dg-do-what-default compile
+}
 }
 
 torture-init
@@ -55,11 +66,11 @@ foreach src [lsort [glob -nocomplain $sr
 # performed if the above runtest_file_p decided this runtest
 # instance should execute the test
 gcc_parallel_test_enable 0
-c-torture-execute $src $additional_flags
 gcc-dg-runtest $src "" $additional_flags
 gcc_parallel_test_enable 1
 }
 
 # All done.
+set dg-do-what-default ${save-dg-do-what-default}
 torture-finish
 dg-finish


[patch, testsuite] don't specify "dg-do run" explicitly for vect test cases

2015-05-20 Thread Sandra Loosemore
On targets such as ARM, some arches are compatible with options needed 
to enable compilation with vectorization, but the specific hardware (or 
simulator or BSP) available for execution tests may not implement or 
enable those features.  The vect.exp test harness already includes some 
magic to determine whether the target hw can execute vectorized code and 
sets dg-do-what-default to compile the tests only if they can't be 
executed.  It's a mistake for individual tests to explicitly say "dg-do 
run" because this overrides the harness's magic default and forces the 
test to be executed, even if doing so just ends up wedging the target.


I already committed two patches last fall (r215627 and r218427) to 
address this, but people keep adding new vect test cases with the same 
problem, so here is yet another installment to clean them up.  I tested 
this on arm-none-eabi with a fairly large collection of multilibs.  OK 
to commit?


-Sandra

2015-05-20  Sandra Loosemore  

	gcc/testsuite/
	* gcc.dg/vect/bb-slp-pr65935.c: Remove explicit "dg-do run".
	* gcc.dg/vect/pr59354.c: Likewise.
	* gcc.dg/vect/pr64252.c: Likewise.
	* gcc.dg/vect/pr64404.c: Likewise.
	* gcc.dg/vect/pr64493.c: Likewise.
	* gcc.dg/vect/pr64495.c: Likewise.
	* gcc.dg/vect/pr64844.c: Likewise.
	* gcc.dg/vect/pr65518.c: Likewise.
	* gcc.dg/vect/vect-aggressive-1.c: Likewise.
Index: gcc/testsuite/gcc.dg/vect/pr65518.c
===
--- gcc/testsuite/gcc.dg/vect/pr65518.c	(revision 223468)
+++ gcc/testsuite/gcc.dg/vect/pr65518.c	(working copy)
@@ -1,5 +1,3 @@
-/* { dg-do run } */
-
 extern void abort (void);
 
 typedef struct giga
Index: gcc/testsuite/gcc.dg/vect/pr64493.c
===
--- gcc/testsuite/gcc.dg/vect/pr64493.c	(revision 223468)
+++ gcc/testsuite/gcc.dg/vect/pr64493.c	(working copy)
@@ -1,5 +1,3 @@
-/* { dg-do run } */
-
 #include "tree-vect.h"
 
 int a, b, c, d, e, f, g, h;
Index: gcc/testsuite/gcc.dg/vect/pr64844.c
===
--- gcc/testsuite/gcc.dg/vect/pr64844.c	(revision 223468)
+++ gcc/testsuite/gcc.dg/vect/pr64844.c	(working copy)
@@ -1,4 +1,3 @@
-/* { dg-do run } */
 /* { dg-require-effective-target vect_double } */
 /* { dg-additional-options "-ffast-math" } */
 
Index: gcc/testsuite/gcc.dg/vect/pr64495.c
===
--- gcc/testsuite/gcc.dg/vect/pr64495.c	(revision 223468)
+++ gcc/testsuite/gcc.dg/vect/pr64495.c	(working copy)
@@ -1,5 +1,3 @@
-/* { dg-do run } */
-
 #include 
 #include "tree-vect.h"
 
Index: gcc/testsuite/gcc.dg/vect/pr59354.c
===
--- gcc/testsuite/gcc.dg/vect/pr59354.c	(revision 223468)
+++ gcc/testsuite/gcc.dg/vect/pr59354.c	(working copy)
@@ -1,4 +1,3 @@
-/* { dg-do run } */
 /* { dg-additional-options "-O3" } */
 
 #include "tree-vect.h"
Index: gcc/testsuite/gcc.dg/vect/pr64404.c
===
--- gcc/testsuite/gcc.dg/vect/pr64404.c	(revision 223468)
+++ gcc/testsuite/gcc.dg/vect/pr64404.c	(working copy)
@@ -1,4 +1,3 @@
-/* { dg-do run } */
 /* { dg-additional-options "--param=sccvn-max-alias-queries-per-access=1" } */
 
 #include "tree-vect.h"
Index: gcc/testsuite/gcc.dg/vect/pr64252.c
===
--- gcc/testsuite/gcc.dg/vect/pr64252.c	(revision 223468)
+++ gcc/testsuite/gcc.dg/vect/pr64252.c	(working copy)
@@ -1,6 +1,5 @@
 /* PR target/64252 */
 /* Test correctness of size 3 store groups permutation.  */
-/* { dg-do run } */
 /* { dg-additional-options "-O3" } */
 /* { dg-additional-options "-mavx" { target avx_runtime } } */
 
Index: gcc/testsuite/gcc.dg/vect/bb-slp-pr65935.c
===
--- gcc/testsuite/gcc.dg/vect/bb-slp-pr65935.c	(revision 223468)
+++ gcc/testsuite/gcc.dg/vect/bb-slp-pr65935.c	(working copy)
@@ -1,4 +1,3 @@
-/* { dg-do run } */
 /* { dg-additional-options "-O3" } */
 /* { dg-require-effective-target vect_double } */
 
Index: gcc/testsuite/gcc.dg/vect/vect-aggressive-1.c
===
--- gcc/testsuite/gcc.dg/vect/vect-aggressive-1.c	(revision 223468)
+++ gcc/testsuite/gcc.dg/vect/vect-aggressive-1.c	(working copy)
@@ -1,4 +1,3 @@
-/* { dg-do run } */
 /* { dg-require-effective-target vect_condition } */
 /* { dg-require-effective-target vect_simd_clones } */
 /* { dg-additional-options "-fopenmp-simd" } */


[PATCH 7/7] always define HAVE_peephole

2015-05-20 Thread tbsaunde+gcc
From: Trevor Saunders 

gcc/ChangeLog:

2015-05-20  Trevor Saunders  

* final.c (final_scan_insn): Don't check HAVE_peephole with the
preprocessor.
* output.h: Likewise.
* genconfig.c (main): Alwways define HAVE_peephole.
* genpeep.c: Don't emit checks of HAVE_peephole.
---
 gcc/ChangeLog   | 8 
 gcc/final.c | 4 +---
 gcc/genconfig.c | 2 ++
 gcc/genpeep.c   | 2 --
 gcc/output.h| 2 --
 5 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c20d608..f41c46e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,13 @@
 2015-05-20  Trevor Saunders  
 
+   * final.c (final_scan_insn): Don't check HAVE_peephole with the
+   preprocessor.
+   * output.h: Likewise.
+   * genconfig.c (main): Alwways define HAVE_peephole.
+   * genpeep.c: Don't emit checks of HAVE_peephole.
+
+2015-05-20  Trevor Saunders  
+
* *.c, *.h: DOn't check HAVE_conditional_move with the preprocessor.
 
 2015-05-20  Trevor Saunders  
diff --git a/gcc/final.c b/gcc/final.c
index f0585ca..c8f059b 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -2905,10 +2905,9 @@ final_scan_insn (rtx_insn *insn, FILE *file, int 
optimize_p ATTRIBUTE_UNUSED,
 
 #endif
 
-#ifdef HAVE_peephole
/* Do machine-specific peephole optimizations if desired.  */
 
-   if (optimize_p && !flag_no_peephole && !nopeepholes)
+   if (HAVE_peephole && optimize_p && !flag_no_peephole && !nopeepholes)
  {
rtx_insn *next = peephole (insn);
/* When peepholing, if there were notes within the peephole,
@@ -2937,7 +2936,6 @@ final_scan_insn (rtx_insn *insn, FILE *file, int 
optimize_p ATTRIBUTE_UNUSED,
/* PEEPHOLE might have changed this.  */
body = PATTERN (insn);
  }
-#endif
 
/* Try to recognize the instruction.
   If successful, verify that the operands satisfy the
diff --git a/gcc/genconfig.c b/gcc/genconfig.c
index a3e5b31..7237dede 100644
--- a/gcc/genconfig.c
+++ b/gcc/genconfig.c
@@ -369,6 +369,8 @@ main (int argc, char **argv)
 
   if (have_peephole_flag)
 printf ("#define HAVE_peephole 1\n");
+  else
+printf ("#define HAVE_peephole 0\n");
 
   if (have_peephole2_flag)
 {
diff --git a/gcc/genpeep.c b/gcc/genpeep.c
index 3ba930c..b914e85 100644
--- a/gcc/genpeep.c
+++ b/gcc/genpeep.c
@@ -389,7 +389,6 @@ from the machine description file `md'.  */\n\n");
   printf ("#include \"flags.h\"\n");
   printf ("#include \"tm-constrs.h\"\n\n");
 
-  printf ("#ifdef HAVE_peephole\n");
   printf ("extern rtx peep_operand[];\n\n");
   printf ("#define operands peep_operand\n\n");
 
@@ -423,7 +422,6 @@ from the machine description file `md'.  */\n\n");
 max_opno = 1;
 
   printf ("rtx peep_operand[%d];\n", max_opno + 1);
-  printf ("#endif\n");
 
   fflush (stdout);
   return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
diff --git a/gcc/output.h b/gcc/output.h
index 81d2ad2..4ce6eea 100644
--- a/gcc/output.h
+++ b/gcc/output.h
@@ -289,9 +289,7 @@ extern void assemble_addr_to_section (rtx, section *);
 /* Return the size of the constant pool.  */
 extern int get_pool_size (void);
 
-#ifdef HAVE_peephole
 extern rtx_insn *peephole (rtx_insn *);
-#endif
 
 extern void output_shared_constant_pool (void);
 
-- 
2.4.0.78.g7c6ecbf



[PATCH 6/7] remove #if HAVE_conditional_move

2015-05-20 Thread tbsaunde+gcc
From: Trevor Saunders 

gcc/ChangeLog:

2015-05-20  Trevor Saunders  

* *.c, *.h: DOn't check HAVE_conditional_move with the preprocessor.
---
 gcc/ChangeLog |  4 
 gcc/combine.c |  5 ++---
 gcc/expmed.c  | 13 +
 gcc/expr.c| 10 ++
 gcc/optabs.c  | 30 --
 gcc/optabs.h  |  2 --
 gcc/toplev.c  | 11 ++-
 7 files changed, 31 insertions(+), 44 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d115f6e..c20d608 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,9 @@
 2015-05-20  Trevor Saunders  
 
+   * *.c, *.h: DOn't check HAVE_conditional_move with the preprocessor.
+
+2015-05-20  Trevor Saunders  
+
* genconfig.c (main): Always define HAVE_conditional_move.
 
 2015-05-20  Trevor Saunders  
diff --git a/gcc/combine.c b/gcc/combine.c
index 45177c8..9615c79 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -6816,9 +6816,8 @@ simplify_set (rtx x)
   && (GET_CODE (XEXP (src, 0)) == EQ || GET_CODE (XEXP (src, 0)) == NE)
   && XEXP (XEXP (src, 0), 1) == const0_rtx
   && GET_MODE (src) == GET_MODE (XEXP (XEXP (src, 0), 0))
-#if HAVE_conditional_move
-  && ! can_conditionally_move_p (GET_MODE (src))
-#endif
+  && (!HAVE_conditional_move
+ || ! can_conditionally_move_p (GET_MODE (src)))
   && (num_sign_bit_copies (XEXP (XEXP (src, 0), 0),
   GET_MODE (XEXP (XEXP (src, 0), 0)))
  == GET_MODE_PRECISION (GET_MODE (XEXP (XEXP (src, 0), 0
diff --git a/gcc/expmed.c b/gcc/expmed.c
index 589a7a3..fa13f8c 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -3797,9 +3797,8 @@ expand_sdiv_pow2 (machine_mode mode, rtx op0, 
HOST_WIDE_INT d)
   return expand_shift (RSHIFT_EXPR, mode, temp, logd, NULL_RTX, 0);
 }
 
-#if HAVE_conditional_move
-  if (BRANCH_COST (optimize_insn_for_speed_p (), false)
-  >= 2)
+  if (HAVE_conditional_move
+  && BRANCH_COST (optimize_insn_for_speed_p (), false) >= 2)
 {
   rtx temp2;
 
@@ -3821,7 +3820,6 @@ expand_sdiv_pow2 (machine_mode mode, rtx op0, 
HOST_WIDE_INT d)
}
   end_sequence ();
 }
-#endif
 
   if (BRANCH_COST (optimize_insn_for_speed_p (),
   false) >= 2)
@@ -,7 +5553,9 @@ emit_store_flag (rtx target, enum rtx_code code, rtx op0, 
rtx op1,
target_mode);
}
 
-#if HAVE_conditional_move
+  if (!HAVE_conditional_move)
+   return 0;
+
   /* Try using a setcc instruction for ORDERED/UNORDERED, followed by a
 conditional move.  */
   tem = emit_store_flag_1 (subtarget, first_code, op0, op1, mode, 0,
@@ -5573,9 +5573,6 @@ emit_store_flag (rtx target, enum rtx_code code, rtx op0, 
rtx op1,
   if (tem == 0)
 delete_insns_since (last);
   return tem;
-#else
-  return 0;
-#endif
 }
 
   /* The remaining tricks only apply to integer comparisons.  */
diff --git a/gcc/expr.c b/gcc/expr.c
index efbf9fb..3605e99 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -2423,7 +2423,6 @@ get_def_for_expr (tree name, enum tree_code code)
   return def_stmt;
 }
 
-#if HAVE_conditional_move
 /* Return the defining gimple statement for SSA_NAME NAME if it is an
assigment and the class of the expresion on the RHS is CLASS.  Return
NULL otherwise.  */
@@ -2443,7 +2442,6 @@ get_def_for_expr_class (tree name, enum tree_code_class 
tclass)
 
   return def_stmt;
 }
-#endif
 
 
 /* Determine whether the LEN bytes generated by CONSTFUN can be
@@ -7517,7 +7515,6 @@ highest_pow2_factor_for_target (const_tree target, 
const_tree exp)
   return MAX (factor, talign);
 }
 
-#if HAVE_conditional_move
 /* Convert the tree comparison code TCODE to the rtl one where the
signedness is UNSIGNEDP.  */
 
@@ -7575,7 +7572,6 @@ convert_tree_comp_to_rtx (enum tree_code tcode, int 
unsignedp)
 }
   return code;
 }
-#endif
 
 /* Subroutine of expand_expr.  Expand the two operands of a binary
expression EXP0 and EXP1 placing the results in OP0 and OP1.
@@ -8021,7 +8017,6 @@ expand_cond_expr_using_cmove (tree treeop0 
ATTRIBUTE_UNUSED,
  tree treeop1 ATTRIBUTE_UNUSED,
  tree treeop2 ATTRIBUTE_UNUSED)
 {
-#if HAVE_conditional_move
   rtx insn;
   rtx op00, op01, op1, op2;
   enum rtx_code comparison_code;
@@ -8105,7 +8100,6 @@ expand_cond_expr_using_cmove (tree treeop0 
ATTRIBUTE_UNUSED,
   /* Otherwise discard the sequence and fall back to code with
  branches.  */
   end_sequence ();
-#endif
   return NULL_RTX;
 }
 
@@ -8892,7 +8886,7 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode 
tmode,
if (code == MIN_EXPR)
  comparison_code = LT;
  }
-#if HAVE_conditional_move
+
/* Use a conditional move if possible.  */
if (can_conditionally_move_p (mode))
  {
@@ -8920,7 +8914,7 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode 
tmode,
   branches.  */
end_sequenc

[PATCH 5/7] always define HAVE_conditional_move

2015-05-20 Thread tbsaunde+gcc
From: Trevor Saunders 

gcc/ChangeLog:

2015-05-20  Trevor Saunders  

* genconfig.c (main): Always define HAVE_conditional_move.
* *.c: Don't check if HAVE_conditional_move is defined.
---
 gcc/ChangeLog |  4 
 gcc/combine.c |  2 +-
 gcc/expmed.c  |  4 ++--
 gcc/expr.c|  8 
 gcc/genconfig.c   |  2 ++
 gcc/ifcvt.c   | 11 ---
 gcc/optabs.c  |  6 +++---
 gcc/optabs.h  |  2 +-
 gcc/toplev.c  |  2 +-
 gcc/tree-ssa-phiopt.c |  4 
 10 files changed, 18 insertions(+), 27 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 21ff1b8..d115f6e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,9 @@
 2015-05-20  Trevor Saunders  
 
+   * genconfig.c (main): Always define HAVE_conditional_move.
+
+2015-05-20  Trevor Saunders  
+
* *.c: Remove comparison of ARG_FRAME_POINTER_REGNUM and
FRAME_POINTER_REGNUM with the preprocessor.
 
diff --git a/gcc/combine.c b/gcc/combine.c
index 812b917..45177c8 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -6816,7 +6816,7 @@ simplify_set (rtx x)
   && (GET_CODE (XEXP (src, 0)) == EQ || GET_CODE (XEXP (src, 0)) == NE)
   && XEXP (XEXP (src, 0), 1) == const0_rtx
   && GET_MODE (src) == GET_MODE (XEXP (XEXP (src, 0), 0))
-#ifdef HAVE_conditional_move
+#if HAVE_conditional_move
   && ! can_conditionally_move_p (GET_MODE (src))
 #endif
   && (num_sign_bit_copies (XEXP (XEXP (src, 0), 0),
diff --git a/gcc/expmed.c b/gcc/expmed.c
index c95299c..589a7a3 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -3797,7 +3797,7 @@ expand_sdiv_pow2 (machine_mode mode, rtx op0, 
HOST_WIDE_INT d)
   return expand_shift (RSHIFT_EXPR, mode, temp, logd, NULL_RTX, 0);
 }
 
-#ifdef HAVE_conditional_move
+#if HAVE_conditional_move
   if (BRANCH_COST (optimize_insn_for_speed_p (), false)
   >= 2)
 {
@@ -,7 +,7 @@ emit_store_flag (rtx target, enum rtx_code code, rtx op0, 
rtx op1,
target_mode);
}
 
-#ifdef HAVE_conditional_move
+#if HAVE_conditional_move
   /* Try using a setcc instruction for ORDERED/UNORDERED, followed by a
 conditional move.  */
   tem = emit_store_flag_1 (subtarget, first_code, op0, op1, mode, 0,
diff --git a/gcc/expr.c b/gcc/expr.c
index 275c636..efbf9fb 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -2423,7 +2423,7 @@ get_def_for_expr (tree name, enum tree_code code)
   return def_stmt;
 }
 
-#ifdef HAVE_conditional_move
+#if HAVE_conditional_move
 /* Return the defining gimple statement for SSA_NAME NAME if it is an
assigment and the class of the expresion on the RHS is CLASS.  Return
NULL otherwise.  */
@@ -7517,7 +7517,7 @@ highest_pow2_factor_for_target (const_tree target, 
const_tree exp)
   return MAX (factor, talign);
 }
 
-#ifdef HAVE_conditional_move
+#if HAVE_conditional_move
 /* Convert the tree comparison code TCODE to the rtl one where the
signedness is UNSIGNEDP.  */
 
@@ -8021,7 +8021,7 @@ expand_cond_expr_using_cmove (tree treeop0 
ATTRIBUTE_UNUSED,
  tree treeop1 ATTRIBUTE_UNUSED,
  tree treeop2 ATTRIBUTE_UNUSED)
 {
-#ifdef HAVE_conditional_move
+#if HAVE_conditional_move
   rtx insn;
   rtx op00, op01, op1, op2;
   enum rtx_code comparison_code;
@@ -8892,7 +8892,7 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode 
tmode,
if (code == MIN_EXPR)
  comparison_code = LT;
  }
-#ifdef HAVE_conditional_move
+#if HAVE_conditional_move
/* Use a conditional move if possible.  */
if (can_conditionally_move_p (mode))
  {
diff --git a/gcc/genconfig.c b/gcc/genconfig.c
index 2247eef..a3e5b31 100644
--- a/gcc/genconfig.c
+++ b/gcc/genconfig.c
@@ -352,6 +352,8 @@ main (int argc, char **argv)
 
   if (have_cmove_flag)
 printf ("#define HAVE_conditional_move 1\n");
+  else
+printf ("#define HAVE_conditional_move 0\n");
 
   if (have_cond_exec_flag)
 printf ("#define HAVE_conditional_execution 1\n");
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index b00aaa4..37117b7 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -72,9 +72,6 @@
 #include "shrink-wrap.h"
 #include "ifcvt.h"
 
-#ifndef HAVE_conditional_move
-#define HAVE_conditional_move 0
-#endif
 #ifndef HAVE_incscc
 #define HAVE_incscc 0
 #endif
@@ -1505,7 +1502,6 @@ noce_emit_cmove (struct noce_if_info *if_info, rtx x, 
enum rtx_code code,
return NULL_RTX;
 }
 
-#if HAVE_conditional_move
   unsignedp = (code == LTU || code == GEU
   || code == LEU || code == GTU);
 
@@ -1562,13 +1558,6 @@ noce_emit_cmove (struct noce_if_info *if_info, rtx x, 
enum rtx_code code,
 }
   else
 return NULL_RTX;
-#else
-  /* We'll never get here, as noce_process_if_block doesn't call the
- functions involved.  Ifdef code, however, should be discouraged
- because it leads to typos in the code not selected.  However,
- emit_conditional_move won'

[PATCH 4/7] don't compare ARG_FRAME_POINTER_REGNUM and FRAME_POINTER_REGNUM with the preprocessor

2015-05-20 Thread tbsaunde+gcc
From: Trevor Saunders 

gcc/ChangeLog:

2015-05-20  Trevor Saunders  

* *.c: Remove comparison of ARG_FRAME_POINTER_REGNUM and
FRAME_POINTER_REGNUM with the preprocessor.
---
 gcc/ChangeLog |  5 +
 gcc/combine.c | 18 +++---
 gcc/df-problems.c |  5 ++---
 gcc/df-scan.c | 19 +++
 gcc/emit-rtl.c|  5 +++--
 gcc/reginfo.c |  5 ++---
 gcc/reload.c  |  5 ++---
 gcc/rtlanal.c |  5 ++---
 8 files changed, 30 insertions(+), 37 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2d51c33..21ff1b8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
 2015-05-20  Trevor Saunders  
 
+   * *.c: Remove comparison of ARG_FRAME_POINTER_REGNUM and
+   FRAME_POINTER_REGNUM with the preprocessor.
+
+2015-05-20  Trevor Saunders  
+
* defaults.h: Add default for STACK_PUSH_CODE.
* expr.c: Don't redefine STACK_PUSH_CODE.
* recog.c: Likewise.
diff --git a/gcc/combine.c b/gcc/combine.c
index a90849e..812b917 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -1028,10 +1028,8 @@ can_combine_def_p (df_ref def)
   || (regno == HARD_FRAME_POINTER_REGNUM
  && (!reload_completed || frame_pointer_needed))
 #endif
-#if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
-  || (regno == ARG_POINTER_REGNUM && fixed_regs[regno])
-#endif
-  )
+  || (FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
+ && regno == ARG_POINTER_REGNUM && fixed_regs[regno]))
 return false;
 
   return true;
@@ -2247,10 +2245,9 @@ combinable_i3pat (rtx_insn *i3, rtx *loc, rtx i2dest, 
rtx i1dest, rtx i0dest,
 #if !HARD_FRAME_POINTER_IS_FRAME_POINTER
  && REGNO (subdest) != HARD_FRAME_POINTER_REGNUM
 #endif
-#if ARG_POINTER_REGNUM != FRAME_POINTER_REGNUM
- && (REGNO (subdest) != ARG_POINTER_REGNUM
- || ! fixed_regs [REGNO (subdest)])
-#endif
+ && (FRAME_POINTER_REGNUM == ARG_POINTER_REGNUM
+ || (REGNO (subdest) != ARG_POINTER_REGNUM
+ || ! fixed_regs [REGNO (subdest)]))
  && REGNO (subdest) != STACK_POINTER_REGNUM)
{
  if (*pi3dest_killed)
@@ -13338,9 +13335,8 @@ mark_used_regs_combine (rtx x)
 #if !HARD_FRAME_POINTER_IS_FRAME_POINTER
  || regno == HARD_FRAME_POINTER_REGNUM
 #endif
-#if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
- || (regno == ARG_POINTER_REGNUM && fixed_regs[regno])
-#endif
+ || (FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
+ && regno == ARG_POINTER_REGNUM && fixed_regs[regno])
  || regno == FRAME_POINTER_REGNUM)
return;
 
diff --git a/gcc/df-problems.c b/gcc/df-problems.c
index 25cfe08..ff08abd 100644
--- a/gcc/df-problems.c
+++ b/gcc/df-problems.c
@@ -933,12 +933,11 @@ df_lr_local_compute (bitmap all_blocks ATTRIBUTE_UNUSED)
 reference of the frame pointer.  */
   bitmap_set_bit (&df->hardware_regs_used, FRAME_POINTER_REGNUM);
 
-#if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
   /* Pseudos with argument area equivalences may require
 reloading via the argument pointer.  */
-  if (fixed_regs[ARG_POINTER_REGNUM])
+  if (FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
+ && fixed_regs[ARG_POINTER_REGNUM])
bitmap_set_bit (&df->hardware_regs_used, ARG_POINTER_REGNUM);
-#endif
 
   /* Any constant, or pseudo with constant equivalences, may
 require reloading from memory using the pic register.  */
diff --git a/gcc/df-scan.c b/gcc/df-scan.c
index c831730..389ce1c 100644
--- a/gcc/df-scan.c
+++ b/gcc/df-scan.c
@@ -3446,12 +3446,11 @@ df_get_regular_block_artificial_uses (bitmap 
regular_block_artificial_uses)
bitmap_set_bit (regular_block_artificial_uses,
HARD_FRAME_POINTER_REGNUM);
 
-#if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
   /* Pseudos with argument area equivalences may require
 reloading via the argument pointer.  */
-  if (fixed_regs[ARG_POINTER_REGNUM])
+  if (FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
+ && fixed_regs[ARG_POINTER_REGNUM])
bitmap_set_bit (regular_block_artificial_uses, ARG_POINTER_REGNUM);
-#endif
 
   /* Any constant, or pseudo with constant equivalences, may
 require reloading from memory using the pic register.  */
@@ -3498,10 +3497,9 @@ df_get_eh_block_artificial_uses (bitmap 
eh_block_artificial_uses)
bitmap_set_bit (eh_block_artificial_uses,
HARD_FRAME_POINTER_REGNUM);
}
-#if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
-  if (fixed_regs[ARG_POINTER_REGNUM])
+  if (FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
+ && fixed_regs[ARG_POINTER_REGNUM])
bitmap_set_bit (eh_block_artificial_uses, ARG_POINTER_REGNUM);
-#endif
 }
 }
 
@@ -3579,12 +3577,11 @@ df_get_entry_block_def_set (bitmap entry_block_defs)
   /* These registers are live everywhere.  */
   if (!reload_completed)
 {
-#if FRAME_POINTER_REGNUM != ARG_PO

[PATCH 3/7] move default for STACK_PUSH_CODE to defaults.h

2015-05-20 Thread tbsaunde+gcc
From: Trevor Saunders 

gcc/ChangeLog:

2015-05-20  Trevor Saunders  

* defaults.h: Add default for STACK_PUSH_CODE.
* expr.c: Don't redefine STACK_PUSH_CODE.
* recog.c: Likewise.
---
 gcc/ChangeLog  | 6 ++
 gcc/defaults.h | 8 
 gcc/expr.c | 8 
 gcc/recog.c| 8 
 4 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1e6bad9..2d51c33 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
 2015-05-20  Trevor Saunders  
 
+   * defaults.h: Add default for STACK_PUSH_CODE.
+   * expr.c: Don't redefine STACK_PUSH_CODE.
+   * recog.c: Likewise.
+
+2015-05-20  Trevor Saunders  
+
* *.c: Use if instead of preprocessor checks with
STACK_GROWS_DOWNWARD.
 
diff --git a/gcc/defaults.h b/gcc/defaults.h
index a01969a..e7bbcb8 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -1233,6 +1233,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. 
 If not, see
 #define STACK_GROWS_DOWNWARD 0
 #endif
 
+#ifndef STACK_PUSH_CODE
+#if STACK_GROWS_DOWNWARD
+#define STACK_PUSH_CODE PRE_DEC
+#else
+#define STACK_PUSH_CODE PRE_INC
+#endif
+#endif
+
 #ifdef GCC_INSN_FLAGS_H
 /* Dependent default target macro definitions
 
diff --git a/gcc/expr.c b/gcc/expr.c
index 09fc694..275c636 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -98,14 +98,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "rtl-chkp.h"
 #include "ccmp.h"
 
-#ifndef STACK_PUSH_CODE
-#if STACK_GROWS_DOWNWARD
-#define STACK_PUSH_CODE PRE_DEC
-#else
-#define STACK_PUSH_CODE PRE_INC
-#endif
-#endif
-
 
 /* If this is nonzero, we do not bother generating VOLATILE
around volatile memory references, and we are willing to
diff --git a/gcc/recog.c b/gcc/recog.c
index 524be67..39a5d1f 100644
--- a/gcc/recog.c
+++ b/gcc/recog.c
@@ -68,14 +68,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "df.h"
 #include "insn-codes.h"
 
-#ifndef STACK_PUSH_CODE
-#if STACK_GROWS_DOWNWARD
-#define STACK_PUSH_CODE PRE_DEC
-#else
-#define STACK_PUSH_CODE PRE_INC
-#endif
-#endif
-
 #ifndef STACK_POP_CODE
 #if STACK_GROWS_DOWNWARD
 #define STACK_POP_CODE POST_INC
-- 
2.4.0.78.g7c6ecbf



[PATCH 1/7] always define STACK_GROWS_DOWNWARD

2015-05-20 Thread tbsaunde+gcc
From: Trevor Saunders 

gcc/c-family/ChangeLog:

2015-05-20  Trevor Saunders  

* c-cppbuiltin.c (c_cpp_builtins): Check the value of
STACK_GROWS_DOWNWARD rather than if it is defined.

gcc/ChangeLog:

2015-05-20  Trevor Saunders  

* *.c: Check the value of STACK_GROWS_DOWNWARD rather than if it
is defined.
* config/**/*.h: Define STACK_GROWS_DOWNWARD to an integer.
* defaults.h: Provide default for STACK_GROWS_DOWNWARD.
---
 gcc/ChangeLog  |  7 +++
 gcc/builtins.c |  6 +++---
 gcc/c-family/ChangeLog |  5 +
 gcc/c-family/c-cppbuiltin.c|  2 +-
 gcc/calls.c|  8 
 gcc/combine-stack-adj.c|  8 
 gcc/config/alpha/alpha.h   |  2 +-
 gcc/config/arc/arc.h   |  2 +-
 gcc/config/avr/avr.h   |  2 +-
 gcc/config/bfin/bfin.h |  2 +-
 gcc/config/c6x/c6x.h   |  2 +-
 gcc/config/cr16/cr16.h |  2 +-
 gcc/config/cris/cris.h |  2 +-
 gcc/config/epiphany/epiphany.h |  2 +-
 gcc/config/h8300/h8300.h   |  2 +-
 gcc/config/i386/i386.h |  2 +-
 gcc/config/iq2000/iq2000.h |  2 +-
 gcc/config/m32r/m32r.h |  2 +-
 gcc/config/mcore/mcore.h   |  2 +-
 gcc/config/microblaze/microblaze.h |  2 +-
 gcc/config/mips/mips.h |  2 +-
 gcc/config/mmix/mmix.h |  2 +-
 gcc/config/mn10300/mn10300.h   |  2 +-
 gcc/config/moxie/moxie.h   |  2 +-
 gcc/config/nds32/nds32.h   |  2 +-
 gcc/config/nios2/nios2.h   |  2 +-
 gcc/config/nvptx/nvptx.h   |  2 +-
 gcc/config/pdp11/pdp11.h   |  2 +-
 gcc/config/rs6000/rs6000.h |  2 +-
 gcc/config/s390/s390.h |  2 +-
 gcc/config/sh/sh.h |  2 +-
 gcc/config/sparc/sparc.h   |  2 +-
 gcc/config/spu/spu.h   |  2 +-
 gcc/config/tilegx/tilegx.h |  2 +-
 gcc/config/tilepro/tilepro.h   |  2 +-
 gcc/config/v850/v850.h |  2 +-
 gcc/config/vax/vax.h   |  2 +-
 gcc/config/xtensa/xtensa.h |  2 +-
 gcc/defaults.h |  4 
 gcc/dwarf2cfi.c|  4 ++--
 gcc/explow.c   | 10 +-
 gcc/expr.c | 20 
 gcc/ira-color.c|  8 
 gcc/lower-subreg.c |  7 ---
 gcc/lra-spills.c   |  8 
 gcc/recog.c|  6 +++---
 gcc/sched-deps.c   |  2 +-
 47 files changed, 71 insertions(+), 98 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5bcbcb4..2dec0c3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2015-05-20  Trevor Saunders  
+
+   * *.c: Check the value of STACK_GROWS_DOWNWARD rather than if it
+   is defined.
+   * config/**/*.h: Define STACK_GROWS_DOWNWARD to an integer.
+   * defaults.h: Provide default for STACK_GROWS_DOWNWARD.
+
 2015-05-20  Mikhail Maltsev  
 
* bb-reorder.c (set_edge_can_fallthru_flag): Use rtx_jump_insn where
diff --git a/gcc/builtins.c b/gcc/builtins.c
index f6012af..e81ab04 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -1521,7 +1521,7 @@ expand_builtin_apply_args_1 (void)
 
   /* Save the arg pointer to the block.  */
   tem = copy_to_reg (crtl->args.internal_arg_pointer);
-#ifdef STACK_GROWS_DOWNWARD
+#if STACK_GROWS_DOWNWARD
   /* We need the pointer as the caller actually passed them to us, not
  as we might have pretended they were passed.  Make sure it's a valid
  operand, as emit_move_insn isn't expected to handle a PLUS.  */
@@ -1613,7 +1613,7 @@ expand_builtin_apply (rtx function, rtx arguments, rtx 
argsize)
   /* Fetch the arg pointer from the ARGUMENTS block.  */
   incoming_args = gen_reg_rtx (Pmode);
   emit_move_insn (incoming_args, gen_rtx_MEM (Pmode, arguments));
-#ifndef STACK_GROWS_DOWNWARD
+#if !STACK_GROWS_DOWNWARD
   incoming_args = expand_simple_binop (Pmode, MINUS, incoming_args, argsize,
   incoming_args, 0, OPTAB_LIB_WIDEN);
 #endif
@@ -1646,7 +1646,7 @@ expand_builtin_apply (rtx function, rtx arguments, rtx 
argsize)
 crtl->need_drap = true;
 
   dest = virtual_outgoing_args_rtx;
-#ifndef STACK_GROWS_DOWNWARD
+#if !STACK_GROWS_DOWNWARD
   if (CONST_INT_P (argsize))
 dest = plus_constant (Pmode, dest, -INTVAL (argsize));
   else
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 9d7736e..7b526a6 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,8 @@
+2015-05-20  Trevor Saunders  
+
+   * c-cppbuiltin.c (c_cpp_builtins): Check the value of
+   STACK_GROWS_DOWNWARD rather than if it is defined.
+
 2015-05-20  Marek Polacek  
 
* c-omp.c (check_omp_for_incr_expr): Use BINARY_CLASS_P.
diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c
index 6

[PATCH 2/7] remove most ifdef STACK_GROWS_DOWNWARD

2015-05-20 Thread tbsaunde+gcc
From: Trevor Saunders 

gcc/c-family/ChangeLog:

2015-05-20  Trevor Saunders  

* c-cppbuiltin.c (c_cpp_builtins): Use if instead of #if with
STACK_GROWS_DOWNWARD.

gcc/ChangeLog:

2015-05-20  Trevor Saunders  

* *.c: Use if instead of preprocessor checks with
STACK_GROWS_DOWNWARD.
---
 gcc/ChangeLog   |  5 
 gcc/builtins.c  | 30 +++
 gcc/c-family/ChangeLog  |  5 
 gcc/c-family/c-cppbuiltin.c |  5 ++--
 gcc/dwarf2cfi.c | 12 +-
 gcc/explow.c| 33 --
 gcc/expr.c  | 58 +++--
 gcc/recog.c |  8 ++-
 gcc/sched-deps.c|  9 ---
 9 files changed, 78 insertions(+), 87 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2dec0c3..1e6bad9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
 2015-05-20  Trevor Saunders  
 
+   * *.c: Use if instead of preprocessor checks with
+   STACK_GROWS_DOWNWARD.
+
+2015-05-20  Trevor Saunders  
+
* *.c: Check the value of STACK_GROWS_DOWNWARD rather than if it
is defined.
* config/**/*.h: Define STACK_GROWS_DOWNWARD to an integer.
diff --git a/gcc/builtins.c b/gcc/builtins.c
index e81ab04..d92535e 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -1521,14 +1521,14 @@ expand_builtin_apply_args_1 (void)
 
   /* Save the arg pointer to the block.  */
   tem = copy_to_reg (crtl->args.internal_arg_pointer);
-#if STACK_GROWS_DOWNWARD
   /* We need the pointer as the caller actually passed them to us, not
  as we might have pretended they were passed.  Make sure it's a valid
  operand, as emit_move_insn isn't expected to handle a PLUS.  */
-  tem
-= force_operand (plus_constant (Pmode, tem, crtl->args.pretend_args_size),
-NULL_RTX);
-#endif
+  if (STACK_GROWS_DOWNWARD)
+tem
+  = force_operand (plus_constant (Pmode, tem,
+ crtl->args.pretend_args_size),
+  NULL_RTX);
   emit_move_insn (adjust_address (registers, Pmode, 0), tem);
 
   size = GET_MODE_SIZE (Pmode);
@@ -1613,10 +1613,9 @@ expand_builtin_apply (rtx function, rtx arguments, rtx 
argsize)
   /* Fetch the arg pointer from the ARGUMENTS block.  */
   incoming_args = gen_reg_rtx (Pmode);
   emit_move_insn (incoming_args, gen_rtx_MEM (Pmode, arguments));
-#if !STACK_GROWS_DOWNWARD
-  incoming_args = expand_simple_binop (Pmode, MINUS, incoming_args, argsize,
-  incoming_args, 0, OPTAB_LIB_WIDEN);
-#endif
+  if (!STACK_GROWS_DOWNWARD)
+incoming_args = expand_simple_binop (Pmode, MINUS, incoming_args, argsize,
+incoming_args, 0, OPTAB_LIB_WIDEN);
 
   /* Push a new argument block and copy the arguments.  Do not allow
  the (potential) memcpy call below to interfere with our stack
@@ -1646,12 +1645,13 @@ expand_builtin_apply (rtx function, rtx arguments, rtx 
argsize)
 crtl->need_drap = true;
 
   dest = virtual_outgoing_args_rtx;
-#if !STACK_GROWS_DOWNWARD
-  if (CONST_INT_P (argsize))
-dest = plus_constant (Pmode, dest, -INTVAL (argsize));
-  else
-dest = gen_rtx_PLUS (Pmode, dest, negate_rtx (Pmode, argsize));
-#endif
+  if (!STACK_GROWS_DOWNWARD)
+{
+  if (CONST_INT_P (argsize))
+   dest = plus_constant (Pmode, dest, -INTVAL (argsize));
+  else
+   dest = gen_rtx_PLUS (Pmode, dest, negate_rtx (Pmode, argsize));
+}
   dest = gen_rtx_MEM (BLKmode, dest);
   set_mem_align (dest, PARM_BOUNDARY);
   src = gen_rtx_MEM (BLKmode, incoming_args);
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 7b526a6..b219cb9 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,5 +1,10 @@
 2015-05-20  Trevor Saunders  
 
+   * c-cppbuiltin.c (c_cpp_builtins): Use if instead of #if with
+   STACK_GROWS_DOWNWARD.
+
+2015-05-20  Trevor Saunders  
+
* c-cppbuiltin.c (c_cpp_builtins): Check the value of
STACK_GROWS_DOWNWARD rather than if it is defined.
 
diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c
index da9cb2f..4170154 100644
--- a/gcc/c-family/c-cppbuiltin.c
+++ b/gcc/c-family/c-cppbuiltin.c
@@ -1138,9 +1138,8 @@ c_cpp_builtins (cpp_reader *pfile)
 TRAMPOLINE_SIZE);
 
   /* For libgcc generic-morestack.c and unwinder code.  */
-#if STACK_GROWS_DOWNWARD
-  cpp_define (pfile, "__LIBGCC_STACK_GROWS_DOWNWARD__");
-#endif
+  if (STACK_GROWS_DOWNWARD)
+   cpp_define (pfile, "__LIBGCC_STACK_GROWS_DOWNWARD__");
 
   /* For libgcc unwinder code.  */
 #ifdef DONT_USE_BUILTIN_SETJMP
diff --git a/gcc/dwarf2cfi.c b/gcc/dwarf2cfi.c
index 8b8931f..4b6929e 100644
--- a/gcc/dwarf2cfi.c
+++ b/gcc/dwarf2cfi.c
@@ -944,9 +944,9 @@ notice_args_size (rtx_insn *insn)
 
   /* Convert a change in args_size (always a positive in the

[PATCH 0/7] Some ifdef removal

2015-05-20 Thread tbsaunde+gcc
From: Trevor Saunders 

Hi,

Another week and more patches to remove conditional compilation ;-)

each patch individually bootstrapped + regtested on x86_64-unknown-linux-gnu,
and run through config-list.mk with a couple more patches I'll commit when I
finish writing ChangeLogs.  Committing to trunk, but of course reviews are
great!

Trev


Trevor Saunders (7):
  always define STACK_GROWS_DOWNWARD
  remove most ifdef STACK_GROWS_DOWNWARD
  move default for STACK_PUSH_CODE to defaults.h
  don't compare ARG_FRAME_POINTER_REGNUM and FRAME_POINTER_REGNUM with
the preprocessor
  always define HAVE_conditional_move
  remove #if HAVE_conditional_move
  always define HAVE_peephole

 gcc/ChangeLog  | 39 ++
 gcc/builtins.c | 30 +++---
 gcc/c-family/ChangeLog | 10 +
 gcc/c-family/c-cppbuiltin.c|  5 +--
 gcc/calls.c|  8 
 gcc/combine-stack-adj.c|  8 
 gcc/combine.c  | 23 +--
 gcc/config/alpha/alpha.h   |  2 +-
 gcc/config/arc/arc.h   |  2 +-
 gcc/config/avr/avr.h   |  2 +-
 gcc/config/bfin/bfin.h |  2 +-
 gcc/config/c6x/c6x.h   |  2 +-
 gcc/config/cr16/cr16.h |  2 +-
 gcc/config/cris/cris.h |  2 +-
 gcc/config/epiphany/epiphany.h |  2 +-
 gcc/config/h8300/h8300.h   |  2 +-
 gcc/config/i386/i386.h |  2 +-
 gcc/config/iq2000/iq2000.h |  2 +-
 gcc/config/m32r/m32r.h |  2 +-
 gcc/config/mcore/mcore.h   |  2 +-
 gcc/config/microblaze/microblaze.h |  2 +-
 gcc/config/mips/mips.h |  2 +-
 gcc/config/mmix/mmix.h |  2 +-
 gcc/config/mn10300/mn10300.h   |  2 +-
 gcc/config/moxie/moxie.h   |  2 +-
 gcc/config/nds32/nds32.h   |  2 +-
 gcc/config/nios2/nios2.h   |  2 +-
 gcc/config/nvptx/nvptx.h   |  2 +-
 gcc/config/pdp11/pdp11.h   |  2 +-
 gcc/config/rs6000/rs6000.h |  2 +-
 gcc/config/s390/s390.h |  2 +-
 gcc/config/sh/sh.h |  2 +-
 gcc/config/sparc/sparc.h   |  2 +-
 gcc/config/spu/spu.h   |  2 +-
 gcc/config/tilegx/tilegx.h |  2 +-
 gcc/config/tilepro/tilepro.h   |  2 +-
 gcc/config/v850/v850.h |  2 +-
 gcc/config/vax/vax.h   |  2 +-
 gcc/config/xtensa/xtensa.h |  2 +-
 gcc/defaults.h | 12 ++
 gcc/df-problems.c  |  5 +--
 gcc/df-scan.c  | 19 -
 gcc/dwarf2cfi.c| 12 +++---
 gcc/emit-rtl.c |  5 ++-
 gcc/explow.c   | 35 
 gcc/expmed.c   | 13 +++---
 gcc/expr.c | 82 +-
 gcc/final.c|  4 +-
 gcc/genconfig.c|  4 ++
 gcc/genpeep.c  |  2 -
 gcc/ifcvt.c| 11 -
 gcc/ira-color.c|  8 
 gcc/lower-subreg.c |  7 
 gcc/lra-spills.c   |  8 
 gcc/optabs.c   | 30 ++
 gcc/optabs.h   |  2 -
 gcc/output.h   |  2 -
 gcc/recog.c| 18 ++---
 gcc/reginfo.c  |  5 +--
 gcc/reload.c   |  5 +--
 gcc/rtlanal.c  |  5 +--
 gcc/sched-deps.c   |  9 ++---
 gcc/toplev.c   | 11 ++---
 gcc/tree-ssa-phiopt.c  |  4 --
 64 files changed, 221 insertions(+), 284 deletions(-)

-- 
2.4.0.78.g7c6ecbf



RE: [PATCH] Fix PR66168: ICE due to incorrect invariant register info

2015-05-20 Thread Thomas Preud'homme
> From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches-
> ow...@gcc.gnu.org] On Behalf Of Thomas Preud'homme
> > From: Steven Bosscher [mailto:stevenb@gmail.com]
> > Sent: Tuesday, May 19, 2015 7:21 PM
> >
> > Not OK.
> > This will break in move_invariants() when it looks at REGNO (inv->reg).
> 
> Indeed. I'm even surprised all tests passed. Ok I will just prevent moving
> in such a case. I'm running the tests now and will get back to you
> tomorrow.

Patch is now tested via bootstrap + testsuite run on x86_64-linux-gnu and
building arm-none-eabi cross-compiler + testsuite run. Both testsuite run
show no regression.

diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c
index 76a009f..4ce3576 100644
--- a/gcc/loop-invariant.c
+++ b/gcc/loop-invariant.c
@@ -1626,7 +1626,7 @@ move_invariant_reg (struct loop *loop, unsigned invno)
   if (REG_P (reg))
regno = REGNO (reg);
 
-  if (!can_move_invariant_reg (loop, inv, reg))
+  if (!can_move_invariant_reg (loop, inv, dest))
{
  reg = gen_reg_rtx_and_attrs (dest);
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr66168.c 
b/gcc/testsuite/gcc.c-torture/compile/pr66168.c
new file mode 100644
index 000..d6bfc7b
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr66168.c
@@ -0,0 +1,15 @@
+int a, b;
+
+void
+fn1 ()
+{
+  for (;;)
+{
+  for (b = 0; b < 3; b++)
+   {
+ char e[2];
+ char f = e[1];
+ a ^= f ? 1 / f : 0;
+   }
+}
+}

Ok for trunk?

Best regards,

Thomas 





Re: [PATCH 3/4] split-stack for powerpc64

2015-05-20 Thread Alan Modra
Older assemblers don't understand .abiversion, so I'm committing the
following as obvious to fix a problem Michael Meissner found when
building gcc for powerpc64-linux.

PR libgcc/66225
* config/rs6000/morestack.S: Remove ".abiversion 1".

Index: libgcc/config/rs6000/morestack.S
===
--- libgcc/config/rs6000/morestack.S(revision 223463)
+++ libgcc/config/rs6000/morestack.S(working copy)
@@ -28,7 +28,6 @@
.abiversion 2
 #define PARAMS 32
 #else
-   .abiversion 1
 #define PARAMS 48
 #endif
 #define MORESTACK_FRAMESIZE(PARAMS+96)

-- 
Alan Modra
Australia Development Lab, IBM


Re: [patch 3/10] debug-early merge: C++ front-end

2015-05-20 Thread Jason Merrill

OK.

Jason


Re: PING^3: [PATCH]: New configure options that make the compiler use -fPIE and -pie as default option

2015-05-20 Thread H.J. Lu
On Wed, May 20, 2015 at 3:53 PM, Hans-Peter Nilsson
 wrote:
>> From: "H.J. Lu" 
>> Date: Tue, 19 May 2015 21:20:46 +0200
>
>> This patch affects your target.  Can you verify if it is OK on
>> your target?
>
> If you mean philosophically, it's ok when the general bits and
> direction are ok, but for the practical part of checking
> e.g. for typos through compilation, please use yourself a script
> like gcc/contrib/config-list.mk.
>

I will run it after I get feedbacks from target maintainers before
I check in my patch.

>
>> * config/cris/linux.h (CRIS_ASM_SUBTARGET_SPEC): Likewise.
>
> ok.
>

Thanks.

-- 
H.J.


Re: [patch,gomp4] error on invalid acc loop clauses

2015-05-20 Thread Cesar Philippidis
On 05/20/2015 07:32 AM, Jakub Jelinek wrote:

> For OpenMP/OpenACC, there is still lots of diagnostics emitted during
> gimplification and at the start of the omp lowering phases, so for
> diagnostics purposes you can consider them as part of a common layer for all
> the 3 FEs.

Thanks, that makes sense. I didn't touch the fortran front end, but I
did revert most of my c and c++ front end changes in gomp-4_0-branch to
defer all of the common error checking to the omp lowering phase.

Is this patch ok for gomp-4_0-branch?

Cesar
2015-05-20  Cesar Philippidis  

	gcc/c/
	* c-parser.c (typedef struct c_parser): Remove oacc_parallel_region
	and oacc_kernels_region.
	(c_parser_oacc_shape_clause): Don't check for parallel-specific
	clauses here.
	(c_parser_oacc_loop): Don't check for incompatible clauses.
	(c_parser_oacc_kernels): Don't check for nested parallelism.
	(c_parser_oacc_parallel): Likewise.

	gcc/cp/
	* parser.h: Remove oacc_parallel_region and oacc_kernels_region. 
	* parser.c (cp_parser_oacc_shape_clause): Don't check for
	parallel-specific clauses here.
	(cp_parser_oacc_loop): Don't check for incompatible clauses.
	(cp_parser_oacc_parallel_kernels): Don't check for nested parallelism.

	gcc/
	* omp-low.c (enclosing_target_ctx): Un-ifdef. Remove null checking
	assert.
	(scan_omp_for): Check for incompatible combination of acc loop clauses.

	 gcc/testsuite/
	* c-c++-common/goacc/loop-2.c (main): New test.
	* c-c++-common/goacc/nesting-fail-1.c (f_acc_parallel): Update error
	messages.


diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index f508b91..4099cc4 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -234,10 +234,6 @@ typedef struct GTY(()) c_parser {
   /* True if we are in a context where the Objective-C "Property attribute"
  keywords are valid.  */
   BOOL_BITFIELD objc_property_attr_context : 1;
-  /* True if we are inside a OpenACC parallel region.  */
-  BOOL_BITFIELD oacc_parallel_region : 1;
-  /* True if we are inside a OpenACC kernels region.  */
-  BOOL_BITFIELD oacc_kernels_region : 1;
 
   /* Cilk Plus specific parser/lexer information.  */
 
@@ -10857,17 +10853,6 @@ c_parser_oacc_shape_clause (c_parser *parser, pragma_omp_clause c_kind,
   if (op1)
 OMP_CLAUSE_OPERAND (c, 1) = op1;
   OMP_CLAUSE_CHAIN (c) = list;
-
-  if (parser->oacc_parallel_region && (op0 != NULL || op1 != NULL))
-{
-  if (c_kind != PRAGMA_OACC_CLAUSE_GANG)
-	c_parser_error (parser, c_kind == PRAGMA_OACC_CLAUSE_WORKER ?
-			"worker clause arguments are not supported in OpenACC parallel regions"
-			: "vector clause arguments are not supported in OpenACC parallel regions");
-  else if (op0 != NULL)
-	c_parser_error (parser, "non-static argument to clause gang");
-}
-
   return c;
 }
 
@@ -12737,10 +12722,7 @@ static tree
 c_parser_oacc_loop (location_t loc, c_parser *parser, char *p_name,
 		omp_clause_mask mask, tree *cclauses)
 {
-  tree stmt, clauses, block, c;
-  bool gwv = false;
-  bool auto_clause = false;
-  bool seq_clause = false;
+  tree stmt, clauses, block;
 
   strcat (p_name, " loop");
   mask |= OACC_LOOP_CLAUSE_MASK;
@@ -12751,33 +12733,6 @@ c_parser_oacc_loop (location_t loc, c_parser *parser, char *p_name,
   if (cclauses)
 clauses = oacc_split_loop_clauses (clauses, cclauses);
 
-  for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
-{
-  switch (OMP_CLAUSE_CODE (c))
-	{
-	case OMP_CLAUSE_GANG:
-	case OMP_CLAUSE_WORKER:
-	case OMP_CLAUSE_VECTOR:
-	  gwv = true;
-	  break;
-	case OMP_CLAUSE_AUTO:
-	  auto_clause = true;
-	  break;
-	case OMP_CLAUSE_SEQ:
-	  seq_clause = true;
-	  break;
-	default:
-	  ;
-	}
-}
-
-  if (gwv && auto_clause)
-c_parser_error (parser, "incompatible use of clause %");
-  else if (gwv && seq_clause)
-c_parser_error (parser, "incompatible use of clause %");
-  else if (auto_clause && seq_clause)
-c_parser_error (parser, "incompatible use of clause % and %");
-
   block = c_begin_compound_stmt (true);
   stmt = c_parser_omp_for_loop (loc, parser, OACC_LOOP, clauses, NULL);
   block = c_end_compound_stmt (loc, block, true);
@@ -12820,13 +12775,6 @@ c_parser_oacc_kernels (location_t loc, c_parser *parser, char *p_name)
 
   strcat (p_name, " kernels");
 
-  if (parser->oacc_parallel_region || parser->oacc_kernels_region)
-{
-  c_parser_error (parser, "nested kernels region");
-}
-
-  parser->oacc_kernels_region = true;
-
   mask = OACC_KERNELS_CLAUSE_MASK;
   if (c_parser_next_token_is (parser, CPP_NAME))
 {
@@ -12840,7 +12788,6 @@ c_parser_oacc_kernels (location_t loc, c_parser *parser, char *p_name)
 	  block = c_begin_omp_parallel ();
 	  c_parser_oacc_loop (loc, parser, p_name, mask, &kernel_clauses);
 	  stmt = c_finish_oacc_kernels (loc, kernel_clauses, block);
-	  parser->oacc_kernels_region = false;
 	  return stmt;
 	}
 }
@@ -12851,7 +12798,6 @@ c_parser_oacc_kernels (location_t loc, c_parser *parser, char *p_name)
   block = c_begin_omp_parallel ();
   add_stmt (c_parser_omp_structu

Re: [PATCH] 65479 - sanitizer stack trace missing frames past #0 on powerpc64

2015-05-20 Thread Martin Sebor

Now that I know a bit more from Jakub & Yuri's comments, I don't think
we should be turning that flag on for all the targets in the testsuite.
  I was primarily trying to avoid someone else having to go through the
same analysis and reach the same conclusion for another port.  But I'm
less concerned about that now.

I totally understand the desire to have a good baseline.  Jakub seems to
prefer not to make this change since it's a short-lived workaround,
which I understand as well.

My inclination is to go ahead with flags changes in the testsuite.
Cleaner results are, in and of themselves, a good thing.  Pulling those
lines out once the port is using the fast unwind stuff is easy enough to
do.


Adding the flags without making any of the other changes will
not improve the pass rate. The tests hardcode the line numbers
expected to be printed in the stack trace and those are wrong
as a result of both the libbacktrace bug and the ASan bug. We
need to fix both of those to eliminate the test failures.


This part should definitely hit the LLVM side first, then we can pull it
into GCC.  So that process should be started.


I opened compiler_rt/23600 and attached the sanitizer patch
to it:

  http://llvm.org/bugs/show_bug.cgi?id=23600

If there are no objections to the bug I'll post the patch for
review next.


So I'll ask the question(s) in a slightly different way and see if that
guides us one direction or another.

Do the libbacktrace changes make sense independently?  ie, are they the
right thing to do, even if they don't fix a visible bug?  ISTM the
answer to both questions is yes.  In which case, that part ought to go
forward now rather than waiting.


Yes. They fix the sort stability bug. The bug can be reproduced
without any ASan patches by compiling the ASan tests on powerpc64
with the -fasynchronous-unwind-tables option. It's also possible
that the bug can be reproduced with other programs on other
targets. It's just not triggered by the same tests on the targets
we commonly test.



The testsuite changes have two components.  One is the new flag the
other is some slight tweaks to the expected output.  I'd hazard a guess
that the expected output changes ought to go forward independently too.
  Again under the same "it's the right thing to do, even if it doesn't
fix a visible bug".

The testsuite flags change isn't as clear cut.  I'd think they'd need to
visibly improve the test results before they could go in.  So they may
need to wait (I'm assuming nothing actually shows visible improvement
without the libsanitizer fixes).


Correct. To improve the test pass rate on powerpc64 we need all
the fixes (ASan, libbacktrace, the flags or fast unwinding, and
the test output adjustments to reflect the adjusted and tightened
up line numbers in the stack trace).



Thoughts?


I'm fine with whatever approach you all decide on but since
there is a strong preference to have the fix in LLVM first and
since the tests depend on that fix it seems the other changes
need to wait until the ASan patch has been merged from LLVM
to GCC. (None of them can be made independently without
breaking some tests on some targets.)

Martin


Re: [PATCH/libiberty] fix build of gdb/binutils with clang.

2015-05-20 Thread Yunlian Jiang
GCC bootstraps with this patch.

On Wed, May 20, 2015 at 12:54 PM, Ian Lance Taylor  wrote:
> This is OK if GCC bootstraps.
>
> Thanks.
>
> Ian
>
> On Wed, May 20, 2015 at 11:25 AM, Yunlian Jiang  wrote:
>> I have the following change to make libiberty compile with _GNU_SOURCE 
>> defined
>> and remove the declaration of asprintf in libiberty.h if
>> HAVE_DECL_ASPRINTF is not
>> defined.
>>
>> diff --git a/include/libiberty.h b/include/libiberty.h
>> index b33dd65..8e096a0 100644
>> --- a/include/libiberty.h
>> +++ b/include/libiberty.h
>> @@ -621,7 +621,7 @@ extern int pexecute (const char *, char * const *,
>> const char *,
>>
>>  extern int pwait (int, int *, int);
>>
>> -#if !HAVE_DECL_ASPRINTF
>> +#if defined(HAVE_DECL_ASPRINTF) && !HAVE_DECL_ASPRINTF
>>  /* Like sprintf but provides a pointer to malloc'd storage, which must
>> be freed by the caller.  */
>>
>> diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
>> index f06cc69..624420d 100644
>> --- a/libiberty/Makefile.in
>> +++ b/libiberty/Makefile.in
>> @@ -113,7 +113,8 @@ installcheck: installcheck-subdir
>>
>>  INCDIR=$(srcdir)/$(MULTISRCTOP)../include
>>
>> -COMPILE.c = $(CC) -c @DEFS@ $(CFLAGS) $(CPPFLAGS) -I. -I$(INCDIR)
>> $(HDEFINES) @ac_libiberty_warn_cflags@
>> +COMPILE.c = $(CC) -c @DEFS@ $(CFLAGS) $(CPPFLAGS) -I. -I$(INCDIR) \
>> +   $(HDEFINES) @ac_libiberty_warn_cflags@ -D_GNU_SOURCE
>>
>>  # Just to make sure we don't use a built-in rule with VPATH
>>  .c.$(objext):
>> diff --git a/libiberty/configure b/libiberty/configure
>> index b06cab2..c6758b0 100755
>> --- a/libiberty/configure
>> +++ b/libiberty/configure
>> @@ -5130,6 +5130,9 @@ $as_echo "#define NEED_DECLARATION_ERRNO 1" 
>> >>confdefs.h
>>  fi
>>
>>
>> +$as_echo "#define _GNU_SOURCE 1" >>confdefs.h
>> +
>> +
>>  # Determine sizes of some types.
>>  # The cast to long int works around a bug in the HP C Compiler
>>  # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
>> diff --git a/libiberty/configure.ac b/libiberty/configure.ac
>> index 922aa86..9f2d661 100644
>> --- a/libiberty/configure.ac
>> +++ b/libiberty/configure.ac
>> @@ -272,6 +272,8 @@ AC_HEADER_TIME
>>
>>  libiberty_AC_DECLARE_ERRNO
>>
>> +AC_DEFINE(_GNU_SOURCE)
>> +
>>  # Determine sizes of some types.
>>  AC_CHECK_SIZEOF([int])
>>  AC_CHECK_SIZEOF([long])
>> diff --git a/libiberty/floatformat.c b/libiberty/floatformat.c
>> index 789fa05..4e73a2d 100644
>> --- a/libiberty/floatformat.c
>> +++ b/libiberty/floatformat.c
>> @@ -19,7 +19,9 @@ along with this program; if not, write to the Free Software
>>  Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
>> 02110-1301, USA.  */
>>
>>  /* This is needed to pick up the NAN macro on some systems.  */
>> +#ifndef _GNU_SOURCE
>>  #define _GNU_SOURCE
>> +#endif
>>
>>  #ifdef HAVE_CONFIG_H
>>  #include "config.h"
>>
>> On Tue, May 19, 2015 at 11:15 AM, Ian Lance Taylor  wrote:
>>> On Tue, May 19, 2015 at 11:08 AM, Yunlian Jiang  wrote:

 I could do that and it make the compilation of libiberty passes.
 However, I  have some other problem when using clang to build gdb
 because of libiberty.

 Some c file from other component may include 'libiberty.h' which contains
 the following

 #if !HAVE_DECL_ASPRINTF
 /* Like sprintf but provides a pointer to malloc'd storage, which must
be freed by the caller.  */

 extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
 #endif

 The HAVE_DECL_ASPRINTF is defined in config.h under libiberty directory.
 If the other c file only includes libiberty.h and does not include the
 libiberty/config.h and
 at the same time, _GNU_SOURCE is defind, the same error happens.
>>>
>>> Probably if HAVE_DECL_ASPRINTF is not defined at all, we should not
>>> declare asprintf in libiberty.h.
>>>
>>> Ian


Re: PING^3: [PATCH]: New configure options that make the compiler use -fPIE and -pie as default option

2015-05-20 Thread Hans-Peter Nilsson
> From: "H.J. Lu" 
> Date: Tue, 19 May 2015 21:20:46 +0200

> This patch affects your target.  Can you verify if it is OK on
> your target?

If you mean philosophically, it's ok when the general bits and
direction are ok, but for the practical part of checking
e.g. for typos through compilation, please use yourself a script
like gcc/contrib/config-list.mk.

> 
> Add --enable-default-pie option to configure GCC to generate PIE by
> default.
> 
> gcc/
> 
> 2015-05-19  Magnus Granberg  
>H.J. Lu  

> * gcc.c (NO_PIE_SPEC): New.
> (PIE_SPEC): Likewise.
> (NO_FPIE1_SPEC): Likewise.
> (FPIE1_SPEC): Likewise.
> (NO_FPIE2_SPEC): Likewise.
> (FPIE2_SPEC): Likewise.
> (NO_FPIE2_SPEC): Likewise.
> (FPIE_SPEC): Likewise.
> (NO_FPIE_SPEC): Likewise.
> (NO_FPIC1_SPEC): Likewise.
> (FPIC1_SPEC): Likewise.
> (NO_FPIC2_SPEC): Likewise.
> (FPIC2_SPEC): Likewise.
> (NO_FPIC2_SPEC): Likewise.
> (FPIC_SPEC): Likewise.
> (NO_FPIC_SPEC): Likewise.
> (NO_FPIE1_AND_FPIC1_SPEC): Likewise.
> (FPIE1_OR_FPIC1_SPEC): Likewise.
> (NO_FPIE2_AND_FPIC2_SPEC): Likewise.
> (FPIE2_OR_FPIC2_SPEC): Likewise.
> (NO_FPIE_AND_FPIC_SPEC): Likewise.
> (FPIE_OR_FPIC_SPEC): Likewise.
> (LD_PIE_SPEC): Likewise.
> (LINK_PIE_SPEC): Handle -no-pie.  Use PIE_SPEC and LD_PIE_SPEC.

> * config/openbsd.h (ASM_SPEC): Use FPIE1_OR_FPIC1_SPEC and
> FPIE2_OR_FPIC2_SPEC.

> * config/cris/linux.h (CRIS_ASM_SUBTARGET_SPEC): Likewise.

ok.

brgds, H-P


PING: Re: [patch 6/10] debug-early merge: Java front-end

2015-05-20 Thread Aldy Hernandez

Perhaps I should've sent this to the java-patches list.

PING.

gcc/java/

	* class.c: Remove pending_static_fields.
	(add_field): Remove use of pending_static_fields.
	(java_write_globals): Remove.
	* decl.c (java_mark_class_local): Remove use of
	pending_static_fields.
	* java-tree.h: Remove pending_static_fields and
	java_write_globals.
	* jcf-parse.c (java_parse_file): Call global_decl_processing.
	* lang.c (LANG_HOOKS_WRITE_GLOBALS): Remove.

diff --git a/gcc/java/class.c b/gcc/java/class.c
index d1adb58..ded4f83 100644
--- a/gcc/java/class.c
+++ b/gcc/java/class.c
@@ -123,10 +123,6 @@ static GTY(()) vec *registered_class;
currently being compiled.  */
 static GTY(()) tree this_classdollar;
 
-/* A list of static class fields.  This is to emit proper debug
-   info for them.  */
-vec *pending_static_fields;
-
 /* Return the node that most closely represents the class whose name
is IDENT.  Start the search from NODE (followed by its siblings).
Return NULL if an appropriate node does not exist.  */
@@ -895,8 +891,6 @@ add_field (tree klass, tree name, tree field_type, int flags)
   /* Considered external unless we are compiling it into this
 	 object file.  */
   DECL_EXTERNAL (field) = (is_compiled_class (klass) != 2);
-  if (!DECL_EXTERNAL (field))
-	vec_safe_push (pending_static_fields, field);
 }
 
   return field;
@@ -3273,17 +3267,4 @@ in_same_package (tree name1, tree name2)
   return (pkg1 == pkg2);
 }
 
-/* lang_hooks.decls.final_write_globals: perform final processing on
-   global variables.  */
-
-void
-java_write_globals (void)
-{
-  tree *vec = vec_safe_address (pending_static_fields);
-  int len = vec_safe_length (pending_static_fields);
-  write_global_declarations ();
-  emit_debug_global_declarations (vec, len);
-  vec_free (pending_static_fields);
-}
-
 #include "gt-java-class.h"
diff --git a/gcc/java/decl.c b/gcc/java/decl.c
index 72133b4..80765c7 100644
--- a/gcc/java/decl.c
+++ b/gcc/java/decl.c
@@ -1971,11 +1971,7 @@ java_mark_class_local (tree klass)
 
   for (t = TYPE_FIELDS (klass); t ; t = DECL_CHAIN (t))
 if (FIELD_STATIC (t))
-  {
-	if (DECL_EXTERNAL (t))
-	  vec_safe_push (pending_static_fields, t);
-	java_mark_decl_local (t);
-  }
+  java_mark_decl_local (t);
 
   for (t = TYPE_METHODS (klass); t ; t = DECL_CHAIN (t))
 if (!METHOD_ABSTRACT (t))
diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h
index 22c9789..58a60b8 100644
--- a/gcc/java/java-tree.h
+++ b/gcc/java/java-tree.h
@@ -1194,10 +1194,6 @@ extern void rewrite_reflection_indexes (void *);
 
 int cxx_keyword_p (const char *name, int length);
 
-extern GTY(()) vec *pending_static_fields;
-
-extern void java_write_globals (void);   
-
 #define DECL_FINAL(DECL) DECL_LANG_FLAG_3 (DECL)
 
 /* Access flags etc for a method (a FUNCTION_DECL): */
diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c
index e609331..8042a02 100644
--- a/gcc/java/jcf-parse.c
+++ b/gcc/java/jcf-parse.c
@@ -60,6 +60,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 #include "bitmap.h"
 #include "target.h"
 #include "wide-int.h"
+#include "toplev.h"
 
 #ifdef HAVE_LOCALE_H
 #include 
@@ -2001,6 +2002,9 @@ java_parse_file (void)
   /* Arrange for any necessary initialization to happen.  */
   java_emit_static_constructor ();
   gcc_assert (global_bindings_p ());
+
+  /* Do final processing on globals.  */
+  global_decl_processing ();
 }
 
 
diff --git a/gcc/java/lang.c b/gcc/java/lang.c
index dac322d..9654ace 100644
--- a/gcc/java/lang.c
+++ b/gcc/java/lang.c
@@ -149,8 +149,6 @@ struct GTY(()) language_function {
 #define LANG_HOOKS_DECL_PRINTABLE_NAME lang_printable_name
 #undef LANG_HOOKS_PRINT_ERROR_FUNCTION
 #define LANG_HOOKS_PRINT_ERROR_FUNCTION	java_print_error_function
-#undef LANG_HOOKS_WRITE_GLOBALS
-#define LANG_HOOKS_WRITE_GLOBALS java_write_globals
 
 #undef LANG_HOOKS_TYPE_FOR_MODE
 #define LANG_HOOKS_TYPE_FOR_MODE java_type_for_mode


Re: [patch 2/10] debug-early merge: C front-end (include c-family/)

2015-05-20 Thread Aldy Hernandez

On 05/20/2015 06:16 PM, Joseph Myers wrote:

On Wed, 20 May 2015, Aldy Hernandez wrote:


Update for the c-family bits removing the flag_syntax_only part Jason
requested.

And BTW, ping for you C front-end maintainers (unless Jason is reviewing the C
bits, in which case the rest of you can sit back and look pretty).


The C front-end changes are OK, assuming this has passed the usual
testing.



Yes they have.  Thank you.

Aldy


Re: [patch 2/10] debug-early merge: C front-end (include c-family/)

2015-05-20 Thread Joseph Myers
On Wed, 20 May 2015, Aldy Hernandez wrote:

> Update for the c-family bits removing the flag_syntax_only part Jason
> requested.
> 
> And BTW, ping for you C front-end maintainers (unless Jason is reviewing the C
> bits, in which case the rest of you can sit back and look pretty).

The C front-end changes are OK, assuming this has passed the usual 
testing.

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


Add statistics to alias.c

2015-05-20 Thread Jan Hubicka
Hi,
this patch extends statistics from tree-ssa-alias to also cover TBAA oracle.
This is useful to keep track of aliasing effectivity.  For example the hack
in alias.c putting globbing all pointers to one costs about 20% of all
answers on firefox. I.e. from 15500978 disambiguations/23744267 querries
(with the hack removed) to 12932078 disambiguations/27256455 querries.

Bootstrapped x86_64-linux, OK?
Honza

* alias.c (alias_stats): New static var.
(alias_sets_conflict_p, alias_sets_must_conflict_p): Update stats.
(dump_alias_stats_in_alias_c): New function.
* alias.h (dump_alias_stats_in_alias_c): Declare.
* tree-ssa-alias.c (dump_alias_stats): Call it.
Index: alias.c
===
--- alias.c (revision 223444)
+++ alias.c (working copy)
@@ -213,6 +213,19 @@ static int write_dependence_p (const_rtx
 
 static void memory_modified_1 (rtx, const_rtx, void *);
 
+/* Query statistics for the different low-level disambiguators.
+   A high-level query may trigger multiple of them.  */
+
+static struct {
+  unsigned long long num_alias_zero;
+  unsigned long long num_same_alias_set;
+  unsigned long long num_same_objects;
+  unsigned long long num_volatile;
+  unsigned long long num_dag;
+  unsigned long long num_disambiguated;
+} alias_stats;
+
+
 /* Set up all info needed to perform alias analysis on memory references.  */
 
 /* Returns the size in bytes of the mode of X.  */
@@ -471,13 +484,20 @@ alias_sets_conflict_p (alias_set_type se
   ase = get_alias_set_entry (set1);
   if (ase != 0
   && ase->children->get (set2))
-return 1;
+{
+  ++alias_stats.num_dag;
+  return 1;
+}
 
   /* Now do the same, but with the alias sets reversed.  */
   ase = get_alias_set_entry (set2);
   if (ase != 0
   && ase->children->get (set1))
-return 1;
+{
+  ++alias_stats.num_dag;
+  return 1;
+}
+  ++alias_stats.num_disambiguated;
 
   /* The two alias sets are distinct and neither one is the
  child of the other.  Therefore, they cannot conflict.  */
@@ -489,8 +509,16 @@ alias_sets_conflict_p (alias_set_type se
 int
 alias_sets_must_conflict_p (alias_set_type set1, alias_set_type set2)
 {
-  if (set1 == 0 || set2 == 0 || set1 == set2)
-return 1;
+  if (set1 == 0 || set2 == 0)
+{
+  ++alias_stats.num_alias_zero;
+  return 1;
+}
+  if (set1 == set2)
+{
+  ++alias_stats.num_same_alias_set;
+  return 1;
+}
 
   return 0;
 }
@@ -512,10 +540,17 @@ objects_must_conflict_p (tree t1, tree t
 return 0;
 
   /* If they are the same type, they must conflict.  */
-  if (t1 == t2
-  /* Likewise if both are volatile.  */
-  || (t1 != 0 && TYPE_VOLATILE (t1) && t2 != 0 && TYPE_VOLATILE (t2)))
-return 1;
+  if (t1 == t2)
+{
+  ++alias_stats.num_same_objects;
+  return 1;
+}
+  /* Likewise if both are volatile.  */
+  if (t1 != 0 && TYPE_VOLATILE (t1) && t2 != 0 && TYPE_VOLATILE (t2))
+{
+  ++alias_stats.num_volatile;
+  return 1;
+}
 
   set1 = t1 ? get_alias_set (t1) : 0;
   set2 = t2 ? get_alias_set (t2) : 0;
@@ -3043,4 +3051,21 @@ end_alias_analysis (void)
   sbitmap_free (reg_known_equiv_p);
 }
 
+void
+dump_alias_stats_in_alias_c (FILE *s)
+{
+  fprintf (s, "  TBAA oracle: %llu disambiguations %llu queries\n"
+ "   %llu are in alias set 0\n"
+ "   %llu queries asked about the same object\n"
+ "   %llu quaries asked about the same alias set\n"
+ "   %llu access volatile\n"
+ "   %llu are dependent in the DAG\n",
+  alias_stats.num_disambiguated,
+  alias_stats.num_alias_zero + alias_stats.num_same_alias_set
+  + alias_stats.num_same_objects + alias_stats.num_volatile
+  + alias_stats.num_dag,
+  alias_stats.num_alias_zero, alias_stats.num_same_alias_set,
+  + alias_stats.num_same_objects, alias_stats.num_volatile,
+  + alias_stats.num_dag);
+}
 #include "gt-alias.h"
Index: alias.h
===
--- alias.h (revision 223444)
+++ alias.h (working copy)
@@ -41,6 +41,7 @@ extern int alias_sets_conflict_p (alias_
 extern int alias_sets_must_conflict_p (alias_set_type, alias_set_type);
 extern int objects_must_conflict_p (tree, tree);
 extern int nonoverlapping_memrefs_p (const_rtx, const_rtx, bool);
+extern void dump_alias_stats_in_alias_c (FILE *s);
 tree reference_alias_ptr_type (tree);
 bool alias_ptr_types_compatible_p (tree, tree);
 
Index: tree-ssa-alias.c
===
--- tree-ssa-alias.c(revision 223444)
+++ tree-ssa-alias.c(working copy)
@@ -163,6 +163,7 @@ dump_alias_stats (FILE *s)
   alias_stats.call_may_clobber_ref_p_no_alias,
   alias_stats.call_may_clobber_ref_p_no_alias

Re: RFA: PATCH to use -std=c++98 in stage 1 of bootstrap

2015-05-20 Thread Alexandre Oliva
On May 20, 2015, Jason Merrill  wrote:

> I want to explicitly pass -std=c++98 to the compiler used in building
> stage 1.  Does this seem like the right way to do that?

It certainly works, but I'm a bit concerned about its overriding the
earlier choices of STAGE1_CXXFLAGS, that use CXXFLAGS or STAGE1_CFLAGS
depending on whether or not C++ is being bootstrapped.  Now, since GCC
is in C++ nowadays, not bootstrapping C++ is not really possible, so it
seems to make sense to just drop it.  The top-level is shared with other
projects written in C++, but this change would only impact them if they
involved bootstrapping too, which AFAIK only GCC does.

The only serious problem with the patch is that it changes Makefile.in,
but not the corresponding part of Makefile.tpl from which it is
generated.  Ok with that change.

Now, if you'd also update the comments just before it, that still
suggest we build only C in stage1, that would be appreciated.

Thanks,

-- 
Alexandre Oliva, freedom fighterhttp://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer


[PATCH v2] Handle OS X deployment targets correctly

2015-05-20 Thread Lawrence Velázquez

As described in PR target/63810, this addresses several problems with
the validation and encoding of deployment target version strings for the
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro.  There are
currently four testcases exercising inputs to -mmacosx-version-min
(gcc/testsuite/gcc.dg/darwin-minversion-*), but they provide minimal
coverage, and one is incorrect.

* The tiny number is now respected, if present.  Thus "10.9.4"
  correctly becomes "1094" instead of "1090", and "10.10.1" becomes
  "101001" instead of "101000".
* Zero padding is now ignored.  Thus "10.09" correctly becomes "1090"
  instead of "100900", and "10.00010" becomes "101000" instead of being
  treated as invalid.
* Deployment targets that are missing minor and tiny numbers are no
  longer considered invalid.  Thus "10" is treated as "10.0.0", which
  becomes "1000" without causing an error.

With this change, trunk matches the behavior of Apple LLVM Compiler
6.1.0 on 8,451 of 8,464 generated test inputs.  (The discrepancies are
due to a bug in Clang.)  I don't notice any testsuite regressions on
OS X 10.10 Yosemite x86-64.

2015-05-15  Lawrence Velázquez  

PR target/63810
* gcc/config/darwin-c.c (version_components): New global enum.
(parse_version, version_as_legacy_macro)
(version_as_modern_macro, macosx_version_as_macro): New functions.
(version_as_macro): Remove.
(darwin_cpp_builtins): Use new function.
* gcc/testsuite/gcc.dg/darwin-minversion-3.c: Update testcase.
* gcc/testsuite/gcc.dg/darwin-minversion-4.c: Ditto.
* gcc/testsuite/gcc.dg/darwin-minversion-5.c: New testcase.
* gcc/testsuite/gcc.dg/darwin-minversion-6.c: Ditto.
* gcc/testsuite/gcc.dg/darwin-minversion-7.c: Ditto.
* gcc/testsuite/gcc.dg/darwin-minversion-8.c: Ditto.
* gcc/testsuite/gcc.dg/darwin-minversion-9.c: Ditto.
* gcc/testsuite/gcc.dg/darwin-minversion-10.c: Ditto.
* gcc/testsuite/gcc.dg/darwin-minversion-11.c: Ditto.
* gcc/testsuite/gcc.dg/darwin-minversion-12.c: Ditto.
---
Re-roll to address patch review on PR target/63810.  Provided as
text/x-patch attachment to accommodate Apple Mail wonkiness.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63810#c21

 gcc/config/darwin-c.c   | 168 +++-
 gcc/testsuite/gcc.dg/darwin-minversion-10.c |  16 +++
 gcc/testsuite/gcc.dg/darwin-minversion-11.c |  16 +++
 gcc/testsuite/gcc.dg/darwin-minversion-12.c |  16 +++
 gcc/testsuite/gcc.dg/darwin-minversion-3.c  |   6 +-
 gcc/testsuite/gcc.dg/darwin-minversion-4.c  |   6 +-
 gcc/testsuite/gcc.dg/darwin-minversion-5.c  |  16 +++
 gcc/testsuite/gcc.dg/darwin-minversion-6.c  |  15 +++
 gcc/testsuite/gcc.dg/darwin-minversion-7.c  |  15 +++
 gcc/testsuite/gcc.dg/darwin-minversion-8.c  |  16 +++
 gcc/testsuite/gcc.dg/darwin-minversion-9.c  |  15 +++
 11 files changed, 273 insertions(+), 32 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/darwin-minversion-10.c
 create mode 100644 gcc/testsuite/gcc.dg/darwin-minversion-11.c
 create mode 100644 gcc/testsuite/gcc.dg/darwin-minversion-12.c
 create mode 100644 gcc/testsuite/gcc.dg/darwin-minversion-5.c
 create mode 100644 gcc/testsuite/gcc.dg/darwin-minversion-6.c
 create mode 100644 gcc/testsuite/gcc.dg/darwin-minversion-7.c
 create mode 100644 gcc/testsuite/gcc.dg/darwin-minversion-8.c
 create mode 100644 gcc/testsuite/gcc.dg/darwin-minversion-9.c

diff --git a/gcc/config/darwin-c.c b/gcc/config/darwin-c.c
index 3803e75..6d49f05 100644
--- a/gcc/config/darwin-c.c
+++ b/gcc/config/darwin-c.c
@@ -599,42 +599,158 @@ find_subframework_header (cpp_reader *pfile, const char *header, cpp_dir **dirp)
   return 0;
 }
 
-/* Return the value of darwin_macosx_version_min suitable for the
-   __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro, so '10.4.2'
-   becomes 1040 and '10.10.0' becomes 101000.  The lowest digit is
-   always zero, as is the second lowest for '10.10.x' and above.
-   Print a warning if the version number can't be understood.  */
+/* Given an OS X version VERSION_STR, return it as a statically-allocated array
+   of three integers. If VERSION_STR is invalid, return NULL.
+
+   VERSION_STR must consist of one, two, or three tokens, each separated by
+   a single period.  Each token must contain only the characters '0' through
+   '9' and is converted to an equivalent non-negative decimal integer. Omitted
+   tokens become zeros.  For example:
+
+"10"  becomes   {10,0,0}
+"10.10"   becomes   {10,10,0}
+"10.10.1" becomes   {10,10,1}
+"10.10.1" becomes   {10,10,1}
+"10.010.001"  becomes   {10,10,1}
+"10.10.1" becomes   {10,10,1}
+".9.1"is invalid
+"10..9"   is invalid
+"10.10."  is invalid  */
+
+enum version_components { MAJOR, MINOR, TINY };
+
+static const unsigned long *

Re: [patch 10/10] debug-early merge: compiler proper

2015-05-20 Thread Aldy Hernandez

On 05/20/2015 05:01 PM, Jan Hubicka wrote:


commit 8824b5ecba26cef065e47b34609c72677c3c36fc
Author: Aldy Hernandez 
Date:   Wed May 20 16:31:14 2015 -0400

 Set DECL_IGNORED_P on temporary arrays created in the switch
 conversion pass.

diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index 6b68a16..a4bcdba 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -1097,6 +1097,7 @@ build_one_array (gswitch *swtch, int num, tree
arr_index_type,
DECL_ARTIFICIAL (decl) = 1;
TREE_CONSTANT (decl) = 1;
TREE_READONLY (decl) = 1;
+  DECL_IGNORED_P (decl) = 1;
varpool_node::finalize_decl (decl);


This looks obvious enough to me.  Technically speaking the array type 
constructed
probalby should be TREE_ARTIFICAIL, but probably it does not matter.


Yeah, that's what I thought.  I ignored the type because it won't make 
it to the debugging back end if we stop things at the DECL itself.


FWIW, Ada is filled with these temporaries and/or types that should 
really be ignored, and are currently causing grief.



If you grep for finalize_decl, there are several other calls:
asan.c:  varpool_node::finalize_decl (var);
asan.c:  varpool_node::finalize_decl (var);
cgraphbuild.c:  varpool_node::finalize_decl (decl);
cgraphunit.c:- varpool_finalize_decl
cgraphunit.c:   varpool_node::finalize_decl (decl);
cgraphunit.c:varpool_node::finalize_decl (tree decl)
coverage.c:   varpool_node::finalize_decl (var);
coverage.c:  varpool_node::finalize_decl (var);


Etc etc.

Hmmm, I bet mainline is generating dwarf for all this.  I don't feel 
comfortable touching all this (ok, I'm lazy), but it would seem like 
almost all of these calls would benefit from DECL_IGNORED_P.  Perhaps we 
could add an argument to finalize_decl() and do it in there.


Aldy


coverage.c:  varpool_node::finalize_decl (fn_info_ary);
coverage.c:  varpool_node::finalize_decl (gcov_info_var);
omp-low.c:varpool_node::finalize_decl (t);
omp-low.c:varpool_node::finalize_decl (t);
omp-low.c:varpool_node::finalize_decl (decl);
omp-low.c:  varpool_node::finalize_decl (vars_decl);
omp-low.c:  varpool_node::finalize_decl (funcs_decl);
passes.c:   varpool_node::finalize_decl (decl);
tree-chkp.c:  varpool_node::finalize_decl (var);
tree-chkp.c:  varpool_node::finalize_decl (bnd_var);
tree-profile.c:  varpool_node::finalize_decl (ic_void_ptr_var);
tree-profile.c:  varpool_node::finalize_decl (ic_gcov_type_ptr_var);
tree-switch-conversion.c:  varpool_node::finalize_decl (decl);
ubsan.c:  varpool_node::finalize_decl (decl);
ubsan.c:  varpool_node::finalize_decl (var);
ubsan.c:  varpool_node::finalize_decl (array);
varasm.c:  varpool_node::finalize_decl (decl);
varpool.c:   Unlike finalize_decl function is intended to be used
varpool.c:  varpool_node::finalize_decl (decl);

I would say most of them needs similar treatment (I am not 100% sure about OMP
ones that may be user visible)

Honza


fetch = build4 (ARRAY_REF, value_type, decl, tidx, NULL_TREE,




Re: [patch 2/10] debug-early merge: C front-end (include c-family/)

2015-05-20 Thread Aldy Hernandez
Update for the c-family bits removing the flag_syntax_only part Jason 
requested.


And BTW, ping for you C front-end maintainers (unless Jason is reviewing 
the C bits, in which case the rest of you can sit back and look pretty).


Aldy
gcc/c-family/

	* c-common.h (c_parse_final_cleanups): New prototype.
	* c-opts.c (c_common_parse_file): Call c_parse_final_cleanups.

gcc/c/

	* c-decl.c (finish_struct): Save C_TYPE_INCOMPLETE_VARS and
	immediately clobber it.
	(c_write_global_declarations_1): Remove call to
	check_global_declaration_1.
	(c_write_global_declarations_2): Remove.
	(c_write_final_cleanups): Rename from c_write_global_declarations.
	Remove call to finalize_compilation_unit.
	Remove calls to debugging hooks.
	* c-objc-common.c: Adjust comment for c_warn_unused_global_decl.
	* c-objc-common.h: Remove LANG_HOOKS_WRITE_GLOBALS.
	* c-tree.h: Remove c_write_global_declarations.

diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 62eac9f..155b799 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -892,6 +892,8 @@ extern HOST_WIDE_INT c_common_to_target_charset (HOST_WIDE_INT);
 /* This is the basic parsing function.  */
 extern void c_parse_file (void);
 
+extern void c_parse_final_cleanups (void);
+
 extern void warn_for_omitted_condop (location_t, tree);
 
 /* These macros provide convenient access to the various _STMT nodes.  */
diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index e9eb511..89e7fbb 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -1090,6 +1090,8 @@ c_common_parse_file (void)
   if (!this_input_filename)
 	break;
 }
+
+  c_parse_final_cleanups ();
 }
 
 /* Returns the appropriate dump file for PHASE to dump with FLAGS.  */
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 4f6761d..ca30a7c 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -7827,10 +7827,18 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
 }
 
   /* If this structure or union completes the type of any previous
- variable declaration, lay it out and output its rtl.  */
-  for (x = C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t));
-   x;
-   x = TREE_CHAIN (x))
+ variable declaration, lay it out and output its rtl.
+
+ Note: C_TYPE_INCOMPLETE_VARS overloads TYPE_VFIELD which is used
+ in dwarf2out via rest_of_decl_compilation below and means
+ something totally different.  Since we will be clearing
+ C_TYPE_INCOMPLETE_VARS shortly after we iterate through them,
+ clear it ahead of time and avoid problems in dwarf2out.  Ideally,
+ C_TYPE_INCOMPLETE_VARS should use some language specific
+ node.  */
+  tree incomplete_vars = C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t));
+  C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t)) = 0;
+  for (x = incomplete_vars; x; x = TREE_CHAIN (x))
 {
   tree decl = TREE_VALUE (x);
   if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
@@ -7843,7 +7851,6 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
 	  rest_of_decl_compilation (decl, toplevel, 0);
 	}
 }
-  C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t)) = 0;
 
   /* Update type location to the one of the definition, instead of e.g.
  a forward declaration.  */
@@ -10667,9 +10674,8 @@ finish_declspecs (struct c_declspecs *specs)
   return specs;
 }
 
-/* A subroutine of c_write_global_declarations.  Perform final processing
-   on one file scope's declarations (or the external scope's declarations),
-   GLOBALS.  */
+/* Perform final processing on one file scope's declarations (or the
+   external scope's declarations), GLOBALS.  */
 
 static void
 c_write_global_declarations_1 (tree globals)
@@ -10682,7 +10688,7 @@ c_write_global_declarations_1 (tree globals)
 {
   /* Check for used but undefined static functions using the C
 	 standard's definition of "used", and set TREE_NO_WARNING so
-	 that check_global_declarations doesn't repeat the check.  */
+	 that check_global_declaration doesn't repeat the check.  */
   if (TREE_CODE (decl) == FUNCTION_DECL
 	  && DECL_INITIAL (decl) == 0
 	  && DECL_EXTERNAL (decl)
@@ -10703,21 +10709,6 @@ c_write_global_declarations_1 (tree globals)
 	reconsider |= wrapup_global_declaration_2 (decl);
 }
   while (reconsider);
-
-  for (decl = globals; decl; decl = DECL_CHAIN (decl))
-check_global_declaration_1 (decl);
-}
-
-/* A subroutine of c_write_global_declarations Emit debug information for each
-   of the declarations in GLOBALS.  */
-
-static void
-c_write_global_declarations_2 (tree globals)
-{
-  tree decl;
-
-  for (decl = globals; decl ; decl = DECL_CHAIN (decl))
-debug_hooks->global_decl (decl);
 }
 
 /* Callback to collect a source_ref from a DECL.  */
@@ -10767,8 +10758,11 @@ for_each_global_decl (void (*callback) (tree decl))
 callback (decl);
 }
 
+/* Perform any final parser cleanups and generate initial debugging
+   information.  */
+
 void
-c_write_global_declarations (voi

Re: [patch 3/10] debug-early merge: C++ front-end

2015-05-20 Thread Aldy Hernandez

On 05/20/2015 03:18 PM, Jason Merrill wrote:

On 05/08/2015 09:14 PM, Aldy Hernandez wrote:

+  if (!flag_syntax_only)
+c_parse_final_cleanups ();


The condition is a significant change of behavior for the C++ front end;
doing final instantiation and such even with -fsyntax-only was a
deliberate choice.  Can we drop the condition?


Sure.  Done.  Will repost this as part of the C front-end which has the 
c-family/ bits where this appeared.



+  timevar_stop (TV_PHASE_PARSING);
+  timevar_start (TV_PHASE_DBGINFO);

   perform_deferred_noexcept_checks ();


The only debug info stuff that was here has been removed, so there's no
longer any need to switch to a debug timevar.  I think we should stay in
DEFERRED for the whole function.


Fixed.

How does this look?

Bootstrapped and retested on x86-64 for --enable-languages=all.

Aldy

gcc/cp/

	* cp-objcp-common.c: Adjust comment for
	cxx_warn_unused_global_decl.
	* cp-objcp-common.h (LANG_HOOKS_WRITE_GLOBALS): Remove
	(LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS): New.
	* cp-tree.h (note_mangling_alias): Protoize.
	(cp_write_global_declarations): Remove.
	(cxx_post_compilation_parsing_cleanups): Protoize.
	* decl.c (wrapup_globals_for_namespace): Remove use of DATA
	argument.
	* decl2.c (mangling_aliases): New global.
	(build_java_method_aliases): New.  Adapted from
	collect_candidates_for_java_method_aliases.
	(collect_candidates_for_java_method_aliases): Remove.
	(build_java_method_aliases): Remove.
	(generate_mangling_aliases): New.
	(note_mangling_alias): New.  Moved from mangle_decl.
	(locus_at_end_of_parsing): New global.
	(c_parse_final_cleanups): Rename from
	cp_write_global_declarations.
	Use locus_at_end_of_parsing.
	Call generate_mangling_aliases.
	Rename call to collect_candidates_for_java_method_aliases into
	build_java_method_aliases.
	Remove call to finalize_compilation_unit.
	Move vtable handling into cxx_post_compilation_parsing_cleanups.
	Do not call check_global_declarations or
	emit_debug_global_declarations.
	(cxx_post_compilation_parsing_cleanups): New.
	* mangle.c (mangle_decl): Move code to note_mangling_alias.
	* name-lookup.c (do_namespace_alias): Call early_global_decl.

diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
index dd8e7c5..40b13ef 100644
--- a/gcc/cp/cp-objcp-common.c
+++ b/gcc/cp/cp-objcp-common.c
@@ -60,7 +60,7 @@ cxx_get_alias_set (tree t)
   return c_common_get_alias_set (t);
 }
 
-/* Called from check_global_declarations.  */
+/* Called from check_global_declaration.  */
 
 bool
 cxx_warn_unused_global_decl (const_tree decl)
diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h
index 8a36e7f..c8572a7 100644
--- a/gcc/cp/cp-objcp-common.h
+++ b/gcc/cp/cp-objcp-common.h
@@ -84,8 +84,8 @@ extern void cp_common_init_ts (void);
 #define LANG_HOOKS_PRINT_ERROR_FUNCTION	cxx_print_error_function
 #undef LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL
 #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL cxx_warn_unused_global_decl
-#undef LANG_HOOKS_WRITE_GLOBALS
-#define LANG_HOOKS_WRITE_GLOBALS cp_write_global_declarations
+#undef LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS
+#define LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS cxx_post_compilation_parsing_cleanups
 #undef  LANG_HOOKS_BUILTIN_FUNCTION
 #define LANG_HOOKS_BUILTIN_FUNCTION cxx_builtin_function
 #undef  LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 4136d98..1998992 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -5469,7 +5469,7 @@ extern tree cp_reconstruct_complex_type		(tree, tree);
 extern bool attributes_naming_typedef_ok	(tree);
 extern void cplus_decl_attributes		(tree *, tree, int);
 extern void finish_anon_union			(tree);
-extern void cp_write_global_declarations	(void);
+extern void cxx_post_compilation_parsing_cleanups (void);
 extern tree coerce_new_type			(tree);
 extern tree coerce_delete_type			(tree);
 extern void comdat_linkage			(tree);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 261a12d..8dadb39 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -892,30 +892,19 @@ walk_namespaces (walk_namespaces_fn f, void* data)
   return walk_namespaces_r (global_namespace, f, data);
 }
 
-/* Call wrapup_globals_declarations for the globals in NAMESPACE.  If
-   DATA is non-NULL, this is the last time we will call
-   wrapup_global_declarations for this NAMESPACE.  */
+/* Call wrapup_globals_declarations for the globals in NAMESPACE.  */
 
 int
-wrapup_globals_for_namespace (tree name_space, void* data)
+wrapup_globals_for_namespace (tree name_space, void* data ATTRIBUTE_UNUSED)
 {
   cp_binding_level *level = NAMESPACE_LEVEL (name_space);
   vec *statics = level->static_decls;
   tree *vec = statics->address ();
   int len = statics->length ();
-  int last_time = (data != 0);
-
-  if (last_time)
-{
-  check_global_declarations (vec, len);
-  emit_debug_global_declarations (vec, len);
-  return 0;
-}
 
   /* Write out any globals that need to be output.  */
   return

C++ PATCH for variable template partial specialization bug

2015-05-20 Thread Jason Merrill
register_specialization complains about a specialization in a different 
namespace from the main template; we shouldn't give that error about an 
instantiation of a partial specialization.  And we were about to 
SET_DECL_IMPLICIT_INSTANTIATION anyway, so let's just do that before we 
call register_specialization.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit a1ab0a6ef49dcb604c12058b9af7522e471bcc5b
Author: Jason Merrill 
Date:   Wed May 20 16:53:57 2015 -0400

	* pt.c (tsubst_decl) [VAR_DECL]: SET_DECL_IMPLICIT_INSTANTIATION
	before register_specialization.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 60f3958..7555114 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -11407,9 +11407,9 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
 	   processing here.  */
 	DECL_EXTERNAL (r) = 1;
 
-	register_specialization (r, gen_tmpl, argvec, false, hash);
 	DECL_TEMPLATE_INFO (r) = build_template_info (tmpl, argvec);
 	SET_DECL_IMPLICIT_INSTANTIATION (r);
+	register_specialization (r, gen_tmpl, argvec, false, hash);
 	  }
 	else if (!cp_unevaluated_operand)
 	  register_local_specialization (r, t);
diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ27.C b/gcc/testsuite/g++.dg/cpp1y/var-templ27.C
new file mode 100644
index 000..da06b01
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/var-templ27.C
@@ -0,0 +1,9 @@
+// { dg-do compile { target c++14 } }
+
+namespace A
+{
+  template  int I = 0;
+  template  int I = 42;
+}
+
+int i = A::I;


C++ PATCH to change -Wc++14-compat operator delete warning

2015-05-20 Thread Jason Merrill
I noticed that -Wc++14-compat was warning about headers that had been 
updated to include a declaration of a global sized operator delete. 
This was intended to catch problematic placement deletes, but now I 
think that C++14 headers that just don't bother to guard the declaration 
with a C++14 #if are going to be much more common than placement 
deletes.  So this patch changes the warning to only trigger if we 
actually use the operator delete as a placement delete.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 9b7c323b8806bb8d9c21a72ab074f7bc961840c9
Author: Jason Merrill 
Date:   Wed May 20 14:23:50 2015 -0400

	* decl.c (grok_op_properties): Don't complain about size_t
	placement delete here.
	* call.c (second_parm_is_size_t): Split out from...
	(non_placement_deallocation_fn_p): ...here.
	(build_op_delete_call): Warn about size_t placement delete with
	-Wc++14-compat.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 07ccea9..bad49f1 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -5748,6 +5748,18 @@ build_new_op (location_t loc, enum tree_code code, int flags,
   return ret;
 }
 
+/* Returns true if FN has two parameters, of which the second has type
+   size_t.  */
+
+static bool
+second_parm_is_size_t (tree fn)
+{
+  tree t = FUNCTION_ARG_CHAIN (fn);
+  return (t
+	  && same_type_p (TREE_VALUE (t), size_type_node)
+	  && TREE_CHAIN (t) == void_list_node);
+}
+
 /* Returns true iff T, an element of an OVERLOAD chain, is a usual
deallocation function (3.7.4.2 [basic.stc.dynamic.deallocation]).  */
 
@@ -5768,11 +5780,9 @@ non_placement_deallocation_fn_p (tree t)
  of which has type std::size_t (18.2), then this function is a usual
  deallocation function.  */
   bool global = DECL_NAMESPACE_SCOPE_P (t);
-  t = FUNCTION_ARG_CHAIN (t);
-  if (t == void_list_node
-  || (t && same_type_p (TREE_VALUE (t), size_type_node)
-	  && (!global || flag_sized_deallocation)
-	  && TREE_CHAIN (t) == void_list_node))
+  if (FUNCTION_ARG_CHAIN (t) == void_list_node
+  || ((!global || flag_sized_deallocation)
+	  && second_parm_is_size_t (t)))
 return true;
   return false;
 }
@@ -5859,23 +5869,49 @@ build_op_delete_call (enum tree_code code, tree addr, tree size,
 	 function (3.7.4.2) and that function, considered as a placement
 	 deallocation function, would have been selected as a match for the
 	 allocation function, the program is ill-formed."  */
-  if (non_placement_deallocation_fn_p (fn))
+  if (second_parm_is_size_t (fn))
 	{
+	  const char *msg1
+	= G_("exception cleanup for this placement new selects "
+		 "non-placement operator delete");
+	  const char *msg2
+	= G_("%q+D is a usual (non-placement) deallocation "
+		 "function in C++14 (or with -fsized-deallocation)");
+
 	  /* But if the class has an operator delete (void *), then that is
 	 the usual deallocation function, so we shouldn't complain
 	 about using the operator delete (void *, size_t).  */
-	  for (t = BASELINK_P (fns) ? BASELINK_FUNCTIONS (fns) : fns;
-	   t; t = OVL_NEXT (t))
+	  if (DECL_CLASS_SCOPE_P (fn))
+	for (t = BASELINK_P (fns) ? BASELINK_FUNCTIONS (fns) : fns;
+		 t; t = OVL_NEXT (t))
+	  {
+		tree elt = OVL_CURRENT (t);
+		if (non_placement_deallocation_fn_p (elt)
+		&& FUNCTION_ARG_CHAIN (elt) == void_list_node)
+		  goto ok;
+	  }
+	  /* Before C++14 a two-parameter global deallocation function is
+	 always a placement deallocation function, but warn if
+	 -Wc++14-compat.  */
+	  else if (!flag_sized_deallocation)
 	{
-	  tree elt = OVL_CURRENT (t);
-	  if (non_placement_deallocation_fn_p (elt)
-		  && FUNCTION_ARG_CHAIN (elt) == void_list_node)
-		goto ok;
+	  if ((complain & tf_warning)
+		  && warning (OPT_Wc__14_compat, msg1))
+		inform (0, msg2, fn);
+	  goto ok;
 	}
-	  if (complain & tf_error)
+
+	  if (complain & tf_warning_or_error)
 	{
-	  permerror (0, "non-placement deallocation function %q+D", fn);
-	  permerror (input_location, "selected for placement delete");
+	  if (permerror (input_location, msg1))
+		{
+		  /* Only mention C++14 for namespace-scope delete.  */
+		  if (DECL_NAMESPACE_SCOPE_P (fn))
+		inform (0, msg2, fn);
+		  else
+		inform (0, "%q+D is a usual (non-placement) deallocation "
+			"function", fn);
+		}
 	}
 	  else
 	return error_mark_node;
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 261a12d..e4d3c1d 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -11767,16 +11767,6 @@ grok_op_properties (tree decl, bool complain)
 	  error ("%qD may not be declared as static", decl);
 	  return false;
 	}
-	  if (!flag_sized_deallocation && warn_cxx14_compat)
-	{
-	  tree parm = FUNCTION_ARG_CHAIN (decl);
-	  if (parm && same_type_p (TREE_VALUE (parm), size_type_node)
-		  && TREE_CHAIN (parm) == void_list_node)
-		warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc__14_compat,
-			"%qD is a usual (non-placem

Re-enable shadd insns on the PA

2015-05-20 Thread Jeff Law


This is the first in a series of patches to fix the fallout from recent 
combiner changes in how shift-add style insns are canonicalized.


This patch effectively just adds a new shift-add insn to the PA port. 
The old shift-add insn stays for now, but will be removed in a follow-up 
once I'm confident all the ways we might generate that insn have been 
updated on the trunk.


My sole remaining PA is dead and the one I had access to via 
parisc-linux.org doesn't seem to be responding.  So testing is limited.


The goal is to generate the same code as we had before the combiner 
changes across the 300+ .i files for a gcc-4.7.3 build on the PA.  This 
patch (in conjuction with several others) has accomplished that goal. 
I'm obviously cherry picking individual hunks out of that work, cleaning 
them up and committing them.


This patch also creates a hppa target testsuite.  Not that it'll ever be 
all that large, we might as well not pollute the rest of the suite with 
PA specific tests.


Installed on the trunk.



Jeff
commit 7176b30ff9f6b2ea07950d392cad0876123dc5e4
Author: Jeff Law 
Date:   Wed May 20 15:07:34 2015 -0600

2015-05-20  Jeff Law  

* config/pa/pa.c (pa_print_operand): New 'o' output modifier.
(pa_mem_shadd_constant_p): Renamed from pa_shadd_constant_p.
(pa_shadd_constant_p): Allow constants for shadd insns rather
than valid scaling constants for memory addresses.
* config/pa/pa-protos.h (pa_mem_shadd_constant_p): Add prototype.
* config/pa/predicates.md (mem_shadd_operand): New predicate.
* config/pa/pa.md (shift-add insns using MULT): Use mem_shadd_operand.
(shift-add insns using ASHIFT): New patterns.

* gcc.target/hppa/hppa.exp: New target test driver.
* gcc.target/hppa/shadd-1.c: New test.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5bcbcb4..490386e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2015-05-20  Jeff Law  
+
+   * config/pa/pa.c (pa_print_operand): New 'o' output modifier.
+   (pa_mem_shadd_constant_p): Renamed from pa_shadd_constant_p.
+   (pa_shadd_constant_p): Allow constants for shadd insns rather
+   than valid scaling constants for memory addresses.
+   * config/pa/pa-protos.h (pa_mem_shadd_constant_p): Add prototype.
+   * config/pa/predicates.md (mem_shadd_operand): New predicate.
+   * config/pa/pa.md (shift-add insns using MULT): Use mem_shadd_operand.
+   (shift-add insns using ASHIFT): New patterns.
+
 2015-05-20  Mikhail Maltsev  
 
* bb-reorder.c (set_edge_can_fallthru_flag): Use rtx_jump_insn where
diff --git a/gcc/config/pa/pa-protos.h b/gcc/config/pa/pa-protos.h
index 4a44dab..58cc463 100644
--- a/gcc/config/pa/pa-protos.h
+++ b/gcc/config/pa/pa-protos.h
@@ -85,6 +85,7 @@ extern int pa_and_mask_p (unsigned HOST_WIDE_INT);
 extern int pa_cint_ok_for_move (HOST_WIDE_INT);
 extern int pa_ior_mask_p (unsigned HOST_WIDE_INT);
 extern int pa_ldil_cint_p (HOST_WIDE_INT);
+extern int pa_mem_shadd_constant_p (int);
 extern int pa_shadd_constant_p (int);
 extern int pa_zdepi_cint_p (unsigned HOST_WIDE_INT);
 
diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c
index cfdafa6..f99cf33 100644
--- a/gcc/config/pa/pa.c
+++ b/gcc/config/pa/pa.c
@@ -5242,6 +5242,11 @@ pa_print_operand (FILE *file, rtx x, int code)
   gcc_assert (GET_CODE (x) == CONST_INT);
   fprintf (file, HOST_WIDE_INT_PRINT_DEC, 32 - (INTVAL (x) & 31));
   return;
+case 'o':
+  gcc_assert (GET_CODE (x) == CONST_INT
+ && (INTVAL (x) == 1 || INTVAL (x) == 2 || INTVAL (x) == 3));
+  fprintf (file, "%d", INTVAL (x));
+  return;
 case 'O':
   gcc_assert (GET_CODE (x) == CONST_INT && exact_log2 (INTVAL (x)) >= 0);
   fprintf (file, "%d", exact_log2 (INTVAL (x)));
@@ -8729,11 +8734,22 @@ pa_fmpysuboperands (rtx *operands)
 }
 
 /* Return 1 if the given constant is 2, 4, or 8.  These are the valid
+   constants for a MULT embedded inside a memory address.  */
+int
+pa_mem_shadd_constant_p (int val)
+{
+  if (val == 2 || val == 4 || val == 8)
+return 1;
+  else
+return 0;
+}
+
+/* Return 1 if the given constant is 1, 2, or 3.  These are the valid
constants for shadd instructions.  */
 int
 pa_shadd_constant_p (int val)
 {
-  if (val == 2 || val == 4 || val == 8)
+  if (val == 1 || val == 2 || val == 3)
 return 1;
   else
 return 0;
diff --git a/gcc/config/pa/pa.md b/gcc/config/pa/pa.md
index cc077a4..73c8f6b 100644
--- a/gcc/config/pa/pa.md
+++ b/gcc/config/pa/pa.md
@@ -6337,7 +6337,7 @@
 (define_insn ""
   [(set (match_operand:SI 0 "register_operand" "=r")
(plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r")
- (match_operand:SI 3 "shadd_operand" ""))
+ (match_operand:SI 3 "mem_shadd_operand" ""))
 (match_operand:SI 1 "register_operand" "r")))]
   ""
   "{sh%O3addl %2,%1,%0|shladd,l %2,%O3,%1,%0} "
@@ -634

Re: PING^3: [PATCH]: New configure options that make the compiler use -fPIE and -pie as default option

2015-05-20 Thread Joseph Myers
On Tue, 19 May 2015, H.J. Lu wrote:

> Here is the complete patch.  Tested on Linux/x86-64.  It is also
> available on hjl/pie/master branch in git mirror.

OK a week after you CC all relevant target maintainers on the patch, in 
the absence of objections from those target maintainers.

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


Re: [patch 10/10] debug-early merge: compiler proper

2015-05-20 Thread Jan Hubicka
> 
> commit 8824b5ecba26cef065e47b34609c72677c3c36fc
> Author: Aldy Hernandez 
> Date:   Wed May 20 16:31:14 2015 -0400
> 
> Set DECL_IGNORED_P on temporary arrays created in the switch
> conversion pass.
> 
> diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
> index 6b68a16..a4bcdba 100644
> --- a/gcc/tree-switch-conversion.c
> +++ b/gcc/tree-switch-conversion.c
> @@ -1097,6 +1097,7 @@ build_one_array (gswitch *swtch, int num, tree
> arr_index_type,
>DECL_ARTIFICIAL (decl) = 1;
>TREE_CONSTANT (decl) = 1;
>TREE_READONLY (decl) = 1;
> +  DECL_IGNORED_P (decl) = 1;
>varpool_node::finalize_decl (decl);

This looks obvious enough to me.  Technically speaking the array type 
constructed
probalby should be TREE_ARTIFICAIL, but probably it does not matter.
If you grep for finalize_decl, there are several other calls:
asan.c:  varpool_node::finalize_decl (var);
asan.c:  varpool_node::finalize_decl (var);
cgraphbuild.c:  varpool_node::finalize_decl (decl);
cgraphunit.c:- varpool_finalize_decl
cgraphunit.c:   varpool_node::finalize_decl (decl);
cgraphunit.c:varpool_node::finalize_decl (tree decl)
coverage.c:   varpool_node::finalize_decl (var);
coverage.c:  varpool_node::finalize_decl (var);
coverage.c:  varpool_node::finalize_decl (fn_info_ary);
coverage.c:  varpool_node::finalize_decl (gcov_info_var);
omp-low.c:varpool_node::finalize_decl (t);
omp-low.c:varpool_node::finalize_decl (t);
omp-low.c:varpool_node::finalize_decl (decl);
omp-low.c:  varpool_node::finalize_decl (vars_decl);
omp-low.c:  varpool_node::finalize_decl (funcs_decl);
passes.c:   varpool_node::finalize_decl (decl);
tree-chkp.c:  varpool_node::finalize_decl (var);
tree-chkp.c:  varpool_node::finalize_decl (bnd_var);
tree-profile.c:  varpool_node::finalize_decl (ic_void_ptr_var);
tree-profile.c:  varpool_node::finalize_decl (ic_gcov_type_ptr_var);
tree-switch-conversion.c:  varpool_node::finalize_decl (decl);
ubsan.c:  varpool_node::finalize_decl (decl);
ubsan.c:  varpool_node::finalize_decl (var);
ubsan.c:  varpool_node::finalize_decl (array);
varasm.c:  varpool_node::finalize_decl (decl);
varpool.c:   Unlike finalize_decl function is intended to be used
varpool.c:  varpool_node::finalize_decl (decl);

I would say most of them needs similar treatment (I am not 100% sure about OMP
ones that may be user visible)

Honza
> 
>fetch = build4 (ARRAY_REF, value_type, decl, tidx, NULL_TREE,


Re: [patch 10/10] debug-early merge: compiler proper

2015-05-20 Thread Aldy Hernandez



How does this version, which has been committed to the debug-early
branch, look?


One more thing Richi.  I merged trunk into the branch once again, and Go 
broke.  I tracked it down to a temporary that was being created late 
that IMO shouldn't even get debug info.


The fact that it gets created with create_tmp_var_name() in the first 
place is suspect.  The problem is actually the type, which doesn't even 
get passed through rest_of_type* or the debug_hooks->type_decl(). 
However, I see no reason to have these temporary variables even get fed 
to the debugger, so I'm marking them as DECL_IGNORED_P.


If you want I can repost the whole compiler proper patch, but this is a 
small enough change that y'all can just wave through.


I've committed the snippet below to the branch.  Everything else is as 
it was.


Branch retested on x86-64 Linux and has been merged with trunk.

commit 8824b5ecba26cef065e47b34609c72677c3c36fc
Author: Aldy Hernandez 
Date:   Wed May 20 16:31:14 2015 -0400

Set DECL_IGNORED_P on temporary arrays created in the switch
conversion pass.

diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index 6b68a16..a4bcdba 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -1097,6 +1097,7 @@ build_one_array (gswitch *swtch, int num, tree 
arr_index_type,

   DECL_ARTIFICIAL (decl) = 1;
   TREE_CONSTANT (decl) = 1;
   TREE_READONLY (decl) = 1;
+  DECL_IGNORED_P (decl) = 1;
   varpool_node::finalize_decl (decl);

   fetch = build4 (ARRAY_REF, value_type, decl, tidx, NULL_TREE,



Re: [PATCH] PR c/66220: Fix false positive from -Wmisleading-indentation

2015-05-20 Thread Jeff Law

On 05/20/2015 11:05 AM, David Malcolm wrote:

This patch fixes the false positive seen from -Wmisleading-indentation
on this code:

 if (v == 2)
 {
 res = 27;
 } else
 {
 res = 18;
 }
 return res;
 ^ FALSE POSITIVE HERE

along with similar code seen when I tested it with linux-4.0.3.

The patch adds a reject for the case where the guard ("else" in
the above example) is more indented than the things it guards.

Doing so uncovered an issue with this testcase:

#define FOR_EACH(VAR, START, STOP) for ((VAR) = (START); (VAR) < (STOP); (VAR++)) /* { 
dg-message "36: ...this 'for' clause, but it is not" } */
void fn_15 (void)
{
   int i;
   FOR_EACH (i, 0, 10) /* { dg-message "3: in expansion of macro" } */
 foo (i);
 bar (i, i); /* { dg-warning "statement is indented as if it were guarded 
by..." } */
}
#undef FOR_EACH

which would then fail to report the warning, due to it using the
location of the "for" in the definition of macro FOR_EACH, rather than
the location of the FOR_EACH (i, 0, 10).  The fix for this is to use
expand_location to get file/line/col of each thing, rather than
expand_location_to_spelling_point.

With that, all testcases in Wmisleading-indentation.c pass (including
the new ones posted in
https://gcc.gnu.org/ml/gcc-patches/2015-05/msg01846.html ).

OK for trunk if it passes bootstrap®rest?  (only tested with
   make check-gcc RUNTESTFLAGS="dg.exp=Wmisleading-indentation.c"
   make check-g++ RUNTESTFLAGS="dg.exp=Wmisleading-indentation.c"
so far)

gcc/c-family/ChangeLog:
PR c/66220:
* c-indentation.c (should_warn_for_misleading_indentation): Use
expand_location rather than expand_location_to_spelling_point.
Don't warn if the guarding statement is more indented than the
next/body stmts.

gcc/testsuite/ChangeLog:
PR c/66220:
* c-c++-common/Wmisleading-indentation.c (fn_35): New.
(fn_36): New.

OK.
jeff



Re: [patch] testsuite enable PIE tests on FreeBSD

2015-05-20 Thread Jeff Law

On 05/20/2015 11:04 AM, Andreas Tobler wrote:

Hi,

the attached patch enables some PIE tests on FreeBSD.

Ok for trunk?

Thanks,
Andreas

2015-05-20  Andreas Tobler  

 * gcc.target/i386/pr32219-1.c: Enable test on FreeBSD.
 * gcc.target/i386/pr32219-2.c: Likewise.
 * gcc.target/i386/pr32219-3.c: Likewise.
 * gcc.target/i386/pr32219-4.c: Likewise.
 * gcc.target/i386/pr32219-5.c: Likewise.
 * gcc.target/i386/pr32219-6.c: Likewise
 * gcc.target/i386/pr32219-7.c: Likewise.
 * gcc.target/i386/pr32219-8.c: Likewise.
 * gcc.target/i386/pr39013-1.c: Likewise.
 * gcc.target/i386/pr39013-2.c: Likewise.
 * gcc.target/i386/pr64317.c: Likewise.

Wouldn't it be better to remove the target selector and instead add:

/* { dg-require-effective-target pie } */

In each of those tests?

While the net effect is the same today, it means there's only one place 
to change if another x86 target gains PIE support in the future.


Pre-approved using that style.
jeff



Re: [PATCH] Contribute FreeBSD unwind support (x86_64 and x86)

2015-05-20 Thread Andreas Tobler

On 20.05.15 21:49, John Marino wrote:

I have maintained unwind support for FreeBSD i386 and x86_64 in my
"gnat-aux" repository for many years (I created it).  I've always
intended on contributing it back to GCC, but I never got around to
"proving" it worked until now.

The version I've been using actually has two flavors: FreeBSD 8 and
below and FreeBSD 9 and above.  However, the last of the FreeBSD 8
releases reaches EOL at the end of June so the unwind support I've
attached here drops the FreeBSD 8 variation for simplicity's sake.

I was under the impression that MD unwinding was used for more than just
GNAT but it looks like that impression was wrong.  When I ran the
testsuite, the only tests affected were Ada tests.


It is, libjava uses it.



Note that I provided a similar unwind support for DragonFly a few months
ago.  Please consider applying the attached patch to gcc trunk.   (copy
of patch found here:
http://leaf.dragonflybsd.org/~marino/freebsd/freebsd-unwind-support.diff )

Suggested text for libgcc/ChangeLog:

2015-05-XX  John Marino 

* config.host (i[34567]86-*-freebsd*, x86_64-*-freebsd*):
Set md_unwind_header
* config/i386/freebsd-unwind.h: New.


Also please recall that my copyright assignment to FSF is in order!


Testing patch locally now.

Thanks,
Andreas



Re: [PATCH] [PATCH][ARM] Fix split-live-ranges-for-shrink-wrap.c testcase.

2015-05-20 Thread Joseph Myers
On Wed, 20 May 2015, Alex Velenko wrote:

> Hi,
> 
> This patch limits testcase split-live-ranges-for-shrink-wrap.c runs to
> supported achitecture versions.
> Object size with -march=armv4t check fails because pop pc is not interworking
> safe on armv4t.
> This test is not supported for -march=armv7 as this test is for thumb1.
> 
> Is patch ok?

Again, the condition you propose to add doesn't make sense.  arm_arch_X_ok 
is only appropriate for tests using an explicit -march=X.  Testing with 
-march=armv7* should automatically skip this test anyway because it would 
cause arm_thumb1_ok to fail.

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


Re: [PATCH] [PATCH][ARM] Fix sibcall testcases.

2015-05-20 Thread Joseph Myers
On Wed, 20 May 2015, Alex Velenko wrote:

> Hi,
> 
> This patch prevents arm_thumb1_ok XPASS in sibcall-3.c and sibcall-4.c
> testcases. Sibcalls are not ok for Thumb1 and testcases need to be fixed.

arm_thumb1_ok means "this is an ARM target where -mthumb causes Thumb-1 to 
be used".  It only ever makes sense to use it in tests that use an 
explicit -mthumb, which these tests don't.

If you want to check "is this test being built for Thumb-1 by the multilib 
options", use arm_thumb1.

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


Re: [PATCH/libiberty] fix build of gdb/binutils with clang.

2015-05-20 Thread Ian Lance Taylor
This is OK if GCC bootstraps.

Thanks.

Ian

On Wed, May 20, 2015 at 11:25 AM, Yunlian Jiang  wrote:
> I have the following change to make libiberty compile with _GNU_SOURCE defined
> and remove the declaration of asprintf in libiberty.h if
> HAVE_DECL_ASPRINTF is not
> defined.
>
> diff --git a/include/libiberty.h b/include/libiberty.h
> index b33dd65..8e096a0 100644
> --- a/include/libiberty.h
> +++ b/include/libiberty.h
> @@ -621,7 +621,7 @@ extern int pexecute (const char *, char * const *,
> const char *,
>
>  extern int pwait (int, int *, int);
>
> -#if !HAVE_DECL_ASPRINTF
> +#if defined(HAVE_DECL_ASPRINTF) && !HAVE_DECL_ASPRINTF
>  /* Like sprintf but provides a pointer to malloc'd storage, which must
> be freed by the caller.  */
>
> diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
> index f06cc69..624420d 100644
> --- a/libiberty/Makefile.in
> +++ b/libiberty/Makefile.in
> @@ -113,7 +113,8 @@ installcheck: installcheck-subdir
>
>  INCDIR=$(srcdir)/$(MULTISRCTOP)../include
>
> -COMPILE.c = $(CC) -c @DEFS@ $(CFLAGS) $(CPPFLAGS) -I. -I$(INCDIR)
> $(HDEFINES) @ac_libiberty_warn_cflags@
> +COMPILE.c = $(CC) -c @DEFS@ $(CFLAGS) $(CPPFLAGS) -I. -I$(INCDIR) \
> +   $(HDEFINES) @ac_libiberty_warn_cflags@ -D_GNU_SOURCE
>
>  # Just to make sure we don't use a built-in rule with VPATH
>  .c.$(objext):
> diff --git a/libiberty/configure b/libiberty/configure
> index b06cab2..c6758b0 100755
> --- a/libiberty/configure
> +++ b/libiberty/configure
> @@ -5130,6 +5130,9 @@ $as_echo "#define NEED_DECLARATION_ERRNO 1" >>confdefs.h
>  fi
>
>
> +$as_echo "#define _GNU_SOURCE 1" >>confdefs.h
> +
> +
>  # Determine sizes of some types.
>  # The cast to long int works around a bug in the HP C Compiler
>  # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
> diff --git a/libiberty/configure.ac b/libiberty/configure.ac
> index 922aa86..9f2d661 100644
> --- a/libiberty/configure.ac
> +++ b/libiberty/configure.ac
> @@ -272,6 +272,8 @@ AC_HEADER_TIME
>
>  libiberty_AC_DECLARE_ERRNO
>
> +AC_DEFINE(_GNU_SOURCE)
> +
>  # Determine sizes of some types.
>  AC_CHECK_SIZEOF([int])
>  AC_CHECK_SIZEOF([long])
> diff --git a/libiberty/floatformat.c b/libiberty/floatformat.c
> index 789fa05..4e73a2d 100644
> --- a/libiberty/floatformat.c
> +++ b/libiberty/floatformat.c
> @@ -19,7 +19,9 @@ along with this program; if not, write to the Free Software
>  Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
> 02110-1301, USA.  */
>
>  /* This is needed to pick up the NAN macro on some systems.  */
> +#ifndef _GNU_SOURCE
>  #define _GNU_SOURCE
> +#endif
>
>  #ifdef HAVE_CONFIG_H
>  #include "config.h"
>
> On Tue, May 19, 2015 at 11:15 AM, Ian Lance Taylor  wrote:
>> On Tue, May 19, 2015 at 11:08 AM, Yunlian Jiang  wrote:
>>>
>>> I could do that and it make the compilation of libiberty passes.
>>> However, I  have some other problem when using clang to build gdb
>>> because of libiberty.
>>>
>>> Some c file from other component may include 'libiberty.h' which contains
>>> the following
>>>
>>> #if !HAVE_DECL_ASPRINTF
>>> /* Like sprintf but provides a pointer to malloc'd storage, which must
>>>be freed by the caller.  */
>>>
>>> extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
>>> #endif
>>>
>>> The HAVE_DECL_ASPRINTF is defined in config.h under libiberty directory.
>>> If the other c file only includes libiberty.h and does not include the
>>> libiberty/config.h and
>>> at the same time, _GNU_SOURCE is defind, the same error happens.
>>
>> Probably if HAVE_DECL_ASPRINTF is not defined at all, we should not
>> declare asprintf in libiberty.h.
>>
>> Ian


[PATCH] Contribute FreeBSD unwind support (x86_64 and x86)

2015-05-20 Thread John Marino
I have maintained unwind support for FreeBSD i386 and x86_64 in my
"gnat-aux" repository for many years (I created it).  I've always
intended on contributing it back to GCC, but I never got around to
"proving" it worked until now.

The version I've been using actually has two flavors: FreeBSD 8 and
below and FreeBSD 9 and above.  However, the last of the FreeBSD 8
releases reaches EOL at the end of June so the unwind support I've
attached here drops the FreeBSD 8 variation for simplicity's sake.

I was under the impression that MD unwinding was used for more than just
GNAT but it looks like that impression was wrong.  When I ran the
testsuite, the only tests affected were Ada tests.

FreeBSD 10.1 / gcc-6.0.0 before patch applied:
http://leaf.dragonflybsd.org/~marino/freebsd/summary-100F64.txt

FreeBSD 10.1 / gcc-6.0.0 after patch applied:
http://leaf.dragonflybsd.org/~marino/freebsd/summary-unwind-100F64.txt

Difference between runs:
http://leaf.dragonflybsd.org/~marino/freebsd/unwind-diff-100F64.txt

FreeBSD 11/amd64 with patch (Ada only):
http://leaf.dragonflybsd.org/~marino/freebsd/summary-110F64.txt

FreeBSD 11/i386 with patch (Ada only)
http://leaf.dragonflybsd.org/~marino/freebsd/summary-110F32.txt


Note that I provided a similar unwind support for DragonFly a few months
ago.  Please consider applying the attached patch to gcc trunk.   (copy
of patch found here:
http://leaf.dragonflybsd.org/~marino/freebsd/freebsd-unwind-support.diff )

Suggested text for libgcc/ChangeLog:

2015-05-XX  John Marino 

* config.host (i[34567]86-*-freebsd*, x86_64-*-freebsd*):
Set md_unwind_header
* config/i386/freebsd-unwind.h: New.


Also please recall that my copyright assignment to FSF is in order!
Thanks,
John Marino

--- /dev/null
+++ libgcc/config/i386/freebsd-unwind.h
@@ -0,0 +1,173 @@
+/* DWARF2 EH unwinding support for FreeBSD: AMD x86-64 and x86.
+   Copyright (C) 2015 Free Software Foundation, Inc.
+   Contributed by John Marino 
+
+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.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+.  */
+
+/* Do code reading to identify a signal frame, and set the frame
+   state data appropriately.  See unwind-dw2.c for the structs. */
+
+#include 
+#include 
+#include 
+#include 
+
+#define REG_NAME(reg)  sf_uc.uc_mcontext.mc_## reg
+
+#ifdef __x86_64__
+#define MD_FALLBACK_FRAME_STATE_FOR x86_64_freebsd_fallback_frame_state
+
+static _Unwind_Reason_Code
+x86_64_freebsd_fallback_frame_state
+(struct _Unwind_Context *context, _Unwind_FrameState *fs)
+{
+  struct sigframe *sf;
+  long new_cfa;
+
+  /* Prior to FreeBSD 9, the signal trampoline was located immediately
+ before the ps_strings.  To support non-executable stacks on AMD64,
+ the sigtramp was moved to a shared page for FreeBSD 9.  Unfortunately
+ this means looking frame patterns again (sys/amd64/amd64/sigtramp.S)
+ rather than using the robust and convenient KERN_PS_STRINGS trick.
+
+ :  lea 0x10(%rsp),%rdi
+ :  pushq   $0x0
+ :  mov $0x1a1,%rax
+ :  syscall
+
+ If we can't find this pattern, we're at the end of the stack.
+  */
+
+  if (!(   *(unsigned int *)(context->ra)  == 0x247c8d48
+&& *(unsigned int *)(context->ra +  4) == 0x48006a10
+&& *(unsigned int *)(context->ra +  8) == 0x01a1c0c7
+&& *(unsigned int *)(context->ra + 12) == 0x050f ))
+return _URC_END_OF_STACK;
+
+  sf = (struct sigframe *) context->cfa;
+  new_cfa = sf->REG_NAME(rsp);
+  fs->regs.cfa_how = CFA_REG_OFFSET;
+  /* Register 7 is rsp  */
+  fs->regs.cfa_reg = 7;
+  fs->regs.cfa_offset = new_cfa - (long) context->cfa;
+
+  /* The SVR4 register numbering macros aren't usable in libgcc.  */
+  fs->regs.reg[0].how = REG_SAVED_OFFSET;
+  fs->regs.reg[0].loc.offset = (long)&sf->REG_NAME(rax) - new_cfa;
+  fs->regs.reg[1].how = REG_SAVED_OFFSET;
+  fs->regs.reg[1].loc.offset = (long)&sf->REG_NAME(rdx) - new_cfa;
+  fs->regs.reg[2].how = REG_SAVED_OFFSET;
+  fs->regs.reg[2].loc.offset = (long)&sf->REG_NAME(rcx) - new_cfa;
+  fs->regs.reg[3].how = REG_SAVED_OFFSET;
+  fs->regs.reg[3].loc.offset = (long)&sf->REG_NAME(rbx) - new_cfa;
+  fs->regs.reg[4].how

Re: Fwd: Re: [PATCH, RFC]: Next stage1, refactoring: propagating rtx subclasses

2015-05-20 Thread Mikhail Maltsev
On 05/20/2015 12:28 AM, Jeff Law wrote:
> Yes, this is OK for the trunk.  Please commit.
> 
> jeff

Applied to trunk (revision 223454).

-- 
Regards,
Mikhail Maltsev


Re: Demangle symbols in debug assertion messages

2015-05-20 Thread François Dumont

On 20/05/2015 12:19, Jonathan Wakely wrote:

On 20/05/15 11:17 +0100, Jonathan Wakely wrote:

On 04/05/15 22:31 +0200, François Dumont wrote:

Hi

  Here is  the patch to demangle symbols in debug messages. I have 
also simplify code in formatter.h.


  Here is an example of assertion message:

/home/fdt/dev/gcc/build/x86_64-unknown-linux-gnu/libstdc++-v3/include/debug/functions.h:213: 


  error: function requires a valid iterator range [__first, __last).

Objects involved in the operation:
iterator "__first" @ 0x0x7fff165d68b0 {
type = 
__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iteratorstd::__cxx1998::vector > >, 
std::__debug::vector > > (mutable iterator);

state = dereferenceable;
references sequence with type `std::__debug::vectorstd::allocator >' @ 0x0x7fff165d69d0

}
iterator "__last" @ 0x0x7fff165d68e0 {
type = 
__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iteratorstd::__cxx1998::vector > >, 
std::__debug::vector > > (mutable iterator);

state = dereferenceable;
references sequence with type `std::__debug::vectorstd::allocator >' @ 0x0x7fff165d69d0

}


  * include/debug/formatter.h (_GLIBCXX_TYPEID): New macro to simplify
  usage of typeid.
  (_Error_formatter::_M_print_type): New.
  * src/c++11/debug.cc
  (_Error_formatter::_Parameter::_M_print_field): Use latter.
  (_Error_formatter::_M_print_type): Implement latter using
  __cxaabiv1::__cxa_demangle to print demangled type name.

I just hope that __cxa_demangle is portable.


It's provided by GCC itself so is always available in the runtime.
(It is also portable, because it's defined by the Itanium C++ ABI).



Ok to commit ?


Yes, this is great, thanks!


Does this fix https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65392 ?

With the patch this code of the bug report generates the following debug 
message:


/home/fdt/dev/gcc/build/x86_64-unknown-linux-gnu/libstdc++-v3/include/debug/safe_iterator.h:395:
error: attempt to retreat a past-the-end iterator 2 steps, which falls
outside its valid range.

Objects involved in the operation:
iterator @ 0x0x7fff32365c50 {
  type = 
__gnu_debug::_Safe_iteratorint*>, std::__debug::deque > > (mutable iterator);

  state = past-the-end;
  references sequence with type `std::__debug::dequestd::allocator >' @ 0x0x7fff32365cd0

}

which looks nice.

However I wouldn't say that bug is fixed because debug mode do not 
generate mangle name, it simply rely on typeid to get it. Shouldn't bug 
report be saying so ? Whatever, symbol generated by typeid can be 
demangle by __cxa_demangle so it mustn't be that bad.


François



Re: [patch 3/10] debug-early merge: C++ front-end

2015-05-20 Thread Jason Merrill

On 05/08/2015 09:14 PM, Aldy Hernandez wrote:

+  if (!flag_syntax_only)
+c_parse_final_cleanups ();


The condition is a significant change of behavior for the C++ front end; 
doing final instantiation and such even with -fsyntax-only was a 
deliberate choice.  Can we drop the condition?



+  timevar_stop (TV_PHASE_PARSING);
+  timevar_start (TV_PHASE_DBGINFO);

   perform_deferred_noexcept_checks ();


The only debug info stuff that was here has been removed, so there's no 
longer any need to switch to a debug timevar.  I think we should stay in 
DEFERRED for the whole function.


Jason




Re: [PATCH] Fix PR target/65730

2015-05-20 Thread Max Filippov
On Wed, May 20, 2015 at 7:36 PM, augustine.sterl...@gmail.com
 wrote:
> On Tue, May 19, 2015 at 8:31 PM, Max Filippov  wrote:
>> 2015-05-20  Max Filippov  
>> gcc/
>> * config/xtensa/xtensa.c (init_alignment_context): Replace MULT
>> by BITS_PER_UNIT with ASHIFT by exact_log2 (BITS_PER_UNIT).
>
> Approved, please apply.

Applied to trunk. Thanks!

-- Max


[PATCH] PR target/66224 _GLIBC_READ_MEM_BARRIER

2015-05-20 Thread David Edelsohn
The current definition of _GLIBC_READ_MEM_BARRIER in libstdc++ is too
weak for an ACQUIRE FENCE, which is what it is intended to be. The
original code emitted an "isync" instead of "lwsync".

All of the guard acquire and set code needs to be cleaned up to use
GCC atomic intrinsics, but this is necessary for correctness.

Steve, any comment about the Linux part?

- David

PR target/66224
* config/os/aix/atomic_word.h (_GLIBCXX_READ_MEM_BARRIER): Use
lwsync if available, not isync.
(_GLIBCXX_WRITE_MEM_BARRIER): Use lwsync if available.
* config/cpu/powerpc/atomic_word.h (_GLIBCXX_READ_MEM_BARRIER):
Use lwsync if available, not isync.

Index: config/os/aix/atomic_word.h
===
--- config/os/aix/atomic_word.h (revision 223444)
+++ config/os/aix/atomic_word.h (working copy)
@@ -33,9 +33,16 @@
 typedef int _Atomic_word;

 #ifdef _ARCH_PPC
-#define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("isync":::"memory")
+
+#ifdef __NO_LWSYNC__
+#define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("sync":::"memory")
 #define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("sync":::"memory")
 #else
+#define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("lwsync":::"memory")
+#define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("lwsync":::"memory")
+#endif
+
+#else
 #define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("":::"memory")
 #define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("":::"memory")
 #endif
Index: config/cpu/powerpc/atomic_word.h
===
--- config/cpu/powerpc/atomic_word.h(revision 223444)
+++ config/cpu/powerpc/atomic_word.h(working copy)
@@ -27,10 +27,11 @@

 typedef int _Atomic_word;

-#define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("isync":::"memory")
 #ifdef __NO_LWSYNC__
+#define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("sync":::"memory")
 #define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("sync":::"memory")
 #else
+#define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("lwsync":::"memory")
 #define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("lwsync":::"memory")
 #endif


[PATCH] [PATCH][ARM] Fix split-live-ranges-for-shrink-wrap.c testcase.

2015-05-20 Thread Alex Velenko
Hi,

This patch limits testcase split-live-ranges-for-shrink-wrap.c runs to
supported achitecture versions.
Object size with -march=armv4t check fails because pop pc is not interworking
safe on armv4t.
This test is not supported for -march=armv7 as this test is for thumb1.

Is patch ok?

gcc/testsuite

2015-05-20  Alex Velenko  

* gcc.target/arm/split-live-ranges-for-shrink-wrap.c (dg-skip-if):
Skip armv4t, armv7-a and later.
---
 gcc/testsuite/gcc.target/arm/split-live-ranges-for-shrink-wrap.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/testsuite/gcc.target/arm/split-live-ranges-for-shrink-wrap.c 
b/gcc/testsuite/gcc.target/arm/split-live-ranges-for-shrink-wrap.c
index e36000b..c649bc1 100644
--- a/gcc/testsuite/gcc.target/arm/split-live-ranges-for-shrink-wrap.c
+++ b/gcc/testsuite/gcc.target/arm/split-live-ranges-for-shrink-wrap.c
@@ -1,6 +1,8 @@
 /* { dg-do assemble } */
 /* { dg-options "-mthumb -Os -fdump-rtl-ira " }  */
 /* { dg-require-effective-target arm_thumb1_ok } */
+/* { dg-skip-if "" { arm_arch_v4t_ok } } */
+/* { dg-skip-if "" { arm_arch_v7a_ok } } */
 
 int foo (char *, char *, int);
 int test (int d, char * out, char *in, int len)
-- 
1.8.1.2



Re: [PATCH/libiberty] fix build of gdb/binutils with clang.

2015-05-20 Thread Yunlian Jiang
I have the following change to make libiberty compile with _GNU_SOURCE defined
and remove the declaration of asprintf in libiberty.h if
HAVE_DECL_ASPRINTF is not
defined.

diff --git a/include/libiberty.h b/include/libiberty.h
index b33dd65..8e096a0 100644
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -621,7 +621,7 @@ extern int pexecute (const char *, char * const *,
const char *,

 extern int pwait (int, int *, int);

-#if !HAVE_DECL_ASPRINTF
+#if defined(HAVE_DECL_ASPRINTF) && !HAVE_DECL_ASPRINTF
 /* Like sprintf but provides a pointer to malloc'd storage, which must
be freed by the caller.  */

diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index f06cc69..624420d 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -113,7 +113,8 @@ installcheck: installcheck-subdir

 INCDIR=$(srcdir)/$(MULTISRCTOP)../include

-COMPILE.c = $(CC) -c @DEFS@ $(CFLAGS) $(CPPFLAGS) -I. -I$(INCDIR)
$(HDEFINES) @ac_libiberty_warn_cflags@
+COMPILE.c = $(CC) -c @DEFS@ $(CFLAGS) $(CPPFLAGS) -I. -I$(INCDIR) \
+   $(HDEFINES) @ac_libiberty_warn_cflags@ -D_GNU_SOURCE

 # Just to make sure we don't use a built-in rule with VPATH
 .c.$(objext):
diff --git a/libiberty/configure b/libiberty/configure
index b06cab2..c6758b0 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -5130,6 +5130,9 @@ $as_echo "#define NEED_DECLARATION_ERRNO 1" >>confdefs.h
 fi


+$as_echo "#define _GNU_SOURCE 1" >>confdefs.h
+
+
 # Determine sizes of some types.
 # The cast to long int works around a bug in the HP C Compiler
 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
diff --git a/libiberty/configure.ac b/libiberty/configure.ac
index 922aa86..9f2d661 100644
--- a/libiberty/configure.ac
+++ b/libiberty/configure.ac
@@ -272,6 +272,8 @@ AC_HEADER_TIME

 libiberty_AC_DECLARE_ERRNO

+AC_DEFINE(_GNU_SOURCE)
+
 # Determine sizes of some types.
 AC_CHECK_SIZEOF([int])
 AC_CHECK_SIZEOF([long])
diff --git a/libiberty/floatformat.c b/libiberty/floatformat.c
index 789fa05..4e73a2d 100644
--- a/libiberty/floatformat.c
+++ b/libiberty/floatformat.c
@@ -19,7 +19,9 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
02110-1301, USA.  */

 /* This is needed to pick up the NAN macro on some systems.  */
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
+#endif

 #ifdef HAVE_CONFIG_H
 #include "config.h"

On Tue, May 19, 2015 at 11:15 AM, Ian Lance Taylor  wrote:
> On Tue, May 19, 2015 at 11:08 AM, Yunlian Jiang  wrote:
>>
>> I could do that and it make the compilation of libiberty passes.
>> However, I  have some other problem when using clang to build gdb
>> because of libiberty.
>>
>> Some c file from other component may include 'libiberty.h' which contains
>> the following
>>
>> #if !HAVE_DECL_ASPRINTF
>> /* Like sprintf but provides a pointer to malloc'd storage, which must
>>be freed by the caller.  */
>>
>> extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
>> #endif
>>
>> The HAVE_DECL_ASPRINTF is defined in config.h under libiberty directory.
>> If the other c file only includes libiberty.h and does not include the
>> libiberty/config.h and
>> at the same time, _GNU_SOURCE is defind, the same error happens.
>
> Probably if HAVE_DECL_ASPRINTF is not defined at all, we should not
> declare asprintf in libiberty.h.
>
> Ian


[PATCH] [PATCH][ARM] Fix sibcall testcases.

2015-05-20 Thread Alex Velenko
Hi,

This patch prevents arm_thumb1_ok XPASS in sibcall-3.c and sibcall-4.c
testcases. Sibcalls are not ok for Thumb1 and testcases need to be fixed.

Is patch ok?

gcc/testsuite

2015-05-20  Alex Velenko  

* gcc.dg/sibcall-3.c (dg-skip-if): Skip if arm_thumb1_ok.
* gcc.dg/sibcall-4.c (dg-skip-if): Likewise.
---
 gcc/testsuite/gcc.dg/sibcall-3.c | 1 +
 gcc/testsuite/gcc.dg/sibcall-4.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/sibcall-3.c b/gcc/testsuite/gcc.dg/sibcall-3.c
index eafe8dd..37f44a1 100644
--- a/gcc/testsuite/gcc.dg/sibcall-3.c
+++ b/gcc/testsuite/gcc.dg/sibcall-3.c
@@ -8,6 +8,7 @@
 /* { dg-do run { xfail { { cris-*-* crisv32-*-* h8300-*-* hppa*64*-*-* 
m32r-*-* mcore-*-* mn10300-*-* msp430*-*-* nds32*-*-* xstormy16-*-* v850*-*-* 
vax-*-* xtensa*-*-* } || { arm*-*-* && { ! arm32 } } } } } */
 /* -mlongcall disables sibcall patterns.  */
 /* { dg-skip-if "" { powerpc*-*-* } { "-mlongcall" } { "" } } */
+/* { dg-skip-if "" { arm*-*-* && arm_thumb1_ok } } */
 /* { dg-options "-O2 -foptimize-sibling-calls" } */
 
 /* The option -foptimize-sibling-calls is the default, but serves as
diff --git a/gcc/testsuite/gcc.dg/sibcall-4.c b/gcc/testsuite/gcc.dg/sibcall-4.c
index 1e039c6..9554a95 100644
--- a/gcc/testsuite/gcc.dg/sibcall-4.c
+++ b/gcc/testsuite/gcc.dg/sibcall-4.c
@@ -8,6 +8,7 @@
 /* { dg-do run { xfail { { cris-*-* crisv32-*-* h8300-*-* hppa*64*-*-* 
m32r-*-* mcore-*-* mn10300-*-* msp430*-*-* nds32*-*-* xstormy16-*-* v850*-*-* 
vax-*-* xtensa*-*-* } || { arm*-*-* && { ! arm32 } } } } } */
 /* -mlongcall disables sibcall patterns.  */
 /* { dg-skip-if "" { powerpc*-*-* } { "-mlongcall" } { "" } } */
+/* { dg-skip-if "" { arm*-*-* && arm_thumb1_ok } } */
 /* { dg-options "-O2 -foptimize-sibling-calls" } */
 
 /* The option -foptimize-sibling-calls is the default, but serves as
-- 
1.8.1.2



Re: [v3 patch] Fix some Filesystem TS operations

2015-05-20 Thread Jonathan Wakely

On 15/05/15 19:37 +0100, Jonathan Wakely wrote:

Testing revealed a few bugs in how I handled paths that don't exist.
The new __gnu_test::nonexistent_path() function is a bit hacky but
should be good enough for the testsuite.


This makes it even hackier but avoids linker warnings for using the
evil tempnam() function.

I know it should use snprintf not sprintf, but that depends on
_GLIBCXX_USE_C99 which may not be defined (because we incorrectly test
for a C99 lib using -std=gnu++98, which I'm going to fix).

commit fc7f3808e940243362d29acde4a09ae90aa0df81
Author: Jonathan Wakely 
Date:   Wed May 20 18:17:56 2015 +0100

	* testsuite/util/testsuite_fs.h (nonexistent_path): Don't use tempnam.

diff --git a/libstdc++-v3/testsuite/util/testsuite_fs.h b/libstdc++-v3/testsuite/util/testsuite_fs.h
index f404a7a..3873a60 100644
--- a/libstdc++-v3/testsuite/util/testsuite_fs.h
+++ b/libstdc++-v3/testsuite/util/testsuite_fs.h
@@ -26,10 +26,8 @@
 #include 
 #include 
 #include 
-#if defined(_GNU_SOURCE) || _XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200112L
-# include 
-# include 
-#endif
+#include 
+#include 
 
 namespace __gnu_test
 {
@@ -84,12 +82,9 @@ namespace __gnu_test
 ::close(fd);
 p = tmp;
 #else
-char* tmp = tempnam(".", "test.");
-if (!tmp)
-  throw std::experimental::filesystem::filesystem_error("tempnam failed",
-	  std::error_code(errno, std::generic_category()));
-p = tmp;
-::free(tmp);
+char buf[64];
+std::sprintf(buf, "test.%lu", (unsigned long)::getpid());
+p = buf;
 #endif
 return p;
   }


Re: [PATCH v2 6/6] i386: Implement asm flag outputs

2015-05-20 Thread Richard Henderson
On 05/20/2015 09:21 AM, Jeff Law wrote:
> What I don't see is any way to know if the target supports asm flag outputs. 
> Are we expecting the kernel folks to do some kind of test then enable/disable
> based on the result?

I'd forgotten that we'd talked about a cpp symbol.
I'll add that.


r~


RFA: PATCH to use -std=c++98 in stage 1 of bootstrap

2015-05-20 Thread Jason Merrill
I want to explicitly pass -std=c++98 to the compiler used in building 
stage 1.  Does this seem like the right way to do that?


Tested x86_64-pc-linux-gnu.
commit 97e77ef17e558cdb6d26d440e691fea710e2a2dc
Author: Jason Merrill 
Date:   Mon May 18 23:58:41 2015 -0400

	* configure.ac: Add -std=c++98 to stage1_cxxflags.
	* Makefile.in (STAGE1_CXXFLAGS): And substitute it.
	* configure: Regenerate.

diff --git a/Makefile.in b/Makefile.in
index c221a0b..c59671a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -489,6 +489,7 @@ STAGEfeedback_CONFIGURE_FLAGS = $(STAGE_CONFIGURE_FLAGS)
 # overrideable (for a bootstrap build stage1 also builds gcc.info).
 
 STAGE1_CFLAGS = @stage1_cflags@
+STAGE1_CXXFLAGS = @stage1_cxxflags@
 STAGE1_CHECKING = @stage1_checking@
 STAGE1_LANGUAGES = @stage1_languages@
 # * We force-disable intermodule optimizations, even if
diff --git a/configure b/configure
index d804329..37079fb 100755
--- a/configure
+++ b/configure
@@ -559,6 +559,7 @@ compare_exclusions
 host_shared
 stage2_werror_flag
 stage1_checking
+stage1_cxxflags
 stage1_cflags
 MAINT
 MAINTAINER_MODE_FALSE
@@ -14755,6 +14756,13 @@ case $build in
   *) stage1_cflags="-g -J" ;;
 esac ;;
 esac
+stage1_cxxflags="$stage1_cflags"
+if test "$GCC" = yes; then
+  # Build stage 1 in C++98 mode to ensure that a C++98 compiler can still
+  # start the bootstrap.
+  stage1_cxxflags="$stage1_cxxflags -std=c++98"
+fi
+
 
 
 
diff --git a/configure.ac b/configure.ac
index 4da04b7..2bf3245 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3476,8 +3476,15 @@ case $build in
   *) stage1_cflags="-g -J" ;;
 esac ;;
 esac
+stage1_cxxflags="$stage1_cflags"
+if test "$GCC" = yes; then
+  # Build stage 1 in C++98 mode to ensure that a C++98 compiler can still
+  # start the bootstrap.
+  stage1_cxxflags="$stage1_cxxflags -std=c++98"
+fi
 
 AC_SUBST(stage1_cflags)
+AC_SUBST(stage1_cxxflags)
 
 # Enable --enable-checking in stage1 of the compiler.
 AC_ARG_ENABLE(stage1-checking,


[patch] libstdc++/66078 __make_move_if_noexcept_iterator should return a constant iterator or a move iterator

2015-05-20 Thread Jonathan Wakely

As discussed in the thread starting at
https://gcc.gnu.org/ml/libstdc++/2014-05/msg00027.html when
__make_move_if_noexcept_iterator decides not to move it returns a
mutable iterator, which can then result in the wrong constructor being
used. This ensures that when not moving we will get a pointer-to-const
which will result in the copy constructor being called.

Tested powerpc64-linux, committed to trunk.
commit 7dc39df13857920ecbb3da1336c2469fdfb30e42
Author: Jonathan Wakely 
Date:   Fri May 9 13:51:39 2014 +0100

	PR libstdc++/66078
	* include/bits/stl_iterator.h (__make_move_if_noexcept_iterator): Add
	overload for pointers.
	* testsuite/20_util/specialized_algorithms/uninitialized_copy/
	808590.cc: Add -std=gnu++03 switch.
	* testsuite/20_util/specialized_algorithms/uninitialized_copy/
	808590-cxx11.cc: Copy of 808590.cc to test with -std=gnu++11.
	* testsuite/23_containers/vector/modifiers/push_back/
	strong_guarantee.cc: New.

diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h
index d4ea657..b8e79df 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -1194,6 +1194,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 __make_move_if_noexcept_iterator(_Iterator __i)
 { return _ReturnType(__i); }
 
+  // Overload for pointers that matches std::move_if_noexcept more closely,
+  // returning a constant iterator when we don't want to move.
+  template::value,
+			   const _Tp*, move_iterator<_Tp*>>::type>
+inline _ReturnType
+__make_move_if_noexcept_iterator(_Tp* __i)
+{ return _ReturnType(__i); }
+
   // @} group iterators
 
   template
diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/808590-cxx11.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/808590-cxx11.cc
new file mode 100644
index 000..9597a7b
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/808590-cxx11.cc
@@ -0,0 +1,53 @@
+// Copyright (C) 2012-2015 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library 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.
+
+// This library 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 this library; see the file COPYING3.  If not see
+// .
+
+// { dg-options "-std=gnu++11" }
+
+// This is identical to ./808590.cc but using -std=gnu++11
+// See https://gcc.gnu.org/ml/libstdc++/2014-05/msg00027.html
+
+#include 
+#include 
+
+// 4.4.x only
+struct c
+{
+  void *m;
+
+  c(void* o = 0) : m(o) {}
+  c(const c &r) : m(r.m) {}
+
+  template
+explicit c(T &o) : m((void*)0xdeadbeef) { }
+};
+
+int main()
+{
+  std::vector cbs;
+  const c cb((void*)0xcafebabe);
+
+  for (int fd = 62; fd < 67; ++fd)
+{
+  cbs.resize(fd + 1);
+  cbs[fd] = cb;
+}
+
+  for (int fd = 62; fd< 67; ++fd)
+if (cb.m != cbs[fd].m)
+  throw std::runtime_error("wrong");
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/808590.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/808590.cc
index 53b2d6d..7d20f85 100644
--- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/808590.cc
+++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/808590.cc
@@ -15,11 +15,13 @@
 // with this library; see the file COPYING3.  If not see
 // .
 
+// { dg-options "-std=gnu++03" }
+
 #include 
 #include 
 
 // 4.4.x only
-struct c 
+struct c
 {
   void *m;
 
@@ -30,12 +32,12 @@ struct c
 explicit c(T &o) : m((void*)0xdeadbeef) { }
 };
 
-int main() 
+int main()
 {
   std::vector cbs;
   const c cb((void*)0xcafebabe);
 
-  for (int fd = 62; fd < 67; ++fd) 
+  for (int fd = 62; fd < 67; ++fd)
 {
   cbs.resize(fd + 1);
   cbs[fd] = cb;
diff --git a/libstdc++-v3/testsuite/23_containers/vector/modifiers/push_back/strong_guarantee.cc b/libstdc++-v3/testsuite/23_containers/vector/modifiers/push_back/strong_guarantee.cc
new file mode 100644
index 000..461f6ea
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/modifiers/push_back/strong_guarantee.cc
@@ -0,0 +1,88 @@
+// Copyright (C) 2015 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as pu

[patch] testsuite enable PIE tests on FreeBSD

2015-05-20 Thread Andreas Tobler

Hi,

the attached patch enables some PIE tests on FreeBSD.

Ok for trunk?

Thanks,
Andreas

2015-05-20  Andreas Tobler  

* gcc.target/i386/pr32219-1.c: Enable test on FreeBSD.
* gcc.target/i386/pr32219-2.c: Likewise.
* gcc.target/i386/pr32219-3.c: Likewise.
* gcc.target/i386/pr32219-4.c: Likewise.
* gcc.target/i386/pr32219-5.c: Likewise.
* gcc.target/i386/pr32219-6.c: Likewise
* gcc.target/i386/pr32219-7.c: Likewise.
* gcc.target/i386/pr32219-8.c: Likewise.
* gcc.target/i386/pr39013-1.c: Likewise.
* gcc.target/i386/pr39013-2.c: Likewise.
* gcc.target/i386/pr64317.c: Likewise.
Index: gcc.target/i386/pr32219-1.c
===
--- gcc.target/i386/pr32219-1.c (revision 223412)
+++ gcc.target/i386/pr32219-1.c (working copy)
@@ -1,4 +1,4 @@
-/* { dg-do compile { target *-*-linux* } } */
+/* { dg-do compile { target *-*-freebsd* *-*-linux* } } */
 /* { dg-options "-O2 -fpie" } */
 
 /* Initialized common symbol with -fpie.  */
Index: gcc.target/i386/pr32219-2.c
===
--- gcc.target/i386/pr32219-2.c (revision 223412)
+++ gcc.target/i386/pr32219-2.c (working copy)
@@ -1,4 +1,4 @@
-/* { dg-do compile { target *-*-linux* } } */
+/* { dg-do compile { target *-*-freebsd* *-*-linux* } } */
 /* { dg-options "-O2 -fpic" } */
 
 /* Common symbol with -fpic.  */
Index: gcc.target/i386/pr32219-3.c
===
--- gcc.target/i386/pr32219-3.c (revision 223412)
+++ gcc.target/i386/pr32219-3.c (working copy)
@@ -1,4 +1,4 @@
-/* { dg-do compile { target *-*-linux* } } */
+/* { dg-do compile { target *-*-freebsd* *-*-linux* } } */
 /* { dg-options "-O2 -fpie" } */
 
 /* Weak common symbol with -fpie.  */
Index: gcc.target/i386/pr32219-4.c
===
--- gcc.target/i386/pr32219-4.c (revision 223412)
+++ gcc.target/i386/pr32219-4.c (working copy)
@@ -1,4 +1,4 @@
-/* { dg-do compile { target *-*-linux* } } */
+/* { dg-do compile { target *-*-freebsd* *-*-linux* } } */
 /* { dg-options "-O2 -fpic" } */
 
 /* Weak common symbol with -fpic.  */
Index: gcc.target/i386/pr32219-5.c
===
--- gcc.target/i386/pr32219-5.c (revision 223412)
+++ gcc.target/i386/pr32219-5.c (working copy)
@@ -1,4 +1,4 @@
-/* { dg-do compile { target *-*-linux* } } */
+/* { dg-do compile { target *-*-freebsd* *-*-linux* } } */
 /* { dg-options "-O2 -fpie" } */
 
 /* Initialized symbol with -fpie.  */
Index: gcc.target/i386/pr32219-6.c
===
--- gcc.target/i386/pr32219-6.c (revision 223412)
+++ gcc.target/i386/pr32219-6.c (working copy)
@@ -1,4 +1,4 @@
-/* { dg-do compile { target *-*-linux* } } */
+/* { dg-do compile { target *-*-freebsd* *-*-linux* } } */
 /* { dg-options "-O2 -fpic" } */
 
 /* Initialized symbol with -fpic.  */
Index: gcc.target/i386/pr32219-7.c
===
--- gcc.target/i386/pr32219-7.c (revision 223412)
+++ gcc.target/i386/pr32219-7.c (working copy)
@@ -1,4 +1,4 @@
-/* { dg-do compile { target *-*-linux* } } */
+/* { dg-do compile { target *-*-freebsd* *-*-linux* } } */
 /* { dg-options "-O2 -fpie" } */
 
 /* Weak initialized symbol with -fpie.  */
Index: gcc.target/i386/pr32219-8.c
===
--- gcc.target/i386/pr32219-8.c (revision 223412)
+++ gcc.target/i386/pr32219-8.c (working copy)
@@ -1,4 +1,4 @@
-/* { dg-do compile { target *-*-linux* } } */
+/* { dg-do compile { target *-*-freebsd* *-*-linux* } } */
 /* { dg-options "-O2 -fpic" } */
 
 /* Weak initialized symbol with -fpic.  */
Index: gcc.target/i386/pr39013-1.c
===
--- gcc.target/i386/pr39013-1.c (revision 223412)
+++ gcc.target/i386/pr39013-1.c (working copy)
@@ -1,5 +1,5 @@
 /* PR target/39013 */
-/* { dg-do compile { target *-*-linux* *-*-gnu* } } */
+/* { dg-do compile { target *-*-freebsd* *-*-linux* *-*-gnu* } } */
 /* { dg-options "-O2 -fpie -std=gnu89" } */
 
 inline int foo (void);
Index: gcc.target/i386/pr39013-2.c
===
--- gcc.target/i386/pr39013-2.c (revision 223412)
+++ gcc.target/i386/pr39013-2.c (working copy)
@@ -1,5 +1,5 @@
 /* PR target/39013 */
-/* { dg-do compile { target *-*-linux* *-*-gnu* } } */
+/* { dg-do compile { target *-*-freebsd* *-*-linux* *-*-gnu* } } */
 /* { dg-options "-O2 -fpie -std=gnu99" } */
 
 inline int foo (void); /* { dg-warning "declared but never defined" } 
*/
Index: gcc.target/i386/pr64317.c
===
--- gcc.target/i386/pr64317.c   (revision 223412)
+++ gcc.target/i386/pr64317.c   (working copy)
@@ 

[PATCH] PR c/66220: Fix false positive from -Wmisleading-indentation

2015-05-20 Thread David Malcolm
This patch fixes the false positive seen from -Wmisleading-indentation
on this code:

if (v == 2)
{
res = 27;
} else
{
res = 18;
}
return res;
^ FALSE POSITIVE HERE

along with similar code seen when I tested it with linux-4.0.3.

The patch adds a reject for the case where the guard ("else" in
the above example) is more indented than the things it guards.

Doing so uncovered an issue with this testcase:

#define FOR_EACH(VAR, START, STOP) for ((VAR) = (START); (VAR) < (STOP); 
(VAR++)) /* { dg-message "36: ...this 'for' clause, but it is not" } */
void fn_15 (void)
{
  int i;
  FOR_EACH (i, 0, 10) /* { dg-message "3: in expansion of macro" } */
foo (i);
bar (i, i); /* { dg-warning "statement is indented as if it were guarded 
by..." } */
}
#undef FOR_EACH

which would then fail to report the warning, due to it using the
location of the "for" in the definition of macro FOR_EACH, rather than
the location of the FOR_EACH (i, 0, 10).  The fix for this is to use
expand_location to get file/line/col of each thing, rather than
expand_location_to_spelling_point.

With that, all testcases in Wmisleading-indentation.c pass (including
the new ones posted in
https://gcc.gnu.org/ml/gcc-patches/2015-05/msg01846.html ).

OK for trunk if it passes bootstrap®rest?  (only tested with
  make check-gcc RUNTESTFLAGS="dg.exp=Wmisleading-indentation.c"
  make check-g++ RUNTESTFLAGS="dg.exp=Wmisleading-indentation.c"
so far)

gcc/c-family/ChangeLog:
PR c/66220:
* c-indentation.c (should_warn_for_misleading_indentation): Use
expand_location rather than expand_location_to_spelling_point.
Don't warn if the guarding statement is more indented than the
next/body stmts.

gcc/testsuite/ChangeLog:
PR c/66220:
* c-c++-common/Wmisleading-indentation.c (fn_35): New.
(fn_36): New.
---
 gcc/c-family/c-indentation.c   | 26 ++-
 .../c-c++-common/Wmisleading-indentation.c | 38 ++
 2 files changed, 56 insertions(+), 8 deletions(-)

diff --git a/gcc/c-family/c-indentation.c b/gcc/c-family/c-indentation.c
index 9aeebae..1e3a6d8 100644
--- a/gcc/c-family/c-indentation.c
+++ b/gcc/c-family/c-indentation.c
@@ -230,10 +230,8 @@ should_warn_for_misleading_indentation (location_t 
guard_loc,
   if (next_tok_type == CPP_SEMICOLON)
 return false;
 
-  expanded_location body_exploc
-= expand_location_to_spelling_point (body_loc);
-  expanded_location next_stmt_exploc
-= expand_location_to_spelling_point (next_stmt_loc);
+  expanded_location body_exploc = expand_location (body_loc);
+  expanded_location next_stmt_exploc = expand_location (next_stmt_loc);
 
   /* They must be in the same file.  */
   if (next_stmt_exploc.file != body_exploc.file)
@@ -257,8 +255,7 @@ should_warn_for_misleading_indentation (location_t 
guard_loc,
   ^ DON'T WARN HERE.  */
   if (next_stmt_exploc.line == body_exploc.line)
 {
-  expanded_location guard_exploc
-   = expand_location_to_spelling_point (guard_loc);
+  expanded_location guard_exploc = expand_location (guard_loc);
   if (guard_exploc.file != body_exploc.file)
return true;
   if (guard_exploc.line < body_exploc.line)
@@ -299,6 +296,15 @@ should_warn_for_misleading_indentation (location_t 
guard_loc,
   #endif
  bar ();
  ^ DON'T WARN HERE
+
+if (flag) {
+  foo ();
+} else
+{
+  bar ();
+}
+baz ();
+^ DON'T WARN HERE
   */
   if (next_stmt_exploc.line > body_exploc.line)
 {
@@ -319,14 +325,18 @@ should_warn_for_misleading_indentation (location_t 
guard_loc,
  /* Don't warn if they aren't aligned on the same column
 as the guard itself (suggesting autogenerated code that
 doesn't bother indenting at all).  */
- expanded_location guard_exploc
-   = expand_location_to_spelling_point (guard_loc);
+ expanded_location guard_exploc = expand_location (guard_loc);
  unsigned int guard_vis_column;
  if (!get_visual_column (guard_exploc, &guard_vis_column))
return false;
  if (guard_vis_column == body_vis_column)
return false;
 
+ /* PR 66220: Don't warn if the guarding statement is more
+indented than the next/body stmts.  */
+ if (guard_vis_column > body_vis_column)
+   return false;
+
  /* Don't warn if there is multiline preprocessor logic between
 the two statements. */
  if (detect_preprocessor_logic (body_exploc, next_stmt_exploc))
diff --git a/gcc/testsuite/c-c++-common/Wmisleading-indentation.c 
b/gcc/testsuite/c-c++-common/Wmisleading-indentation.c
index 6363d71..443e3dd 100644
--- a/gcc/testsuite/c-c++-common/Wmisleading-indentation.c
+++ b/gcc/testsuite/c-c++-common/Wmisleading-indentation.c
@@ -653,3 +653,41 @@ v

Re: Fix two more memory leaks in threader

2015-05-20 Thread Jakub Jelinek
On Wed, May 20, 2015 at 10:36:25AM -0600, Jeff Law wrote:
> 
> These fix the remaining leaks in the threader that I'm aware of.  We failed
> to properly clean-up when we had to cancel certain jump threading
> opportunities.  So thankfully this wasn't a big leak.
> 
> Bootstrapped and regression tested on x86_64-unknown-linux-gnu. Installed on
> the trunk.
> 
> Jeff

> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index fe4dfc4..27435c6 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,3 +1,9 @@
> +2015-05-20  Jeff Law  
> +
> + * tree-ssa-threadupdate.c (mark_threaded_blocks): Properly
> + dispose of the jump thread path when the jump threading
> + opportunity is cancelled.
> +
>  2015-05-20  Manuel López-Ibáñez  
>  
>   * diagnostic.c (diagnostic_print_caret_line): Fix off-by-one error
> diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
> index c5b78a4..4bccad0 100644
> --- a/gcc/tree-ssa-threadupdate.c
> +++ b/gcc/tree-ssa-threadupdate.c
> @@ -2159,9 +2159,16 @@ mark_threaded_blocks (bitmap threaded_blocks)
>  {
> /* Attach the path to the starting edge if none is yet recorded.  */
>if ((*path)[0]->e->aux == NULL)
> -(*path)[0]->e->aux = path;
> -   else if (dump_file && (dump_flags & TDF_DETAILS))
> - dump_jump_thread_path (dump_file, *path, false);
> + {
> +  (*path)[0]->e->aux = path;
> + }

Why the braces around single stmt if body?
Also, the indentation seems to be weird.

Jakub


Fix two more memory leaks in threader

2015-05-20 Thread Jeff Law


These fix the remaining leaks in the threader that I'm aware of.  We 
failed to properly clean-up when we had to cancel certain jump threading 
opportunities.  So thankfully this wasn't a big leak.


Bootstrapped and regression tested on x86_64-unknown-linux-gnu. 
Installed on the trunk.


Jeff
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fe4dfc4..27435c6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-05-20  Jeff Law  
+
+   * tree-ssa-threadupdate.c (mark_threaded_blocks): Properly
+   dispose of the jump thread path when the jump threading
+   opportunity is cancelled.
+
 2015-05-20  Manuel López-Ibáñez  
 
* diagnostic.c (diagnostic_print_caret_line): Fix off-by-one error
diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
index c5b78a4..4bccad0 100644
--- a/gcc/tree-ssa-threadupdate.c
+++ b/gcc/tree-ssa-threadupdate.c
@@ -2159,9 +2159,16 @@ mark_threaded_blocks (bitmap threaded_blocks)
 {
  /* Attach the path to the starting edge if none is yet recorded.  */
   if ((*path)[0]->e->aux == NULL)
-(*path)[0]->e->aux = path;
- else if (dump_file && (dump_flags & TDF_DETAILS))
-   dump_jump_thread_path (dump_file, *path, false);
+   {
+  (*path)[0]->e->aux = path;
+   }
+ else
+   {
+ paths.unordered_remove (i);
+ if (dump_file && (dump_flags & TDF_DETAILS))
+   dump_jump_thread_path (dump_file, *path, false);
+ delete_jump_thread_path (path);
+   }
 }
 }
   /* Second, look for paths that have any other jump thread attached to
@@ -2185,8 +2192,10 @@ mark_threaded_blocks (bitmap threaded_blocks)
  else
{
  e->aux = NULL;
+ paths.unordered_remove (i);
  if (dump_file && (dump_flags & TDF_DETAILS))
dump_jump_thread_path (dump_file, *path, false);
+ delete_jump_thread_path (path);
}
}
 }


Re: [PATCH] Fix PR target/65730

2015-05-20 Thread augustine.sterl...@gmail.com
On Tue, May 19, 2015 at 8:31 PM, Max Filippov  wrote:
> 2015-05-20  Max Filippov  
> gcc/
> * config/xtensa/xtensa.c (init_alignment_context): Replace MULT
> by BITS_PER_UNIT with ASHIFT by exact_log2 (BITS_PER_UNIT).

Approved, please apply.


Re: [PATCH v2 6/6] i386: Implement asm flag outputs

2015-05-20 Thread H. Peter Anvin
Well, these kinds of asm are inherently target specific, but I did already ask 
for a cpp symbol to indicate this faculty us available.

On May 20, 2015 9:21:07 AM PDT, Jeff Law  wrote:
>On 05/15/2015 09:37 AM, Richard Henderson wrote:
>> Version 2 includes proper test cases and documentation.
>> Hopefully the documentation even makes sense.  Suggestions
>> and improvements there gratefully appreciated.
>>
>>
>> r~
>> ---
>>   gcc/config/i386/constraints.md |   5 ++
>>   gcc/config/i386/i386.c | 137
>+++--
>>   gcc/doc/extend.texi|  76 
>>   gcc/testsuite/gcc.target/i386/asm-flag-0.c |  15 
>>   gcc/testsuite/gcc.target/i386/asm-flag-1.c |  18 
>>   gcc/testsuite/gcc.target/i386/asm-flag-2.c |  16 
>>   gcc/testsuite/gcc.target/i386/asm-flag-3.c |  22 +
>>   gcc/testsuite/gcc.target/i386/asm-flag-4.c |  20 +
>>   gcc/testsuite/gcc.target/i386/asm-flag-5.c |  19 
>>   9 files changed, 321 insertions(+), 7 deletions(-)
>>   create mode 100644 gcc/testsuite/gcc.target/i386/asm-flag-0.c
>>   create mode 100644 gcc/testsuite/gcc.target/i386/asm-flag-1.c
>>   create mode 100644 gcc/testsuite/gcc.target/i386/asm-flag-2.c
>>   create mode 100644 gcc/testsuite/gcc.target/i386/asm-flag-3.c
>>   create mode 100644 gcc/testsuite/gcc.target/i386/asm-flag-4.c
>>   create mode 100644 gcc/testsuite/gcc.target/i386/asm-flag-5.c
>It all seems to make sense.  Obviously you'll need a ChangeLog and the 
>usual testing before committing.
>
>I won't stress much if this needs a bit of further tweaking as the 
>kernel folks start to exploit the capability and we find weaknesses in 
>the implementation.
>
>What I don't see is any way to know if the target supports asm flag 
>outputs.  Are we expecting the kernel folks to do some kind of test
>then 
>enable/disable based on the result?
>
>I'm going to assume the mapping of the constraints to the actual modes 
>and codes is correct.
>
>
>Jeff

-- 
Sent from my mobile phone.  Please pardon brevity and lack of formatting.


Re: [PATCH v2 6/6] i386: Implement asm flag outputs

2015-05-20 Thread Jeff Law

On 05/15/2015 09:37 AM, Richard Henderson wrote:

Version 2 includes proper test cases and documentation.
Hopefully the documentation even makes sense.  Suggestions
and improvements there gratefully appreciated.


r~
---
  gcc/config/i386/constraints.md |   5 ++
  gcc/config/i386/i386.c | 137 +++--
  gcc/doc/extend.texi|  76 
  gcc/testsuite/gcc.target/i386/asm-flag-0.c |  15 
  gcc/testsuite/gcc.target/i386/asm-flag-1.c |  18 
  gcc/testsuite/gcc.target/i386/asm-flag-2.c |  16 
  gcc/testsuite/gcc.target/i386/asm-flag-3.c |  22 +
  gcc/testsuite/gcc.target/i386/asm-flag-4.c |  20 +
  gcc/testsuite/gcc.target/i386/asm-flag-5.c |  19 
  9 files changed, 321 insertions(+), 7 deletions(-)
  create mode 100644 gcc/testsuite/gcc.target/i386/asm-flag-0.c
  create mode 100644 gcc/testsuite/gcc.target/i386/asm-flag-1.c
  create mode 100644 gcc/testsuite/gcc.target/i386/asm-flag-2.c
  create mode 100644 gcc/testsuite/gcc.target/i386/asm-flag-3.c
  create mode 100644 gcc/testsuite/gcc.target/i386/asm-flag-4.c
  create mode 100644 gcc/testsuite/gcc.target/i386/asm-flag-5.c
It all seems to make sense.  Obviously you'll need a ChangeLog and the 
usual testing before committing.


I won't stress much if this needs a bit of further tweaking as the 
kernel folks start to exploit the capability and we find weaknesses in 
the implementation.


What I don't see is any way to know if the target supports asm flag 
outputs.  Are we expecting the kernel folks to do some kind of test then 
enable/disable based on the result?


I'm going to assume the mapping of the constraints to the actual modes 
and codes is correct.



Jeff




Re: [PR c/52952] More precise locations within format strings

2015-05-20 Thread Jeff Law

On 05/20/2015 10:08 AM, Manuel López-Ibáñez wrote:



I don't particularly like file scoped "offset_is_invalid" variable.  It
appears that it's only set within check_format_arg, but it's used from a
variety of other locations via location_from_offset.  Given the current
structure of the code, alternatives would be even uglier.


This comes from the previous version of the patch, but it is not
necessary anymore, since before using an offset, we try to read the
string at the location, and if there is no string, the offset is zero.

Ah, well, if it isn't needed, then let's kill it :-)



The variable is set here:

if (TREE_CODE (format_tree) == VAR_DECL
 && TREE_CODE (TREE_TYPE (format_tree)) == ARRAY_TYPE
 && (array_init = decl_constant_value (format_tree)) != format_tree
 && TREE_CODE (array_init) == STRING_CST)
   {
 /* Extract the string constant initializer.  Note that this may include
a trailing NUL character that is not in the array (e.g.
const char a[3] = "foo";).  */
 array_size = DECL_SIZE_UNIT (format_tree);
 format_tree = array_init;
 offset_is_invalid = true;
   }

to handle this case:

void foo()
{
   const char a[] = " %d ";
   __builtin_printf(a, 0.5);
}

in such a case, the location we get is the one of the use of 'a', thus
we cannot get at the actual string " %d " to find an offset. Thus, it
preserves the current (not ideal) behavior.

OK with offset_is_invalid removed after regtesting?

Yes.

jeff



Re: [PR c/52952] More precise locations within format strings

2015-05-20 Thread Manuel López-Ibáñez
On 20 May 2015 at 15:33, Jeff Law  wrote:
> So if I'm understanding the situation correctly, with this new version
> behaviour for non-concatenated tokens is preserved which was the only
> behaviour regression in the prior patch, right?

The new version will also handle most escape sequences correctly and
simply preserve the current location for those that are not handled.

> Thus, this version of the patch is strictly an improvement (points to the
> issue within the format string rather than to the start of the string).
> Right?

I hope so :)

> I don't particularly like file scoped "offset_is_invalid" variable.  It
> appears that it's only set within check_format_arg, but it's used from a
> variety of other locations via location_from_offset.  Given the current
> structure of the code, alternatives would be even uglier.

This comes from the previous version of the patch, but it is not
necessary anymore, since before using an offset, we try to read the
string at the location, and if there is no string, the offset is zero.

The variable is set here:

if (TREE_CODE (format_tree) == VAR_DECL
&& TREE_CODE (TREE_TYPE (format_tree)) == ARRAY_TYPE
&& (array_init = decl_constant_value (format_tree)) != format_tree
&& TREE_CODE (array_init) == STRING_CST)
  {
/* Extract the string constant initializer.  Note that this may include
   a trailing NUL character that is not in the array (e.g.
   const char a[3] = "foo";).  */
array_size = DECL_SIZE_UNIT (format_tree);
format_tree = array_init;
offset_is_invalid = true;
  }

to handle this case:

void foo()
{
  const char a[] = " %d ";
  __builtin_printf(a, 0.5);
}

in such a case, the location we get is the one of the use of 'a', thus
we cannot get at the actual string " %d " to find an offset. Thus, it
preserves the current (not ideal) behavior.

OK with offset_is_invalid removed after regtesting?

Cheers,

Manuel.


Re: [PATCH] 65479 - sanitizer stack trace missing frames past #0 on powerpc64

2015-05-20 Thread Jeff Law

On 04/20/2015 04:32 PM, Martin Sebor wrote:

I also wonder if other targets need -fasynchronous-unwind-tables and
whether or not we should just add it unconditionally.


I initially only tested powerpc64* and x86_64. I had tried s370
but asan doesn't appear to be built there (is it not supported?)
I've now also tried aarch64 (partly because the patch also fixes
a latent bug there). Of these targets, only powerpc64* needs
the option, and only until the fast unwinding that Jakub
mentioned is implemented. I plan to work on it but I wanted to
get this simpler fix in first if only so there is a working
baseline to start from.

Sorry for the deep context switch

asan is only supported on a few platforms and I'm pretty sure s390 isn't 
one of them.


Now that I know a bit more from Jakub & Yuri's comments, I don't think 
we should be turning that flag on for all the targets in the testsuite. 
 I was primarily trying to avoid someone else having to go through the 
same analysis and reach the same conclusion for another port.  But I'm 
less concerned about that now.


I totally understand the desire to have a good baseline.  Jakub seems to 
prefer not to make this change since it's a short-lived workaround, 
which I understand as well.


My inclination is to go ahead with flags changes in the testsuite. 
Cleaner results are, in and of themselves, a good thing.  Pulling those 
lines out once the port is using the fast unwind stuff is easy enough to do.




Is libsanitizer maintained in LLVM?  If so, we want to minimize
divergence, so it may be better to get this approved in LLVM then pick
it up via a merge.


I can certainly see about submitting the sanitizer bits of
the patch to LLVM. It will probably take some time and I
was hoping for cleaner powerpc test results in 5.0 (or 5.1
as it sounds like the release will be called). I don't yet
have a sense of whether it's preferable to do one or the
other or whether it makes sense to do both (i.e., commit
the fix now and then merge).
This part should definitely hit the LLVM side first, then we can pull it 
into GCC.  So that process should be started.





Given this hits 3 distinct pieces of code, do any of them make sense in
isolation or do they have to land together as a unit?


65479 (this bug) depends on 65749 (sanitizer stack trace
pc off by 1). The asan tests cannot very well be made to
pass without fixing the latter bug.

Let me know how you'd like to proceed with the patch.

That's part of what I was trying to figure out myself :-)

So I'll ask the question(s) in a slightly different way and see if that 
guides us one direction or another.


Do the libbacktrace changes make sense independently?  ie, are they the 
right thing to do, even if they don't fix a visible bug?  ISTM the 
answer to both questions is yes.  In which case, that part ought to go 
forward now rather than waiting.


The testsuite changes have two components.  One is the new flag the 
other is some slight tweaks to the expected output.  I'd hazard a guess 
that the expected output changes ought to go forward independently too. 
 Again under the same "it's the right thing to do, even if it doesn't 
fix a visible bug".


The testsuite flags change isn't as clear cut.  I'd think they'd need to 
visibly improve the test results before they could go in.  So they may 
need to wait (I'm assuming nothing actually shows visible improvement 
without the libsanitizer fixes).


Thoughts?

jeff


[obvious fix] fix off-by-one error when printing the caret character

2015-05-20 Thread Manuel López-Ibáñez
It seems I made an off-by-one error in my last patch for multiple
locations. This only affected the position of the caret character,
which we don't test (since the testsuite uses
-fno-diagnostics-show-caret). Fixed thusly and added a comment to
remind me and others that locations start at 1, but we still want to
start at 0 (but not start at 0 and add an extra space like I did
before).

Cheers,

Manuel.

Index: ChangeLog
===
--- ChangeLog   (revision 223445)
+++ ChangeLog   (working copy)
@@ -1,3 +1,8 @@
+2015-05-20  Manuel López-Ibáñez  
+
+   * diagnostic.c (diagnostic_print_caret_line): Fix off-by-one error
+   when printing the caret character.
+
 2015-05-20  Marek Polacek  

* cfgexpand.c (expand_debug_expr): Use UNARY_CLASS_P.
Index: diagnostic.c
===
--- diagnostic.c(revision 223445)
+++ diagnostic.c(working copy)
@@ -420,7 +420,8 @@
   int caret_min = cmin == xloc1.column ? caret1 : caret2;
   int caret_max = cmin == xloc1.column ? caret2 : caret1;

-  pp_space (context->printer);
+  /* cmin is >= 1, but we indent with an extra space at the start like
+ we did above.  */
   int i;
   for (i = 0; i < cmin; i++)
 pp_space (context->printer);


Re: [PATCH 3/4] split-stack for powerpc64

2015-05-20 Thread Lynn A. Boger

Anytime go code built with gccgo is linked against libraries
built with gcc (without split stack) there could be mixing of split stack
 and non split stack code.  I think that will be a common case.
My understanding is that if you don't use the gold linker in these
cases, it is possible that the app could fail and it won't be clear why.

Maybe the gold linker isn't required to make it work for most cases,
but it will fail for some cases without it.

On 05/20/2015 07:58 AM, David Edelsohn wrote:

On Wed, May 20, 2015 at 8:13 AM, Lynn A. Boger
 wrote:


On 05/19/2015 07:52 PM, Alan Modra wrote:

On Tue, May 19, 2015 at 07:40:15AM -0500, Lynn A. Boger wrote:

Questions on the use of the options for split stack:

- The way this is implemented, split stack is generated if the
target platform supports split stack, on ppc64/ppc64le as well
as on x86, and the use of -fno-split-stack doesn't seem to affect it
for any of these.  Is that the way it should work?  I would expect
-fno-split-stack to disable it completely.

Can you give a testcase to show what you mean?  Picking one of the go
testsuite programs at random, I see
$ gcc/xgcc -Bgcc/ -S -I powerpc64le-linux/libgo
/src/gcc-virgin/gcc/testsuite/go.test/test/args.go
$ grep morestack args.s
 bl __morestack
 bl __morestack
$ gcc/xgcc -Bgcc/ -fno-split-stack -S -I powerpc64le-linux/libgo
/src/gcc-virgin/gcc/testsuite/go.test/test/args.go
$ grep morestack args.s
$
That shows -fno-split-stack being honoured.

You are correct.  I made some mistake in my testing.

- The comments say that the gold linker is used for some
situations but I don't see any reference in the code to enabling
the gold linker for ppc64le, ppc64, or x86.  Is the user expected
   to add the option for the gold linker if needed?

At the moment I believe this is true.


I have been trying to use the gold linker with your patch and seems to work
fine.  I added the following to
the STACK_SPLIT_SPEC in gcc/gcc.c to enable the gold linker if -fsplit-stack
is set, but that will cause problems
  on systems where the gold linker (and the correct level of binutils for
Power) is not available.  Is this an
absolute requirement to use split stack?  Could the configure determine if
gold is available and
generate this one way or another?

--- gcc.c   (revision 223217)
+++ gcc.c   (working copy)
@@ -541,7 +541,8 @@ proper position among the other output files.  */
 libgcc.  This is not yet a real spec, though it could become one;
 it is currently just stuffed into LINK_SPEC.  FIXME: This wrapping
 only works with GNU ld and gold.  */
-#define STACK_SPLIT_SPEC " %{fsplit-stack: --wrap=pthread_create}"
+#define STACK_SPLIT_SPEC \
+  " %{fsplit-stack: --wrap=pthread_create -fuse-ld=gold}"

  #ifndef LIBASAN_SPEC
  #define STATIC_LIBASAN_LIBS \

Lynn,

split-stack does not require Gold linker.  This is a non-starter.

Gold is necessary for some corner cases of mixing split-stack and
non-split-stack modules.

- David







Re: [PATCH] -Wmisleading-indentation: Increase test coverage

2015-05-20 Thread Jeff Law

On 05/20/2015 09:43 AM, David Malcolm wrote:

Add various new tests to Wmisleading-indentation.c:

   * Ensure that users can use pragma to turn off
 -Wmisleading-indentation for a range of code.

   * Add functions demonstrating a variety of indentation styles
 seen:

   (a) on http://en.wikipedia.org/wiki/Indent_style

   (b) via the manpage of GNU "indent"

 to verify that -Wmisleading-indentation doesn't emit false
 positives for these.

Tested with:

   make check-gcc RUNTESTFLAGS="-v -v dg.exp=Wmisleading-indentation.c"
   # of expected passes 42

   make check-g++ RUNTESTFLAGS="-v -v dg.exp=Wmisleading-indentation.c"
   # of expected passes 126

In both cases, the # of expected passes remained unchanged, and no new
fails were reported.

OK for trunk?

gcc/testsuite/ChangeLog:
* c-c++-common/Wmisleading-indentation.c (fn_32): New.
(fn_33_k_and_r_style): New.
(fn_33_stroustrup_style): New.
(fn_33_allman_style): New.
(fn_33_whitesmiths_style): New.
(fn_33_horstmann_style): New.
(fn_33_ratliff_banner_style): New.
(fn_33_lisp_style): New.
(fn_34_indent_dash_gnu): New.
(fn_34_indent_dash_kr): New.
(fn_34_indent_dash_orig): New.
(fn_34_indent_linux_style): New.

OK.
jeff



[PATCH] -Wmisleading-indentation: Increase test coverage

2015-05-20 Thread David Malcolm
Add various new tests to Wmisleading-indentation.c:

  * Ensure that users can use pragma to turn off
-Wmisleading-indentation for a range of code.

  * Add functions demonstrating a variety of indentation styles
seen:

  (a) on http://en.wikipedia.org/wiki/Indent_style

  (b) via the manpage of GNU "indent"

to verify that -Wmisleading-indentation doesn't emit false
positives for these.

Tested with:

  make check-gcc RUNTESTFLAGS="-v -v dg.exp=Wmisleading-indentation.c"
  # of expected passes 42

  make check-g++ RUNTESTFLAGS="-v -v dg.exp=Wmisleading-indentation.c"
  # of expected passes  126

In both cases, the # of expected passes remained unchanged, and no new
fails were reported.

OK for trunk?

gcc/testsuite/ChangeLog:
* c-c++-common/Wmisleading-indentation.c (fn_32): New.
(fn_33_k_and_r_style): New.
(fn_33_stroustrup_style): New.
(fn_33_allman_style): New.
(fn_33_whitesmiths_style): New.
(fn_33_horstmann_style): New.
(fn_33_ratliff_banner_style): New.
(fn_33_lisp_style): New.
(fn_34_indent_dash_gnu): New.
(fn_34_indent_dash_kr): New.
(fn_34_indent_dash_orig): New.
(fn_34_indent_linux_style): New.
---
 .../c-c++-common/Wmisleading-indentation.c | 224 +
 1 file changed, 224 insertions(+)

diff --git a/gcc/testsuite/c-c++-common/Wmisleading-indentation.c 
b/gcc/testsuite/c-c++-common/Wmisleading-indentation.c
index 3dbbb8b..6363d71 100644
--- a/gcc/testsuite/c-c++-common/Wmisleading-indentation.c
+++ b/gcc/testsuite/c-c++-common/Wmisleading-indentation.c
@@ -429,3 +429,227 @@ void fn_31 (void)
   else
 foo (3);
 }
+
+/* Ensure that we can disable the warning.  */
+int
+fn_32 (int flag)
+{
+  int x = 4, y = 5;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmisleading-indentation"
+  if (flag)
+x = 3;
+y = 2;
+#pragma GCC diagnostic pop
+
+  return x * y;
+}
+
+/* Verify that a variety of different indentation styles are supported
+   without leading to warnings.  */
+void
+fn_33_k_and_r_style (void)
+{
+  int i;
+  for (i = 0; i < 10; i++) {
+if (flagB) {
+  foo(0);
+  foo(1);
+} else {
+  foo(2);
+  foo(3);
+}
+foo(4);
+  }
+}
+
+void
+fn_33_stroustrup_style (void)
+{
+  int i;
+  for (i = 0; i < 10; i++) {
+if (flagA) {
+  foo(0);
+  foo(1);
+}
+else {
+  foo(2);
+  foo(3);
+}
+foo(4);
+  }
+}
+
+void
+fn_33_allman_style (void)
+{
+  int i;
+  for (i = 0; i < 10; i++)
+  {
+if (flagA)
+{
+  foo(0);
+  foo(1);
+}
+else
+{
+  foo(2);
+  foo(3);
+}
+foo(4);
+  }
+}
+
+void
+fn_33_whitesmiths_style (void)
+{
+int i;
+for (i = 0; i < 10; i++)
+{
+if (flagA)
+{
+foo(0);
+foo(1);
+}
+else
+{
+foo(2);
+foo(3);
+}
+foo(4);
+}
+}
+
+void
+fn_33_horstmann_style (void)
+{
+int i;
+for (i = 0; i < 10; i++)
+{   if (flagA)
+{   foo(0);
+foo(1);
+}
+else
+{   foo(2);
+foo(3);
+}
+foo(4);
+}
+}
+
+void
+fn_33_ratliff_banner_style (void)
+{
+int i;
+for (i = 0; i < 10; i++) {
+   if (flagA) {
+   foo(0);
+   foo(1);
+   }
+   else {
+foo(2);
+foo(3);
+}
+   foo(4);
+   }
+}
+
+void
+fn_33_lisp_style (void)
+{
+  int i;
+  for (i = 0; i < 10; i++) {
+if (flagA) {
+foo(0);
+foo(1); }
+else {
+foo(2);
+foo(3); }
+foo(4); }
+}
+
+/* A function run through GNU "indent" with various options.
+   None of these should lead to warnings.  */
+
+/* "indent -gnu".  */
+void
+fn_34_indent_dash_gnu (void)
+{
+  int i;
+  while (flagA)
+for (i = 0; i < 10; i++)
+  {
+   if (flagB)
+ {
+   foo (0);
+   foo (1);
+ }
+   else
+ {
+   foo (2);
+   foo (3);
+ }
+   foo (4);
+  }
+  foo (5);
+}
+
+/* "indent -kr".  */
+void fn_34_indent_dash_kr(void)
+{
+int i;
+while (flagA)
+   for (i = 0; i < 10; i++) {
+   if (flagB) {
+   foo(0);
+   foo(1);
+   } else {
+   foo(2);
+   foo(3);
+   }
+   foo(4);
+   }
+foo(5);
+}
+
+/* "indent -orig".  */
+void
+fn_34_indent_dash_orig(void)
+{
+int i;
+while (flagA)
+   for (i = 0; i < 10; i++) {
+   if (flagB) {
+   foo(0);
+   foo(1);
+   } else {
+   foo(2);
+   foo(3);
+   }
+   foo(4);
+   }
+foo(5);
+}
+
+/* Linux style:
+   "indent \
+  -nbad -bap -nbc -bbo -hnl -br -brs -c33 -cd33 -ncdb -ce -ci4  \
+  -cli0 -d0 -di1 -nfc1 -i8 -ip0 -l80 -lp -npc

Re: [C++17] Implement N3928 - Extending static_assert

2015-05-20 Thread Jason Merrill

On 05/02/2015 04:16 PM, Ed Smith-Rowland wrote:

This extends' static assert to not require a message string.
I elected to make this work also for C++11 and C++14 and warn only with
-pedantic.
I think many people just write
   static_assert(thing, "");
.

I took the path of building an empty string in the parser in this case.
I wasn't sure if setting message to NULL_TREE would cause sadness later
on or not.


Hmm.  Yes, this technically implements the feature, but my impression of 
the (non-normative) intent was that they wanted leaving out the string 
to print the argument expression, in about the same way as


#define BOOST_STATIC_ASSERT( B ) static_assert(B, #B)

So the patch is OK as is, but you might also look into some libcpp magic 
to insert a second argument that stringizes the first.


Jason



Re: [Patch, fortran, pr65548, 2nd take, v5] [5/6 Regression] gfc_conv_procedure_call

2015-05-20 Thread Andre Vehreschild
Hi all,

Mikael, thanks for the review. Committed as r223445 (without the else-branch).

Regards,
Andre
-- 
Andre Vehreschild * Email: vehre ad gmx dot de 
Index: gcc/fortran/ChangeLog
===
--- gcc/fortran/ChangeLog	(Revision 223444)
+++ gcc/fortran/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,13 @@
+2015-05-20  Andre Vehreschild  
+
+	PR fortran/65548
+	* trans-stmt.c (gfc_trans_allocate): Always retrieve the
+	descriptor or a reference to a source= expression for
+	arrays and non-arrays, respectively.  Use a temporary
+	symbol and gfc_trans_assignment for all source=
+	assignments to allocated objects besides for class and
+	derived types.
+
 2015-05-19  Jakub Jelinek  
 
 	PR middle-end/66199
Index: gcc/fortran/trans-stmt.c
===
--- gcc/fortran/trans-stmt.c	(Revision 223444)
+++ gcc/fortran/trans-stmt.c	(Arbeitskopie)
@@ -5088,7 +5088,7 @@
 gfc_trans_allocate (gfc_code * code)
 {
   gfc_alloc *al;
-  gfc_expr *expr;
+  gfc_expr *expr, *e3rhs = NULL;
   gfc_se se, se_sz;
   tree tmp;
   tree parm;
@@ -5109,6 +5109,7 @@
   stmtblock_t post;
   tree nelems;
   bool upoly_expr, tmp_expr3_len_flag = false, al_len_needs_set;
+  gfc_symtree *newsym = NULL;
 
   if (!code->ext.alloc.list)
 return NULL_TREE;
@@ -5148,14 +5149,11 @@
   TREE_USED (label_finish) = 0;
 }
 
-  /* When an expr3 is present, try to evaluate it only once.  In most
- cases expr3 is invariant for all elements of the allocation list.
- Only exceptions are arrays.  Furthermore the standards prevent a
- dependency of expr3 on the objects in the allocate list.  Therefore
- it is safe to pre-evaluate expr3 for complicated expressions, i.e.
- everything not a variable or constant.  When an array allocation
- is wanted, then the following block nevertheless evaluates the
- _vptr, _len and element_size for expr3.  */
+  /* When an expr3 is present evaluate it only once.  The standards prevent a
+ dependency of expr3 on the objects in the allocate list.  An expr3 can
+ be pre-evaluated in all cases.  One just has to make sure, to use the
+ correct way, i.e., to get the descriptor or to get a reference
+ expression.  */
   if (code->expr3)
 {
   bool vtab_needed = false;
@@ -5168,75 +5166,77 @@
 	   al = al->next)
 	vtab_needed = (al->expr->ts.type == BT_CLASS);
 
-  /* A array expr3 needs the scalarizer, therefore do not process it
-	 here.  */
-  if (code->expr3->expr_type != EXPR_ARRAY
-	  && (code->expr3->rank == 0
-	  || code->expr3->expr_type == EXPR_FUNCTION)
-	  && (!code->expr3->symtree
-	  || !code->expr3->symtree->n.sym->as)
-	  && !gfc_is_class_array_ref (code->expr3, NULL))
+  /* When expr3 is a variable, i.e., a very simple expression,
+	 then convert it once here.  */
+  if (code->expr3->expr_type == EXPR_VARIABLE
+	  || code->expr3->expr_type == EXPR_ARRAY
+	  || code->expr3->expr_type == EXPR_CONSTANT)
 	{
-	  /* When expr3 is a variable, i.e., a very simple expression,
-	 then convert it once here.  */
-	  if ((code->expr3->expr_type == EXPR_VARIABLE)
-	  || code->expr3->expr_type == EXPR_CONSTANT)
+	  if (!code->expr3->mold
+	  || code->expr3->ts.type == BT_CHARACTER
+	  || vtab_needed)
 	{
-	  if (!code->expr3->mold
-		  || code->expr3->ts.type == BT_CHARACTER
-		  || vtab_needed)
-		{
-		  /* Convert expr3 to a tree.  */
-		  gfc_init_se (&se, NULL);
-		  se.want_pointer = 1;
-		  gfc_conv_expr (&se, code->expr3);
-		  if (!code->expr3->mold)
-		expr3 = se.expr;
-		  else
-		expr3_tmp = se.expr;
-		  expr3_len = se.string_length;
-		  gfc_add_block_to_block (&block, &se.pre);
-		  gfc_add_block_to_block (&post, &se.post);
-		}
-	  /* else expr3 = NULL_TREE set above.  */
-	}
-	  else
-	{
-	  /* In all other cases evaluate the expr3 and create a
-		 temporary.  */
+	  /* Convert expr3 to a tree.  */
 	  gfc_init_se (&se, NULL);
-	  if (code->expr3->rank != 0
-		  && code->expr3->expr_type == EXPR_FUNCTION
-		  && code->expr3->value.function.isym)
+	  /* For all "simple" expression just get the descriptor or the
+		 reference, respectively, depending on the rank of the expr.  */
+	  if (code->expr3->rank != 0)
 		gfc_conv_expr_descriptor (&se, code->expr3);
 	  else
 		gfc_conv_expr_reference (&se, code->expr3);
-	  if (code->expr3->ts.type == BT_CLASS)
-		gfc_conv_class_to_class (&se, code->expr3,
-	 code->expr3->ts,
-	 false, true,
-	 false, false);
+	  if (!code->expr3->mold)
+		expr3 = se.expr;
+	  else
+		expr3_tmp = se.expr;
+	  expr3_len = se.string_length;
 	  gfc_add_block_to_block (&block, &se.pre);
 	  gfc_add_block_to_block (&post, &se.post);
-	  /* Prevent aliasing, i.e., se.expr may be already a
+	}
+	  /* else expr3 = NULL_TREE set above.  */
+	}
+  else
+	{
+	  /* In all other cases e

Re: [PATCH] Fix memory leak in C++ pretty printer

2015-05-20 Thread Jason Merrill

On 05/11/2015 02:01 PM, Jason Merrill wrote:

On 05/11/2015 12:57 PM, Jason Merrill wrote:

On 05/11/2015 08:03 AM, Manuel López-Ibáñez wrote:

My preference would be to replace the static with a pointer and
placement-new with proper new and delete


Actually, on second thought, there really doesn't seem to be a need for
that.  The patch should be OK; if it doesn't work I'd like to know why.
I think the existing pattern is just a holdover from the C days.


So go ahead and apply the patch.  If you would also make the similar fix 
to other front ends, that would be great, too.


Jason



Re: ODR merging and implicit typedefs

2015-05-20 Thread Jan Hubicka
> > I bootstrapped/regtested on x86_64-linux the patch bellow. If it will work
> > for Firefox and Chrome I will go ahead with it at least temporarily.
> 
> Really?  This introduced a LTO failure in the gnat.dg testsuite:
> 
> FAIL: gnat.dg/lto8.adb (internal compiler error)
> FAIL: gnat.dg/lto8.adb (test for excess errors)
> WARNING: gnat.dg/lto8.adb compilation failed to produce executable
> 
> lto1: internal compiler error: in odr_types_equivalent_p, at ipa-devirt.c:1276
> 0x86a263 odr_types_equivalent_p
>   /home/eric/svn/gcc/gcc/ipa-devirt.c:1276
> 0x86bf44 odr_types_equivalent_p(tree_node*, tree_node*)
>   /home/eric/svn/gcc/gcc/ipa-devirt.c:1718
> 0x5c563a warn_type_compatibility_p
>   /home/eric/svn/gcc/gcc/lto/lto-symtab.c:219

Hmm, ICE here means that we think the global symbols are defined by a type in 
anonymous
namespace.  We really need to solve the problem of reliably identifying these
https://gcc.gnu.org/ml/gcc-patches/2015-05/msg01245.html
It is not at all that hard to do it, we just need to decide on the 
representation.

I will take a look if I can improve type_in_anonymous_namepsace somehow.  So Ada
produces TYPE_DECL with DECL_ABSTRACT that do have TYPE_STUB_DECL with 
TREE_PUBLIC
NULL I suppose.

Honza

> 0x5c6103 lto_symtab_merge
>   /home/eric/svn/gcc/gcc/lto/lto-symtab.c:336
> 0x5c6103 lto_symtab_merge_decls_2
>   /home/eric/svn/gcc/gcc/lto/lto-symtab.c:520
> 0x5c6103 lto_symtab_merge_decls_1
>   /home/eric/svn/gcc/gcc/lto/lto-symtab.c:671
> 0x5c6103 lto_symtab_merge_decls()
>   /home/eric/svn/gcc/gcc/lto/lto-symtab.c:694
> 0x5bb9cc read_cgraph_and_symbols
>   /home/eric/svn/gcc/gcc/lto/lto.c:2891
> 0x5bb9cc lto_main()
>   /home/eric/svn/gcc/gcc/lto/lto.c:3277
> 
> -- 
> Eric Botcazou


Re: [patch,gomp4] error on invalid acc loop clauses

2015-05-20 Thread Jakub Jelinek
On Wed, May 20, 2015 at 07:17:35AM -0700, Cesar Philippidis wrote:
> > ..., and this: why not do such nesting checking in
> > gcc/omp-low.c:check_omp_nesting_restrictions?  Currently (changed by
> > Bernd in internal r442824, 2014-11-29) we're allowing all
> > OpenACC-inside-OpenACC nesting -- shouldn't that be changed instead of
> > repeating the checks in every front end (Jakub?)?
> 
> The fortran front end is doing this. Also, Joseph told me the front ends
> should report error messages when possible. I have no problems reverting
> back to the original behavior though.

For OpenMP/OpenACC, there is still lots of diagnostics emitted during
gimplification and at the start of the omp lowering phases, so for
diagnostics purposes you can consider them as part of a common layer for all
the 3 FEs.

Jakub


Re: [PATCH i386] Allow sibcalls in no-PLT PIC

2015-05-20 Thread Michael Matz
Hi,

On Wed, 20 May 2015, Rich Felker wrote:

> > of a win that often, outside toy examples.  Sure, the compiler can hoist 
> > function addresses trivially, but I think it will lead to spilling more 
> > often than not, or alternatively the hoisting will be undone by the 
> > register allocators rematerialization.  Of course, this would have to be 
> > measured for real not hand-waved, but, well, I'd be surprised if it's not 
> > so.
> 
> The obvious example where it's useful on x86_64 is a major class: 

Yes, I can construct all kinds of examples where it's useful.  That 
doesn't touch the topic of real-world cases or hard numbers actually 
comparing the number of hoisted callee addresses, the number that stay 
hoisted until after register allocation and the number of spills added by 
hoisting, on some relevant code base, like gcc itself, or SPEC.

> anything where the majority of the callee's data is floating point and 
> thus kept in xmm registers.

This code tends to work on multiple arrays in practice, and hence integer 
registers are required for all the addresses and offsets and loop 
counters.

> In that case register pressure is a lot lower,

Register pressure on x86 is never low :)  Yes, x86-64 and others are much 
better in this regard.

> and there's also an obvious class of cross-DSO functions calls you'd be 
> making over and over again: anything from libm.


Ciao,
Michael.


Re: [patch,gomp4] error on invalid acc loop clauses

2015-05-20 Thread Cesar Philippidis
On 05/20/2015 01:23 AM, Thomas Schwinge wrote:

>> I included two new test cases in this patch. They are mostly identical
>> but, unfortunately, the c and c++ front ends emit slightly different
>> error messages.
> 
> The preference is to keep these as single files (so that C and C++ can
> easily be maintained together), and use the appropriate dg-* directives
> to select the expected C or C++ error message, respectively, or use
> regular expressions so as to match both the expected C and C++ error
> variants in one go, if they're similar enough.
> 
>> The front ends still need to be cleaned before this functionality should
>> be considered for mainline. So for the time being I've applied this
>> patch to gomp-4_0-branch.
> 
> What remains to be done?

Jakub made some general comments a couple of weeks ago when you applied
our internal changes to gomp-4_0-branch. I was planning on addressing
those comments first before requesting the merge to trunk.

> Then, what about the Fortran front end?  Checking already done as well as
> test coverage existing, similar to C and C++?

Fortran is good.

> Patch review comments:
> 
>> --- a/gcc/c/c-parser.c
>> +++ b/gcc/c/c-parser.c
>> @@ -234,6 +234,10 @@ typedef struct GTY(()) c_parser {
>>/* True if we are in a context where the Objective-C "Property attribute"
>>   keywords are valid.  */
>>BOOL_BITFIELD objc_property_attr_context : 1;
>> +  /* True if we are inside a OpenACC parallel region.  */
>> +  BOOL_BITFIELD oacc_parallel_region : 1;
>> +  /* True if we are inside a OpenACC kernels region.  */
>> +  BOOL_BITFIELD oacc_kernels_region : 1;
> 
> Hmm.

What's wrong with this? Fortran does something similar. Besides, this is
only temporary until OpenACC 2.5.

>> @@ -10839,6 +10843,7 @@ c_parser_oacc_shape_clause (c_parser *parser, 
>> pragma_omp_clause c_kind,
>>mark_exp_read (expr);
>>require_positive_expr (expr, expr_loc, str);
>>*op_to_parse = expr;
>> +  op_to_parse = &op0;
>>  }
>>while (!c_parser_next_token_is (parser, CPP_CLOSE_PAREN));
>>c_parser_consume_token (parser);
>> @@ -10852,6 +10857,17 @@ c_parser_oacc_shape_clause (c_parser *parser, 
>> pragma_omp_clause c_kind,
>>if (op1)
>>  OMP_CLAUSE_OPERAND (c, 1) = op1;
>>OMP_CLAUSE_CHAIN (c) = list;
>> +
>> +  if (parser->oacc_parallel_region && (op0 != NULL || op1 != NULL))
>> +{
>> +  if (c_kind != PRAGMA_OACC_CLAUSE_GANG)
>> +c_parser_error (parser, c_kind == PRAGMA_OACC_CLAUSE_WORKER ?
>> +"worker clause arguments are not supported in OpenACC 
>> parallel regions"
>> +: "vector clause arguments are not supported in OpenACC 
>> parallel regions");
>> +  else if (op0 != NULL)
>> +c_parser_error (parser, "non-static argument to clause gang");
>> +}
> 
> Instead of in c_parser_oacc_shape_clause, shouldn't such checking rather
> be done inside the function invoking c_parser_oacc_shape_clause, that is,
> c_parser_oacc_parallel, etc.?

I don't think that will help. c_parser_oacc_shape_clause parses 'gang',
'worker' and 'vector' which aren't available to acc parallel or acc
kernels. Well, they are, be rigged up the front end to split acc
parallel loops and acc kernels loop.

>> @@ -12774,6 +12820,13 @@ c_parser_oacc_kernels (location_t loc, c_parser 
>> *parser, char *p_name)
>>  
>>strcat (p_name, " kernels");
>>  
>> +  if (parser->oacc_parallel_region || parser->oacc_kernels_region)
>> +{
>> +  c_parser_error (parser, "nested kernels region");
>> +}
>> +
>> +  parser->oacc_kernels_region = true;
> 
> Regarding this...
> 
>> @@ -12843,6 +12898,13 @@ c_parser_oacc_parallel (location_t loc, c_parser 
>> *parser, char *p_name)
>>  
>>strcat (p_name, " parallel");
>>  
>> +  if (parser->oacc_parallel_region || parser->oacc_kernels_region)
>> +{
>> +  c_parser_error (parser, "nested parallel region");
>> +}
>> +
>> +  parser->oacc_parallel_region = true;
> 
> ..., and this: why not do such nesting checking in
> gcc/omp-low.c:check_omp_nesting_restrictions?  Currently (changed by
> Bernd in internal r442824, 2014-11-29) we're allowing all
> OpenACC-inside-OpenACC nesting -- shouldn't that be changed instead of
> repeating the checks in every front end (Jakub?)?

The fortran front end is doing this. Also, Joseph told me the front ends
should report error messages when possible. I have no problems reverting
back to the original behavior though.

> I see that some checking is also being done gcc/omp-low.c:scan_omp_for:
> »gang, worker and vector may occur only once in a loop nest«, and »gang,
> worker and vector must occur in this order in a loop nest«.  Don't know
> if that conceptually also belongs into
> gcc/omp-low.c:check_omp_nesting_restrictions?

Yeah, someone needs to clean that up. I tried to keep this patch local
to the c and c++ front ends.

>> --- a/gcc/testsuite/c-c++-common/goacc/nesting-fail-1.c
>> +++ b/gcc/testsuite/c-c++-common/goacc

Re: [PATCH i386] Allow sibcalls in no-PLT PIC

2015-05-20 Thread Rich Felker
On Wed, May 20, 2015 at 02:10:41PM +0200, Michael Matz wrote:
> Hi,
> 
> On Tue, 19 May 2015, Richard Henderson wrote:
> 
> > It is.  The relaxation that HJ is working on requires that the reads 
> > from the got not be hoisted.  I'm not especially convinced that what 
> > he's working on is a win.
> > 
> > With LTO, the compiler can do the same job that he's attempting in the 
> > linker, without an extra nop.  Without LTO, leaving it to the linker 
> > means that you can't hoist the load and hide the memory latency.
> 
> Well, hoisting always needs a register, and if hoisted out of a loop 
> (which you all seem to be after) that register is live through the whole 
> loop body.  You need a register for each different called function in such 
> loop, trading the one GOT pointer with N other registers.  For 
> register-starved machines this is a real problem, even x86-64 doesn't have 
> that many.  I.e. I'm not convinced that this hoisting will really be much 
> of a win that often, outside toy examples.  Sure, the compiler can hoist 
> function addresses trivially, but I think it will lead to spilling more 
> often than not, or alternatively the hoisting will be undone by the 
> register allocators rematerialization.  Of course, this would have to be 
> measured for real not hand-waved, but, well, I'd be surprised if it's not 
> so.

The obvious example where it's useful on x86_64 is a major class:
anything where the majority of the callee's data is floating point and
thus kept in xmm registers. In that case register pressure is a lot
lower, and there's also an obvious class of cross-DSO functions calls
you'd be making over and over again: anything from libm.

Rich


[Patch AArch64] PR target/66200 - gcc / libstdc++ TLC for weak memory models.

2015-05-20 Thread Ramana Radhakrishnan

Hi,

	Someone privately pointed out that the ARM and AArch64 ports do not 
define TARGET_RELAXED_ORDERING given that the architecture(s) mandates a 
weak memory model. This patch fixes it for AArch64, the ARM patch 
follows in due course after appropriate testing.


I will also note that we can define __test_and_acquire as well as 
__set_and_release and I'm toying with a follow-up patch for the same.


Also it may make sense to consider changing the defaults to a safer 
form, or indeed forcing ports to define some of this rather than 
allowing for silent wrong code issues. However I'm not about to do so in 
the context of this patch.


Bootstrapped and regression tested on aarch64-none-linux-gnu with no 
regressions.


Ok to apply to trunk and all release branches ?

gcc/

PR target/66200

* config/aarch64/aarch64.c (TARGET_RELAXED_ORDERING): Define

libstdc++-v3/

PR target/66200

* configure.host (host_cpu): Add aarch64 case.
* config/cpu/aarch64/atomic_word.h: New file




regards
Ramana


P.S.  It's interesting to note that ia64 doesn't define the barriers 
which appear to be used in a number of other places than just the 
constructor guard functions (probably wrongly on the assumption that one 
doesn't need the barriers elsewhere). I suspect other architectures like 
MIPS may also be affected by this.
commit 414345c424fa020717c6c3083089cd987f3032db
Author: Ramana Radhakrishnan 
Date:   Wed May 20 13:55:44 2015 +0100

Add relaxed memory ordering cases.

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 7f0cc0d..273aa06 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -11644,6 +11644,9 @@ aarch64_gen_adjusted_ldpstp (rtx *operands, bool load,
 #undef TARGET_SCHED_FUSION_PRIORITY
 #define TARGET_SCHED_FUSION_PRIORITY aarch64_sched_fusion_priority
 
+#undef TARGET_RELAXED_ORDERING
+#define TARGET_RELAXED_ORDERING true
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-aarch64.h"
diff --git a/libstdc++-v3/config/cpu/aarch64/atomic_word.h 
b/libstdc++-v3/config/cpu/aarch64/atomic_word.h
new file mode 100644
index 000..4afe6ed
--- /dev/null
+++ b/libstdc++-v3/config/cpu/aarch64/atomic_word.h
@@ -0,0 +1,44 @@
+// Low-level type for atomic operations -*- C++ -*-
+
+// Copyright (C) 2015 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library 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.
+
+// This library 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.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// .
+
+/** @file atomic_word.h
+ *  This file is a GNU extension to the Standard C++ Library.
+ */
+
+#ifndef _GLIBCXX_ATOMIC_WORD_H
+#define _GLIBCXX_ATOMIC_WORD_H 1
+
+
+typedef int _Atomic_word;
+
+// This one prevents loads from being hoisted across the barrier;
+// in other words, this is a Load-Load acquire barrier.
+// This is necessary iff TARGET_RELAXED_ORDERING is defined in tm.h.
+#define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("dmb ishld":::"memory")
+
+// This one prevents stores from being sunk across the barrier; in other
+// words, a Store-Store release barrier.
+#define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("dmb ishst":::"memory")
+
+#endif
diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
index a349ce3..42a45d9 100644
--- a/libstdc++-v3/configure.host
+++ b/libstdc++-v3/configure.host
@@ -153,6 +153,9 @@ esac
 # Most can just use generic.
 # THIS TABLE IS SORTED.  KEEP IT THAT WAY.
 case "${host_cpu}" in
+  aarch64*)
+atomic_word_dir=cpu/aarch64
+;;
   alpha*)
 atomic_word_dir=cpu/alpha
 ;;


Re: [PATCH] Simple optimization for MASK_STORE.

2015-05-20 Thread Yuri Rumyantsev
Hi All,

Here is updated patch to optimize mask stores. The main goal of it is
to avoid execution of mask store if its mask is zero vector since
loads that follow it can be blocked.
The following changes were done:
  1.  A test on sink legality was added - it simply prohibits to cross
statements with non-null vdef or vuse.
  2. New phi node is created in join block for moved MASK_STORE statements.
  3. Test was changed to check that 2 MASK_STORE statements are not
moved to the same block.
  4. New field was added to loop_vec_info structure to mark loops
having MASK_STORE's.

Any comments will be appreciated.
Yuri.

2015-05-20  Yuri Rumyantsev  

* config/i386/i386.c: Include files stringpool.h and tree-ssanames.h.
(ix86_vectorize_is_zero_vector): New function.
(TARGET_VECTORIZE_IS_ZERO_VECTOR): New target macro
* doc/tm.texi.in: Add @hook TARGET_VECTORIZE_IS_ZERO_VECTOR.
* doc/tm.texi: Updated.
* target.def (is_zero_vector): New DEFHOOK.
* tree-vect-stmts.c : Include tree-into-ssa.h.
(vectorizable_mask_load_store): Initialize has_mask_store field.
(is_valid_sink): New function.
(optimize_mask_stores): New function.
* tree-vectorizer.c (vectorize_loops): Invoke optimaze_mask_stores for
loops having masked stores.
* tree-vectorizer.h (loop_vec_info): Add new has_mask_store field and
correspondent macros.
(optimize_mask_stores): Update prototype.

gcc/testsuite/ChangeLog:
* gcc.target/i386/avx2-vect-mask-store-move1.c: New test.


patch.2
Description: Binary data


Re: [gomp4] New builtins, preparation for oacc vector-single

2015-05-20 Thread Bernd Schmidt

On 05/20/2015 02:39 PM, Jakub Jelinek wrote:

On Wed, May 20, 2015 at 02:01:44PM +0200, Bernd Schmidt wrote:

To implement OpenACC vector-single mode, we need to ensure that only one
thread out of the group representing a worker executes. The others skip
computations but follow along the CFG, so the results of conditional branch
decisions must be broadcast to them.

The patch below adds a new builtin and nvptx pattern to implement that
broadcast functionality.


So, is the goal of this that threads in the warp other than the 0th
don't do anything except in vectorized regions, where all the threads
in the warp participate in the vectorization?


Yes.


Thus, for OpenMP, should the whole warp be a single thread
(thus omp_get_thread_num () would be tid.x >> 5)?


Do you mean for an OMP port to nvptx? I haven't looked at OpenMP enough 
to say if or how it could be mapped to GPU hardware; it's not something 
we intend to do for this project.



Bernd



Re: [PATCH][tree-ssa-math-opts] Expand pow (x, CONST) using square roots when possible

2015-05-20 Thread Kyrill Tkachov


On 18/05/15 11:32, Richard Biener wrote:

On Wed, May 13, 2015 at 5:33 PM, Kyrill Tkachov
 wrote:

Hi Richard,

On 13/05/15 12:27, Richard Biener wrote:

I notice that we don't have a testuite check that the target has

a hw sqrt instructions. Would you like me to add one? Or can I make
the testcase aarch64-specific?

Would be great to have a testsuite check for this.


I've committed the patch with r223167.

The attached patch adds a testsuite check for hardware sqrt instructions.
In this version I've included arm (on the condition that vfp is possible),
aarch64, x86_64 and powerpc with vsx.
Is this definition ok?

I'm particularly not familiar with the powerpc architectures.

With this check in place, I've migrated the pow synthesis test from
gcc.target/aarch64 to gcc.dg.

This test passes on arm-none-eabi, aarch64-none-elf and x86_64-linux.

Ok?

Ok.


Thanks.
However, after some discussion on IRC I'd prefer to rename the testsuite check
to sqrt_insn so as not to give the impression that it is a runtime hardware 
check.

Also, this version adds an entry in sourcebuild.texi.

I'll commit this version in 24 hours unless someone objects.
Test still passes on arm, x86_64 and aarch64.

Cheers,
Kyrill

2015-05-20  Kyrylo Tkachov  

 * lib/target-supports.exp (check_effective_target_sqrt_insn): New check.
 * gcc.dg/pow-sqrt-synth-1.c: New test.
 * gcc.target/aarch64/pow-sqrt-synth-1.c: Delete.

2015-05-20  Kyrylo Tkachov  

* doc/sourcebuild.texi (7.2.3.9 Other hardware attributes):
Document sqrt_insn.


Thanks,
Richard.


2015-05-13  Kyrylo Tkachov  

 * lib/target-supports.exp (check_effective_target_hw_sqrt): New check.
 * gcc.dg/pow-sqrt-synth-1.c: New test.
 * gcc.target/aarch64/pow-sqrt-synth-1.c: Delete.


commit e35362535c9888daf00d1430e2d3a932d7ece228
Author: Kyrylo Tkachov 
Date:   Wed May 13 16:08:03 2015 +0100

Add testsuite check for hw sqrt. Add generic test for pow sqrt synthesis

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index c6ef40e..abe0779 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -1695,6 +1695,9 @@ Target supports FPU instructions.
 @item non_strict_align
 Target does not require strict alignment.
 
+@item sqrt_insn
+Target has a square root instruction that the compiler can generate.
+
 @item sse
 Target supports compiling @code{sse} instructions.
 
diff --git a/gcc/testsuite/gcc.dg/pow-sqrt-synth-1.c b/gcc/testsuite/gcc.dg/pow-sqrt-synth-1.c
new file mode 100644
index 000..d55b626
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pow-sqrt-synth-1.c
@@ -0,0 +1,38 @@
+/* { dg-do compile { target sqrt_insn } } */
+/* { dg-options "-fdump-tree-sincos -Ofast --param max-pow-sqrt-depth=8" } */
+/* { dg-additional-options "-mfloat-abi=softfp -mfpu=neon-vfpv4" { target arm*-*-* } } */
+
+double
+foo (double a)
+{
+  return __builtin_pow (a, -5.875);
+}
+
+double
+foof (double a)
+{
+  return __builtin_pow (a, 0.75f);
+}
+
+double
+bar (double a)
+{
+  return __builtin_pow (a, 1.0 + 0.00390625);
+}
+
+double
+baz (double a)
+{
+  return __builtin_pow (a, -1.25) + __builtin_pow (a, 5.75) - __builtin_pow (a, 3.375);
+}
+
+#define N 256
+void
+vecfoo (double *a)
+{
+  for (int i = 0; i < N; i++)
+a[i] = __builtin_pow (a[i], 1.25);
+}
+
+/* { dg-final { scan-tree-dump-times "synthesizing" 7 "sincos" } } */
+/* { dg-final { cleanup-tree-dump "sincos" } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/pow-sqrt-synth-1.c b/gcc/testsuite/gcc.target/aarch64/pow-sqrt-synth-1.c
deleted file mode 100644
index 52514fb..000
--- a/gcc/testsuite/gcc.target/aarch64/pow-sqrt-synth-1.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-fdump-tree-sincos -Ofast --param max-pow-sqrt-depth=8" } */
-
-
-double
-foo (double a)
-{
-  return __builtin_pow (a, -5.875);
-}
-
-double
-foof (double a)
-{
-  return __builtin_pow (a, 0.75f);
-}
-
-double
-bar (double a)
-{
-  return __builtin_pow (a, 1.0 + 0.00390625);
-}
-
-double
-baz (double a)
-{
-  return __builtin_pow (a, -1.25) + __builtin_pow (a, 5.75) - __builtin_pow (a, 3.375);
-}
-
-#define N 256
-void
-vecfoo (double *a)
-{
-  for (int i = 0; i < N; i++)
-a[i] = __builtin_pow (a[i], 1.25);
-}
-
-/* { dg-final { scan-tree-dump-times "synthesizing" 7 "sincos" } } */
-/* { dg-final { cleanup-tree-dump "sincos" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 3728927..e3c4416 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -4668,6 +4668,27 @@ proc check_effective_target_vect_call_copysignf { } {
 return $et_vect_call_copysignf_saved
 }
 
+# Return 1 if the target supports hardware square root instructions.
+
+proc check_effective_target_sqrt_insn { } {
+global et_sqrt_insn_saved
+
+if [info exists et_sqrt_insn_saved] {
+	verbose "check_effective_target_hw_sqrt: using cached result" 2
+} else {
+	set et

Re: [PR c/52952] More precise locations within format strings

2015-05-20 Thread Jeff Law

On 05/20/2015 02:15 AM, Manuel López-Ibáñez wrote:

This is a new version of the patch submitted here:

https://gcc.gnu.org/ml/gcc-patches/2014-11/msg00663.html

but handling (some) escape sequences.

I could not figure out a way to re-use the code from libcpp for this,
thus I implemented a simple function that given a string and offset in
bytes, it computes the visual column corresponding to that offset. The
function is very conservative: As soon as something unknown or
inconsistent is detected, it returns zero, thus preserving the current
behavior. This also preserves the current behavior for
non-concatenated tokens.

Bootstrapped and regression tested on x86_64-linux-gnu.

OK?


gcc/testsuite/ChangeLog:

2015-05-20  Manuel López-Ibáñez  

 PR c/52952
 * gcc.dg/redecl-4.c: Update column numbers.
 * gcc.dg/format/bitfld-1.c: Likewise.
 * gcc.dg/format/attr-2.c: Likewise.
 * gcc.dg/format/attr-6.c: Likewise.
 * gcc.dg/format/attr-7.c (baz): Likewise.
 * gcc.dg/format/asm_fprintf-1.c: Likewise.
 * gcc.dg/format/attr-4.c: Likewise.
 * gcc.dg/format/branch-1.c: Likewise.
 * gcc.dg/format/c90-printf-1.c: Likewise. Add tests for column
 locations within strings with embedded escape sequences.

gcc/c-family/ChangeLog:

2015-05-20  Manuel López-Ibáñez  

 PR c/52952
 * c-format.c (location_column_from_byte_offset): New.
 (location_from_offset): New.
 (struct format_wanted_type): Add offset_loc field.
 (check_format_info): Move handling of location for extra arguments
 closer to the point of warning.
 (check_format_arg): Set offset_is_invalid.
 (check_format_info_main): Pass the result of location_from_offset
 to warning_at.
 (format_type_warning): Pass the result of location_from_offset
 to warning_at.
So if I'm understanding the situation correctly, with this new version 
behaviour for non-concatenated tokens is preserved which was the only 
behaviour regression in the prior patch, right?


Thus, this version of the patch is strictly an improvement (points to 
the issue within the format string rather than to the start of the 
string).  Right?


I don't particularly like file scoped "offset_is_invalid" variable.  It 
appears that it's only set within check_format_arg, but it's used from a 
variety of other locations via location_from_offset.  Given the current 
structure of the code, alternatives would be even uglier.


Ok for the trunk.

Thanks,
Jeff


RE: Refactor gimple_expr_type

2015-05-20 Thread Aditya K



> Date: Wed, 20 May 2015 11:11:52 +0200
> Subject: Re: Refactor gimple_expr_type
> From: richard.guent...@gmail.com
> To: hiradi...@msn.com
> CC: tbsau...@tbsaunde.org; gcc-patches@gcc.gnu.org
>
> On Tue, May 19, 2015 at 6:50 PM, Aditya K  wrote:
>>
>>
>> 
>>> Date: Tue, 19 May 2015 11:33:16 +0200
>>> Subject: Re: Refactor gimple_expr_type
>>> From: richard.guent...@gmail.com
>>> To: hiradi...@msn.com
>>> CC: tbsau...@tbsaunde.org; gcc-patches@gcc.gnu.org
>>>
>>> On Tue, May 19, 2015 at 12:04 AM, Aditya K  wrote:


 
> Date: Mon, 18 May 2015 12:08:58 +0200
> Subject: Re: Refactor gimple_expr_type
> From: richard.guent...@gmail.com
> To: hiradi...@msn.com
> CC: tbsau...@tbsaunde.org; gcc-patches@gcc.gnu.org
>
> On Sun, May 17, 2015 at 5:31 PM, Aditya K  wrote:
>>
>>
>> 
>>> Date: Sat, 16 May 2015 11:53:57 -0400
>>> From: tbsau...@tbsaunde.org
>>> To: hiradi...@msn.com
>>> CC: gcc-patches@gcc.gnu.org
>>> Subject: Re: Refactor gimple_expr_type
>>>
>>> On Fri, May 15, 2015 at 07:13:35AM +, Aditya K wrote:
 Hi,
 I have tried to refactor gimple_expr_type to make it more readable. 
 Removed the switch block and redundant if.

 Please review this patch.
>>>
>>> for some reason your mail client seems to be inserting non breaking
>>> spaces all over the place. Please either configure it to not do that,
>>> or use git send-email for patches.
>>
>> Please see the updated patch.
>
> Ok if this passed bootstrap and regtest. (I wish if gimple_expr_type
> didn't exist btw...)

 Thanks for the review. Do you have any suggestions on how to remove 
 gimple_expr_type. Are there any alternatives to it?
 I can look into refactoring more (if it is not too complicated) since I'm 
 already doing this.
>>>
>>> Look at each caller - usually they should be fine with using TREE_TYPE
>>> (gimple_get_lhs ()) (or a more specific one
>>> dependent on what stmts are expected at the place). You might want to
>>> first refactor the code
>>>
>>> else if (code == GIMPLE_COND)
>>> gcc_unreachable ();
>>>
>>> and deal with the fallout in callers (similar for the void_type_node 
>>> return).
>>
>> Thanks for the suggestions. I looked at the use cases there are 47 usages in 
>> different files. That might be a lot of changes I assume, and would take 
>> some time.
>> This patch passes bootstrap and make check (although I'm not very confident 
>> that my way of make check ran all the regtests)
>>
>> If this patch is okay to merge please do that. I'll continue working on 
>> removing gimle_expr_type.
>
> Please re-send the patch as attachment, your mailer garbles the text
> (send mails as non-unicode text/plain).
>

Sure. I have attached the file.

Thanks,
-Aditya

> Richard.
>
>> Thanks,
>> -Aditya
>>
>>
>>>
>>> Richard.
>>>
>>>
 -Aditya

>
> Thanks,
> Richard.
>
>> gcc/ChangeLog:
>>
>> 2015-05-15 hiraditya 
>>
>> * gimple.h (gimple_expr_type): Refactor to make it concise. Remove 
>> redundant if.
>>
>> diff --git a/gcc/gimple.h b/gcc/gimple.h
>> index 95e4fc8..3a83e8f 100644
>> --- a/gcc/gimple.h
>> +++ b/gcc/gimple.h
>> @@ -5717,36 +5717,26 @@ static inline tree
>> gimple_expr_type (const_gimple stmt)
>> {
>> enum gimple_code code = gimple_code (stmt);
>> -
>> - if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
>> + /* In general we want to pass out a type that can be substituted
>> + for both the RHS and the LHS types if there is a possibly
>> + useless conversion involved. That means returning the
>> + original RHS type as far as we can reconstruct it. */
>> + if (code == GIMPLE_CALL)
>> {
>> - tree type;
>> - /* In general we want to pass out a type that can be substituted
>> - for both the RHS and the LHS types if there is a possibly
>> - useless conversion involved. That means returning the
>> - original RHS type as far as we can reconstruct it. */
>> - if (code == GIMPLE_CALL)
>> - {
>> - const gcall *call_stmt = as_a  (stmt);
>> - if (gimple_call_internal_p (call_stmt)
>> - && gimple_call_internal_fn (call_stmt) == IFN_MASK_STORE)
>> - type = TREE_TYPE (gimple_call_arg (call_stmt, 3));
>> - else
>> - type = gimple_call_return_type (call_stmt);
>> - }
>> + const gcall *call_stmt = as_a  (stmt);
>> + if (gimple_call_internal_p (call_stmt)
>> + && gimple_call_internal_fn (call_stmt) == IFN_MASK_STORE)
>> + return TREE_TYPE (gimple_call_arg (call_stmt, 3));
>> + else
>> + return gimple_call_return_type (call_stmt);
>> + }
>> + else if (code == GIMPLE_ASSIGN)
>> + {
>> + if (gimple_assign_rhs_code (s

Re: [PATCH 1/4] rs6000_stack_info changes for -fsplit-stack

2015-05-20 Thread Alan Modra
On Wed, May 20, 2015 at 09:02:40AM -0400, David Edelsohn wrote:
> On Tue, May 19, 2015 at 9:09 PM, Alan Modra  wrote:
> > On Mon, May 18, 2015 at 02:05:59PM -0400, David Edelsohn wrote:
> >> On Sun, May 17, 2015 at 10:54 PM, Alan Modra  wrote:
> >> > This patch changes rs6000_stack_info to keep save areas offsets even
> >> > when not used.  I need lr_save_offset valid for split-stack, and it
> >> > seemed reasonable to treat the other offsets the same.  Not zeroing
> >> > the offsets requires just one change in code that uses them, the
> >> > use_backchain_to_restore_sp expression in rs6000_emit_epilogue, not
> >> > counting the debug_stack_info changes.
> >> >
> >> > * config/rs6000/rs6000.c (rs6000_stack_info): Don't zero offsets
> >> > when not saving registers.
> >> > (debug_stack_info): Adjust to omit printing unused offsets,
> >> > as before.
> >> > (rs6000_emit_epilogue): Adjust use_backchain_to_restore_sp
> >> > expression.
> >>
> >> I think that the vrsave_save_offset change may break saving of
> >> callee-saved VRs.  See PR 55276.
> >
> > I checked.  It doesn't break that testcase.  PR 55276 was really
> > caused by using vrsave_mask for two purposes, firstly to track which
> > altivec registers have been saved, and secondly to control use of the
> > vrsave stack slot and whether mfvrsave/mtvrsave insns are generated.
> > Patch 2/4 removes this conflation.
> 
> Okay, but that confirms Patch 1 is not safe without the patch series.

No, patch 1/4 is safe by itself.  That's what I tested when I said I'd
checked.  Patch 2/4 doesn't correct a fault in patch 1/4.  The
explanation I gave re PR 55276 is saying that patch 2/4 prevents the
confusion that caused PR 55276 from re-occurring, at least as far as
vrsave_mask is concerned.

-- 
Alan Modra
Australia Development Lab, IBM


Re: [Patch, fortran, pr65548, 2nd take, v5] [5/6 Regression] gfc_conv_procedure_call

2015-05-20 Thread Mikael Morin
Le 20/05/2015 10:24, Andre Vehreschild a écrit :
> Hi Mikael,
> 
> when I got you right on IRC, then you proposed this change about the pointer
> attribute:
> 
> diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
> index 6d565ae..545f778 100644
> --- a/gcc/fortran/trans-stmt.c
> +++ b/gcc/fortran/trans-stmt.c
> @@ -5361,6 +5361,7 @@ gfc_trans_allocate (gfc_code * code)
>   /* Mark the symbol referenced or gfc_trans_assignment will
>  bug.  */
>   newsym->n.sym->attr.referenced = 1;
> + newsym->n.sym->attr.pointer = 1;
>   e3rhs->expr_type = EXPR_VARIABLE;
>   /* Set the symbols type, upto it was BT_UNKNOWN.  */
>   newsym->n.sym->ts = e3rhs->ts;
> @@ -5374,7 +5375,6 @@ gfc_trans_allocate (gfc_code * code)
>   /* Set the dimension and pointer attribute for arrays
>  to be on the safe side.  */
>   newsym->n.sym->attr.dimension = 1;
> - newsym->n.sym->attr.pointer = 1;
>   newsym->n.sym->as = arr;
>   gfc_add_full_array_ref (e3rhs, arr);
> }
> 
> Unfortunately does this lead to numerous regressions in the testsuite. For
> example:
> 
> ./gfortran.sh -g allocate_alloc_opt_6.f90 -o allocate_alloc_opt_6
> Fortraning using ***DEVelopment*** version...
> allocate_alloc_opt_6.f90:26:0:
> 
>allocate(t, source=mytype(1.0,2))
>  ^
> internal compiler error: Segmentation fault
> 0xe09a08 crash_signal
>   
> /home/vehre/Projekte/c_gcc_fortran2003_enhancements_cmbant_freelancer//gcc/gcc/toplev.c:380
> 0xa9cbe1 useless_type_conversion_p(tree_node*, tree_node*)
>   
> /home/vehre/Projekte/c_gcc_fortran2003_enhancements_cmbant_freelancer//gcc/gcc/gimple-expr.c:83
> 0x10622ae tree_ssa_useless_type_conversion(tree_node*)
>   
> /home/vehre/Projekte/c_gcc_fortran2003_enhancements_cmbant_freelancer//gcc/gcc/tree-ssa.c:1178
> 0x10622fe tree_ssa_strip_useless_type_conversions(tree_node*)
>   
> /home/vehre/Projekte/c_gcc_fortran2003_enhancements_cmbant_freelancer//gcc/gcc/tree-ssa.c:1190
> 0xb6c4ae gimplify_expr(tree_node**, gimple_statement_base**,
>gimple_statement_base**, bool (*)(tree_node*), int)
>   
> /home/vehre/Projekte/c_gcc_fortran2003_enhancements_cmbant_freelancer//gcc/gcc/gimplify.c:7815
> 0xb5e883 gimplify_modify_expr
>   
> /home/vehre/Projekte/c_gcc_fortran2003_enhancements_cmbant_freelancer//gcc/gcc/gimplify.c:4644
> 
> I therefore came to a more elaborate change (revert the above one before
> testing this):
> 
> diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
> index 6d565ae..7b466de 100644
> --- a/gcc/fortran/trans-stmt.c
> +++ b/gcc/fortran/trans-stmt.c
> @@ -5378,6 +5378,10 @@ gfc_trans_allocate (gfc_code * code)
>   newsym->n.sym->as = arr;
>   gfc_add_full_array_ref (e3rhs, arr);
> }
> + else if (POINTER_TYPE_P (TREE_TYPE (expr3)))
> +   newsym->n.sym->attr.pointer = 1;
> + else
> +   newsym->n.sym->attr.value = 1;
>   /* The string length is known to.  Set it for char arrays.  */
>   if (e3rhs->ts.type == BT_CHARACTER)
> newsym->n.sym->ts.u.cl->backend_decl = expr3_len;
> 
> This patch bootstraps and regtests fine again. Ok to commit?
> 
You can drop the else branch.  OK to commit with that change.
Thanks.

Mikael


Re: [match-and-simplify] reject expanding operator-list to implicit 'for'

2015-05-20 Thread Prathamesh Kulkarni
On 20 May 2015 at 18:18, Richard Biener  wrote:
> On Wed, 20 May 2015, Prathamesh Kulkarni wrote:
>
>> On 20 May 2015 at 17:01, Richard Biener  wrote:
>> > On Wed, 20 May 2015, Prathamesh Kulkarni wrote:
>> >
>> >> On 20 May 2015 at 16:17, Prathamesh Kulkarni
>> >>  wrote:
>> >> > Hi,
>> >> > This patch rejects expanding operator-list to implicit 'for'.
>> >> On second thoughts, should we reject expansion of operator-list _only_
>> >> if it's mixed with 'for' ?
>> >
>> > At least that, yes.
Well I suppose we could extend it to be mixed with 'for' ?
Add the operator lists to the inner-most 'for'.
eg:
(define_operator_list olist ...)

(for op (...)
  (simplify
(op (olist ...

would be equivalent to:

(for op (...)
  temp (olist)
  (simplify
(op (olist ...

operator-list expansion can be said to simply a short-hand for single
'for' with number of iterators = number of operator-lists.
If the operator-lists are enclosed within 'for', add them to the
innermost 'for'.

Thanks,
Prathamesh

>> >
>> >> We could define multiple operator-lists in simplify to be the same as
>> >> enclosing the simplify in 'for' with number of iterators
>> >> equal to number of operator-lists.
>> >> So we could allow
>> >> (define_operator_list op1 ...)
>> >> (define_operator_list op2 ...)
>> >>
>> >> (simplify
>> >>   (op1 (op2 ... )))
>> >>
>> >> is equivalent to:
>> >> (for  temp1 (op1)
>> >>temp2 (op2)
>> >>   (simplify
>> >> (temp1 (temp2 ...
>> >>
>> >> I think we have patterns like these in match-builtin.pd in the
>> >> match-and-simplify branch
>> >> And reject mixing of 'for' and operator-lists.
>> >> Admittedly the implicit 'for' behavior is not obvious from the syntax -;(
>> >
>> > Hmm, indeed we have for example
>> >
>> > /* Optimize pow(1.0,y) = 1.0.  */
>> > (simplify
>> >  (POW real_onep@0 @1)
>> >  @0)
>> >
>> > and I remember wanting that implicit for to make those less ugly.
>> >
>> > So can you rework only rejecting it within for?
>> This patch rejects expanding operator-list inside 'for'.
>> OK for trunk after bootstrap+testing ?
>
> Ok.
>
> Thanks,
> Richard.
>
>> Thanks,
>> Prathamesh
>> >
>> > Thanks,
>> > Richard.
>> >
>> >
>> >> Thanks,
>> >> Prathamesh
>> >> > OK for trunk after bootstrap+testing ?
>> >> >
>> >> > Thanks,
>> >> > Prathamesh
>> >>
>> >>
>> >
>> > --
>> > Richard Biener 
>> > SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Dilip Upmanyu, 
>> > Graham Norton, HRB 21284 (AG Nuernberg)
>>
>
> --
> Richard Biener 
> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Dilip Upmanyu, Graham 
> Norton, HRB 21284 (AG Nuernberg)


Re: [PATCH, C, ARM] PING c-family builtin export + attribute target (thumb,arm) [2.1/6] respin (5th)

2015-05-20 Thread Jeff Law

On 05/20/2015 01:19 AM, Christian Bruel wrote:

Hi,

Could a global reviewer have a look at the c-family part ?, this is
blocking for the TARGET_CPU_CPP_BUILTINS macro redefinition in C (arm
but probably others)

https://gcc.gnu.org/ml/gcc-patches/2015-05/msg01185.html
The c-family bits are OK.  Sorry I totally ignored this thread not 
realizing there were things outside the ARM port that needed review.


Thanks,
Jeff


Re: [PATCH 1/4] rs6000_stack_info changes for -fsplit-stack

2015-05-20 Thread David Edelsohn
On Tue, May 19, 2015 at 9:09 PM, Alan Modra  wrote:
> On Mon, May 18, 2015 at 02:05:59PM -0400, David Edelsohn wrote:
>> On Sun, May 17, 2015 at 10:54 PM, Alan Modra  wrote:
>> > This patch changes rs6000_stack_info to keep save areas offsets even
>> > when not used.  I need lr_save_offset valid for split-stack, and it
>> > seemed reasonable to treat the other offsets the same.  Not zeroing
>> > the offsets requires just one change in code that uses them, the
>> > use_backchain_to_restore_sp expression in rs6000_emit_epilogue, not
>> > counting the debug_stack_info changes.
>> >
>> > * config/rs6000/rs6000.c (rs6000_stack_info): Don't zero offsets
>> > when not saving registers.
>> > (debug_stack_info): Adjust to omit printing unused offsets,
>> > as before.
>> > (rs6000_emit_epilogue): Adjust use_backchain_to_restore_sp
>> > expression.
>>
>> I think that the vrsave_save_offset change may break saving of
>> callee-saved VRs.  See PR 55276.
>
> I checked.  It doesn't break that testcase.  PR 55276 was really
> caused by using vrsave_mask for two purposes, firstly to track which
> altivec registers have been saved, and secondly to control use of the
> vrsave stack slot and whether mfvrsave/mtvrsave insns are generated.
> Patch 2/4 removes this conflation.

Okay, but that confirms Patch 1 is not safe without the patch series.

- David


[AArch64] PR 63521. define REG_ALLOC_ORDER/HONOR_REG_ALLOC_ORDER

2015-05-20 Thread Jiong Wang
Current IRA still use both target macros in a few places.

Tell IRA to use the order we defined rather than with it's own cost
calculation. Allocate caller saved first, then callee saved.

This is especially useful for LR/x30, as it's free to allocate and is
pure caller saved when used in leaf function.

Haven't noticed significant impact on benchmarks, but by grepping some
keywords like "Spilling", "Push.*spill" etc in ira rtl dump, the number
is smaller.

OK for trunk?

2015-05-19  Jiong. Wang  

gcc/
  PR 63521
  * config/aarch64/aarch64.h (REG_ALLOC_ORDER): Define.
  (HONOR_REG_ALLOC_ORDER): Define.

Regards,
Jiong

diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index bf59e40..0acdf10 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -337,6 +337,31 @@ extern unsigned long aarch64_tune_flags;
 V_ALIASES(28), V_ALIASES(29), V_ALIASES(30), V_ALIASES(31)  \
   }
 
+#define REG_ALLOC_ORDER\
+{		\
+  /* Reverse order for argument registers.  */	\
+  7, 6, 5, 4, 3, 2, 1, 0,			\
+  /* Other caller-saved registers.  */		\
+  8, 9, 10, 11, 12, 13, 14, 15,			\
+  16, 17, 18, 30,\
+  /* Callee-saved registers.  */		\
+  19, 20, 21, 22, 23, 24, 25, 26,		\
+  27, 28,	\
+  /* All other registers.  */			\
+  29, 31,	\
+  /* Reverse order for argument vregisters.  */	\
+  39, 38, 37, 36, 35, 34, 33, 32,		\
+  /* Other caller-saved vregisters.  */		\
+  48, 49, 50, 51, 52, 53, 54, 55,		\
+  56, 57, 58, 59, 60, 61, 62, 63,		\
+  /* Callee-saved vregisters.  */		\
+  40, 41, 42, 43, 44, 45, 46, 47,		\
+  /* Other pseudo registers.  */		\
+  64, 65, 66	\
+}
+
+#define HONOR_REG_ALLOC_ORDER 1
+
 /* Say that the epilogue uses the return address register.  Note that
in the case of sibcalls, the values "used by the epilogue" are
considered live at the start of the called function.  */


Re: [PATCH 3/4] split-stack for powerpc64

2015-05-20 Thread David Edelsohn
On Wed, May 20, 2015 at 8:13 AM, Lynn A. Boger
 wrote:
>
>
> On 05/19/2015 07:52 PM, Alan Modra wrote:
>>
>> On Tue, May 19, 2015 at 07:40:15AM -0500, Lynn A. Boger wrote:
>>>
>>> Questions on the use of the options for split stack:
>>>
>>> - The way this is implemented, split stack is generated if the
>>> target platform supports split stack, on ppc64/ppc64le as well
>>> as on x86, and the use of -fno-split-stack doesn't seem to affect it
>>> for any of these.  Is that the way it should work?  I would expect
>>> -fno-split-stack to disable it completely.
>>
>> Can you give a testcase to show what you mean?  Picking one of the go
>> testsuite programs at random, I see
>> $ gcc/xgcc -Bgcc/ -S -I powerpc64le-linux/libgo
>> /src/gcc-virgin/gcc/testsuite/go.test/test/args.go
>> $ grep morestack args.s
>> bl __morestack
>> bl __morestack
>> $ gcc/xgcc -Bgcc/ -fno-split-stack -S -I powerpc64le-linux/libgo
>> /src/gcc-virgin/gcc/testsuite/go.test/test/args.go
>> $ grep morestack args.s
>> $
>> That shows -fno-split-stack being honoured.
>
> You are correct.  I made some mistake in my testing.
>>>
>>> - The comments say that the gold linker is used for some
>>> situations but I don't see any reference in the code to enabling
>>> the gold linker for ppc64le, ppc64, or x86.  Is the user expected
>>>   to add the option for the gold linker if needed?
>>
>> At the moment I believe this is true.
>
>
> I have been trying to use the gold linker with your patch and seems to work
> fine.  I added the following to
> the STACK_SPLIT_SPEC in gcc/gcc.c to enable the gold linker if -fsplit-stack
> is set, but that will cause problems
>  on systems where the gold linker (and the correct level of binutils for
> Power) is not available.  Is this an
> absolute requirement to use split stack?  Could the configure determine if
> gold is available and
> generate this one way or another?
>
> --- gcc.c   (revision 223217)
> +++ gcc.c   (working copy)
> @@ -541,7 +541,8 @@ proper position among the other output files.  */
> libgcc.  This is not yet a real spec, though it could become one;
> it is currently just stuffed into LINK_SPEC.  FIXME: This wrapping
> only works with GNU ld and gold.  */
> -#define STACK_SPLIT_SPEC " %{fsplit-stack: --wrap=pthread_create}"
> +#define STACK_SPLIT_SPEC \
> +  " %{fsplit-stack: --wrap=pthread_create -fuse-ld=gold}"
>
>  #ifndef LIBASAN_SPEC
>  #define STATIC_LIBASAN_LIBS \

Lynn,

split-stack does not require Gold linker.  This is a non-starter.

Gold is necessary for some corner cases of mixing split-stack and
non-split-stack modules.

- David


Re: [match-and-simplify] reject expanding operator-list to implicit 'for'

2015-05-20 Thread Richard Biener
On Wed, 20 May 2015, Prathamesh Kulkarni wrote:

> On 20 May 2015 at 17:01, Richard Biener  wrote:
> > On Wed, 20 May 2015, Prathamesh Kulkarni wrote:
> >
> >> On 20 May 2015 at 16:17, Prathamesh Kulkarni
> >>  wrote:
> >> > Hi,
> >> > This patch rejects expanding operator-list to implicit 'for'.
> >> On second thoughts, should we reject expansion of operator-list _only_
> >> if it's mixed with 'for' ?
> >
> > At least that, yes.
> >
> >> We could define multiple operator-lists in simplify to be the same as
> >> enclosing the simplify in 'for' with number of iterators
> >> equal to number of operator-lists.
> >> So we could allow
> >> (define_operator_list op1 ...)
> >> (define_operator_list op2 ...)
> >>
> >> (simplify
> >>   (op1 (op2 ... )))
> >>
> >> is equivalent to:
> >> (for  temp1 (op1)
> >>temp2 (op2)
> >>   (simplify
> >> (temp1 (temp2 ...
> >>
> >> I think we have patterns like these in match-builtin.pd in the
> >> match-and-simplify branch
> >> And reject mixing of 'for' and operator-lists.
> >> Admittedly the implicit 'for' behavior is not obvious from the syntax -;(
> >
> > Hmm, indeed we have for example
> >
> > /* Optimize pow(1.0,y) = 1.0.  */
> > (simplify
> >  (POW real_onep@0 @1)
> >  @0)
> >
> > and I remember wanting that implicit for to make those less ugly.
> >
> > So can you rework only rejecting it within for?
> This patch rejects expanding operator-list inside 'for'.
> OK for trunk after bootstrap+testing ?

Ok.

Thanks,
Richard.

> Thanks,
> Prathamesh
> >
> > Thanks,
> > Richard.
> >
> >
> >> Thanks,
> >> Prathamesh
> >> > OK for trunk after bootstrap+testing ?
> >> >
> >> > Thanks,
> >> > Prathamesh
> >>
> >>
> >
> > --
> > Richard Biener 
> > SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Dilip Upmanyu, 
> > Graham Norton, HRB 21284 (AG Nuernberg)
> 

-- 
Richard Biener 
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Dilip Upmanyu, Graham 
Norton, HRB 21284 (AG Nuernberg)


Re: [gomp4] New builtins, preparation for oacc vector-single

2015-05-20 Thread Jakub Jelinek
On Wed, May 20, 2015 at 02:01:44PM +0200, Bernd Schmidt wrote:
> To implement OpenACC vector-single mode, we need to ensure that only one
> thread out of the group representing a worker executes. The others skip
> computations but follow along the CFG, so the results of conditional branch
> decisions must be broadcast to them.
> 
> The patch below adds a new builtin and nvptx pattern to implement that
> broadcast functionality.

So, is the goal of this that threads in the warp other than the 0th
don't do anything except in vectorized regions, where all the threads
in the warp participate in the vectorization?
Thus, for OpenMP, should the whole warp be a single thread
(thus omp_get_thread_num () would be tid.x >> 5)?
If so, is the GCC vectorizer going to be taught about this?

Jakub


Re: [PATCH i386] Allow sibcalls in no-PLT PIC

2015-05-20 Thread H.J. Lu
On Wed, May 20, 2015 at 5:10 AM, Michael Matz  wrote:
> Hi,
>
> On Tue, 19 May 2015, Richard Henderson wrote:
>
>> It is.  The relaxation that HJ is working on requires that the reads
>> from the got not be hoisted.  I'm not especially convinced that what
>> he's working on is a win.
>>
>> With LTO, the compiler can do the same job that he's attempting in the
>> linker, without an extra nop.  Without LTO, leaving it to the linker
>> means that you can't hoist the load and hide the memory latency.
>
> Well, hoisting always needs a register, and if hoisted out of a loop
> (which you all seem to be after) that register is live through the whole
> loop body.  You need a register for each different called function in such
> loop, trading the one GOT pointer with N other registers.  For
> register-starved machines this is a real problem, even x86-64 doesn't have
> that many.  I.e. I'm not convinced that this hoisting will really be much
> of a win that often, outside toy examples.  Sure, the compiler can hoist
> function addresses trivially, but I think it will lead to spilling more
> often than not, or alternatively the hoisting will be undone by the
> register allocators rematerialization.  Of course, this would have to be
> measured for real not hand-waved, but, well, I'd be surprised if it's not
> so.
>

We should replace "call/jmp *foo@GOTPCREL(%rip)" with
 "call/jmp *foo@GOTRELAX(%rip)".   As an option, we apply
-fno-plt to both PIC and non-PIC codes, if foo is externally defined.
It will save one indirect branch if GCC is right.  If GCC is wrong
and foo is defined locally, we get a nop prefix/suffix. We have
nothing to lose.

-- 
H.J.


[gomp4] Unidirectional branches for nvptx

2015-05-20 Thread Bernd Schmidt
This adds functionality to the nvptx backend to emit uni-directional 
branches. The idea is to recognize the previously introduced 
warp-broadcast pattern; we know that its result is constant across an 
entire warp of threads, so any value based on that result has the same 
property. If a jump condition is constant across a warp, add ".uni".


Committed on gomp-4_0-branch.


Bernd
Index: gcc/ChangeLog.gomp
===
--- gcc/ChangeLog.gomp	(revision 223443)
+++ gcc/ChangeLog.gomp	(working copy)
@@ -1,3 +1,13 @@
+2015-05-20  Bernd Schmidt  
+
+	* config/nvptx/nvptx.c: Include "dumpfile,h".
+	(condition_unidirectional_p): New static function.
+	(nvptx_print_operand): Use it for new 'U' handling.
+	(nvptx_reorg): Compute warp_equal_pseudos.
+	* config/nvptx/nvptx.h (struct machine_function): New field
+	warp_equal_pseudos.
+	* config/nvptx/nvptx.md (br_true, br_false): Add %U modifier.
+
 2015-05-19  Bernd Schmidt  
 
 	* omp-builtins.def (GOACC_thread_broadcast,
Index: gcc/config/nvptx/nvptx.c
===
--- gcc/config/nvptx/nvptx.c	(revision 223443)
+++ gcc/config/nvptx/nvptx.c	(working copy)
@@ -72,6 +72,7 @@
 #include "cfgrtl.h"
 #include "stor-layout.h"
 #include "df.h"
+#include "dumpfile.h"
 #include "builtins.h"
 
 /* Record the function decls we've written, and the libfuncs and function
@@ -1646,6 +1647,23 @@ nvptx_print_operand_address (FILE *file,
   nvptx_print_address_operand (file, addr, VOIDmode);
 }
 
+/* Return true if the value of COND is the same across all threads in a
+   warp.  */
+
+static bool
+condition_unidirectional_p (rtx cond)
+{
+  if (CONSTANT_P (cond))
+return true;
+  if (GET_CODE (cond) == REG)
+return cfun->machine->warp_equal_pseudos[REGNO (cond)];
+  if (GET_RTX_CLASS (GET_CODE (cond)) == RTX_COMPARE
+  || GET_RTX_CLASS (GET_CODE (cond)) == RTX_COMM_COMPARE)
+return (condition_unidirectional_p (XEXP (cond, 0))
+	&& condition_unidirectional_p (XEXP (cond, 1)));
+  return false;
+}
+
 /* Print an operand, X, to FILE, with an optional modifier in CODE.
 
Meaning of CODE:
@@ -1659,7 +1677,9 @@ nvptx_print_operand_address (FILE *file,
f -- print a full reg even for something that must always be split
t -- print a type opcode suffix, promoting QImode to 32 bits
T -- print a type size in bits
-   u -- print a type opcode suffix without promotions.  */
+   u -- print a type opcode suffix without promotions.
+   U -- print ".uni" if a condition consists only of values equal across all
+threads in a warp.  */
 
 static void
 nvptx_print_operand (FILE *file, rtx x, int code)
@@ -1732,6 +1752,11 @@ nvptx_print_operand (FILE *file, rtx x,
   fprintf (file, "@!");
   goto common;
 
+case 'U':
+  if (condition_unidirectional_p (x))
+	fprintf (file, ".uni");
+  break;
+
 case 'c':
   op_mode = GET_MODE (XEXP (x, 0));
   switch (x_code)
@@ -1899,6 +1924,12 @@ nvptx_reorg (void)
 
   df_clear_flags (DF_LR_RUN_DCE);
   df_analyze ();
+  regstat_init_n_sets_and_refs ();
+  int max_regs = max_reg_num ();
+
+  for (int i = LAST_VIRTUAL_REGISTER + 1; i < max_regs; i++)
+if (REG_N_SETS (i) == 0 && REG_N_REFS (i) == 0)
+  regno_reg_rtx[i] = const0_rtx;
 
   thread_prologue_and_epilogue_insns ();
 
@@ -1911,6 +1942,11 @@ nvptx_reorg (void)
   siregs.mode = SImode;
   diregs.mode = DImode;
 
+  cfun->machine->warp_equal_pseudos
+= ggc_cleared_vec_alloc (max_regs);
+
+  auto_vec warp_reg_worklist;
+
   for (insn = get_insns (); insn; insn = next)
 {
   next = NEXT_INSN (insn);
@@ -1919,11 +1955,25 @@ nvptx_reorg (void)
 	  || GET_CODE (PATTERN (insn)) == USE
 	  || GET_CODE (PATTERN (insn)) == CLOBBER)
 	continue;
+
   qiregs.n_in_use = 0;
   hiregs.n_in_use = 0;
   siregs.n_in_use = 0;
   diregs.n_in_use = 0;
   extract_insn (insn);
+
+  if (recog_memoized (insn) == CODE_FOR_oacc_thread_broadcastsi
+	  || (GET_CODE (PATTERN (insn)) == SET
+	  && CONSTANT_P (SET_SRC (PATTERN (insn)
+	{
+	  rtx dest = recog_data.operand[0];
+	  if (REG_P (dest) && REG_N_SETS (REGNO (dest)) == 1)
+	{
+	  cfun->machine->warp_equal_pseudos[REGNO (dest)] = true;
+	  warp_reg_worklist.safe_push (REGNO (dest));
+	}
+	}
+
   enum attr_subregs_ok s_ok = get_attr_subregs_ok (insn);
   for (int i = 0; i < recog_data.n_operands; i++)
 	{
@@ -1978,12 +2028,55 @@ nvptx_reorg (void)
 	}
 }
 
-  int maxregs = max_reg_num ();
-  regstat_init_n_sets_and_refs ();
+  while (!warp_reg_worklist.is_empty ())
+{
+  int regno = warp_reg_worklist.pop ();
+  
+  df_ref use = DF_REG_USE_CHAIN (regno);
+  for (; use; use = DF_REF_NEXT_REG (use))
+	{
+	  rtx_insn *insn;
+	  if (!DF_REF_INSN_INFO (use))
+	continue;
+	  insn = DF_REF_INSN (use);
+	  if (DEBUG_INSN_P (insn))
+	continue;
 
-  for (int i = LAST_VIRTUAL_REGISTER + 1; i < maxregs; i++)
-if 

Re: [PATCH 3/4] split-stack for powerpc64

2015-05-20 Thread Lynn A. Boger



On 05/19/2015 07:52 PM, Alan Modra wrote:

On Tue, May 19, 2015 at 07:40:15AM -0500, Lynn A. Boger wrote:

Questions on the use of the options for split stack:

- The way this is implemented, split stack is generated if the
target platform supports split stack, on ppc64/ppc64le as well
as on x86, and the use of -fno-split-stack doesn't seem to affect it
for any of these.  Is that the way it should work?  I would expect
-fno-split-stack to disable it completely.

Can you give a testcase to show what you mean?  Picking one of the go
testsuite programs at random, I see
$ gcc/xgcc -Bgcc/ -S -I powerpc64le-linux/libgo 
/src/gcc-virgin/gcc/testsuite/go.test/test/args.go
$ grep morestack args.s
bl __morestack
bl __morestack
$ gcc/xgcc -Bgcc/ -fno-split-stack -S -I powerpc64le-linux/libgo 
/src/gcc-virgin/gcc/testsuite/go.test/test/args.go
$ grep morestack args.s
$
That shows -fno-split-stack being honoured.

You are correct.  I made some mistake in my testing.

- The comments say that the gold linker is used for some
situations but I don't see any reference in the code to enabling
the gold linker for ppc64le, ppc64, or x86.  Is the user expected
  to add the option for the gold linker if needed?

At the moment I believe this is true.


I have been trying to use the gold linker with your patch and seems to 
work fine.  I added the following to
the STACK_SPLIT_SPEC in gcc/gcc.c to enable the gold linker if 
-fsplit-stack is set, but that will cause problems
 on systems where the gold linker (and the correct level of binutils 
for Power) is not available.  Is this an
absolute requirement to use split stack?  Could the configure determine 
if gold is available and

generate this one way or another?

--- gcc.c   (revision 223217)
+++ gcc.c   (working copy)
@@ -541,7 +541,8 @@ proper position among the other output files.  */
libgcc.  This is not yet a real spec, though it could become one;
it is currently just stuffed into LINK_SPEC.  FIXME: This wrapping
only works with GNU ld and gold.  */
-#define STACK_SPLIT_SPEC " %{fsplit-stack: --wrap=pthread_create}"
+#define STACK_SPLIT_SPEC \
+  " %{fsplit-stack: --wrap=pthread_create -fuse-ld=gold}"

 #ifndef LIBASAN_SPEC
 #define STATIC_LIBASAN_LIBS \




Re: [PATCH i386] Allow sibcalls in no-PLT PIC

2015-05-20 Thread Michael Matz
Hi,

On Tue, 19 May 2015, Richard Henderson wrote:

> It is.  The relaxation that HJ is working on requires that the reads 
> from the got not be hoisted.  I'm not especially convinced that what 
> he's working on is a win.
> 
> With LTO, the compiler can do the same job that he's attempting in the 
> linker, without an extra nop.  Without LTO, leaving it to the linker 
> means that you can't hoist the load and hide the memory latency.

Well, hoisting always needs a register, and if hoisted out of a loop 
(which you all seem to be after) that register is live through the whole 
loop body.  You need a register for each different called function in such 
loop, trading the one GOT pointer with N other registers.  For 
register-starved machines this is a real problem, even x86-64 doesn't have 
that many.  I.e. I'm not convinced that this hoisting will really be much 
of a win that often, outside toy examples.  Sure, the compiler can hoist 
function addresses trivially, but I think it will lead to spilling more 
often than not, or alternatively the hoisting will be undone by the 
register allocators rematerialization.  Of course, this would have to be 
measured for real not hand-waved, but, well, I'd be surprised if it's not 
so.


Ciao,
Michael.


Re: [match-and-simplify] reject expanding operator-list to implicit 'for'

2015-05-20 Thread Prathamesh Kulkarni
On 20 May 2015 at 17:01, Richard Biener  wrote:
> On Wed, 20 May 2015, Prathamesh Kulkarni wrote:
>
>> On 20 May 2015 at 16:17, Prathamesh Kulkarni
>>  wrote:
>> > Hi,
>> > This patch rejects expanding operator-list to implicit 'for'.
>> On second thoughts, should we reject expansion of operator-list _only_
>> if it's mixed with 'for' ?
>
> At least that, yes.
>
>> We could define multiple operator-lists in simplify to be the same as
>> enclosing the simplify in 'for' with number of iterators
>> equal to number of operator-lists.
>> So we could allow
>> (define_operator_list op1 ...)
>> (define_operator_list op2 ...)
>>
>> (simplify
>>   (op1 (op2 ... )))
>>
>> is equivalent to:
>> (for  temp1 (op1)
>>temp2 (op2)
>>   (simplify
>> (temp1 (temp2 ...
>>
>> I think we have patterns like these in match-builtin.pd in the
>> match-and-simplify branch
>> And reject mixing of 'for' and operator-lists.
>> Admittedly the implicit 'for' behavior is not obvious from the syntax -;(
>
> Hmm, indeed we have for example
>
> /* Optimize pow(1.0,y) = 1.0.  */
> (simplify
>  (POW real_onep@0 @1)
>  @0)
>
> and I remember wanting that implicit for to make those less ugly.
>
> So can you rework only rejecting it within for?
This patch rejects expanding operator-list inside 'for'.
OK for trunk after bootstrap+testing ?

Thanks,
Prathamesh
>
> Thanks,
> Richard.
>
>
>> Thanks,
>> Prathamesh
>> > OK for trunk after bootstrap+testing ?
>> >
>> > Thanks,
>> > Prathamesh
>>
>>
>
> --
> Richard Biener 
> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Dilip Upmanyu, Graham 
> Norton, HRB 21284 (AG Nuernberg)
2015-05-20  Prathamesh Kulkarni  

* genmatch.c (parser::parse_operation): Reject expanding operator-list 
inside 'for'.
Index: genmatch.c
===
--- genmatch.c  (revision 223437)
+++ genmatch.c  (working copy)
@@ -2913,7 +2913,10 @@
 
   user_id *p = dyn_cast (op);
   if (p && p->is_oper_list)
-record_operlist (id_tok->src_loc, p);
+if (active_fors.length() == 0)
+  record_operlist (id_tok->src_loc, p);
+else
+  fatal_at (id_tok, "operator-list %s cannot be exapnded inside 'for'", 
id);
   return op;
 }
 


  1   2   >