Re: [PATCH, Pointer Bounds Checker 6/x] New static constructor types

2014-09-15 Thread Ilya Enkovich
Ping

2014-06-05 15:03 GMT+04:00 Ilya Enkovich enkovich@gmail.com:
 2014-06-04 17:35 GMT+04:00 Richard Biener richard.guent...@gmail.com:
 On Wed, Jun 4, 2014 at 3:13 PM, Ilya Enkovich enkovich@gmail.com wrote:
 2014-06-04 13:58 GMT+04:00 Richard Biener richard.guent...@gmail.com:
 On Wed, Apr 16, 2014 at 2:33 PM, Ilya Enkovich enkovich@gmail.com 
 wrote:
 Hi,

 This patch add new static constructor types used by Pointer Bounds 
 Checker.  It was approved earlier for 4.9 and I'll assume patch is OK for 
 trunk if no objections arise.

 Patch was bootstrapped and tested for linux-x86_64.

 Thanks,
 Ilya
 --
 gcc/

 2014-04-16  Ilya Enkovich  ilya.enkov...@intel.com

 * ipa.c (cgraph_build_static_cdtor_1): Support contructors
 with chkp ctor and bnd_legacy attributes.
 * gimplify.c (gimplify_init_constructor): Avoid infinite
 loop during gimplification of bounds initializer.


 diff --git a/gcc/gimplify.c b/gcc/gimplify.c
 index 7441784..67ab515 100644
 --- a/gcc/gimplify.c
 +++ b/gcc/gimplify.c
 @@ -3803,10 +3803,19 @@ gimplify_init_constructor (tree *expr_p, 
 gimple_seq *pre_p, gimple_seq *post_p,
individual element initialization.  Also don't do this for 
 small
all-zero initializers (which aren't big enough to merit
clearing), and don't try to make bitwise copies of
 -  TREE_ADDRESSABLE types.  */
 +  TREE_ADDRESSABLE types.
 +
 +  We cannot apply such transformation when compiling chkp static
 +  initializer because creation of initializer image in the memory
 +  will require static initialization of bounds for it.  It should
 +  result in another gimplification of similar initializer and we
 +  may fall into infinite loop.  */
 if (valid_const_initializer
  !(cleared || num_nonzero_elements == 0)
 -!TREE_ADDRESSABLE (type))
 +!TREE_ADDRESSABLE (type)
 +(!current_function_decl
 +   || !lookup_attribute (chkp ctor,
 + DECL_ATTRIBUTES 
 (current_function_decl

 Simply make the type TREE_ADDRESSABLE?

 Wouldn't it be a hack to mark it addressable just to not hit this
 condition? It would also require to have an unshared copy of the type
 to not affect other statements with that type.


   {
 HOST_WIDE_INT size = int_size_in_bytes (type);
 unsigned int align;
 diff --git a/gcc/ipa.c b/gcc/ipa.c
 index 26e9b03..5ab3aed 100644
 --- a/gcc/ipa.c
 +++ b/gcc/ipa.c
 @@ -1345,9 +1345,11 @@ make_pass_ipa_whole_program_visibility 
 (gcc::context *ctxt)
  }

  /* Generate and emit a static constructor or destructor.  WHICH must
 -   be one of 'I' (for a constructor) or 'D' (for a destructor).  BODY
 -   is a STATEMENT_LIST containing GENERIC statements.  PRIORITY is the
 -   initialization priority for this constructor or destructor.
 +   be one of 'I' (for a constructor), 'D' (for a destructor), 'P'
 +   (for chp static vars constructor) or 'B' (for chkp static bounds
 +   constructor).  BODY is a STATEMENT_LIST containing GENERIC
 +   statements.  PRIORITY is the initialization priority for this
 +   constructor or destructor.

 FINAL specify whether the externally visible name for collect2 should
 be produced. */
 @@ -1406,6 +1408,20 @@ cgraph_build_static_cdtor_1 (char which, tree 
 body, int priority, bool final)
DECL_STATIC_CONSTRUCTOR (decl) = 1;
decl_init_priority_insert (decl, priority);
break;
 +case 'P':
 +  DECL_STATIC_CONSTRUCTOR (decl) = 1;
 +  DECL_ATTRIBUTES (decl) = tree_cons (get_identifier (chkp ctor),
 + NULL,
 + NULL_TREE);

 Ick.  Please try to avoid using attributes for this.  Rather adjust the
 caller of this function to set a flag in the cgraph node.

 It is too late because all early local passes are executed by that
 time and I need this attribute to be set before them.

 Ok, so where do you call this from?  It should be possible to create
 the function in GIMPLE form directly, avoiding the need to go through
 gimplification.

 I create constructors at the end of unit compilation in
 chkp_finish_file. Constructor body in this case is MODIFY_EXPRs for
 all statically initialized pointers. chkp ctor attribute is used to
 instrument this constructor properly - all pointer modifications
 should be replaced with corresponding bounds initialization. Thus
 gimplification is not the only place where this attribute is used.

 Ilya


 Richard.

 Ilya


 So I don't like this patch at all.

 Richard.

 +  decl_init_priority_insert (decl, priority);
 +  break;
 +case 'B':
 +  DECL_STATIC_CONSTRUCTOR (decl) = 1;
 +  DECL_ATTRIBUTES (decl) = tree_cons (get_identifier (bnd_legacy),
 + NULL,
 + NULL_TREE);
 +  

Re: [PATCH, Pointer Bounds Checker 20/x] Follow transparent alias chains

2014-09-15 Thread Ilya Enkovich
Ping

2014-06-03 13:01 GMT+04:00 Richard Biener richard.guent...@gmail.com:
 On Mon, Jun 2, 2014 at 5:15 PM, Ilya Enkovich enkovich@gmail.com wrote:
 Hi,

 In the most case we follow transparent alias chains wne assemble names.  But 
 in some cases it is not performed.  For instrumented functions it is 
 critical and following patch fixes that.  It also adds a visibility 
 inheritance for instrtumented functions.

 It feels like this should be handled by the symtab code nowadays ... Honza?

 Richard.

 Bootstrapped and tested on linux-x86_64.

 Thanks,
 Ilya
 --
 gcc/

 2014-06-02  Ilya Enkovich  ilya.enkov...@intel.com

 * varasm.c: Include tree-chkp.h.
 (ultimate_transparent_alias_target): Move up.
 (make_decl_rtl): For instrumented function use
 name of the original decl.
 (assemble_start_function): Mark function as global
 in case it is instrumentation clone of the global
 function.
 (do_assemble_alias): Follow transparent alias chain
 for identifier.  Check if original alias is public.
 (maybe_assemble_visibility): Use visibility of the
 original function for instrumented version.
 (default_unique_section): Likewise.


 diff --git a/gcc/varasm.c b/gcc/varasm.c
 index fcae2fa..d473bc7 100644
 --- a/gcc/varasm.c
 +++ b/gcc/varasm.c
 @@ -54,6 +54,7 @@ along with GCC; see the file COPYING3.  If not see
  #include pointer-set.h
  #include asan.h
  #include basic-block.h
 +#include tree-chkp.h

  #ifdef XCOFF_DEBUGGING_INFO
  #include xcoffout.h  /* Needed for external data
 @@ -1200,6 +1201,30 @@ use_blocks_for_decl_p (tree decl)
return targetm.use_blocks_for_decl_p (decl);
  }

 +/* Follow the IDENTIFIER_TRANSPARENT_ALIAS chain starting at *ALIAS
 +   until we find an identifier that is not itself a transparent alias.
 +   Modify the alias passed to it by reference (and all aliases on the
 +   way to the ultimate target), such that they do not have to be
 +   followed again, and return the ultimate target of the alias
 +   chain.  */
 +
 +static inline tree
 +ultimate_transparent_alias_target (tree *alias)
 +{
 +  tree target = *alias;
 +
 +  if (IDENTIFIER_TRANSPARENT_ALIAS (target))
 +{
 +  gcc_assert (TREE_CHAIN (target));
 +  target = ultimate_transparent_alias_target (TREE_CHAIN (target));
 +  gcc_assert (! IDENTIFIER_TRANSPARENT_ALIAS (target)
 +  ! TREE_CHAIN (target));
 +  *alias = target;
 +}
 +
 +  return target;
 +}
 +
  /* Create the DECL_RTL for a VAR_DECL or FUNCTION_DECL.  DECL should
 have static storage duration.  In other words, it should not be an
 automatic variable, including PARM_DECLs.
 @@ -1214,6 +1239,7 @@ make_decl_rtl (tree decl)
  {
const char *name = 0;
int reg_number;
 +  tree id;
rtx x;

/* Check that we are not being given an automatic variable.  */
 @@ -1271,7 +1297,12 @@ make_decl_rtl (tree decl)
return;
  }

 -  name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
 +  id = DECL_ASSEMBLER_NAME (decl);
 +  if (TREE_CODE (decl) == FUNCTION_DECL
 +   cgraph_get_node (decl)
 +   cgraph_get_node (decl)-instrumentation_clone)
 +ultimate_transparent_alias_target (id);
 +  name = IDENTIFIER_POINTER (id);

if (name[0] != '*'  TREE_CODE (decl) != FUNCTION_DECL
 DECL_REGISTER (decl))
 @@ -1699,7 +1730,10 @@ assemble_start_function (tree decl, const char 
 *fnname)

/* Make function name accessible from other files, if appropriate.  */

 -  if (TREE_PUBLIC (decl))
 +  if (TREE_PUBLIC (decl)
 +  || (cgraph_get_node (decl)-instrumentation_clone
 +  cgraph_get_node (decl)-instrumented_version
 +  TREE_PUBLIC (cgraph_get_node 
 (decl)-instrumented_version-decl)))
  {
notice_global_symbol (decl);

 @@ -2386,30 +2420,6 @@ mark_decl_referenced (tree decl)
  }


 -/* Follow the IDENTIFIER_TRANSPARENT_ALIAS chain starting at *ALIAS
 -   until we find an identifier that is not itself a transparent alias.
 -   Modify the alias passed to it by reference (and all aliases on the
 -   way to the ultimate target), such that they do not have to be
 -   followed again, and return the ultimate target of the alias
 -   chain.  */
 -
 -static inline tree
 -ultimate_transparent_alias_target (tree *alias)
 -{
 -  tree target = *alias;
 -
 -  if (IDENTIFIER_TRANSPARENT_ALIAS (target))
 -{
 -  gcc_assert (TREE_CHAIN (target));
 -  target = ultimate_transparent_alias_target (TREE_CHAIN (target));
 -  gcc_assert (! IDENTIFIER_TRANSPARENT_ALIAS (target)
 -  ! TREE_CHAIN (target));
 -  *alias = target;
 -}
 -
 -  return target;
 -}
 -
  /* Output to FILE (an assembly file) a reference to NAME.  If NAME
 starts with a *, the rest of NAME is output verbatim.  Otherwise
 NAME is transformed in a target-specific way (usually by the
 @@ -5544,6 +5554,9 @@ vecalias_pair, va_gc *alias_pairs;
  void
  do_assemble_alias (tree 

Re: [PATCH, i386, Pointer Bounds Checker 32/x] Pointer Bounds Checker hooks for i386 target

2014-09-15 Thread Ilya Enkovich
Ping

2014-06-11 18:00 GMT+04:00 Ilya Enkovich enkovich@gmail.com:
 Hi,

 This patch adds i386 target hooks for Pointer Bounds Checker.

 Bootstrapped and tested on linux-x86_64.

 Thanks,
 Ilya
 --
 gcc/

 2014-06-11  Ilya Enkovich  ilya.enkov...@intel.com

 * config/i386/i386.c: Include tree-iterator.h.
 (ix86_function_value_bounds): New.
 (ix86_builtin_mpx_function): New.
 (ix86_load_bounds): New.
 (ix86_store_bounds): New.
 (ix86_load_returned_bounds): New.
 (ix86_store_returned_bounds): New.
 (ix86_fn_abi_va_list_bounds_size): New.
 (ix86_mpx_bound_mode): New.
 (ix86_make_bounds_constant): New.
 (ix86_initialize_bounds):
 (TARGET_LOAD_BOUNDS_FOR_ARG): New.
 (TARGET_STORE_BOUNDS_FOR_ARG): New.
 (TARGET_LOAD_RETURNED_BOUNDS): New.
 (TARGET_STORE_RETURNED_BOUNDS): New.
 (TARGET_CHKP_BOUND_MODE): New.
 (TARGET_BUILTIN_CHKP_FUNCTION): New.
 (TARGET_FN_ABI_VA_LIST_BOUNDS_SIZE): New.
 (TARGET_CHKP_FUNCTION_VALUE_BOUNDS): New.
 (TARGET_CHKP_MAKE_BOUNDS_CONSTANT): New.
 (TARGET_CHKP_INITIALIZE_BOUNDS): New.


 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
 index ac79231..dac83d0 100644
 --- a/gcc/config/i386/i386.c
 +++ b/gcc/config/i386/i386.c
 @@ -81,6 +81,7 @@ along with GCC; see the file COPYING3.  If not see
  #include context.h
  #include pass_manager.h
  #include target-globals.h
 +#include tree-iterator.h
  #include tree-chkp.h
  #include rtl-chkp.h

 @@ -7971,6 +7972,39 @@ ix86_function_value (const_tree valtype, const_tree 
 fntype_or_decl,
return ix86_function_value_1 (valtype, fntype_or_decl, orig_mode, mode);
  }

 +static rtx
 +ix86_function_value_bounds (const_tree valtype,
 +   const_tree fntype_or_decl ATTRIBUTE_UNUSED,
 +   bool outgoing ATTRIBUTE_UNUSED)
 +{
 +  rtx res = NULL_RTX;
 +
 +  if (BOUNDED_TYPE_P (valtype))
 +res = gen_rtx_REG (BNDmode, FIRST_BND_REG);
 +  else if (chkp_type_has_pointer (valtype))
 +{
 +  bitmap slots = chkp_find_bound_slots (valtype);
 +  rtx bounds[2];
 +  bitmap_iterator bi;
 +  unsigned i, bnd_no = 0;
 +
 +  EXECUTE_IF_SET_IN_BITMAP (slots, 0, i, bi)
 +   {
 + rtx reg = gen_rtx_REG (BNDmode, FIRST_BND_REG + bnd_no);
 + rtx offs = GEN_INT (i * POINTER_SIZE / BITS_PER_UNIT);
 + gcc_assert (bnd_no  2);
 + bounds[bnd_no++] = gen_rtx_EXPR_LIST (VOIDmode, reg, offs);
 +   }
 +
 +  res = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (bnd_no, bounds));
 +  BITMAP_FREE (slots);
 +}
 +  else
 +res = NULL_RTX;
 +
 +  return res;
 +}
 +
  /* Pointer function arguments and return values are promoted to
 word_mode.  */

 @@ -36620,6 +36654,173 @@ static tree ix86_get_builtin (enum ix86_builtins 
 code)
  return NULL_TREE;
  }

 +/* Return function decl for target specific builtin
 +   for given MPX builtin passed i FCODE.  */
 +static tree
 +ix86_builtin_mpx_function (unsigned fcode)
 +{
 +  switch (fcode)
 +{
 +case BUILT_IN_CHKP_BNDMK:
 +  return ix86_builtins[IX86_BUILTIN_BNDMK];
 +
 +case BUILT_IN_CHKP_BNDSTX:
 +  return ix86_builtins[IX86_BUILTIN_BNDSTX];
 +
 +case BUILT_IN_CHKP_BNDLDX:
 +  return ix86_builtins[IX86_BUILTIN_BNDLDX];
 +
 +case BUILT_IN_CHKP_BNDCL:
 +  return ix86_builtins[IX86_BUILTIN_BNDCL];
 +
 +case BUILT_IN_CHKP_BNDCU:
 +  return ix86_builtins[IX86_BUILTIN_BNDCU];
 +
 +case BUILT_IN_CHKP_BNDRET:
 +  return ix86_builtins[IX86_BUILTIN_BNDRET];
 +
 +case BUILT_IN_CHKP_INTERSECT:
 +  return ix86_builtins[IX86_BUILTIN_BNDINT];
 +
 +case BUILT_IN_CHKP_NARROW:
 +  return ix86_builtins[IX86_BUILTIN_BNDNARROW];
 +
 +case BUILT_IN_CHKP_SIZEOF:
 +  return ix86_builtins[IX86_BUILTIN_SIZEOF];
 +
 +case BUILT_IN_CHKP_EXTRACT_LOWER:
 +  return ix86_builtins[IX86_BUILTIN_BNDLOWER];
 +
 +case BUILT_IN_CHKP_EXTRACT_UPPER:
 +  return ix86_builtins[IX86_BUILTIN_BNDUPPER];
 +
 +default:
 +  return NULL_TREE;
 +}
 +
 +  gcc_unreachable ();
 +}
 +
 +/* Load bounds PTR pointer value loaded from SLOT.
 +   if SLOT is a register then load bounds associated
 +   with special address identified by BND.
 +
 +   Return loaded bounds.  */
 +static rtx
 +ix86_load_bounds (rtx slot, rtx ptr, rtx bnd)
 +{
 +  rtx addr = NULL;
 +  rtx reg;
 +
 +  if (!ptr)
 +{
 +  gcc_assert (MEM_P (slot));
 +  ptr = copy_to_mode_reg (Pmode, slot);
 +}
 +
 +  if (!slot || REG_P (slot))
 +{
 +  if (slot)
 +   ptr = slot;
 +
 +  gcc_assert (CONST_INT_P (bnd));
 +
 +  /* Here we have the case when more than four pointers are
 +passed in registers.  In this case we are out of bound
 +registers and have to use bndldx to load bound.  RA,
 +RA - 8, etc. are used for address translation in bndldx.  */
 +  addr = 

Re: [PATCH, i386, Pointer Bounds Checker 34/x] Vararg functions support

2014-09-15 Thread Ilya Enkovich
Ping

2014-06-11 18:06 GMT+04:00 Ilya Enkovich enkovich@gmail.com:
 Hi,

 This patch introduces initialization of incoming bounds for vararg function 
 on i386 target.

 Bootstrapped and tested on linux-x86_64.

 Thanks,
 Ilya
 --
 gcc/

 2014-06-11  Ilya Enkovich  ilya.enkov...@intel.com

 * config/i386/i386.c (ix86_setup_incoming_varargs): New.
 (ix86_va_start): Initialize bounds for pointers in va_list.
 (TARGET_SETUP_INCOMING_VARARG_BOUNDS): New.


 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
 index a67e6e7..c520f26 100644
 --- a/gcc/config/i386/i386.c
 +++ b/gcc/config/i386/i386.c
 @@ -8456,6 +8456,72 @@ ix86_setup_incoming_varargs (cumulative_args_t cum_v, 
 enum machine_mode mode,
  setup_incoming_varargs_64 (next_cum);
  }

 +static void
 +ix86_setup_incoming_vararg_bounds (cumulative_args_t cum_v,
 +  enum machine_mode mode,
 +  tree type,
 +  int *pretend_size ATTRIBUTE_UNUSED,
 +  int no_rtl)
 +{
 +  CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v);
 +  CUMULATIVE_ARGS next_cum;
 +  tree fntype;
 +  rtx save_area;
 +  int bnd_reg, i, max;
 +
 +  gcc_assert (!no_rtl);
 +
 +  if (!TARGET_64BIT)
 +return;
 +
 +  fntype = TREE_TYPE (current_function_decl);
 +
 +  /* For varargs, we do not want to skip the dummy va_dcl argument.
 + For stdargs, we do want to skip the last named argument.  */
 +  next_cum = *cum;
 +  if (stdarg_p (fntype))
 +ix86_function_arg_advance (pack_cumulative_args (next_cum), mode, type,
 +  true);
 +  if (cum-call_abi == MS_ABI)
 +return;
 +
 +  save_area = frame_pointer_rtx;
 +
 +  max = cum-regno + cfun-va_list_gpr_size / UNITS_PER_WORD;
 +  if (max  X86_64_REGPARM_MAX)
 +max = X86_64_REGPARM_MAX;
 +
 +  bnd_reg = cum-bnd_regno + cum-force_bnd_pass;
 +  if (chkp_function_instrumented_p (current_function_decl))
 +for (i = cum-regno; i  max; i++)
 +  {
 +   rtx addr = plus_constant (Pmode, save_area, i * UNITS_PER_WORD);
 +   rtx reg = gen_rtx_REG (DImode,
 +  x86_64_int_parameter_registers[i]);
 +   rtx ptr = reg;
 +   rtx bounds;
 +
 +   if (bnd_reg = LAST_BND_REG)
 + bounds = gen_rtx_REG (BNDmode, bnd_reg);
 +   else
 + {
 +   rtx ldx_addr = plus_constant (Pmode, arg_pointer_rtx,
 + (LAST_BND_REG - bnd_reg) * 8);
 +   bounds = gen_reg_rtx (BNDmode);
 +   emit_insn (TARGET_64BIT
 +  ? gen_bnd64_ldx (bounds, ldx_addr, ptr)
 +  : gen_bnd32_ldx (bounds, ldx_addr, ptr));
 + }
 +
 +   emit_insn (TARGET_64BIT
 +  ? gen_bnd64_stx (addr, ptr, bounds)
 +  : gen_bnd32_stx (addr, ptr, bounds));
 +
 +   bnd_reg++;
 +  }
 +}
 +
 +
  /* Checks if TYPE is of kind va_list char *.  */

  static bool
 @@ -8478,7 +8544,7 @@ ix86_va_start (tree valist, rtx nextarg)
  {
HOST_WIDE_INT words, n_gpr, n_fpr;
tree f_gpr, f_fpr, f_ovf, f_sav;
 -  tree gpr, fpr, ovf, sav, t;
 +  tree gpr, fpr, ovf, sav, t, t1;
tree type;
rtx ovf_rtx;

 @@ -8529,6 +8595,13 @@ ix86_va_start (tree valist, rtx nextarg)
crtl-args.arg_offset_rtx,
NULL_RTX, 0, OPTAB_LIB_WIDEN);
   convert_move (va_r, next, 0);
 +
 + /* Store zero bounds for va_list.  */
 + if (chkp_function_instrumented_p (current_function_decl))
 +   chkp_expand_bounds_reset_for_mem (valist,
 + make_tree (TREE_TYPE (valist),
 +next));
 +
 }
return;
  }
 @@ -8582,10 +8655,15 @@ ix86_va_start (tree valist, rtx nextarg)
t = make_tree (type, ovf_rtx);
if (words != 0)
  t = fold_build_pointer_plus_hwi (t, words * UNITS_PER_WORD);
 +  t1 = t;
t = build2 (MODIFY_EXPR, type, ovf, t);
TREE_SIDE_EFFECTS (t) = 1;
expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);

 +  /* Store zero bounds for overflow area pointer.  */
 +  if (chkp_function_instrumented_p (current_function_decl))
 +chkp_expand_bounds_reset_for_mem (ovf, t1);
 +
if (ix86_varargs_gpr_size || ix86_varargs_fpr_size)
  {
/* Find the register save area.
 @@ -8594,9 +8672,14 @@ ix86_va_start (tree valist, rtx nextarg)
t = make_tree (type, frame_pointer_rtx);
if (!ix86_varargs_gpr_size)
 t = fold_build_pointer_plus_hwi (t, -8 * X86_64_REGPARM_MAX);
 +  t1 = t;
t = build2 (MODIFY_EXPR, type, sav, t);
TREE_SIDE_EFFECTS (t) = 1;
expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
 +
 +  /* Store zero bounds for save area pointer.  */
 +  if (chkp_function_instrumented_p (current_function_decl))
 +   

Re: [PATCH, i386, Pointer Bounds Checker 31/x] Pointer Bounds Checker builtins for i386 target

2014-09-15 Thread Ilya Enkovich
Ping

2014-06-11 17:58 GMT+04:00 Ilya Enkovich enkovich@gmail.com:
 Hi,

 This patch adds i386 target builtins for Pointer Bounds Checker.

 Bootstrapped and tested on linux-x86_64.

 Thanks,
 Ilya
 --
 gcc/

 2014-06-11  Ilya Enkovich  ilya.enkov...@intel.com

 * config/i386/i386-builtin-types.def (BND): New.
 (ULONG): New.
 (BND_FTYPE_PCVOID_ULONG): New.
 (VOID_FTYPE_BND_PCVOID): New.
 (VOID_FTYPE_PCVOID_PCVOID_BND): New.
 (BND_FTYPE_PCVOID_PCVOID): New.
 (BND_FTYPE_PCVOID): New.
 (BND_FTYPE_BND_BND): New.
 (PVOID_FTYPE_PVOID_PVOID_ULONG): New.
 (PVOID_FTYPE_PCVOID_BND_ULONG): New.
 (ULONG_FTYPE_VOID): New.
 (PVOID_FTYPE_BND): New.
 * config/i386/i386.c: Include tree-chkp.h, rtl-chkp.h.
 (ix86_builtins): Add
 IX86_BUILTIN_BNDMK, IX86_BUILTIN_BNDSTX,
 IX86_BUILTIN_BNDLDX, IX86_BUILTIN_BNDCL,
 IX86_BUILTIN_BNDCU, IX86_BUILTIN_BNDRET,
 IX86_BUILTIN_BNDNARROW, IX86_BUILTIN_BNDINT,
 IX86_BUILTIN_SIZEOF, IX86_BUILTIN_BNDLOWER,
 IX86_BUILTIN_BNDUPPER.
 (builtin_isa): Add leaf_p and nothrow_p fields.
 (def_builtin): Initialize leaf_p and nothrow_p.
 (ix86_add_new_builtins): Handle leaf_p and nothrow_p
 flags.
 (bdesc_mpx): New.
 (bdesc_mpx_const): New.
 (ix86_init_mpx_builtins): New.
 (ix86_init_builtins): Call ix86_init_mpx_builtins.
 (ix86_emit_move_max): New.
 (ix86_expand_builtin): Expand IX86_BUILTIN_BNDMK,
 IX86_BUILTIN_BNDSTX, IX86_BUILTIN_BNDLDX,
 IX86_BUILTIN_BNDCL, IX86_BUILTIN_BNDCU,
 IX86_BUILTIN_BNDRET, IX86_BUILTIN_BNDNARROW,
 IX86_BUILTIN_BNDINT, IX86_BUILTIN_SIZEOF,
 IX86_BUILTIN_BNDLOWER, IX86_BUILTIN_BNDUPPER.


 diff --git a/gcc/config/i386/i386-builtin-types.def 
 b/gcc/config/i386/i386-builtin-types.def
 index 822c5e5..169d40a 100644
 --- a/gcc/config/i386/i386-builtin-types.def
 +++ b/gcc/config/i386/i386-builtin-types.def
 @@ -47,6 +47,7 @@ DEF_PRIMITIVE_TYPE (UCHAR, unsigned_char_type_node)
  DEF_PRIMITIVE_TYPE (QI, char_type_node)
  DEF_PRIMITIVE_TYPE (HI, intHI_type_node)
  DEF_PRIMITIVE_TYPE (SI, intSI_type_node)
 +DEF_PRIMITIVE_TYPE (BND, pointer_bounds_type_node)
  # ??? Logically this should be intDI_type_node, but that maps to long
  # with 64-bit, and that's not how the emmintrin.h is written.  Again,
  # changing this would change name mangling.
 @@ -60,6 +61,7 @@ DEF_PRIMITIVE_TYPE (USHORT, short_unsigned_type_node)
  DEF_PRIMITIVE_TYPE (INT, integer_type_node)
  DEF_PRIMITIVE_TYPE (UINT, unsigned_type_node)
  DEF_PRIMITIVE_TYPE (UNSIGNED, unsigned_type_node)
 +DEF_PRIMITIVE_TYPE (ULONG, long_unsigned_type_node)
  DEF_PRIMITIVE_TYPE (LONGLONG, long_long_integer_type_node)
  DEF_PRIMITIVE_TYPE (ULONGLONG, long_long_unsigned_type_node)
  DEF_PRIMITIVE_TYPE (UINT8, unsigned_char_type_node)
 @@ -806,3 +808,15 @@ DEF_FUNCTION_TYPE_ALIAS (V2DI_FTYPE_V2DI_V2DI, TF)
  DEF_FUNCTION_TYPE_ALIAS (V4SF_FTYPE_V4SF_V4SF, TF)
  DEF_FUNCTION_TYPE_ALIAS (V4SI_FTYPE_V4SI_V4SI, TF)
  DEF_FUNCTION_TYPE_ALIAS (V8HI_FTYPE_V8HI_V8HI, TF)
 +
 +# MPX builtins
 +DEF_FUNCTION_TYPE (BND, PCVOID, ULONG)
 +DEF_FUNCTION_TYPE (VOID, PCVOID, BND)
 +DEF_FUNCTION_TYPE (VOID, PCVOID, BND, PCVOID)
 +DEF_FUNCTION_TYPE (BND, PCVOID, PCVOID)
 +DEF_FUNCTION_TYPE (BND, PCVOID)
 +DEF_FUNCTION_TYPE (BND, BND, BND)
 +DEF_FUNCTION_TYPE (PVOID, PVOID, PVOID, ULONG)
 +DEF_FUNCTION_TYPE (PVOID, PCVOID, BND, ULONG)
 +DEF_FUNCTION_TYPE (ULONG, VOID)
 +DEF_FUNCTION_TYPE (PVOID, BND)
 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
 index 888f5ad..ac79231 100644
 --- a/gcc/config/i386/i386.c
 +++ b/gcc/config/i386/i386.c
 @@ -81,6 +81,8 @@ along with GCC; see the file COPYING3.  If not see
  #include context.h
  #include pass_manager.h
  #include target-globals.h
 +#include tree-chkp.h
 +#include rtl-chkp.h

  static rtx legitimize_dllimport_symbol (rtx, bool);
  static rtx legitimize_pe_coff_extern_decl (rtx, bool);
 @@ -28723,6 +28725,19 @@ enum ix86_builtins
IX86_BUILTIN_XABORT,
IX86_BUILTIN_XTEST,

 +  /* MPX */
 +  IX86_BUILTIN_BNDMK,
 +  IX86_BUILTIN_BNDSTX,
 +  IX86_BUILTIN_BNDLDX,
 +  IX86_BUILTIN_BNDCL,
 +  IX86_BUILTIN_BNDCU,
 +  IX86_BUILTIN_BNDRET,
 +  IX86_BUILTIN_BNDNARROW,
 +  IX86_BUILTIN_BNDINT,
 +  IX86_BUILTIN_SIZEOF,
 +  IX86_BUILTIN_BNDLOWER,
 +  IX86_BUILTIN_BNDUPPER,
 +
/* BMI instructions.  */
IX86_BUILTIN_BEXTR32,
IX86_BUILTIN_BEXTR64,
 @@ -28796,6 +28811,8 @@ struct builtin_isa {
enum ix86_builtin_func_type tcode; /* type to use in the declaration */
HOST_WIDE_INT isa;   /* isa_flags this builtin is defined for */
bool const_p;/* true if the declaration is 
 constant */
 +  bool leaf_p; /* true if the declaration has leaf attribute 
 */
 +  bool nothrow_p;  /* true if the declaration has nothrow 
 attribute */
bool 

Re: [PATCH, i386, Pointer Bounds Checker 33/x] MPX ABI

2014-09-15 Thread Ilya Enkovich
Ping

2014-06-11 18:03 GMT+04:00 Ilya Enkovich enkovich@gmail.com:
 Hi,

 This patch adds MPX ABI support for i386 target.

 Bootstrapped and tested on linux-x86_64.

 Thanks,
 Ilya
 --
 gcc/

 2014-06-11  Ilya Enkovich  ilya.enkov...@intel.com

 * config/i386/i386.c (ix86_option_override_internal): Do not
 support x32 with MPX.
 is not available.
 (init_cumulative_args): Init stdarg, bnd_regno, bnds_in_bt
 and force_bnd_pass.
 (function_arg_advance_32): Return number of used integer
 registers.
 (function_arg_advance_64): Likewise.
 (function_arg_advance_ms_64): Likewise.
 (ix86_function_arg_advance): Handle pointer bounds.
 (ix86_function_arg): Likewise.
 (ix86_function_value_regno_p): Mark fisrt bounds registers as
 possible function value.
 (ix86_function_value_1): Handle pointer bounds type/mode
 (ix86_return_in_memory): Likewise.
 (ix86_print_operand): Analyse insn to decide abounfbnd prefix.
 (ix86_expand_call): Generate returned bounds.
 (ix86_bnd_prefixed_insn_p): Check if we have instrumented call
 or function.
 * config/i386/i386.h (ix86_args): Add bnd_regno, bnds_in_bt,
 force_bnd_pass and stdarg fields.
 * config/i386/i386.md (UNSPEC_BNDRET): New.
 (*call_value): Add returned bounds.
 (*sibcall_value): Likewise.
 (*call_value_rex64_ms_sysv): Likewise.
 (*call_value_pop): Likewise.
 (*sibcall_value_pop): Likewise.
 * config/i386/predicates.md (call_rex64_ms_sysv_operation): Adjust
 to changed call patterns.


 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
 index dac83d0..a67e6e7 100644
 --- a/gcc/config/i386/i386.c
 +++ b/gcc/config/i386/i386.c
 @@ -3693,6 +3693,9 @@ ix86_option_override_internal (bool main_args_p,
if (TARGET_X32  (opts-x_ix86_isa_flags  OPTION_MASK_ISA_MPX))
  error (Intel MPX does not support x32);

 +  if (TARGET_X32  (ix86_isa_flags  OPTION_MASK_ISA_MPX))
 +error (Intel MPX does not support x32);
 +
if (!strcmp (opts-x_ix86_arch_string, generic))
  error (generic CPU can be used only for %stune=%s %s,
prefix, suffix, sw);
 @@ -6170,10 +6173,15 @@ init_cumulative_args (CUMULATIVE_ARGS *cum,  /* 
 Argument info to initialize */
   FIXME: once typesytem is fixed, we won't need this code anymore.  */
if (i  i-local  i-can_change_signature)
  fntype = TREE_TYPE (fndecl);
 +  cum-stdarg = fntype ? stdarg_p (fntype) : false;
cum-maybe_vaarg = (fntype
   ? (!prototype_p (fntype) || stdarg_p (fntype))
   : !libname);

 +  cum-bnd_regno = FIRST_BND_REG;
 +  cum-bnds_in_bt = 0;
 +  cum-force_bnd_pass = 0;
 +
if (!TARGET_64BIT)
  {
/* If there are variable arguments, then we won't pass anything
 @@ -7108,11 +7116,13 @@ construct_container (enum machine_mode mode, enum 
 machine_mode orig_mode,
 and data type TYPE.  (TYPE is null for libcalls where that information
 may not be available.)  */

 -static void
 +static int
  function_arg_advance_32 (CUMULATIVE_ARGS *cum, enum machine_mode mode,
  const_tree type, HOST_WIDE_INT bytes,
  HOST_WIDE_INT words)
  {
 +  int res = 0;
 +
switch (mode)
  {
  default:
 @@ -7130,7 +7140,8 @@ function_arg_advance_32 (CUMULATIVE_ARGS *cum, enum 
 machine_mode mode,
cum-words += words;
cum-nregs -= words;
cum-regno += words;
 -
 +  if (cum-nregs = 0)
 +   res = words;
if (cum-nregs = 0)
 {
   cum-nregs = 0;
 @@ -7201,36 +7212,42 @@ function_arg_advance_32 (CUMULATIVE_ARGS *cum, enum 
 machine_mode mode,
 }
break;
  }
 +
 +  return res;
  }

 -static void
 +static int
  function_arg_advance_64 (CUMULATIVE_ARGS *cum, enum machine_mode mode,
  const_tree type, HOST_WIDE_INT words, bool named)
  {
 -  int int_nregs, sse_nregs;
 +  int int_nregs, sse_nregs, exam;

/* Unnamed 512 and 256bit vector mode parameters are passed on stack.  */
if (!named  (VALID_AVX512F_REG_MODE (mode)
  || VALID_AVX256_REG_MODE (mode)))
 -return;
 +return 0;
 +
 +  exam = examine_argument (mode, type, 0, int_nregs, sse_nregs);

 -  if (examine_argument (mode, type, 0, int_nregs, sse_nregs)
 +  if (exam
 sse_nregs = cum-sse_nregs  int_nregs = cum-nregs)
  {
cum-nregs -= int_nregs;
cum-sse_nregs -= sse_nregs;
cum-regno += int_nregs;
cum-sse_regno += sse_nregs;
 +  return int_nregs;
  }
else
  {
int align = ix86_function_arg_boundary (mode, type) / BITS_PER_WORD;
cum-words = (cum-words + align - 1)  ~(align - 1);
cum-words += words;
 +  return 0;
  }
  }

 -static void
 +static int
  function_arg_advance_ms_64 (CUMULATIVE_ARGS *cum, HOST_WIDE_INT 

Re: [PATCH, i386, Pointer Bounds Checker 30/x] Size relocation

2014-09-15 Thread Ilya Enkovich
Ping

2014-06-11 12:56 GMT+04:00 Ilya Enkovich enkovich@gmail.com:
 Hi,

 This patch adds size relocation support for i386 target.  Relocation is used 
 to compute bounds for static objects with incomplete type.

 Thanks,
 Ilya
 --
 gcc/

 2014-06-11  Ilya Enkovich  ilya.enkov...@intel.com

 * config/i386/i386.md (UNSPEC_SIZEOF): New.
 (move_size_reloc_si): New.
 (move_size_reloc_di): New.
 * config/i386/predicates.md (symbol_operand): New.


 diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
 index 32db2c6..5fd556b 100644
 --- a/gcc/config/i386/i386.md
 +++ b/gcc/config/i386/i386.md
 @@ -79,6 +79,7 @@
UNSPEC_PLTOFF
UNSPEC_MACHOPIC_OFFSET
UNSPEC_PCREL
 +  UNSPEC_SIZEOF

;; Prologue support
UNSPEC_STACK_ALLOC
 @@ -18340,6 +18341,32 @@
bndstx\t{%2, %3|%3, %2}
[(set_attr type mpxst)])

 +(define_insn move_size_reloc_si
 +  [(set (match_operand:SI 0 register_operand =r)
 +   (unspec:SI
 +[(match_operand:SI 1 symbol_operand)]
 +UNSPEC_SIZEOF))]
 +  TARGET_MPX
 +  mov{l}\t{%1@SIZE, %0|%0, %1@SIZE}
 +  [(set_attr type imov)
 +   (set_attr mode SI)])
 +
 +(define_insn move_size_reloc_di
 +  [(set (match_operand:DI 0 register_operand =r)
 +   (unspec:DI
 +[(match_operand:DI 1 symbol_operand)]
 +UNSPEC_SIZEOF))]
 +  TARGET_64BIT  TARGET_MPX
 +{
 +  if (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE
 +  || ix86_cmodel == CM_MEDIUM_PIC || ix86_cmodel == CM_LARGE_PIC)
 +return movabs{q}\t{%1@SIZE, %0|%0, %1@SIZE};
 +  else
 +return mov{l}\t{%1@SIZE, %k0|%k0, %1@SIZE};
 +}
 +  [(set_attr type imov)
 +   (set_attr mode DI)])
 +
  (include mmx.md)
  (include sse.md)
  (include sync.md)
 diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
 index a738033..e4c5d21 100644
 --- a/gcc/config/i386/predicates.md
 +++ b/gcc/config/i386/predicates.md
 @@ -119,6 +119,10 @@
 (match_test TARGET_64BIT)
 (match_test REGNO (op)  BX_REG)))

 +;; Return true if VALUE is symbol reference
 +(define_predicate symbol_operand
 +  (match_code symbol_ref))
 +
  ;; Return true if VALUE can be stored in a sign extended immediate field.
  (define_predicate x86_64_immediate_operand
(match_code const_int,symbol_ref,label_ref,const)


Re: [PATCH, i386, Pointer Bounds Checker 18/x] Expand instrumented builtin function calls

2014-09-15 Thread Ilya Enkovich
Ping

2014-06-06 13:32 GMT+04:00 Ilya Enkovich enkovich@gmail.com:
 2014-06-03 12:46 GMT+04:00 Richard Biener richard.guent...@gmail.com:
 On Mon, Jun 2, 2014 at 4:51 PM, Ilya Enkovich enkovich@gmail.com wrote:
 Hi,

 This patch adds support for normal builtin function calls (target ones are 
 not instrumented).  The basic idea of the patch is to make call expr copy 
 with no bounds and expand it instead.  If expr is going to be emitted as a 
 function call then original instrumented expr takes place.  Handle string 
 function separately because they are of high interest for the checker.

 It seems to be this should be user-controllable (always expand builtins with
 bounds as calls, or not), rather than deciding what is of interest yourself.

 User has no idea what can be transformed into a builtin call. He may
 pragmas in his source code to control instrumentation. Compiler just
 tries to cover as much code as it can but reasonable compromise with
 performance should be made.


 From a high-level perspective the expansion path doing inline expansion
 should be separated from that expanding as a call (or expanding as a
 different call).  I don't like that building of yet another GENERIC call expr
 in this code ... it goes very much backwards of the idea that we should
 expand from the GIMPLE representation.  You are making such transition
 even harder.

 Can't you do that frobbing from cfgexpand.c:expand_call_stmt instead 
 (please!)?

 I need both instrumented and not instrumented versions of call in
 expand_builtin, so I do not see how it may be handled in
 expand_call_stmt.

 Ilya

 Thanks,
 Richard.

 Bootstrapped and tested on linux-x86_64.

 Thanks,
 Ilya
 --
 gcc/

 2014-06-02  Ilya Enkovich  ilya.enkov...@intel.com

 * builtins.c: Include rtl-chkp.h, tree-chkp.h.
 (expand_builtin_mempcpy_args): Add orig exp as argument.
 Support BUILT_IN_CHKP_MEMPCPY_NOBND_NOCHK.
 (expand_builtin_mempcpy): Adjust expand_builtin_mempcpy_args call.
 (expand_builtin_stpcpy): Likewise.
 (expand_builtin_memset_args): Support 
 BUILT_IN_CHKP_MEMSET_NOBND_NOCHK.
 (std_expand_builtin_va_start): Initialize bounds for va_list.
 (expand_builtin): Support instrumented calls.


 diff --git a/gcc/builtins.c b/gcc/builtins.c
 index 7357124..c0140e1 100644
 --- a/gcc/builtins.c
 +++ b/gcc/builtins.c
 @@ -59,6 +59,8 @@ along with GCC; see the file COPYING3.  If not see
  #include builtins.h
  #include ubsan.h
  #include cilk.h
 +#include tree-chkp.h
 +#include rtl-chkp.h


  static tree do_mpc_arg1 (tree, tree, int (*)(mpc_ptr, mpc_srcptr, 
 mpc_rnd_t));
 @@ -124,7 +126,7 @@ static rtx builtin_memcpy_read_str (void *, 
 HOST_WIDE_INT, enum machine_mode);
  static rtx expand_builtin_memcpy (tree, rtx);
  static rtx expand_builtin_mempcpy (tree, rtx, enum machine_mode);
  static rtx expand_builtin_mempcpy_args (tree, tree, tree, rtx,
 -   enum machine_mode, int);
 +   enum machine_mode, int, tree);
  static rtx expand_builtin_strcpy (tree, rtx);
  static rtx expand_builtin_strcpy_args (tree, tree, rtx);
  static rtx expand_builtin_stpcpy (tree, rtx, enum machine_mode);
 @@ -3284,7 +3286,8 @@ expand_builtin_mempcpy (tree exp, rtx target, enum 
 machine_mode mode)
tree src = CALL_EXPR_ARG (exp, 1);
tree len = CALL_EXPR_ARG (exp, 2);
return expand_builtin_mempcpy_args (dest, src, len,
 - target, mode, /*endp=*/ 1);
 + target, mode, /*endp=*/ 1,
 + exp);
  }
  }

 @@ -3296,10 +3299,23 @@ expand_builtin_mempcpy (tree exp, rtx target, enum 
 machine_mode mode)

  static rtx
  expand_builtin_mempcpy_args (tree dest, tree src, tree len,
 -rtx target, enum machine_mode mode, int endp)
 +rtx target, enum machine_mode mode, int endp,
 +tree orig_exp)
  {
 +  tree fndecl = get_callee_fndecl (orig_exp);
 +
  /* If return value is ignored, transform mempcpy into memcpy.  */
 -  if (target == const0_rtx  builtin_decl_implicit_p (BUILT_IN_MEMCPY))
 +  if (target == const0_rtx
 +   DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CHKP_MEMPCPY_NOBND_NOCHK
 +   builtin_decl_implicit_p (BUILT_IN_CHKP_MEMCPY_NOBND_NOCHK))
 +{
 +  tree fn = builtin_decl_implicit (BUILT_IN_CHKP_MEMCPY_NOBND_NOCHK);
 +  tree result = build_call_nofold_loc (UNKNOWN_LOCATION, fn, 3,
 +  dest, src, len);
 +  return expand_expr (result, target, mode, EXPAND_NORMAL);
 +}
 +  else if (target == const0_rtx
 +   builtin_decl_implicit_p (BUILT_IN_MEMCPY))
  {
tree fn = builtin_decl_implicit (BUILT_IN_MEMCPY);
tree result = build_call_nofold_loc (UNKNOWN_LOCATION, fn, 3,
 @@ -3484,7 +3500,8 @@ expand_builtin_stpcpy (tree 

Re: [PATCH, Pointer Bounds Checker 25/x] DCE

2014-09-15 Thread Ilya Enkovich
Ping

2014-06-06 11:00 GMT+04:00 Ilya Enkovich enkovich@gmail.com:
 On 03 Jun 17:27, Ilya Enkovich wrote:
 2014-06-03 15:56 GMT+04:00 Richard Biener richard.guent...@gmail.com:
  On Tue, Jun 3, 2014 at 1:36 PM, Ilya Enkovich enkovich@gmail.com 
  wrote:
  2014-06-03 13:45 GMT+04:00 Richard Biener richard.guent...@gmail.com:
  On Tue, Jun 3, 2014 at 9:23 AM, Ilya Enkovich enkovich@gmail.com 
  wrote:
  Hi,
 
  This patch adjusts alloc-free removal algorithm in DCE to take into 
  account BUILT_IN_CHKP_BNDRET call returning bounds of allocated memory.
 
  Bootstrapped and tested on linux-x86_64.
 
  Thanks,
  Ilya
  --
  gcc/
 
  2014-06-03  Ilya Enkovich  ilya.enkov...@intel.com
 
  * tree-ssa-dce.c: Include target.h.
  (propagate_necessity): For free call fed by alloc check
  bounds are also provided by the same alloc.
  (eliminate_unnecessary_stmts): Handle BUILT_IN_CHKP_BNDRET
  used by free calls.
 
  diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
  index 13a71ce..59a0b71 100644
  --- a/gcc/tree-ssa-dce.c
  +++ b/gcc/tree-ssa-dce.c
  @@ -73,6 +73,7 @@ along with GCC; see the file COPYING3.  If not see
   #include flags.h
   #include cfgloop.h
   #include tree-scalar-evolution.h
  +#include target.h
 
   static struct stmt_stats
   {
  @@ -778,7 +779,23 @@ propagate_necessity (bool aggressive)
 DECL_BUILT_IN_CLASS (def_callee) == BUILT_IN_NORMAL
 (DECL_FUNCTION_CODE (def_callee) == BUILT_IN_MALLOC
|| DECL_FUNCTION_CODE (def_callee) == 
  BUILT_IN_CALLOC))
  -   continue;
  +   {
  + tree retfndecl
  +   = targetm.builtin_chkp_function 
  (BUILT_IN_CHKP_BNDRET);
  + gimple bounds_def_stmt;
  + tree bounds;
  +
  + /* For instrumented calls we should also check used
  +bounds are returned by the same allocation call.  
  */
  + if (!gimple_call_with_bounds_p (stmt)
  + || ((bounds = gimple_call_arg (stmt, 1))
 
  Please provide an abstraction for this - I seem to recall seeing multiple
  (variants) of this.  Esp. repeated calls to the target hook above look
  expensive to me (generally it will not be needed).
 
  I'd like to see gimple_call_bndarg (stmt) to get rid of the magic 1 
  and I'd
  like to see sth similar to gimple_call_builtin_p, for example
  gimple_call_chkp_p (stmt, BUILT_IN_CHKP_BNDRET) doing the
  target hook invocation and the fndecl check.
 
  I do not see how to get rid of constant in gimple_call_arg call here.
  What semantics does proposed gimple_call_bndarg have? It has to return
  the first bounds arg but it's not clear from its name and function
  seems to be very specialized.
 
  Ah, ok.  I see now, so the code is ok as-is.
 
 
  +  TREE_CODE (bounds) == SSA_NAME
 
  What about constant bounds?  That shouldn't make the call necessary 
  either?
 
  Yep, it would be useless.
 
  So please fix.
 
 
  +  (bounds_def_stmt = SSA_NAME_DEF_STMT 
  (bounds))
  +  is_gimple_call (bounds_def_stmt)
  +  gimple_call_fndecl (bounds_def_stmt) == 
  retfndecl
  +  gimple_call_arg (bounds_def_stmt, 0) == 
  ptr))
  +   continue;
 
  So this all becomes
 
 if (!gimple_call_with_bounds_p (stmt)
 || ((bounds = gimple_call_bndarg (stmt))
  TREE_CODE (bounds) == SSA_NAME
  (bounds_def_stmt = SSA_NAME_DEF_STMT 
  (bounds))
  is_gimple_call (bounds_def_stmt)
  gimple_call_chkp_p (bounds_def_stmt,
  BUILT_IN_CHKP_BNDRET)
  ...
 
  btw, I wonder how BUILT_IN_CHKP_BNDRET is in scope here but you
  need a target hook to compare the fndecl?  Why isn't it enough to
  just check DECL_FUNCTION_CODE and DECL_BUILT_IN?
 
  Call is required because builtins for Pointer Bounds Checker are
  provided by target depending on available features. That is why
  gimple_call_builtin_p is not used. I may add new interface function
  into tree-chkp.h as you propose (e.g. chkp_gimple_call_builtin_p). But
  I do not see how it may speed-up the code. New function would still
  need to switch by function code and compare with proper decl which is
  basically what we have with target hook.
 
  I don't understand - does this mean the builtin calls are in the GIMPLE
  IL even though the target doesn't have the feature?  Isn't the presence
  of the call enough?

 Call is generated using function decl provided by target. Therefore we
 do not know its code and has to compare using fndecl comparison.

 
  It is possible to make faster if use the fact that all chkp builtins
  codes (normal, not target ones) are consequent. Then we may just check
  

Re: [PATCH, Pointer Bounds Checker 26/x] CCP

2014-09-15 Thread Ilya Enkovich
Ping

2014-06-06 11:02 GMT+04:00 Ilya Enkovich enkovich@gmail.com:
 On 03 Jun 11:54, Richard Biener wrote:
 On Tue, Jun 3, 2014 at 9:38 AM, Ilya Enkovich enkovich@gmail.com wrote:
  Hi,
 
  This patch allows BUILT_IN_CHKP_BNDRET as a consumer of a result of 
  BUILT_IN_STACK_SAVE call.
 
  Bootstrapped and tested on linux-x86_64.
 
  Thanks,
  Ilya
  --
  gcc/
 
  2014-06-03  Ilya Enkovich  ilya.enkov...@intel.com
 
  * tree-ssa-ccp.c (insert_clobber_before_stack_restore): Handle
  BUILT_IN_CHKP_BNDRET calls.
 
 
  diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
  index eeefeaf..c138337 100644
  --- a/gcc/tree-ssa-ccp.c
  +++ b/gcc/tree-ssa-ccp.c
  @@ -1848,7 +1848,7 @@ insert_clobber_before_stack_restore (tree saved_val, 
  tree var,
   gimple_htab *visited)
   {
 gimple stmt, clobber_stmt;
  -  tree clobber;
  +  tree clobber, fndecl;
 imm_use_iterator iter;
 gimple_stmt_iterator i;
 gimple *slot;
  @@ -1880,6 +1880,10 @@ insert_clobber_before_stack_restore (tree 
  saved_val, tree var,
   else if (gimple_assign_ssa_name_copy_p (stmt))
 insert_clobber_before_stack_restore (gimple_assign_lhs (stmt), var,
 visited);
  +else if (gimple_code (stmt) == GIMPLE_CALL
  + (fndecl = targetm.builtin_chkp_function 
  (BUILT_IN_CHKP_BNDRET))
  + gimple_call_fndecl (stmt) == fndecl)
  +  continue;

 Please change this to use the proper abstraction once implemented.  It should
 be sth like

 else if (is_gimple_call (stmt)
 gimple_call_builtin_p (stmt, BUILT_IN_CHKP_BNDRET))
continue;

 I assume now that the builtins are not target builtins but added to
 builtins.def.

 Richard.

   else
 gcc_assert (is_gimple_debug (stmt));
   }

 Here is a fixed version with proper predicate.

 Bootstrapped and tested on linux_x86-64.

 Thanks,
 Ilya
 --
 gcc/

 2014-06-05  Ilya Enkovich  ilya.enkov...@intel.com

 * tree-ssa-ccp.c: Include tree-chkp.h.
 (insert_clobber_before_stack_restore): Handle
 BUILT_IN_CHKP_BNDRET calls.


 diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
 index eeefeaf..e99bcf5 100644
 --- a/gcc/tree-ssa-ccp.c
 +++ b/gcc/tree-ssa-ccp.c
 @@ -144,6 +144,7 @@ along with GCC; see the file COPYING3.  If not see
  #include diagnostic-core.h
  #include dbgcnt.h
  #include params.h
 +#include tree-chkp.h


  /* Possible lattice values.  */
 @@ -1880,6 +1881,9 @@ insert_clobber_before_stack_restore (tree saved_val, 
 tree var,
  else if (gimple_assign_ssa_name_copy_p (stmt))
insert_clobber_before_stack_restore (gimple_assign_lhs (stmt), var,
visited);
 +else if (gimple_code (stmt) == GIMPLE_CALL
 + chkp_gimple_call_builtin_p (stmt, BUILT_IN_CHKP_BNDRET))
 +  continue;
  else
gcc_assert (is_gimple_debug (stmt));
  }


Re: [PATCH, Pointer Bounds Checker 19/x] Support bounds in expand

2014-09-15 Thread Ilya Enkovich
Ping

2014-06-05 18:46 GMT+04:00 Ilya Enkovich enkovich@gmail.com:
 On 04 Jun 16:36, Michael Matz wrote:
 Hi,

 On Mon, 2 Jun 2014, Ilya Enkovich wrote:

   There is exactly one place (except for the self-recursive ones) where
   you call the new store_expr with a non-null argument for bounds
   target, and it seems to be only necessary for when some sub-expression
   of the RHS is a call.  Can you somehow arrange to move that handling
   to the single place in expand_assignment() so that you don't need to
   change the signature of store_expr?
 
  I see the only nice way to do it - store_expr should return bounds of
  expanded exp. Currently it always return NULL_RTX. Does it look better
  than a new argument?

 IMHO it does.  That or introducing a new store_expr_with_bounds (with the
 new argument) and letting store_expr be a wrapper for that, passing the
 NULL.  Basically anything that avoids adding a new parameter for most of
 the existing calls to store_expr.


 Ciao,
 Michael.

 Here is an updated version using store_expr_with_bounds and store_expr as a 
 wrapper for it.

 Bootstrapped and tested on linux-x86_64.

 Thanks,
 Ilya
 --
 gcc/

 2014-06-05  Ilya Enkovich  ilya.enkov...@intel.com

 * calls.c: Include tree-chkp.h, rtl-chkp.h, bitmap.h.
 (arg_data): Add fields special_slot, pointer_arg and
 pointer_offset.
 (store_bounds): New.
 (emit_call_1): Propagate instrumentation flag for CALL.
 (initialize_argument_information): Compute pointer_arg,
 pointer_offset and special_slot for pointer bounds arguments.
 (finalize_must_preallocate): Preallocate when storing bounds
 in bounds table.
 (compute_argument_addresses): Skip pointer bounds.
 (expand_call): Store bounds into tables separately.  Return
 result joined with resulting bounds.
 * cfgexpand.c: Include tree-chkp.h, rtl-chkp.h.
 (expand_call_stmt): Propagate bounds flag for CALL_EXPR.
 (expand_return): Add returned bounds arg.  Handle returned bounds.
 (expand_gimple_stmt_1): Adjust to new expand_return signature.
 (gimple_expand_cfg): Reset rtx bounds map.
 * expr.c: Include tree-chkp.h, rtl-chkp.h.
 (expand_assignment): Handle returned bounds.
 (store_expr_with_bounds): New.  Replaces store_expr with new bounds
 target argument.  Handle bounds returned by calls.
 (store_expr): Now wraps store_expr_with_bounds.
 * expr.h (store_expr_with_bounds): New.
 * function.c: Include tree-chkp.h, rtl-chkp.h.
 (bounds_parm_data): New.
 (use_register_for_decl): Do not registerize decls used for bounds
 stores and loads.
 (assign_parms_augmented_arg_list): Add bounds of the result
 structure pointer as the second argument.
 (assign_parm_find_entry_rtl): Mark bounds are never passed on
 the stack.
 (assign_parm_is_stack_parm): Likewise.
 (assign_parm_load_bounds): New.
 (assign_bounds): New.
 (assign_parms): Load bounds and determine a location for
 returned bounds.
 (diddle_return_value_1): New.
 (diddle_return_value): Handle returned bounds.
 * function.h (rtl_data): Add field for returned bounds.


 diff --git a/gcc/calls.c b/gcc/calls.c
 index e1dc8eb..5fbbe9f 100644
 --- a/gcc/calls.c
 +++ b/gcc/calls.c
 @@ -44,11 +44,14 @@ along with GCC; see the file COPYING3.  If not see
  #include tm_p.h
  #include timevar.h
  #include sbitmap.h
 +#include bitmap.h
  #include langhooks.h
  #include target.h
  #include cgraph.h
  #include except.h
  #include dbgcnt.h
 +#include tree-chkp.h
 +#include rtl-chkp.h

  /* Like PREFERRED_STACK_BOUNDARY but in units of bytes, not bits.  */
  #define STACK_BYTES (PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT)
 @@ -76,6 +79,15 @@ struct arg_data
/* If REG is a PARALLEL, this is a copy of VALUE pulled into the correct
   form for emit_group_move.  */
rtx parallel_value;
 +  /* If value is passed in neither reg nor stack, this field holds a number
 + of a special slot to be used.  */
 +  rtx special_slot;
 +  /* For pointer bounds hold an index of parm bounds are bound to.  -1 if
 + there is no such pointer.  */
 +  int pointer_arg;
 +  /* If pointer_arg refers a structure, then pointer_offset holds an offset
 + of a pointer in this structure.  */
 +  int pointer_offset;
/* If REG was promoted from the actual mode of the argument expression,
   indicates whether the promotion is sign- or zero-extended.  */
int unsignedp;
 @@ -133,6 +145,7 @@ static void emit_call_1 (rtx, tree, tree, tree, 
 HOST_WIDE_INT, HOST_WIDE_INT,
  HOST_WIDE_INT, rtx, rtx, int, rtx, int,
  cumulative_args_t);
  static void precompute_register_parameters (int, struct arg_data *, int *);
 +static void store_bounds (struct arg_data *, struct arg_data *);
  static int 

Re: [PATCH, Pointer Bounds Checker 22/x] Inline

2014-09-15 Thread Ilya Enkovich
Ping

2014-08-18 19:35 GMT+04:00 Ilya Enkovich enkovich@gmail.com:
 On 06 Jun 11:59, Ilya Enkovich wrote:
 2014-06-03 13:07 GMT+04:00 Richard Biener richard.guent...@gmail.com:
  On Mon, Jun 2, 2014 at 5:56 PM, Ilya Enkovich enkovich@gmail.com 
  wrote:
  +
  +  /* If indirect call has following BUILT_IN_CHKP_BNDRET
  +call then we need to make it's copy for the direct
  +call.  */
  +  if (iretbnd_stmt)
  +   {
  + if (gimple_call_lhs (iretbnd_stmt))
  +   {
  + gimple copy;
  +
  + gimple_set_vdef (iretbnd_stmt, NULL_TREE);
  + gimple_set_vuse (iretbnd_stmt, NULL_TREE);
  + update_stmt (iretbnd_stmt);
 
  This looks bogus - what are you trying to workaround?

 I did not try to workaround something. I just looked at how this
 function makes a copy for a call and repeated the process for retbnd
 call.

 
  Richard.
 
  + result = gimple_call_lhs (iretbnd_stmt);
  + phi = create_phi_node (result, join_bb);
  +
  + copy = gimple_copy (iretbnd_stmt);
  + gimple_call_set_arg (copy, 0,
  +  gimple_call_lhs (dcall_stmt));
  + gimple_call_set_lhs (copy, duplicate_ssa_name (result, 
  copy));
  + gsi_insert_on_edge (e_dj, copy);
  + add_phi_arg (phi, gimple_call_lhs (copy),
  +  e_dj, UNKNOWN_LOCATION);
  +
  + gimple_call_set_arg (iretbnd_stmt, 0,
  +  gimple_call_lhs (icall_stmt));
  + gimple_call_set_lhs (iretbnd_stmt,
  +  duplicate_ssa_name (result, 
  iretbnd_stmt));
  + psi = gsi_for_stmt (iretbnd_stmt);
  + gsi_remove (psi, false);
  + gsi_insert_on_edge (e_ij, iretbnd_stmt);
  + add_phi_arg (phi, gimple_call_lhs (iretbnd_stmt),
  +  e_ij, UNKNOWN_LOCATION);
  +
  + gsi_commit_edge_inserts ();
 
  Are you sure this is a good idea?  IMNSHO you should be using
  either gsi_commit_one_edge_insert or be using gsi_insert_on_edge_immediate.

 Will replace it with a couple of gsi_commit_one_edge_insert.

 Thanks,
 Ilya
 
  Richard.
 
 

 Here is an updated version.

 Thanks,
 Ilya
 --
 2014-08-15  Ilya Enkovich  ilya.enkov...@intel.com

 * ipa-inline.c (early_inliner): Check edge has summary allocated.
 * tree-inline.c: Include tree-chkp.h.
 (declare_return_variable): Add arg holding
 returned bounds slot.  Create and initialize returned bounds var.
 (remap_gimple_stmt): Handle returned bounds.
 Return sequence of statements instead of a single statement.
 (insert_init_stmt): Add declaration.
 (remap_gimple_seq): Adjust to new remap_gimple_stmt signature.
 (copy_bb): Adjust to changed return type of remap_gimple_stmt.
 (expand_call_inline): Handle returned bounds.  Add bounds copy
 for generated mem to mem assignments.
 * tree-inline.h (copy_body_data): Add fields retbnd and
 assign_stmts.
 * cgraph.c: Include tree-chkp.h.
 (cgraph_redirect_edge_call_stmt_to_callee): Support
 returned bounds.
 * value-prof.c: Include tree-chkp.h.
 (gimple_ic): Support returned bounds.


 diff --git a/gcc/cgraph.c b/gcc/cgraph.c
 index 0dfcce2..dcd54a6 100644
 --- a/gcc/cgraph.c
 +++ b/gcc/cgraph.c
 @@ -1394,6 +1394,33 @@ cgraph_redirect_edge_call_stmt_to_callee (struct 
 cgraph_edge *e)
   e-speculative = false;
   e-caller-set_call_stmt_including_clones (e-call_stmt, new_stmt,
  false);
 +
 + /* Fix edges for BUILT_IN_CHKP_BNDRET calls attached to the
 +processed call stmt.  */
 + if (gimple_call_with_bounds_p (new_stmt)
 +  gimple_call_lhs (new_stmt)
 +  chkp_retbnd_call_by_val (gimple_call_lhs (e2-call_stmt)))
 +   {
 + tree dresult = gimple_call_lhs (new_stmt);
 + tree iresult = gimple_call_lhs (e2-call_stmt);
 + gimple dbndret = chkp_retbnd_call_by_val (dresult);
 + gimple ibndret = chkp_retbnd_call_by_val (iresult);
 + struct cgraph_edge *iedge
 +   = e2-caller-cgraph_node::get_edge (ibndret);
 + struct cgraph_edge *dedge;
 +
 + if (dbndret)
 +   {
 + dedge = iedge-caller-create_edge (iedge-callee,
 + dbndret, e-count,
 + e-frequency);
 + dedge-frequency = compute_call_stmt_bb_frequency
 +   (dedge-caller-decl, gimple_bb (dedge-call_stmt));
 +   }
 + iedge-frequency = compute_call_stmt_bb_frequency
 +   (iedge-caller-decl, gimple_bb (iedge-call_stmt));
 +

Re: [patch i386]: Sibcall tail-call improvement and partial fix PR/60104

2014-09-15 Thread Mike Stump
On Sep 14, 2014, at 5:43 PM, Segher Boessenkool seg...@kernel.crashing.org 
wrote:
 On Sun, Sep 14, 2014 at 02:38:45PM -0700, Mike Stump wrote:
 +  SIBLING_CALL_P (tmp) = 1;
 +  SIBLING_CALL_P (tmp) = 1;
 
 The second time is to make sure?  :-)

No, just a last minute cut and paste…  I’ll remove it.

Re: Stream ODR types

2014-09-15 Thread Richard Biener
On Fri, 12 Sep 2014, Jan Hubicka wrote:

   For ODR warnings and TBAA I think i want other types, too.  But yep, we 
   need to handle
   gracefuly component types that does not have names and we could drop 
   names of types
   and handle them as component types as it seems fit.
   
   OK, so if you agree, I will go ahead with this patch and we can resolve 
   these details
   incrementally.
  
  Yes, but please disable !record type handing for now.
 Bugzilla already has case where we report useful warning about union. I 
 suppose
 but unions and arrays would also make sense.  I will test patch limiting for
 records for now and lets see how much difference it makes (real world warnings
 I saw was all class types IMO)
 
 The confused uint8 warning was my local hack in the - if warning happened on
 component type I went into type it was constructed from. The anonymous arrays
 indeed have different size.  Mainline just reports type difference without
 giving reason and while analyzing strange reports on libreoffice I added this
 hoping to get extra info. I suppose I should extent warning of type mismatch
 to be able to report array size difference.
 
 Note that uint8 mangling is same as char's (i.e. typedefs do not matter). So
 stremaing those should not be terribly expensive, but we can probably just
 establish equivalency by main variant as these ought to be reliably merged?

They are not merged if they have different name.

Richard.


Re: [PATCH, Pointer Bounds Checker 9/x] Cgraph extension

2014-09-15 Thread Ilya Enkovich
On 03 Sep 13:32, Jeff Law wrote:
 On 07/24/14 03:59, Ilya Enkovich wrote:
 --
 2014-07-24  Ilya Enkovich  ilya.enkov...@intel.com
 
  * cgraph.h (cgraph_thunk_info): Add add_pointer_bounds_args
  field.
  (cgraph_node): Add instrumented_version, orig_decl and
  instrumentation_clone fields.
  (symtab_alias_target): Allow IPA_REF_CHKP reference.
  * cgraph.c (cgraph_remove_node): Fix instrumented_version
  of the referenced node if any.
  (dump_cgraph_node): Dump instrumentation_clone and
  instrumented_version fields.
  (verify_cgraph_node): Check correctness of IPA_REF_CHKP
  references and instrumentation thunks.
  * cgraphbuild.c (rebuild_cgraph_edges): Rebuild IPA_REF_CHKP
  reference.
  (cgraph_rebuild_references): Likewise.
  * cgraphunit.c (assemble_thunks_and_aliases): Skip thunks
  calling instrumneted function version.
  * ipa-ref.h (ipa_ref_use): Add IPA_REF_CHKP.
  (ipa_ref): increase size of use field.
  * ipa-ref.c (ipa_ref_use_name): Add element for IPA_REF_CHKP.
  * lto-cgraph.c (lto_output_node): Output instrumentation_clone,
  thunk.add_pointer_bounds_args and orig_decl field.
  (lto_output_ref): Adjust to new ipa_ref::use field size.
  (input_overwrite_node): Read instrumentation_clone field.
  (input_node): Read thunk.add_pointer_bounds_args and orig_decl
  fields.
  (input_ref): Adjust to new ipa_ref::use field size.
  (input_cgraph_1): Compute instrumented_version fields and restore
  IDENTIFIER_TRANSPARENT_ALIAS chains.
  * lto-streamer.h (LTO_minor_version): Change minor version from
  0 to 1.
  * ipa.c (symtab_remove_unreachable_nodes): Consider instrumented
  clone as address taken if the original one is address taken.
  (cgraph_externally_visible_p): Mark instrumented 'main' as
  externally visible.
  (function_and_variable_visibility): Filter instrumentation
  thunks.
 Thanks for adding the additional checking.
 
 
 @@ -513,6 +517,11 @@ cgraph_rebuild_references (void)
  ipa_record_stmt_references (node, gsi_stmt (gsi));
   }
 record_eh_tables (node, cfun);
 +
 +
 +  if (node-instrumented_version
 +   !node-instrumentation_clone)
 +ipa_record_reference (node, node-instrumented_version, IPA_REF_CHKP, 
 NULL);
   }
 Trivial nit here -- just one vertical space here.
 
 With that nit fixed, this is OK.
 
 jeff
 

Thanks for review!  Below is an updated version.  It also includes usage of 
syntab classes.  No functional changes added.

Thanks,
Ilya
--
2014-09-15  Ilya Enkovich  ilya.enkov...@intel.com

* cgraph.h (cgraph_thunk_info): Add add_pointer_bounds_args
field.
(cgraph_node): Add instrumented_version, orig_decl and
instrumentation_clone fields.
(symtab_node::get_alias_target): Allow IPA_REF_CHKP reference.
* cgraph.c (cgraph_node::remove): Fix instrumented_version
of the referenced node if any.
(cgraph_node::dump): Dump instrumentation_clone and
instrumented_version fields.
(cgraph_node::verify_node): Check correctness of IPA_REF_CHKP
references and instrumentation thunks.
* cgraphbuild.c (rebuild_cgraph_edges): Rebuild IPA_REF_CHKP
reference.
(cgraph_rebuild_references): Likewise.
* cgraphunit.c (assemble_thunks_and_aliases): Skip thunks
calling instrumneted function version.
* ipa-ref.h (ipa_ref_use): Add IPA_REF_CHKP.
(ipa_ref): increase size of use field.
* symtab.c (ipa_ref_use_name): Add element for IPA_REF_CHKP.
* lto-cgraph.c (lto_output_node): Output instrumentation_clone,
thunk.add_pointer_bounds_args and orig_decl field.
(lto_output_ref): Adjust to new ipa_ref::use field size.
(input_overwrite_node): Read instrumentation_clone field.
(input_node): Read thunk.add_pointer_bounds_args and orig_decl
fields.
(input_ref): Adjust to new ipa_ref::use field size.
(input_cgraph_1): Compute instrumented_version fields and restore
IDENTIFIER_TRANSPARENT_ALIAS chains.
* lto-streamer.h (LTO_minor_version): Change minor version from
0 to 1.
* ipa.c (symtab_remove_unreachable_nodes): Consider instrumented
clone as address taken if the original one is address taken.
* ipa-visibility.c (cgraph_externally_visible_p): Mark
instrumented 'main' as externally visible.
(function_and_variable_visibility): Filter instrumentation
thunks.


diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 5a0b903..d8fdda1 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -1823,6 +1823,12 @@ cgraph_node::remove (void)
 }
   cgraph_n_nodes--;
 
+  if (instrumented_version)
+{
+  instrumented_version-instrumented_version = NULL;
+  instrumented_version = NULL;
+}
+
   /* Clear out the node to NULL all pointers and add the node to the free
  list.  

Re: [PATCH, Pointer Bounds Checker 24/x] PRE

2014-09-15 Thread Ilya Enkovich
On 03 Sep 13:25, Jeff Law wrote:
 On 08/18/14 07:02, Ilya Enkovich wrote:
 On 03 Jun 11:33, Richard Biener wrote:
 On Tue, Jun 3, 2014 at 9:13 AM, Ilya Enkovich enkovich@gmail.com 
 wrote:
 Hi,
 
 This patch preserves CALL_WITH_BOUNDS flag for calls during PRE.
 
 Ok.
 
 Richard.
 
 
 Merging with the trunk I found that op2 field of vn_reference_op_struct is 
 now used to pass EH context for calls and there is no more free field to 
 store with_bounds flag.  So I added one.  Does it look OK?
 
 
 Thanks,
 Ilya
 --
 2014-08-14  Ilya Enkovich  ilya.enkov...@intel.com
 
  * tree-ssa-sccvn.h (vn_reference_op_struct): Transform opcode
  into bit field and add with_bounds field.
  * tree-ssa-sccvn.c (copy_reference_ops_from_call): Set
  with_bounds field for instrumented calls.
  * tree-ssa-pre.c (create_component_ref_by_pieces_1): Restore
  CALL_WITH_BOUNDS_P flag for calls.
 For consistency, make the bitfield 16 bits (see ipa-inline.h,
 tree-core.h and tree-ssa-sccvn.h.
 
 OK with that change.
 
 jeff
 

Thanks for your comments!  Below is a fixed version.

Ilya
--

2014-09-15  Ilya Enkovich  ilya.enkov...@intel.com

* tree-ssa-sccvn.h (vn_reference_op_struct): Transform opcode
into bit field and add with_bounds field.
* tree-ssa-sccvn.c (copy_reference_ops_from_call): Set
with_bounds field for instrumented calls.
* tree-ssa-pre.c (create_component_ref_by_pieces_1): Restore
CALL_WITH_BOUNDS_P flag for calls.


diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index 8b4d2ba..8d286c9 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -2581,6 +2581,8 @@ create_component_ref_by_pieces_1 (basic_block block, 
vn_reference_t ref,
   (TREE_CODE (fn) == FUNCTION_DECL
? build_fold_addr_expr (fn) : fn),
   nargs, args);
+   if (currop-with_bounds)
+ CALL_WITH_BOUNDS_P (folded) = true;
free (args);
if (sc)
  CALL_EXPR_STATIC_CHAIN (folded) = sc;
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index ec0bf6b..c6f749d 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -1149,6 +1149,8 @@ copy_reference_ops_from_call (gimple call,
   if (stmt_could_throw_p (call)  (lr = lookup_stmt_eh_lp (call))  0)
 temp.op2 = size_int (lr);
   temp.off = -1;
+  if (gimple_call_with_bounds_p (call))
+temp.with_bounds = 1;
   result-safe_push (temp);
 
   /* Copy the call arguments.  As they can be references as well,
diff --git a/gcc/tree-ssa-sccvn.h b/gcc/tree-ssa-sccvn.h
index 84ea278..5608e3a 100644
--- a/gcc/tree-ssa-sccvn.h
+++ b/gcc/tree-ssa-sccvn.h
@@ -80,7 +80,9 @@ typedef const struct vn_phi_s *const_vn_phi_t;
 
 typedef struct vn_reference_op_struct
 {
-  enum tree_code opcode;
+  ENUM_BITFIELD(tree_code) opcode : 16;
+  /* 1 for instrumented calls.  */
+  unsigned with_bounds : 1;
   /* Constant offset this op adds or -1 if it is variable.  */
   HOST_WIDE_INT off;
   tree type;


Re: [PATCH. libstdc++] Use the correct C++14 __cplusplus value (201402L). Added C++1z to the preprocessor.

2014-09-15 Thread Paolo Carlini

Hi again,

On 08/26/2014 10:54 AM, Paolo Carlini wrote:

Hi,

On 08/26/2014 10:52 AM, Jonathan Wakely wrote:

That seems like a good idea, but I'm not convinced there's any benefit
in Ed's changes to do:

-#if __cplusplus  201103L
+#if __cplusplus = 201402L

It seems like unnecessary churn to me,

about this, I had the same thought ;)
By the way, in case isn't already clear, it occurs to me that the kind 
of change proposed by Ed, thus standardize on __cplusplus = required 
version, will make more sense when the C++17 Standard will be closer. 
So far, since we can simply do everything with only 201103L, my idea too 
of adding _GLIBCXX_CXX11  co seems quite pointless.


Paolo.


Re: [PATCH 1/2] Always set DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT correctly

2014-09-15 Thread Richard Biener
On Fri, Sep 12, 2014 at 4:32 PM, Andi Kleen a...@firstfloor.org wrote:
 From: Andi Kleen a...@linux.intel.com

 When profiling is disabled force DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT
 for each function to one. This information is then preserved
 through LTO.

 With this patch for LTO builds -pg needs to be set on both the
 LTO final link and the original source build, to allow -pg
 (or -pg -fentry) to be active for that source file. This allows
 to build large projects mostly with -pg, except for a few files,
 and still use LTO.

 Originally suggested by Richard Biener
 Passes bootstrap and testing on x86_64-linux.

Ok with...

 gcc/:

 2014-09-11  Andi Kleen  a...@linux.intel.com

 * function.c (allocate_struct_function): Force
 DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT to zero when

to one.

Thanks,
Richard.

 profiling is disabled.
 ---
  gcc/function.c | 3 +++
  1 file changed, 3 insertions(+)

 diff --git a/gcc/function.c b/gcc/function.c
 index c8daf95..f07fdcf 100644
 --- a/gcc/function.c
 +++ b/gcc/function.c
 @@ -4555,6 +4555,9 @@ allocate_struct_function (tree fndecl, bool abstract_p)
   but is this worth the hassle?  */
cfun-can_throw_non_call_exceptions = flag_non_call_exceptions;
cfun-can_delete_dead_exceptions = flag_delete_dead_exceptions;
 +
 +  if (!profile_flag  !flag_instrument_function_entry_exit)
 +   DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (fndecl) = 1;
  }
  }

 --
 2.1.0



Re: [PATCH 2/2] Add some more test cases for fentry and pg

2014-09-15 Thread Richard Biener
On Fri, Sep 12, 2014 at 4:32 PM, Andi Kleen a...@firstfloor.org wrote:
 From: Andi Kleen a...@linux.intel.com

 Test fentry and no_instrument_function overriding.

 No test cases for the LTO test for now, as the LTO
 harness doesn't seem to support different flags for the final
 link.

Sure it does - via dg-extra-ld-options (you have to negate compile-time
opts to remove them).

Are you sure the tests are target independent enough?  That is,
'mcount' is really 'mcount' on all targets?

Ok.

Thanks,
Richard.

 gcc/testsuite/:

 2014-09-11  Andi Kleen  a...@linux.intel.com

 * gcc.dg/pg-override.c: New test.
 * gcc.dg/pg.c: New test.
 * gcc.target/i386/fentry-override.c: New test.
 * gcc.target/i386/fentry.c: New test.
 ---
  gcc/testsuite/gcc.dg/pg-override.c  | 18 ++
  gcc/testsuite/gcc.dg/pg.c   | 18 ++
  gcc/testsuite/gcc.target/i386/fentry-override.c | 18 ++
  gcc/testsuite/gcc.target/i386/fentry.c  | 18 ++
  4 files changed, 72 insertions(+)
  create mode 100644 gcc/testsuite/gcc.dg/pg-override.c
  create mode 100644 gcc/testsuite/gcc.dg/pg.c
  create mode 100644 gcc/testsuite/gcc.target/i386/fentry-override.c
  create mode 100644 gcc/testsuite/gcc.target/i386/fentry.c

 diff --git a/gcc/testsuite/gcc.dg/pg-override.c 
 b/gcc/testsuite/gcc.dg/pg-override.c
 new file mode 100644
 index 000..7cd6680
 --- /dev/null
 +++ b/gcc/testsuite/gcc.dg/pg-override.c
 @@ -0,0 +1,18 @@
 +/* Test -fprofile override */
 +/* { dg-do compile } */
 +/* { dg-options -fprofile } */
 +/* { dg-final { scan-assembler-not mcount } } */
 +/* Origin: Andi Kleen */
 +extern void foobar(const char *);
 +
 +__attribute__((no_instrument_function)) void func(void)
 +{
 +  foobar (Hello world\n);
 +}
 +
 +__attribute__((no_instrument_function)) void func2(void)
 +{
 +  int i;
 +  for (i = 0; i  10; i++)
 +foobar (Hello world);
 +}
 diff --git a/gcc/testsuite/gcc.dg/pg.c b/gcc/testsuite/gcc.dg/pg.c
 new file mode 100644
 index 000..7cd6680
 --- /dev/null
 +++ b/gcc/testsuite/gcc.dg/pg.c
 @@ -0,0 +1,18 @@
 +/* Test -fprofile override */
 +/* { dg-do compile } */
 +/* { dg-options -fprofile } */
 +/* { dg-final { scan-assembler-not mcount } } */
 +/* Origin: Andi Kleen */
 +extern void foobar(const char *);
 +
 +__attribute__((no_instrument_function)) void func(void)
 +{
 +  foobar (Hello world\n);
 +}
 +
 +__attribute__((no_instrument_function)) void func2(void)
 +{
 +  int i;
 +  for (i = 0; i  10; i++)
 +foobar (Hello world);
 +}
 diff --git a/gcc/testsuite/gcc.target/i386/fentry-override.c 
 b/gcc/testsuite/gcc.target/i386/fentry-override.c
 new file mode 100644
 index 000..3771f19
 --- /dev/null
 +++ b/gcc/testsuite/gcc.target/i386/fentry-override.c
 @@ -0,0 +1,18 @@
 +/* Test -mfentry override */
 +/* { dg-do compile } */
 +/* { dg-options -mfentry } */
 +/* { dg-final { scan-assembler-not __fentry__ } } */
 +/* Origin: Andi Kleen */
 +extern void foobar(const char *);
 +
 +void __attribute__((no_instrument_function)) func(void)
 +{
 +  foobar (Hello world\n);
 +}
 +
 +void __attribute__((no_instrument_function)) func2(void)
 +{
 +  int i;
 +  for (i = 0; i  10; i++)
 +foobar (Hello world);
 +}
 diff --git a/gcc/testsuite/gcc.target/i386/fentry.c 
 b/gcc/testsuite/gcc.target/i386/fentry.c
 new file mode 100644
 index 000..bd3db13
 --- /dev/null
 +++ b/gcc/testsuite/gcc.target/i386/fentry.c
 @@ -0,0 +1,18 @@
 +/* Test -mfentry */
 +/* { dg-do compile } */
 +/* { dg-options -fprofile -mfentry } */
 +/* { dg-final { scan-assembler __fentry__ } } */
 +/* Origin: Andi Kleen */
 +extern void foobar(const char *);
 +
 +void func(void)
 +{
 +  foobar (Hello world\n);
 +}
 +
 +void func2(void)
 +{
 +  int i;
 +  for (i = 0; i  10; i++)
 +foobar (Hello world);
 +}
 --
 2.1.0



Re: [debug-early] reuse variable DIEs and fix their context

2014-09-15 Thread Richard Biener
On Fri, Sep 12, 2014 at 7:10 PM, Aldy Hernandez al...@redhat.com wrote:
 On 09/12/14 08:15, Jason Merrill wrote:

 On 09/11/2014 08:51 PM, Aldy Hernandez wrote:

 -  timevar_start (TV_PHASE_DEFERRED);


 -  timevar_stop (TV_PHASE_DEFERRED);
 -  timevar_start (TV_PHASE_OPT_GEN);


 Why?


 TV_PHASE_OPT_GEN is now in compile_file(), where we call
 finalize_compilation_unit directly.

 TV_PHASE_DEFERRED, on the other hand, is a bit problematic because it was
 originally wrapping the code inside LANG_HOOKS_WRITE_GLOBALS, which will now
 reside inside the parser (and is thus included in TV_PHASE_PARSING now).
 Originally it was mutually exclusive with TV_PHASE_PARSING, but now resides
 within the parser, so I decided to get rid of it since it's all technically
 in the parser.

 There is code in timevar*.c that makes sure that TV_PHASE_* elapsed times
 add up to the total time.  So we either get rid of TV_PHASE_DEFERRED and
 include its time in TV_PHASE_PARSING (avoiding double counting), or we
 include a separate, non PHASE timer for it, with timevar_push(TV_blah) where
 blah is NOT PHASE.

 Up to you, but I'm highly in favor of getting rid of things ;-).


/* Generate hidden aliases for Java.  */
 -  if (candidates)
 +  if (java_hidden_aliases)
  {
 -  build_java_method_aliases (candidates);
 -  delete candidates;
 +  build_java_method_aliases (java_hidden_aliases);
 +  delete java_hidden_aliases;
  }


 Didn't it work to move this before finalize?  I think the VTV stuff is
 all that really needs to come after it, and that can move out of the
 front end if this hook is a problem (which I don't really think it is).


 I was too chicken to try.  I will do so as a follow up.

Didn't work in the past btw - I've tried it once or twice.

Btw, if the VTV stuff really needs to come afterwards how does VTV
work with LTO then?

Eventually the VTV stuff can be integrated with the cgraph instead.

Richard.

 I am committing the patch to the branch, and will address both issues you
 speak of in followups.  Let me know what you prefer for the timevar issue.

 Thanks.
 Aldy



[PATCH][PING] Enable -fsanitize-recover for KASan

2014-09-15 Thread Yury Gribov

On 09/05/2014 10:54 AM, Yury Gribov wrote:

Hi all,

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

Bootstrapped and regtested on x64.

Ok to commit?

-Y


Rebased patch to current trunk.

-Y
2014-09-15  Yury Gribov  y.gri...@samsung.com

gcc/
	* asan.c (report_error_func): Optionally call recoverable
	routines.
	(asan_expand_check_ifn): Likewise.
	(check_func): Fix formatting.
	* common.opt (fsanitize-recover): Disable by default.
	* sanitizer.def: New builtins.
	* opts.c (common_handle_option): Enable flag_sanitize_recover
	for UBSan and KASan by default.
	* flag-types.h (SANITIZE_UNDEFINED_NONDEFAULT): Rename.
	* gcc.c (sanitize_spec_function): Likewise.
	* opts.c (common_handle_option): Likewise.

gcc/testsuite/
	* c-c++-common/asan/recovery-1.c: New test.
	* c-c++-common/asan/recovery-2.c: New test.
	* c-c++-common/asan/recovery-common.inc: New file.

commit 080184e321b49641cd1e3bab2615eaf82164c683
Author: Yury Gribov y.gri...@samsung.com
Date:   Fri Aug 29 16:43:42 2014 +0400

2014-09-04  Yury Gribov  y.gri...@samsung.com

gcc/
	* asan.c (report_error_func): Optionally call recoverable
	routines.
	(asan_expand_check_ifn): Likewise.
	(check_func): Fix formatting.
	* common.opt (fsanitize-recover): Disable by default.
	* sanitizer.def: New builtins.
	* opts.c (common_handle_option): Enable flag_sanitize_recover
	for UBSan and KASan by default.
	* flag-types.h (SANITIZE_UNDEFINED_NONDEFAULT): Rename.
	* gcc.c (sanitize_spec_function): Likewise.
	* opts.c (common_handle_option): Likewise.

gcc/testsuite/
	* c-c++-common/asan/recovery-1.c: New test.
	* c-c++-common/asan/recovery-2.c: New test.
	* c-c++-common/asan/recovery-common.inc: New file.

diff --git a/gcc/asan.c b/gcc/asan.c
index e6820ea..1d0a26a 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -1373,22 +1373,36 @@ asan_protect_global (tree decl)
IS_STORE is either 1 (for a store) or 0 (for a load).  */
 
 static tree
-report_error_func (bool is_store, HOST_WIDE_INT size_in_bytes, int *nargs)
-{
-  static enum built_in_function report[2][6]
-= { { BUILT_IN_ASAN_REPORT_LOAD1, BUILT_IN_ASAN_REPORT_LOAD2,
-	  BUILT_IN_ASAN_REPORT_LOAD4, BUILT_IN_ASAN_REPORT_LOAD8,
-	  BUILT_IN_ASAN_REPORT_LOAD16, BUILT_IN_ASAN_REPORT_LOAD_N },
-	{ BUILT_IN_ASAN_REPORT_STORE1, BUILT_IN_ASAN_REPORT_STORE2,
-	  BUILT_IN_ASAN_REPORT_STORE4, BUILT_IN_ASAN_REPORT_STORE8,
-	  BUILT_IN_ASAN_REPORT_STORE16, BUILT_IN_ASAN_REPORT_STORE_N } };
+report_error_func (bool is_store, bool recover_p, HOST_WIDE_INT size_in_bytes,
+		   int *nargs)
+{
+  static enum built_in_function report[2][2][6]
+= { { { BUILT_IN_ASAN_REPORT_LOAD1, BUILT_IN_ASAN_REPORT_LOAD2,
+	BUILT_IN_ASAN_REPORT_LOAD4, BUILT_IN_ASAN_REPORT_LOAD8,
+	BUILT_IN_ASAN_REPORT_LOAD16, BUILT_IN_ASAN_REPORT_LOAD_N },
+	  { BUILT_IN_ASAN_REPORT_STORE1, BUILT_IN_ASAN_REPORT_STORE2,
+	BUILT_IN_ASAN_REPORT_STORE4, BUILT_IN_ASAN_REPORT_STORE8,
+	BUILT_IN_ASAN_REPORT_STORE16, BUILT_IN_ASAN_REPORT_STORE_N } },
+	{ { BUILT_IN_ASAN_REPORT_RECOVER_LOAD1,
+	BUILT_IN_ASAN_REPORT_RECOVER_LOAD2,
+	BUILT_IN_ASAN_REPORT_RECOVER_LOAD4,
+	BUILT_IN_ASAN_REPORT_RECOVER_LOAD8,
+	BUILT_IN_ASAN_REPORT_RECOVER_LOAD16,
+	BUILT_IN_ASAN_REPORT_RECOVER_LOAD_N },
+	  { BUILT_IN_ASAN_REPORT_RECOVER_STORE1,
+	BUILT_IN_ASAN_REPORT_RECOVER_STORE2,
+	BUILT_IN_ASAN_REPORT_RECOVER_STORE4,
+	BUILT_IN_ASAN_REPORT_RECOVER_STORE8,
+	BUILT_IN_ASAN_REPORT_RECOVER_STORE16,
+	BUILT_IN_ASAN_REPORT_RECOVER_STORE_N } } };
   if (size_in_bytes == -1)
 {
   *nargs = 2;
-  return builtin_decl_implicit (report[is_store][5]);
+  return builtin_decl_implicit (report[recover_p][is_store][5]);
 }
   *nargs = 1;
-  return builtin_decl_implicit (report[is_store][exact_log2 (size_in_bytes)]);
+  int size_log2 = exact_log2 (size_in_bytes);
+  return builtin_decl_implicit (report[recover_p][is_store][size_log2]);
 }
 
 /* Construct a function tree for __asan_{load,store}{1,2,4,8,16,_n}.
@@ -1399,11 +1413,11 @@ check_func (bool is_store, int size_in_bytes, int *nargs)
 {
   static enum built_in_function check[2][6]
 = { { BUILT_IN_ASAN_LOAD1, BUILT_IN_ASAN_LOAD2,
-  BUILT_IN_ASAN_LOAD4, BUILT_IN_ASAN_LOAD8,
-  BUILT_IN_ASAN_LOAD16, BUILT_IN_ASAN_LOADN },
+	  BUILT_IN_ASAN_LOAD4, BUILT_IN_ASAN_LOAD8,
+	  BUILT_IN_ASAN_LOAD16, BUILT_IN_ASAN_LOADN },
 	{ BUILT_IN_ASAN_STORE1, BUILT_IN_ASAN_STORE2,
-  BUILT_IN_ASAN_STORE4, BUILT_IN_ASAN_STORE8,
-  BUILT_IN_ASAN_STORE16, BUILT_IN_ASAN_STOREN } };
+	  BUILT_IN_ASAN_STORE4, BUILT_IN_ASAN_STORE8,
+	  BUILT_IN_ASAN_STORE16, BUILT_IN_ASAN_STOREN } };
   if (size_in_bytes == -1)
   

[PATCH][Kasan][PING] Allow to override Asan shadow offset from command line

2014-09-15 Thread Yury Gribov

On 09/08/2014 06:29 PM, Yury Gribov wrote:

Hi all,

Kasan developers has asked for an option to override offset of Asan
shadow memory region. This should simplify experimenting with memory
layouts on 64-bit architectures.

I've bootstrapped and regtested this on x64.

Ok to commit?

-Y


commit 95d37bbfcb9f7e35c64f3b708b120d70f220e1d2
Author: Yury Gribov y.gri...@samsung.com
Date:   Fri Aug 29 11:58:03 2014 +0400

Allow to override Asan shadow offset.

2014-09-08  Yury Gribov  y.gri...@samsung.com

gcc/
	* asan.c (set_asan_shadow_offset): New function.
	(asan_shadow_offset): Likewise.
	(asan_emit_stack_protection): Call asan_shadow_offset.
	(build_shadow_mem_access): Likewise.
	* asan.h (set_asan_shadow_offset): Declare.
	* common.opt (fasan-shadow-offset): New option.
	* doc/invoke.texi (fasan-shadow-offset): Describe new option.
	* opts-global.c (handle_common_deferred_options): Handle
	-fasan-shadow-offset.
	* opts.c (common_handle_option): Likewise.

gcc/testsuite/
	* c-c++-common/asan/shadow-offset-1.c: New test.

diff --git a/gcc/asan.c b/gcc/asan.c
index cf5de27..e6820ea 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -235,6 +235,39 @@ along with GCC; see the file COPYING3.  If not see
A destructor function that calls the runtime asan library function
_asan_unregister_globals is also installed.  */
 
+static unsigned HOST_WIDE_INT asan_shadow_offset_value;
+static bool asan_shadow_offset_computed;
+
+/* Sets shadow offset to value in string VAL.  */
+
+bool
+set_asan_shadow_offset (const char *val)
+{
+  char *endp;
+  
+  errno = 0;
+  asan_shadow_offset_value = strtoul (val, endp, 0);
+  if (!(*val != '\0'  *endp == '\0'  errno == 0))
+return false;
+
+  asan_shadow_offset_computed = true;
+
+  return true;
+}
+
+/* Returns Asan shadow offset.  */
+
+static unsigned HOST_WIDE_INT
+asan_shadow_offset ()
+{
+  if (!asan_shadow_offset_computed)
+{
+  asan_shadow_offset_computed = true;
+  asan_shadow_offset_value = targetm.asan_shadow_offset ();
+}
+  return asan_shadow_offset_value;
+}
+
 alias_set_type asan_shadow_set = -1;
 
 /* Pointer types to 1 resp. 2 byte integers in shadow memory.  A separate
@@ -1121,7 +1154,7 @@ asan_emit_stack_protection (rtx base, rtx pbase, unsigned int alignb,
 			  NULL_RTX, 1, OPTAB_DIRECT);
   shadow_base
 = plus_constant (Pmode, shadow_base,
-		 targetm.asan_shadow_offset ()
+		 asan_shadow_offset ()
 		 + (base_align_bias  ASAN_SHADOW_SHIFT));
   gcc_assert (asan_shadow_set != -1
 	   (ASAN_RED_ZONE_SIZE  ASAN_SHADOW_SHIFT) == 4);
@@ -1499,7 +1532,7 @@ insert_if_then_before_iter (gimple cond,
 }
 
 /* Build
-   (base_addr  ASAN_SHADOW_SHIFT) + targetm.asan_shadow_offset ().  */
+   (base_addr  ASAN_SHADOW_SHIFT) + asan_shadow_offset ().  */
 
 static tree
 build_shadow_mem_access (gimple_stmt_iterator *gsi, location_t location,
@@ -1516,7 +1549,7 @@ build_shadow_mem_access (gimple_stmt_iterator *gsi, location_t location,
   gimple_set_location (g, location);
   gsi_insert_after (gsi, g, GSI_NEW_STMT);
 
-  t = build_int_cst (uintptr_type, targetm.asan_shadow_offset ());
+  t = build_int_cst (uintptr_type, asan_shadow_offset ());
   g = gimple_build_assign_with_ops (PLUS_EXPR,
 make_ssa_name (uintptr_type, NULL),
 gimple_assign_lhs (g), t);
diff --git a/gcc/asan.h b/gcc/asan.h
index 198433f..eadf029 100644
--- a/gcc/asan.h
+++ b/gcc/asan.h
@@ -36,7 +36,7 @@ extern gimple_stmt_iterator create_cond_insert_point
 extern alias_set_type asan_shadow_set;
 
 /* Shadow memory is found at
-   (address  ASAN_SHADOW_SHIFT) + targetm.asan_shadow_offset ().  */
+   (address  ASAN_SHADOW_SHIFT) + asan_shadow_offset ().  */
 #define ASAN_SHADOW_SHIFT	3
 
 /* Red zone size, stack and global variables are padded by ASAN_RED_ZONE_SIZE
@@ -76,4 +76,6 @@ asan_red_zone_size (unsigned int size)
   return c ? 2 * ASAN_RED_ZONE_SIZE - c : ASAN_RED_ZONE_SIZE;
 }
 
+extern bool set_asan_shadow_offset (const char *);
+
 #endif /* TREE_ASAN */
diff --git a/gcc/common.opt b/gcc/common.opt
index 7d78803..36c8310 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -879,6 +879,10 @@ fsanitize=
 Common Driver Report Joined
 Select what to sanitize
 
+fasan-shadow-offset=
+Common Joined RejectNegative Var(common_deferred_options) Defer
+-fasan-shadow-offset=string	Use custom shadow memory offset.
+
 fsanitize-recover
 Common Report Var(flag_sanitize_recover) Init(1)
 After diagnosing undefined behavior attempt to continue execution
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 55e6d56..98e3eab 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -296,7 +296,7 @@ Objective-C and Objective-C++ Dialects}.
 @xref{Debugging Options,,Options for Debugging Your Program or GCC}.
 @gccoptlist{-d@var{letters}  -dumpspecs  -dumpmachine  -dumpversion @gol
 -fsanitize=@var{style} -fsanitize-recover @gol
--fsanitize-undefined-trap-on-error @gol

Re: [arm][patch] fix arm_neon_ok check on !arm_arch7

2014-09-15 Thread Richard Earnshaw
On 13/09/14 22:39, Andrew Stubbs wrote:
 Hi,
 
 I get a lot of vect/* and neon-* test failure in my armv5te testing 
 because the arm_neon_ok test incorrectly detects that NEON is valid on 
 arm926ej-s.
 
 It turns out that the reason is that the compiler only disallows NEON 
 for Thumb1 or soft-float configurations. Otherwise it just takes 
 -mfpu=neon at face value, regardless of -march or -mcpu.
 
 This patch limits NEON to armv7 or higher.
 
 OK?
 
 Andrew
 
 
 arm_neon_ok.patch
 
 
 2014-09-13  Andrew Stubbs  a...@codesourcery.com
 
   gcc/
   * config/arm/arm.h (TARGET_NEON): Ensure target is v7 or higher.
 
 Index: gcc/config/arm/arm.h
 ===
 --- gcc/config/arm/arm.h  (revision 215228)
 +++ gcc/config/arm/arm.h  (working copy)
 @@ -323,6 +323,7 @@
 and TARGET_HARD_FLOAT to ensure that NEON instructions are
 available.  */
  #define TARGET_NEON (TARGET_32BIT  TARGET_HARD_FLOAT \
 +   arm_arch7 \
 TARGET_VFP  arm_fpu_desc-neon)
  
  /* Q-bit is present.  */
 


Hmm, I wonder if arm_override_options should reject neon + (arch  7).

R.



Re: [PATCH, Pointer Bounds Checker 23/x] Function split

2014-09-15 Thread Ilya Enkovich
2014-09-03 23:12 GMT+04:00 Jeff Law l...@redhat.com:
 On 08/18/14 09:55, Ilya Enkovich wrote:

 On 04 Jun 01:15, Jeff Law wrote:

 On 06/03/14 01:10, Ilya Enkovich wrote:

 Hi,

 This patch does not allow splitting in case bounds are returned until
 retutrned bounds are supported.  It also propagates instrumentation marks
 for generated call and function.

 Bootstrapped and tested on linux-x86_64.

 Thanks,
 Ilya
 --
 gcc/

 2014-06-03  Ilya Enkovich  ilya.enkov...@intel.com

 * ipa-split.c: Include tree-chkp.h.
 (consider_split): Do not split when return bounds.
 (split_function): Propagate Pointer Bounds Checker
 instrumentation marks.

 It's a hack.  There's no reason we can't support this.  So I'll
 approve on the condition that you do look at removing this
 limitation in the future.

 jeff


 I did some work for function splitting and now patch cover more cases.
 Now returned bounds are supported but it is not allowed to split producers
 of returned pointer and its bounds.  Is it OK?

 Thanks,
 Ilya
 --
 2014-08-15  Ilya Enkovich  ilya.enkov...@intel.com

 * ipa-split.c: Include tree-chkp.h.
 (find_retbnd): New.
 (consider_split): Do not split retbnd and retval
 producers.
 (split_function): Propagate Pointer Bounds Checker
 instrumentation marks and handle returned bounds.

 I don't think it's sufficient to just look at the SSA_NAME_DEFSTMT and
 verify that it's not in the header.

 You could easily have the SSA_NAME_DEF_STMT be a PHI which is in the same
 partition as the RETURN statement.  One of the PHI arguments might be fed
 from a statement in the header, right?

 Don't you have to look at the entire set of definitions which directly and
 indirectly feed the return statement and verify that each and every one is
 in the same partition as the return statement?

A problem I'm trying to avoid is that bounds in return statement are
not taken into account when checking for data dependencies between
parts.  It means we may have a case when return statement with bounds
is put into split part but bounds producer is not.  If
SSA_NAME_DEFSTMT for returned bounds is in the same partition as a
return then I do not think I should care about the rest of definitions
chain because regular split point checks should make sure we have
everything required.


 And if so, that makes me start to think the original hack wasn't so bad
 after all :-)

It's always nice to have a backup plan! :)

Ilya


 jeff



Re: [PATCHv2] Vimrc config with GNU formatting

2014-09-15 Thread Yury Gribov

On 09/14/2014 02:30 PM, Alexander Monakov wrote:

On Thu, 11 Sep 2014, Yury Gribov wrote:

Ok, it tooks some time. Basically we want brace symbol to behave differently
in two contexts:

1) not add any additional offset when not following control flow operator:
void
f ()
{
   int x;
   {
   }
}


Note that GCC commonly uses custom iteration macros, e.g.:

   FOR_EACH_BB_FN(bb, fn)
 {
   do_stuff;
 }

and cinoptions that get the braces-in-switch case wrong should get constructs
like the above right.


Right, looks like a fair tradeoff.


(to get gnu-style autoindent in Vim, I've been using
http://www.vim.org/scripts/script.php?script_id=575 and would adjust braces in
switch by hand if need arose; the script is probably very close to one of
approaches posted in this thread, but I haven't checked)


Thanks for sharing, these Vim configs just keep popping up. Here are 
results of quick analysis.


Plugin's pros:
* KR-style parameters are 4 chars instead of 5 (not sure that's 
important for GCC but matters in e.g. zlib so makes sense to borrow; 
I'll update next version of patch with this)

* explicitly set f0 in cino (again makes sense to borrow)

And cons:
* sets formatting globally for all *.c files
* only works for C sources and headers so e.g. won't work for libstdc++
* does not know about C++ formatting (e.g. public:, etc.)
* continuation line is indented by 1 char instead of GCC's 2

And also some stuff which we probably don't care about:
* plugin does not use softtabstop so Tab inserts a real tab character
* better formatting of special type of comments:
/* Start
 * Middle
 */
* sets up browsefilter on MS platforms

-Y


Re: (Corrected patch) Simple patch for gcc/testsuite/gcc.target/aarch64/vdup_lane_2.c

2014-09-15 Thread James Greenhalgh
On Fri, Sep 05, 2014 at 03:58:30PM +0100, Marcus Shawcroft wrote:
 On 5 September 2014 14:46, David Sherwood david.sherw...@arm.com wrote:
  Apologies, resent with correct patch not containing ChangeLog changes.
  
 
  Hi,
 
  I have a simple patch for the vdup_lane_2.c test that fixes up the
  force_simd macro so that it does
  something sensible for execute type test cases. Is this ok to install?
 
  Tested on aarch64 little and big endian.
 
  Regards,
  David Sherwood.
 
  ChangeLog:
  2014-09-02  David Sherwood  david.sherw...@arm.com
 
  * gcc.target/aarch64/vdup_lane_2.c (force_simd): Emit simd mov.
 
 OK, thanks
 /Marcus

One of my builds over the weekend tripped up because of this bug and
I don't see David in MAINTAINERS, so I don't think he has commit rights.

Consequently, I've committed this patch on David's behalf as revision 215260

Thanks,
James



Re: [PATCH 2/2] add static typed insn_deleted_p

2014-09-15 Thread Yury Gribov

On 09/12/2014 05:17 AM, Trevor Saunders wrote:

On Thu, Sep 11, 2014 at 08:06:02PM -0400, David Malcolm wrote:

FWIW, in case it's helpful, I have a script here that I use to help make
ChangeLog entries:
https://github.com/davidmalcolm/gcc-refactoring-scripts/blob/master/generate-changelog.py
(needs to be able to import the sibling refactor module)

You feed it a git diff, and it generates a fragment of ChangeLog,
grouped according to subdirectory appropriately (based on which have
ChangeLog files), with each hunk indented so you can see what changed,
and write stuff accordingly (the assumption being that any automated
approach is going to get things wrong, and that human review is
necessary).


yeah, I tend to use contrib/mklog except in cases like this where I'm
going to give the same comment for a bunch of files.  In that case I use
something like git diff --stat | sed and then handle the few single
items manually, but it turns out the problem with humans is they make
mistakes.

btw it would be great to merge your thing with mklog somehow ideally
resulting in less perl ;-)


Rewriting mklog in Python has been discussed a dozen of times (it's not 
that I like Python). Note that this would probably require significant 
testing (I can share my mklog testsuite). E.g. current 
generate-changelog.py does not seem to handle context diffs.


-Y



Re: [PATCH v2] Use sscanf instead of atoll in gcov-tool.c

2014-09-15 Thread Richard Biener
On Sun, Sep 14, 2014 at 9:04 PM, John David Anglin dave.ang...@bell.net wrote:
 On 8-Sep-14, at 5:21 AM, Richard Biener wrote:

 On Sun, Sep 7, 2014 at 7:36 PM, John David Anglin dave.ang...@bell.net
 wrote:

 The attached patch fixes bootstrap on hpux which doesn't have the atoll
 function.

 Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.

 OK for trunk?


 ll is not portable (it's GNU), I think BSD uses q and windows may
 use sth else.  I think the code shouldn't use 'long long' but int64_t
 and the appropriate SCNd64 macros for the sscanf format specifier.


 Attached is an updated version using the SCNd64 macro.  It works fine
 on hpux.  The PRI/SCN macrocs are available back to at least hpux10.20.

Ok, I'd be happy to require all hosts having proper inttypes.h.

So if it works this way for SCNd64 maybe we can remove the hand-crafting
of PRId64 stuff in hwint.h ... (or we have to hand-craft SCNd64 as well...).
After all atoll is C99 as well...

 The other alternative is to use the atoll implementation in read-rtl.c.

Also a possibility.  Which would ask for a libiberty implementation
I suppose.

 Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.

 OK for trunk?

Let's wait for other opinions.

Thanks,
Richard.

 Dave
 --
 John David Anglin   dave.ang...@bell.net




Re: [arm][patch] fix arm_neon_ok check on !arm_arch7

2014-09-15 Thread Andrew Stubbs

On 15/09/14 10:46, Richard Earnshaw wrote:

Hmm, I wonder if arm_override_options should reject neon + (arch  7).


Is this more to your taste?

Andrew

P.S. arm_override_options was renamed in 2010.
2014-09-15  Andrew Stubbs  a...@codesourcery.com

	* gcc/config/arm/arm.c (arm_option_override): Reject -mfpu=neon
	when architecture is older than ARMv7.

Index: gcc/config/arm/arm.c
===
--- gcc/config/arm/arm.c	(revision 215228)
+++ gcc/config/arm/arm.c	(working copy)
@@ -2845,6 +2845,9 @@
 
   arm_fpu_desc = all_fpus[arm_fpu_index];
 
+  if (TARGET_NEON  !arm_arch7)
+error (target CPU does not support NEON);
+
   switch (arm_fpu_desc-model)
 {
 case ARM_FP_MODEL_VFP:


Re: [patch i386]: Sibcall tail-call improvement and partial fix PR/60104

2014-09-15 Thread Iain Sandoe
Hi Mike,

On 15 Sep 2014, at 08:33, Mike Stump wrote:

 On Sep 14, 2014, at 5:43 PM, Segher Boessenkool seg...@kernel.crashing.org 
 wrote:
 On Sun, Sep 14, 2014 at 02:38:45PM -0700, Mike Stump wrote:
 + SIBLING_CALL_P (tmp) = 1;
 + SIBLING_CALL_P (tmp) = 1;
 
 The second time is to make sure?  :-)
 
 No, just a last minute cut and paste…  I’ll remove it.

While the patch fixes the fallout from Kai's patch, I am concerned that:

1. It would be good to see how this [original] code path was tested on any 
other platform than Darwin (where it breaks).
 - I.E. a non-Mach-O test case that exercises that path of the original patch's 
code.
 - AFAICT this (exercise) does NOT happen for bootstrap and reg-test on 
x86-64-linux (so how was the original patch tested?).

2. The comment above the new code fragment has not been adjusted to reflect the 
new/changed functionality.

==

This has been ~ 3 months and the same questions / observations above have been 
raised on the PR thread and on @patches list.  This does not seem to me to be a 
darwin-only issue, and just assuming that it's some unspecified fault with 
Darwin's address legalisation seems like an unwarranted leap (especially for 
x86-64, where Darwin shares a substantial part of its ABI with Linux).

Perhaps it would be safer simply to revert that hunk of the original patch 
unless/until (1) and (2) above are addressed?

0.02GBP, as usual,
Iain



[patch] Rename template parameters in std::regex

2014-09-15 Thread Jonathan Wakely

Fix an over-eager find'n'replace.

Tested x86_64-linux, committed to trunk.
commit 3e9a05fcd4278438229a6d1515ad0d6d3b17f4a9
Author: Jonathan Wakely jwak...@redhat.com
Date:   Mon Sep 15 11:13:52 2014 +0100

	* include/bits/regex.h (basic_regex): Rename _Ch_typeraits template
	parameters to _Ch_traits.

diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h
index 9dc83fd..5205089 100644
--- a/libstdc++-v3/include/bits/regex.h
+++ b/libstdc++-v3/include/bits/regex.h
@@ -577,9 +577,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*
* @param __s A pointer to a string containing a regular expression.
*/
-  templatetypename _Ch_typeraits, typename _Alloc
+  templatetypename _Ch_traits, typename _Alloc
 	basic_regex
-	operator=(const basic_string_Ch_type, _Ch_typeraits, _Alloc __s)
+	operator=(const basic_string_Ch_type, _Ch_traits, _Alloc __s)
 	{ return this-assign(__s, flags()); }
 
   // [7.8.3] assign
@@ -654,9 +654,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* expression pattern interpreted according to @p __flags.  If
* regex_error is thrown, *this remains unchanged.
*/
-  templatetypename _Ch_typeraits, typename _Alloc
+  templatetypename _Ch_traits, typename _Alloc
 	basic_regex
-	assign(const basic_string_Ch_type, _Ch_typeraits, _Alloc __s,
+	assign(const basic_string_Ch_type, _Ch_traits, _Alloc __s,
 	   flag_type __flags = ECMAScript)
 	{
 	  _M_flags = __flags;


Re: [PATCH. libstdc++] Use the correct C++14 __cplusplus value (201402L). Added C++1z to the preprocessor.

2014-09-15 Thread Ed Smith-Rowland

On 09/15/2014 05:17 AM, Paolo Carlini wrote:

Hi again,

On 08/26/2014 10:54 AM, Paolo Carlini wrote:

Hi,

On 08/26/2014 10:52 AM, Jonathan Wakely wrote:

That seems like a good idea, but I'm not convinced there's any benefit
in Ed's changes to do:

-#if __cplusplus  201103L
+#if __cplusplus = 201402L

It seems like unnecessary churn to me,

about this, I had the same thought ;)
By the way, in case isn't already clear, it occurs to me that the kind 
of change proposed by Ed, thus standardize on __cplusplus = required 
version, will make more sense when the C++17 Standard will be closer. 
So far, since we can simply do everything with only 201103L, my idea 
too of adding _GLIBCXX_CXX11  co seems quite pointless.


Paolo.

I understand.  I guess I was looking far ahead through the eyes of some 
new maintainer where we have CXX11, CXX14, CXX17, CXX20, ... and after 
the experimental names Cxx0x, Cxx1y had long lost their meaning and 
thinking that these dates and names would be a jumble. As new library 
components come into std:: proper we should look at straightening that 
out and standardizing on something.  For now, one date works well.


The new libraries are safely tucked away in experimental behind
#if __cplusplus = 201103L
# include bits/c++14_warning.h
#else

*** Jonathan: filesystem uses:

#if __cplusplus  201103L
# include bits/c++0x_warning.h
#else
and should probably eventually be like the others.

Ed




Re: [PATCH. libstdc++] Use the correct C++14 __cplusplus value (201402L). Added C++1z to the preprocessor.

2014-09-15 Thread Jonathan Wakely

On 15/09/14 07:15 -0400, Ed Smith-Rowland wrote:

The new libraries are safely tucked away in experimental behind
#if __cplusplus = 201103L
# include bits/c++14_warning.h
#else

*** Jonathan: filesystem uses:

#if __cplusplus  201103L
# include bits/c++0x_warning.h
#else
and should probably eventually be like the others.


My Filesystem implementation works fine in C++11, I see no reason to
force C++14 usage when it isn't needed.



Re: [patch i386]: Sibcall tail-call improvement and partial fix PR/60104

2014-09-15 Thread FX
 Perhaps it would be safer simply to revert that hunk of the original patch 
 unless/until (1) and (2) above are addressed?

Given that the original patch addresses “only” a missed-optimization (and 
causes ice-on-valid), it makes sense to me.

FX

[PATCH][match-and-simplify] Enable simplifying of GIMPLE_CONDs

2014-09-15 Thread Richard Biener

To get desired transforms from tree-ssa-forwprop.c which uses
fold_stmt.

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

Richard.

2014-09-15  Richard Biener  rguent...@suse.de

* gimple-fold.c: Include tree-eh.c.
(fold_stmt_1): Handle GIMPLE_CONDs for gimple_simplify.
* gimple-match-head.c (gimple_simplify): Likewise.
* match-comparison.pd (bool != 0): Avoid some churn on
GIMPLE and amend comment.

Index: gcc/gimple-fold.c
===
--- gcc/gimple-fold.c   (revision 215212)
+++ gcc/gimple-fold.c   (working copy)
@@ -55,6 +55,7 @@ along with GCC; see the file COPYING3.
 #include dbgcnt.h
 #include builtins.h
 #include output.h
+#include tree-eh.h
 #include gimple-match.h
 
 
@@ -2881,15 +2882,67 @@ fold_stmt_1 (gimple_stmt_iterator *gsi,
  no further stmts need to be inserted (basically disallow
  creating of new SSA names).  */
   if (!inplace
-  || is_gimple_assign (stmt))
+  || is_gimple_assign (stmt)
+  || gimple_code (stmt) == GIMPLE_COND)
 {
   gimple_seq seq = NULL;
   code_helper rcode;
   tree ops[3] = {};
   if (gimple_simplify (stmt, rcode, ops, inplace ? NULL : seq, valueize))
{
- if (is_gimple_assign (stmt)
-  rcode.is_tree_code ())
+ if (gimple_code (stmt) == GIMPLE_COND)
+   {
+ gcc_assert (rcode.is_tree_code ());
+ if (TREE_CODE_CLASS ((enum tree_code)rcode) == tcc_comparison
+ /* GIMPLE_CONDs condition may not throw.  */
+ /* ???  Not sure how we want to deal with combining
+from possibly throwing statements.  Trivial
+simplifications may lead to DCEing an internal
+throw.  But we probably still want to simplify
+things to a constant for example?  Similar to
+abnormals we could discard the simplification
+result if we ever push a could-throw stmt to
+the sequence.  */
+  (!flag_exceptions
+ || !cfun-can_throw_non_call_exceptions
+ || !operation_could_trap_p (rcode, FLOAT_TYPE_P 
(TREE_TYPE (ops[0])), false, NULL_TREE)))
+   gimple_cond_set_condition (stmt, rcode, ops[0], ops[1]);
+ else if (rcode == SSA_NAME)
+   gimple_cond_set_condition (stmt, NE_EXPR, ops[0],
+  build_zero_cst (TREE_TYPE (ops[0])));
+ else if (rcode == INTEGER_CST)
+   {
+ if (integer_zerop (ops[0]))
+   gimple_cond_make_false (stmt);
+ else
+   gimple_cond_make_true (stmt);
+   }
+ else if (!inplace)
+   {
+ tree res = maybe_push_res_to_seq (rcode, boolean_type_node,
+   ops, seq);
+ if (!res)
+   goto fail;
+ gimple_cond_set_condition (stmt, NE_EXPR, res,
+build_zero_cst (TREE_TYPE (res)));
+   }
+ else
+   goto fail;
+ if (dump_file  (dump_flags  TDF_DETAILS))
+   {
+ fprintf (dump_file, gimple_simplified to );
+ if (!gimple_seq_empty_p (seq))
+   print_gimple_seq (dump_file, seq, 0, TDF_SLIM);
+ print_gimple_stmt (dump_file, gsi_stmt (*gsi),
+0, TDF_SLIM);
+   }
+ gsi_insert_seq_before (gsi, seq, GSI_SAME_STMT);
+ changed = true;
+fail:
+ ;
+   }
+ else if (is_gimple_assign (stmt)
+   rcode.is_tree_code ())
{
  if ((!inplace
   || gimple_num_ops (stmt) = get_gimple_rhs_num_ops (rcode))
Index: gcc/gimple-match-head.c
===
--- gcc/gimple-match-head.c (revision 215212)
+++ gcc/gimple-match-head.c (working copy)
@@ -573,213 +573,244 @@ gimple_simplify (gimple stmt,
 code_helper *rcode, tree *ops,
 gimple_seq *seq, tree (*valueize)(tree))
 {
-  if (is_gimple_assign (stmt))
+  switch (gimple_code (stmt))
 {
-  enum tree_code code = gimple_assign_rhs_code (stmt);
-  tree type = TREE_TYPE (gimple_assign_lhs (stmt));
-  switch (gimple_assign_rhs_class (stmt))
-   {
-   case GIMPLE_SINGLE_RHS:
- if (code == REALPART_EXPR
- || code == IMAGPART_EXPR
- || code == VIEW_CONVERT_EXPR)
+case GIMPLE_ASSIGN:
+  {
+   enum tree_code code = gimple_assign_rhs_code (stmt);
+   tree type = TREE_TYPE (gimple_assign_lhs (stmt));
+   switch (gimple_assign_rhs_class (stmt))
+ {
+ case 

Re: [patch i386]: Sibcall tail-call improvement and partial fix PR/60104

2014-09-15 Thread Dominique Dhumieres
  Perhaps it would be safer simply to revert that hunk of the original patch
  unless/until (1) and (2) above are addressed?

 Given that the original patch addresses 'only' a missed-optimization
 (and causes ice-on-valid), it makes sense to me.

(1) Iain already asked the questions more than two months ago at
https://gcc.gnu.org/ml/gcc-patches/2014-07/msg00374.html
without answer AFAICT.

(2) I think it is enough to revert the commit of gcc/config/i386/i386.c as

--- ../_clean/gcc/config/i386/i386.c2014-09-12 23:04:53.0 +0200
+++ gcc/config/i386/i386.c  2014-09-12 15:55:34.0 +0200
@@ -38965,16 +38965,7 @@ x86_output_mi_thunk (FILE *file, tree, H
  For our purposes here, we can get away with (ab)using a jump pattern,
  because we're going to do no optimization.  */
   if (MEM_P (fnaddr))
-{
-  if (sibcall_insn_operand (fnaddr, word_mode))
-   {
- tmp = gen_rtx_CALL (VOIDmode, fnaddr, const0_rtx);
-  tmp = emit_call_insn (tmp);
-  SIBLING_CALL_P (tmp) = 1;
-   }
-  else
-   emit_jump_insn (gen_indirect_jump (fnaddr));
-}
+emit_jump_insn (gen_indirect_jump (fnaddr));
   else
 {
   if (ix86_cmodel == CM_LARGE_PIC  SYMBOLIC_CONST (fnaddr))

see https://gcc.gnu.org/ml/gcc-testresults/2014-09/msg01414.html

Dominique


Re: [arm][patch] fix arm_neon_ok check on !arm_arch7

2014-09-15 Thread Richard Earnshaw
On 15/09/14 11:56, Andrew Stubbs wrote:
 On 15/09/14 10:46, Richard Earnshaw wrote:
 Hmm, I wonder if arm_override_options should reject neon + (arch  7).
 
 Is this more to your taste?
 

Yep, that's fine.

 Andrew
 
 P.S. arm_override_options was renamed in 2010.

I'm getting old :-(

R.

 
 
 arm_neon_ok-2.patch
 
 
 2014-09-15  Andrew Stubbs  a...@codesourcery.com
 
   * gcc/config/arm/arm.c (arm_option_override): Reject -mfpu=neon
   when architecture is older than ARMv7.
 
 Index: gcc/config/arm/arm.c
 ===
 --- gcc/config/arm/arm.c  (revision 215228)
 +++ gcc/config/arm/arm.c  (working copy)
 @@ -2845,6 +2845,9 @@
  
arm_fpu_desc = all_fpus[arm_fpu_index];
  
 +  if (TARGET_NEON  !arm_arch7)
 +error (target CPU does not support NEON);
 +
switch (arm_fpu_desc-model)
  {
  case ARM_FP_MODEL_VFP:
 




Re: [PATCH] Improve prepare_shrink_wrap to sink more instructions

2014-09-15 Thread Jiong Wang


On 11/09/14 21:39, Jeff Law wrote:

On 09/08/14 07:57, Jiong Wang wrote:

Conceptually OK.  Some questions/concerns about the implementation.

Hi Jeff,

thanks very much for your review.

It seems to me that what you're trying to describe on the RHS is
REG_P || CONSTANT_P

yes.

and actually I am trying to detect all rtx which contains any number
of RTX_CONST_OBJs and no more than one REG.

Note that CONSTANT_P will catch things like (high (symbol_ref)) and
(lo_sum (reg) (symbol_ref)) which are often used to build addresses on
some targets.

With that in mind, rather than using a for_each_rtx callback, test
if (REG_P (src) || CONSTANT_P (src))

Note that SRC, when it is a CONSTANT_P,  may have a variety of forms
with embedded registers.  You'll need to verify that all of those
registers are not assigned after the insn with the CONSTANT_P source
operand.  Right now you only perform that check when SRC is a REG_P.

I am using the for_each_rtx because I want to scan src so that
any sub-operands are checked,  the number of REG and non-constant
objects are record in reg_found and nonconst_found.  the embedded
register found also record in the reg field of the structure
rtx_search_arg,

Constants in this context are going to satisfy CONSTANT_P, you don't
need to manually verify them.  It will include simple constants and
constants which are built up out of multiple instructions (symbolic
constants in particular).


Jeff,

 thanks, I partially understand your meaning here.

  take the function ira_implicitly_set_insn_hard_regs in ira-lives.c for 
example,

  when generating address rtl, gcc will automatically generate const operator 
to prefix
  the address expression, like the following. so a simple CONSTANT_P check is 
enough in
  case there is no embedded register.

  (insn 309 310 308 3 (set (reg:DI 44 r15 [orig:94 ivtmp.674 ] [94])
(const:DI (plus:DI (symbol_ref:DI (recog_data) [flags 0x40]  var_decl 
0x2b2c2ff91510 recog_data)
(const_int 480 [0x1e0] -1


  but for architecture like aarch64, the following instruction sequences to 
forming address
  may be generated

(insn 73 14 74 4 (set (reg/f:DI 20 x20 [99])
(high:DI (symbol_ref:DI (global_a) [flags 0xc0]  var_decl 
0x7ff755a60900 stats))) 35 {*movdi_aarch64}
 (expr_list:REG_EQUIV (high:DI (symbol_ref:DI (global_a) [flags 0xc0]  
var_decl 0x7ff755a60900 stats))
(nil)))

(insn 17 30 25 5 (set (reg/f:DI 4 x4 [83])
(lo_sum:DI (reg/f:DI 20 x20 [99])
(symbol_ref:DI (global_a) [flags 0xc0]  var_decl 0x7ff755a60900 
stats))) {add_losym_di}
 (expr_list:REG_EQUIV (symbol_ref:DI (global_a) [flags 0xc0]  var_decl 
0x7ff755a60900 stats)
(nil)))

 while CONSTANT_P could not catch the latter lo_sum case, as the RTX_CLASS of 
lo_sum is RTX_OBJ not RTX_CONST_OBJ,
 so the

 the manually verification

  FOR_EACH_SUBRTX_VAR (iter, array, src, ALL)
{
  rtx x = *iter;
  if (REG_P (x))
{
  reg_num++;
  src_inner = x;
}
  else if (!CONSTANT_P (x)  OBJECT_P (x))
nonconstobj_num++;
}

 is to catch cases like the lo_sum insn above which contains no more than 1 
register and only contains
 RTX_CONST_OBJ.


I suspect you still need the callback to verify the # of registers is
just 1 so that the later tests work.  However, please don't use
for_each_rtx, we're moving away from that to a more efficient walker
FOR_EACH_SUBRTX.


 
  fixed, patch updated, please review.


  thanks.

  BTW, when I verifying this patch on gilbc x86-64 build, I found there may be 
another hiding
  issue when calculating live_in when splitting edge in 
move_insn_for_shrink_wrap, I will reply
  on that historical email thread directly.

Regards,
Jiong



Jeff



diff --git a/gcc/shrink-wrap.c b/gcc/shrink-wrap.c
index fd24135..739e957 100644
--- a/gcc/shrink-wrap.c
+++ b/gcc/shrink-wrap.c
@@ -53,6 +53,7 @@ along with GCC; see the file COPYING3.  If not see
 #include bb-reorder.h
 #include shrink-wrap.h
 #include regcprop.h
+#include rtl-iter.h
 
 #ifdef HAVE_simple_return
 
@@ -169,7 +170,9 @@ move_insn_for_shrink_wrap (basic_block bb, rtx_insn *insn,
 {
   rtx set, src, dest;
   bitmap live_out, live_in, bb_uses, bb_defs;
-  unsigned int i, dregno, end_dregno, sregno, end_sregno;
+  unsigned int i, dregno, end_dregno;
+  unsigned int sregno = FIRST_PSEUDO_REGISTER;
+  unsigned int end_sregno = FIRST_PSEUDO_REGISTER;
   basic_block next_block;
   edge live_edge;
 
@@ -179,7 +182,34 @@ move_insn_for_shrink_wrap (basic_block bb, rtx_insn *insn,
 return false;
   src = SET_SRC (set);
   dest = SET_DEST (set);
-  if (!REG_P (dest) || !REG_P (src)
+
+  if (!REG_P (src))
+{
+  unsigned int reg_num = 0;
+  unsigned int nonconstobj_num = 0;
+  rtx src_inner = NULL_RTX;
+
+  subrtx_var_iterator::array_type array;
+  FOR_EACH_SUBRTX_VAR (iter, array, src, ALL)
+	{
+	  rtx x = *iter;
+	  if 

Re: [PATCH] PowerPC: Implement TARGET_ATOMIC_ASSIGN_EXPAND_FENV

2014-09-15 Thread Maciej W. Rozycki
On Thu, 4 Sep 2014, Adhemerval Zanella wrote:

   While at it, may I propose another change on top of this?
 
   I've noticed the test case is rather slow, it certainly takes much more 
  time than the average one, I've seen elapsed times of well over a minute 
  on reasonably fast hardware and occasionally a timeout midway through even 
  though the test case was otherwise progressing just fine.  I think lock 
  contention or unrelated system activity such as hardware interrupts (think 
  a busy network!) may contribute to it for systems using LL/SC loops for 
  atomicity.
 
   So I think the default timeout that's used for really quick tests should 
  be extended a bit.  I propose a factor of 2, just not to make it too 
  excessive, at least for the beginning (maybe it'll have to be higher 
  eventually).
 
 Do you mind if I incorporate this change on my patchset?

 I missed your e-mail previously, sorry.  Surely I don't!  Thanks.

  Maciej


Re: [PATCH] PR62120

2014-09-15 Thread Ilya Tocar
On 01 Sep 18:38, Ilya Tocar wrote:
  Please mention the PR in the ChangeLog entry and add some testcases
  (can be gcc.target/i386/, but we should have it tested).
  Does this change anything on say register short sil __asm (sil); in 32-bit
  mode (when it IMHO should be rejected too?)?
 
 Do we support sil at all? In i386.h i see:
 
 /* Note we are omitting these since currently I don't know how
 to get gcc to use these, since they want the same but different
 number as al, and ax.
 */
 #define QI_REGISTER_NAMES \
 {al, dl, cl, bl, sil, dil, bpl, spl,}
 
 And gcc doesn't recognize sil.
 
 Added testcase, and fixed avx512f-additional-reg-names.c to be valid on
 32 bits. Ok for trunk?


Slightly updated tests.
Ok for trunk?

gcc/

2014-09-15  Ilya Tocar  ilya.to...@intel.com

   PR middle-end/62120
   * varasm.c (decode_reg_name_and_count): Check availability for
   registers from ADDITIONAL_REGISTER_NAMES.

Testsuite/

2014-09-15  Ilya Tocar  ilya.to...@intel.com

   PR middle-end/62120
   * gcc.target/i386/avx512f-additional-reg-names.c: Use register vaild
   in 32-bit mode.
   * gcc.target/i386/pr62120.c: New.

---
 gcc/testsuite/gcc.target/i386/avx512f-additional-reg-names.c | 2 +-
 gcc/testsuite/gcc.target/i386/pr62120.c  | 8 
 gcc/varasm.c | 5 +++--
 3 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr62120.c

diff --git a/gcc/testsuite/gcc.target/i386/avx512f-additional-reg-names.c 
b/gcc/testsuite/gcc.target/i386/avx512f-additional-reg-names.c
index 164a1de..98a9052 100644
--- a/gcc/testsuite/gcc.target/i386/avx512f-additional-reg-names.c
+++ b/gcc/testsuite/gcc.target/i386/avx512f-additional-reg-names.c
@@ -3,7 +3,7 @@
 
 void foo ()
 {
-  register int zmm_var asm (zmm9) __attribute__((unused));
+  register int zmm_var asm (zmm7) __attribute__((unused));
 
   __asm__ __volatile__(vxorpd %%zmm0, %%zmm0, %%zmm7\n : : : zmm7 );
 }
diff --git a/gcc/testsuite/gcc.target/i386/pr62120.c 
b/gcc/testsuite/gcc.target/i386/pr62120.c
new file mode 100644
index 000..bfb8c47
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr62120.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options -mno-sse } */
+
+void foo ()
+{
+  register int zmm_var asm (ymm9);/* { dg-error invalid register name } */
+  register int zmm_var2 asm (23);/* { dg-error invalid register name } */
+}
diff --git a/gcc/varasm.c b/gcc/varasm.c
index cd4a230..9c12b81 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -888,7 +888,7 @@ decode_reg_name_and_count (const char *asmspec, int *pnregs)
   if (asmspec[0] != 0  i  0)
{
  i = atoi (asmspec);
- if (i  FIRST_PSEUDO_REGISTER  i = 0)
+ if (i  FIRST_PSEUDO_REGISTER  i = 0  reg_names[i][0])
return i;
  else
return -2;
@@ -925,7 +925,8 @@ decode_reg_name_and_count (const char *asmspec, int *pnregs)
 
for (i = 0; i  (int) ARRAY_SIZE (table); i++)
  if (table[i].name[0]
-  ! strcmp (asmspec, table[i].name))
+  ! strcmp (asmspec, table[i].name)
+  reg_names[table[i].number][0])
return table[i].number;
   }
 #endif /* ADDITIONAL_REGISTER_NAMES */
-- 
1.8.3.1



[PATCH] AArch64: Improve regmove_costs for 128-bit types

2014-09-15 Thread Wilco Dijkstra
Hi,

This patch improves the register move costs for 128-bit types.

OK for commit?

ChangeLog:
2014-09-15  Wilco Dijkstra wdijk...@arm.com

* gcc/config/aarch64/aarch64.c (aarch64_register_move_cost):
Add register move costs for 128-bit types.

---
 gcc/config/aarch64/aarch64.c | 29 +
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 51e2c70..b032e93 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -5950,6 +5950,27 @@ aarch64_register_move_cost (enum machine_mode mode,
 return aarch64_register_move_cost (mode, from, GENERAL_REGS)
 + aarch64_register_move_cost (mode, GENERAL_REGS, to);
 
+  if (GET_MODE_SIZE (mode) == 16)
+{
+  /* 128-bit operations on general registers require 2 instructions.  */
+  if (from == GENERAL_REGS  to == GENERAL_REGS)
+   return regmove_cost-GP2GP * 2;
+  else if (from == GENERAL_REGS)
+   return regmove_cost-GP2FP * 2;
+  else if (to == GENERAL_REGS)
+   return regmove_cost-FP2GP * 2;
+
+  /* When AdvSIMD instructions are disabled it is not possible to move
+a 128-bit value directly between Q registers.  This is handled in
+secondary reload.  A general register is used as a scratch to move
+the upper DI value and the lower DI value is moved directly,
+hence the cost is the sum of three moves. */
+  if (! TARGET_SIMD)
+   return regmove_cost-GP2FP + regmove_cost-FP2GP + regmove_cost-FP2FP;
+
+  return regmove_cost-FP2FP;
+}
+
   if (from == GENERAL_REGS  to == GENERAL_REGS)
 return regmove_cost-GP2GP;
   else if (from == GENERAL_REGS)
@@ -5957,14 +5978,6 @@ aarch64_register_move_cost (enum machine_mode mode,
   else if (to == GENERAL_REGS)
 return regmove_cost-FP2GP;
 
-  /* When AdvSIMD instructions are disabled it is not possible to move
- a 128-bit value directly between Q registers.  This is handled in
- secondary reload.  A general register is used as a scratch to move
- the upper DI value and the lower DI value is moved directly,
- hence the cost is the sum of three moves. */
-  if (! TARGET_SIMD  GET_MODE_SIZE (mode) == 16)
-return regmove_cost-GP2FP + regmove_cost-FP2GP + regmove_cost-FP2FP;
-
   return regmove_cost-FP2FP;
 }
 
-- 
1.9.1





Re: [PATCH, Pointer Bounds Checker 26/x] CCP

2014-09-15 Thread Jeff Law

On 09/15/14 01:20, Ilya Enkovich wrote:



2014-06-05  Ilya Enkovich  ilya.enkov...@intel.com

 * tree-ssa-ccp.c: Include tree-chkp.h.
 (insert_clobber_before_stack_restore): Handle
 BUILT_IN_CHKP_BNDRET calls.


diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index eeefeaf..e99bcf5 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -144,6 +144,7 @@ along with GCC; see the file COPYING3.  If not see
  #include diagnostic-core.h
  #include dbgcnt.h
  #include params.h
+#include tree-chkp.h


  /* Possible lattice values.  */
@@ -1880,6 +1881,9 @@ insert_clobber_before_stack_restore (tree saved_val, tree 
var,
  else if (gimple_assign_ssa_name_copy_p (stmt))
insert_clobber_before_stack_restore (gimple_assign_lhs (stmt), var,
visited);
+else if (gimple_code (stmt) == GIMPLE_CALL
+ chkp_gimple_call_builtin_p (stmt, BUILT_IN_CHKP_BNDRET))
+  continue;
  else
gcc_assert (is_gimple_debug (stmt));

I think Richi also wanted the

gimple_code (stmt) == GIMPLE_CALL

Turned into:

is_gimple_call (stmt)


Presumably using chkp_gimple_call_builtin_p rather than 
gimple_call_builtin_p is related to using different codes for the 
instrumented builtin calls?  Otherwise why use 
chkp_gimple_call_builtin_p rather than gimple_call_builtin_p?



jeff



Re: [PATCH, 2/2] shrink wrap a function with a single loop: split live_edge

2014-09-15 Thread Jiong Wang

On 08/05/14 09:07, Zhenqiang Chen wrote:

  static bool
  move_insn_for_shrink_wrap (basic_block bb, rtx insn,
const HARD_REG_SET uses,
const HARD_REG_SET defs,
-  HARD_REG_SET *last_uses)
+  HARD_REG_SET *last_uses,
+  bool *split_p)
{
rtx set, src, dest;
bitmap live_out, live_in, bb_uses, bb_defs;
unsigned int i, dregno, end_dregno, sregno, end_sregno;
basic_block next_block;
+  edge live_edge;

/* Look for a simple register copy.  */
set = single_set (insn);
@@ -5582,17 +5589,31 @@ move_insn_for_shrink_wrap (basic_block bb, rtx insn,
|| overlaps_hard_reg_set_p (defs, GET_MODE (dest), dregno))
  return false;

-  /* See whether there is a successor block to which we could move INSN.  */
-  next_block = next_block_for_reg (bb, dregno, end_dregno);
-  if (!next_block)
+  live_edge = next_block_for_reg (bb, dregno, end_dregno);
+  if (!live_edge)
   return false;

+  next_block = live_edge-dest;
+
/* If the destination register is referred in later insn,
   try to forward it.  */
if (overlaps_hard_reg_set_p (*last_uses, GET_MODE (dest), dregno)
 !try_copy_prop (bb, insn, src, dest, last_uses))
  return false;

+  /* Create a new basic block on the edge.  */
+  if (EDGE_COUNT (next_block-preds) == 2)
+{
+  next_block = split_edge (live_edge);
+
+  bitmap_copy (df_get_live_in (next_block), df_get_live_out (bb));


(re-sent, looks like the first send not received by the server...)

 for the function _IO_wdefault_xsputn in glibc wgenops.c (.dot file attached)

 174: NOTE_INSN_BASIC_BLOCK 21 are the new created basic block because of the 
sink of move
instruction ax:DI = 0 and split edge.

 but the live_in of this BB is copied from live_out of BB 2 which is too big, 
and
actually prevent the later sink of 16: r12:DI=dx:DI.

 Should it be better to copy live_in from next_block-next_bb instead of live_out from 
bb,
as it will model what's needed more accurately?

+  bitmap_copy (df_get_live_in (next_block), df_get_live_in 
(next_block-next_bb));

 After this modification, pass x86-64 bootstrap, and this function could be 
shrink-wrapped.

-- Jiong


+  df_set_bb_dirty (next_block);
+
+  /* We should not split more than once for a function.  */
+  gcc_assert (!(*split_p));
+  *split_p = true;
+}
+
/* At this point we are committed to moving INSN, but let's try to
   move it as far as we can.  */
do
@@ -5610,7 +5631,10 @@ move_insn_for_shrink_wrap (basic_block bb, rtx insn,
 {
   for (i = dregno; i  end_dregno; i++)
 {
- if (REGNO_REG_SET_P (bb_uses, i) || REGNO_REG_SET_P (bb_defs, i)
+
+ if (*split_p
+ || REGNO_REG_SET_P (bb_uses, i)
+ || REGNO_REG_SET_P (bb_defs, i)
   || REGNO_REG_SET_P (DF_LIVE_BB_INFO (bb)-gen, i))
 next_block = NULL;
   CLEAR_REGNO_REG_SET (live_out, i);
@@ -5621,7 +5645,8 @@ move_insn_for_shrink_wrap (basic_block bb, rtx insn,
  Either way, SRC is now live on entry.  */
   for (i = sregno; i  end_sregno; i++)
 {
- if (REGNO_REG_SET_P (bb_defs, i)
+ if (*split_p
+ || REGNO_REG_SET_P (bb_defs, i)
   || REGNO_REG_SET_P (DF_LIVE_BB_INFO (bb)-gen, i))
 next_block = NULL;
   SET_REGNO_REG_SET (live_out, i);
@@ -5650,21 +5675,31 @@ move_insn_for_shrink_wrap (basic_block bb, rtx insn,
/* If we don't need to add the move to BB, look for a single
  successor block.  */
if (next_block)
-   next_block = next_block_for_reg (next_block, dregno, end_dregno);
+   {
+ live_edge = next_block_for_reg (next_block, dregno, end_dregno);
+ if (!live_edge || EDGE_COUNT (live_edge-dest-preds)  1)
+   break;
+ next_block = live_edge-dest;
+   }
  }
while (next_block);

-  /* BB now defines DEST.  It only uses the parts of DEST that overlap SRC
- (next loop).  */
-  for (i = dregno; i  end_dregno; i++)
+  /* For the new created basic block, there is no dataflow info at all.
+ So skip the following dataflow update and check.  */
+  if (!(*split_p))
  {
-  CLEAR_REGNO_REG_SET (bb_uses, i);
-  SET_REGNO_REG_SET (bb_defs, i);
-}
+  /* BB now defines DEST.  It only uses the parts of DEST that overlap SRC
+(next loop).  */
+  for (i = dregno; i  end_dregno; i++)
+   {
+ CLEAR_REGNO_REG_SET (bb_uses, i);
+ SET_REGNO_REG_SET (bb_defs, i);
+   }

-  /* BB now uses SRC.  */
-  for (i = sregno; i  end_sregno; i++)
-SET_REGNO_REG_SET (bb_uses, i);
+  /* BB now uses SRC.  */
+  for (i = sregno; i  end_sregno; i++)
+   SET_REGNO_REG_SET (bb_uses, i);
+}

emit_insn_after (PATTERN (insn), bb_note 

[PATCH,i386] Properly check xgetbv for zmm support.

2014-09-15 Thread Ilya Tocar
Hi,

Currently we don't check zmm/mask-registers related bits in xgetbv
output, when detecting native cpu. Patch below fixes it.
Bootstraps/passes make check.
Ok for trunk?

ChangeLog:

gcc/
2014-09-15  Ilya Tocar  ilya.to...@intel.com

* config/i386/driver-i386.c (host_detect_local_cpu): Detect lack of 
zmm/k regs support.

testsuite/
2014-09-15  Ilya Tocar  ilya.to...@intel.com

* gcc.target/i386/avx512f-os-support.h: Remove magic number.

---
 gcc/config/i386/driver-i386.c  | 17 +
 gcc/testsuite/gcc.target/i386/avx512f-os-support.h | 17 +++--
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/gcc/config/i386/driver-i386.c b/gcc/config/i386/driver-i386.c
index af3088e..4d6bf83 100644
--- a/gcc/config/i386/driver-i386.c
+++ b/gcc/config/i386/driver-i386.c
@@ -533,6 +533,9 @@ const char *host_detect_local_cpu (int argc, const char 
**argv)
 #define XSTATE_FP  0x1
 #define XSTATE_SSE 0x2
 #define XSTATE_YMM 0x4
+#define XSTATE_OPMASK  0x20
+#define XSTATE_ZMM 0x40
+#define XSTATE_HI_ZMM  0x80
   if (has_osxsave)
 asm (.byte 0x0f; .byte 0x01; .byte 0xd0
 : =a (eax), =d (edx)
@@ -554,6 +557,20 @@ const char *host_detect_local_cpu (int argc, const char 
**argv)
   has_xsavec = 0;
 }
 
+  if (!has_osxsave
+  || (eax 
+ (XSTATE_SSE | XSTATE_YMM | XSTATE_OPMASK | XSTATE_ZMM | 
XSTATE_HI_ZMM))
+ != (XSTATE_SSE | XSTATE_YMM | XSTATE_OPMASK | XSTATE_ZMM | 
XSTATE_HI_ZMM))
+{
+  has_avx512f = 0;
+  has_avx512er = 0;
+  has_avx512pf = 0;
+  has_avx512cd = 0;
+  has_avx512dq = 0;
+  has_avx512bw = 0;
+  has_avx512vl = 0;
+}
+
   if (!arch)
 {
   if (vendor == signature_AMD_ebx
diff --git a/gcc/testsuite/gcc.target/i386/avx512f-os-support.h 
b/gcc/testsuite/gcc.target/i386/avx512f-os-support.h
index deefa5e..2f1ed03 100644
--- a/gcc/testsuite/gcc.target/i386/avx512f-os-support.h
+++ b/gcc/testsuite/gcc.target/i386/avx512f-os-support.h
@@ -1,10 +1,23 @@
 /* Check if the OS supports executing AVX512F instructions.  */
 
+#define XCR_XFEATURE_ENABLED_MASK  0x0
+
+#define XSTATE_FP  0x1
+#define XSTATE_SSE 0x2
+#define XSTATE_YMM 0x4
+#define XSTATE_OPMASK  0x20
+#define XSTATE_ZMM 0x40
+#define XSTATE_HI_ZMM  0x80
+
 static int
 avx512f_os_support (void)
 {
   unsigned int eax, edx;
+  unsigned int ecx = XCR_XFEATURE_ENABLED_MASK;
+  unsigned int mask = XSTATE_SSE | XSTATE_YMM | XSTATE_OPMASK
+ | XSTATE_ZMM | XSTATE_HI_ZMM;
+
+  __asm__ (xgetbv : =a (eax), =d (edx) : c (ecx));
 
-  __asm__ (xgetbv : =a (eax), =d (edx) : c (0));
-  return (eax  230) == 230;
+  return ((eax  mask) == mask);
 }
-- 
1.8.3.1



Re: [PATCH] microblaze: microblaze.md: Use 'SI' instead of 'VOID' for operand 1 of 'call_value_intern'

2014-09-15 Thread Michael Eager

On 09/14/14 21:19, Chen Gang wrote:


On 9/15/14 11:03, Michael Eager wrote:

On 09/14/14 00:51, Chen Gang wrote:

Hello maintainers:

I also find some warnings during compiling microblaze, I also shall try
to fix them, but excuse me, I am not quite familiar the testsuite for
microblaze, could you provide any related information for it?


Hi Chen --

This is the gcc DejaGNU test suite.  You can find info about DejaGNU
at http://www.gnu.org/software/dejagnu.  There is also info about
testing GCC here: https://gcc.gnu.org/wiki/Testing_GCC



OK, thanks. I finished about x86_64 testsuite, and also tried microblaze
testsuite under x86_64 machine, but failed. Do I need any additional
information for microblaze testsuite?


I run tests using these options:
-mno-xl-soft-mul -mxl-barrel-shift -mcpu=v6.00.a

Configuring DejaGNU for cross-target testing requires creating a configuration
file describing the target board.



Rather than the standard make check-gcc described on the wiki
page and elsewhere, I use a script which sets some configuration
options and executes runtest directly.  This uses a MicroBlaze processor
simulator called vpexec which was included with an older version of
Xilinx's EDK.  Xilinx no longer supports vpexec.

You can use a hardware target board to test microblaze-gcc,
or a different simulator such as QEMU.



OK, thanks, I shall try Qemu (it is the additional chance for me to
familiar with Qemu).

And do you mean I need try testsuite under the related microblaze host (
e.g. Qemu microblaze simulator)?


After finish environments construction, I shall also try to test a patch
for ((void (*)(void)) 0)() fixing.


Thanks.




--
Michael Eagerea...@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077


Re: [PATCH,i386] Properly check xgetbv for zmm support.

2014-09-15 Thread Uros Bizjak
On Mon, Sep 15, 2014 at 5:28 PM, Ilya Tocar tocarip.in...@gmail.com wrote:

 Currently we don't check zmm/mask-registers related bits in xgetbv
 output, when detecting native cpu. Patch below fixes it.
 Bootstraps/passes make check.
 Ok for trunk?

 ChangeLog:

 gcc/
 2014-09-15  Ilya Tocar  ilya.to...@intel.com

 * config/i386/driver-i386.c (host_detect_local_cpu): Detect lack of
 zmm/k regs support.

 testsuite/
 2014-09-15  Ilya Tocar  ilya.to...@intel.com

 * gcc.target/i386/avx512f-os-support.h: Remove magic number.

OK.

Thanks,
Uros.


Re: [PATCH, Pointer Bounds Checker 25/x] DCE

2014-09-15 Thread Jeff Law

On 09/15/14 01:20, Ilya Enkovich wrote:




Here is a fixed version.

Bootstrapped and tested on linux_x86-64.

Thanks,
Ilya
--
gcc/

2014-06-05  Ilya Enkovich  ilya.enkov...@intel.com

 * tree-ssa-dce.c: Include tree-chkp.h.
 (propagate_necessity): For free call fed by alloc check
 bounds are also provided by the same alloc.
 (eliminate_unnecessary_stmts): Handle BUILT_IN_CHKP_BNDRET
 used by free calls.

OK.
jeff



Re: [patch i386]: Sibcall tail-call improvement and partial fix PR/60104

2014-09-15 Thread Jeff Law

On 09/15/14 05:25, FX wrote:

Perhaps it would be safer simply to revert that hunk of the original patch 
unless/until (1) and (2) above are addressed?


Given that the original patch addresses “only” a missed-optimization (and 
causes ice-on-valid), it makes sense to me.
What I think we need is folks with an understanding of those systems to 
chime in with the information Kai needs to fix the problem.  I don't 
recall seeing that, so if I missed it, feel free to point me to it.


I'd rather not start going backwards and reverting because we simply 
haven't done the digging to really understand the issues on other other 
ports.


jeff


Re: [PATCH, Pointer Bounds Checker 23/x] Function split

2014-09-15 Thread Jeff Law

On 09/15/14 03:51, Ilya Enkovich wrote:

2014-08-15  Ilya Enkovich  ilya.enkov...@intel.com

 * ipa-split.c: Include tree-chkp.h.
 (find_retbnd): New.
 (consider_split): Do not split retbnd and retval
 producers.
 (split_function): Propagate Pointer Bounds Checker
 instrumentation marks and handle returned bounds.


I don't think it's sufficient to just look at the SSA_NAME_DEFSTMT and
verify that it's not in the header.

You could easily have the SSA_NAME_DEF_STMT be a PHI which is in the same
partition as the RETURN statement.  One of the PHI arguments might be fed
from a statement in the header, right?

Don't you have to look at the entire set of definitions which directly and
indirectly feed the return statement and verify that each and every one is
in the same partition as the return statement?


A problem I'm trying to avoid is that bounds in return statement are
not taken into account when checking for data dependencies between
parts.  It means we may have a case when return statement with bounds
is put into split part but bounds producer is not.  If
SSA_NAME_DEFSTMT for returned bounds is in the same partition as a
return then I do not think I should care about the rest of definitions
chain because regular split point checks should make sure we have
everything required.
Is the data dependency in the gimple IL?  If so there shouldn't be 
anything particularly special we need to do.  If not, then how ugly 
would it be to use the bounds at the return statement to expose the 
missing dependency?


Not asking you to make that change, just want to make sure that I 
understand the core issue and that if something is missing from a 
dependency standpoint that we consider what it would take to expose the 
missing dependency.


jeff



Re: [C++14 PATCH] Do not diagnose lambda default arguments in c++14 modes.

2014-09-15 Thread Jason Merrill

On 09/14/2014 10:55 AM, Ville Voutilainen wrote:

 * g++.dg/cpp0x/lambda/lambda-defarg.C: Enable in c++11_only.
 * g++.dg/cpp1y/lambda-defarg.C: New.


Instead of adding a second test, make only the dg-error c++11_only.

Jason



Re: [PATCH, Pointer Bounds Checker 26/x] CCP

2014-09-15 Thread Ilya Enkovich
On 15 Sep 09:20, Jeff Law wrote:
 On 09/15/14 01:20, Ilya Enkovich wrote:
 
 
 2014-06-05  Ilya Enkovich  ilya.enkov...@intel.com
 
  * tree-ssa-ccp.c: Include tree-chkp.h.
  (insert_clobber_before_stack_restore): Handle
  BUILT_IN_CHKP_BNDRET calls.
 
 
 diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
 index eeefeaf..e99bcf5 100644
 --- a/gcc/tree-ssa-ccp.c
 +++ b/gcc/tree-ssa-ccp.c
 @@ -144,6 +144,7 @@ along with GCC; see the file COPYING3.  If not see
   #include diagnostic-core.h
   #include dbgcnt.h
   #include params.h
 +#include tree-chkp.h
 
 
   /* Possible lattice values.  */
 @@ -1880,6 +1881,9 @@ insert_clobber_before_stack_restore (tree saved_val, 
 tree var,
   else if (gimple_assign_ssa_name_copy_p (stmt))
 insert_clobber_before_stack_restore (gimple_assign_lhs (stmt), var,
 visited);
 +else if (gimple_code (stmt) == GIMPLE_CALL
 + chkp_gimple_call_builtin_p (stmt, BUILT_IN_CHKP_BNDRET))
 +  continue;
   else
 gcc_assert (is_gimple_debug (stmt));
 I think Richi also wanted the
 
 gimple_code (stmt) == GIMPLE_CALL
 
 Turned into:
 
 is_gimple_call (stmt)
 
 
 Presumably using chkp_gimple_call_builtin_p rather than
 gimple_call_builtin_p is related to using different codes for the
 instrumented builtin calls?  Otherwise why use
 chkp_gimple_call_builtin_p rather than gimple_call_builtin_p?
 
 
 jeff
 

The reason is that target may provide own version of builtin (and currently 
does it) for instrumentation.  Therefore we should obtain fndecl from target 
and then compare.  That is what chkp_gimple_call_builtin_p does.  I just moved 
gimple code check into chkp_gimple_call_builtin_p to make similar to 
gimple_call_builtin_p.

Thanks,
Ilya
--
2014-09-15  Ilya Enkovich  ilya.enkov...@intel.com

* tree-ssa-ccp.c: Include tree-chkp.h.
(insert_clobber_before_stack_restore): Handle
BUILT_IN_CHKP_BNDRET calls.


diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index a90f708..7c73c23 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -155,6 +155,7 @@ along with GCC; see the file COPYING3.  If not see
 #include params.h
 #include wide-int-print.h
 #include builtins.h
+#include tree-chkp.h
 
 
 /* Possible lattice values.  */
@@ -1938,6 +1939,8 @@ insert_clobber_before_stack_restore (tree saved_val, tree 
var,
 else if (gimple_assign_ssa_name_copy_p (stmt))
   insert_clobber_before_stack_restore (gimple_assign_lhs (stmt), var,
   visited);
+else if (chkp_gimple_call_builtin_p (stmt, BUILT_IN_CHKP_BNDRET))
+  continue;
 else
   gcc_assert (is_gimple_debug (stmt));
 }


Re: [PATCH 2/2] Add some more test cases for fentry and pg

2014-09-15 Thread Andi Kleen
On Mon, Sep 15, 2014 at 11:29:50AM +0200, Richard Biener wrote:
 On Fri, Sep 12, 2014 at 4:32 PM, Andi Kleen a...@firstfloor.org wrote:
  From: Andi Kleen a...@linux.intel.com
 
  Test fentry and no_instrument_function overriding.
 
  No test cases for the LTO test for now, as the LTO
  harness doesn't seem to support different flags for the final
  link.
 
 Sure it does - via dg-extra-ld-options (you have to negate compile-time
 opts to remove them).

Ok. I'll add test cases for that too then.

 
 Are you sure the tests are target independent enough?  That is,
 'mcount' is really 'mcount' on all targets?

I'm not. I'll make them x86 only.

Thanks,

-Andi


Re: [patch i386]: Sibcall tail-call improvement and partial fix PR/60104

2014-09-15 Thread Iain Sandoe
Hi Jeff,

On 15 Sep 2014, at 16:42, Jeff Law wrote:

 On 09/15/14 05:25, FX wrote:
 Perhaps it would be safer simply to revert that hunk of the original patch 
 unless/until (1) and (2) above are addressed?
 
 Given that the original patch addresses “only” a missed-optimization (and 
 causes ice-on-valid), it makes sense to me.
 What I think we need is folks with an understanding of those systems to chime 
 in with the information Kai needs to fix the problem.  I don't recall seeing 
 that, so if I missed it, feel free to point me to it.

The information to date is in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61387

 I'd rather not start going backwards and reverting because we simply haven't 
 done the digging to really understand the issues on other other ports.

Well, I'm not in the habit of suggesting reverting parts of patches normally, 
however...

1) 

The first problem I am having is finding *any* platform test (other than 
Darwin) that exercises the code in question (and it fails on Darwin).

Ergo, the situation is not about other ports - but where is the testcase that 
exercises this new code on some reference port?

FWIW: When the problem first occurred, I placed a gcc_abort in that position 
and ran bootstrap and check on x86-64-linux without the abort being triggered 
(so I don't think that saying the patch passed regression testing on 
x86-64-linux is helping much here).

If Darwin has a bug, fine - then we will go hunting it - but first we need 
something solid to base the investigation on.

2)

Regardless of port-related issues, the code in question has been significantly 
altered - but the comment describing it has not been adjusted - at the least 
the comment should be amended to state the new intent of the code.

thanks
Iain



Re: [PATCH] gcc parallel make check

2014-09-15 Thread Jakub Jelinek
On Fri, Sep 12, 2014 at 04:42:25PM -0700, Mike Stump wrote:
 On Sep 12, 2014, at 9:32 AM, Jakub Jelinek ja...@redhat.com wrote:
  Here is my latest version of the patch.
 
 I did a timing test:

Here is an updated version.
Changes since last version:
1) acats parallelized the same way (just, because it is in shell,
   using mkdir instead of open with O_EXCL|O_CREAT);
   also, as acats has pretty significant initial setup time
   (up to a minute or so on not really fast box), I'm now
   creating the /support stuff before spawning the parallel
   jobs and let the parallel jobs use the same shared support
   directory
2) I'm now using addprefix instead of patsubst where appropriate
3) I'm using $(if ...) instead of $(or ...) to make it usable
   with make 3.80 (3.81 already supports or)
4) parallelization is performed for any kinds of RUNTESTFLAGS arguments now
5) struct-layout-1.exp apparently doesn't have to be performed serially,
   and for gnu-encoding.exp I've used similar change as for go-test.exp
6) in libstdc++, abi.exp, pretty-printers.exp and xmethods.exp are performed
   together with conformance.exp, so again parallelization for any
   RUNTESTFLAGS flags; abi.exp and xmethods.exp are serially tested
   by the first runtest instance to encounter them

Regtested on x86_64-linux, without the patch toplevel make -k check
took 8hrs3minutes (don't have time data for that run), without the
patch toplevel make -j48 -k check took:
real40m21.984s
user341m51.675s
sys 112m46.993s
and with the patch make -j48 -k check took:
real32m22.066s
user355m1.788s
sys 117m5.809s
I saw over 45 jobs running pretty much as the point where all the
testing was done, and test_summary run from the non-parallel testing
is the same as test_summary from the -j48 testing with the patch.
Is this version ok for trunk?

2014-09-14  Jakub Jelinek  ja...@redhat.com

gcc/
* Makefile.in (dg_target_exps): Remove.
(check_gcc_parallelize): Change to just an upper bound number.
(check-%-subtargets): Always print the non-parallelized goals.
(check_p_vars, check_p_comma, check_p_subwork): Remove.
(check_p_count, check_p_numbers0, check_p_numbers1, check_p_numbers2,
check_p_numbers3, check_p_numbers4, check_p_numbers5,
check_p_numbers6): New variables.
(check_p_numbers): Set to sequence from 1 to .
(check_p_subdirs): Set to sequence from 1 to minimum of
$(check_p_count) and either GCC_TEST_PARALLEL_SLOTS env var if set,
or 128.
(check-%, check-parallel-%): Rewritten so that for parallelized
testing each job runs all the *.exp files, with
GCC_RUNTEST_PARALLELIZE_DIR set in environment.
gcc/go/
* Make-lang.in (check_go_parallelize): Change to just an upper bound
number.
gcc/fortran/
* Make-lang.in (check_gfortran_parallelize): Change to just an upper
bound number.
gcc/cp/
* Make-lang.in (check_g++_parallelize): Change to just an upper bound
number.
gcc/objc/
* Make-lang.in (check_objc_parallelize): Change to just an upper
bound number.
gcc/ada/
* gcc-interface/Make-lang.in (check_acats_numbers0,
check_acats_numbers1, check_acats_numbers2, check_acats_numbers3,
check_acats_numbers4, check_acats_numbers5, check_acats_numbers6,
check_acats_numbers, check_acats_subdirs): New variables.
(check_acats_targets): Use $(check_acats_subdirs).
(check-acats, check-acats%): Rewritten so that for parallelized
testing each job runs all the chapters files, with
GCC_RUNTEST_PARALLELIZE_DIR set in environment.  Prepare the support
directory sequentially and share it.
(check-acats-subtargets): Always print just check-acats.
gcc/testsuite/
* lib/gcc-defs.exp (gcc_parallel_test_run_p,
gcc_parallel_test_enable): New procedures.  If
GCC_RUNTEST_PARALLELIZE_DIR is set in environment, override
runtest_file_p to invoke also gcc_parallel_test_run_p.
* g++.dg/guality/guality.exp (check_guality): Save/restore
test_counts array around the body of the procedure.
* gcc.dg/guality/guality.exp (check_guality): Likewise.
* g++.dg/plugin/plugin.exp: Run all the tests serially
by the first parallel runtest encountering it.
* gcc.dg/plugin/plugin.exp: Likewise.
* gcc.misc-tests/matrix1.exp: Likewise.
* gcc.misc-tests/dhry.exp: Likewise.
* gcc.misc-tests/acker1.exp: Likewise.
* gcc.misc-tests/linkage.exp: Likewise.
* gcc.misc-tests/mg.exp: Likewise.
* gcc.misc-tests/mg-2.exp: Likewise.
* gcc.misc-tests/sort2.exp: Likewise.
* gcc.misc-tests/sieve.exp: Likewise.
* gcc.misc-tests/options.exp: Likewise.
* gcc.misc-tests/help.exp: Likewise.
* go.test/go-test.exp (go-gc-tests): Use
gcc_parallel_test_enable {0, 1} around all handling of
 

[PATCH] Avoid inter-test dependencies in gfortran.dg (PR fortran/56408)

2014-09-15 Thread Jakub Jelinek
Hi!

Here is an attempt to fix gfortran dg.exp testing in case of very
fine-grained parallelization.
So far tested just with
make check-gfortran RUNTESTFLAGS=dg.exp='binding_label_tests_10_main.f03 
binding_label_tests_11_main.f03 binding_label_tests_13_main.f03 
binding_label_tests_26b.f90 coarray_29_2.f90 
test_common_binding_labels_2_main.f03 test_common_binding_labels_3_main.f03 
whole_file_29.f90 whole_file_31.f90 class_45b.f03 class_4a.f03'
and
make check-gfortran RUNTESTFLAGS=dg.exp='binding_label_tests_10.f03 
binding_label_tests_11.f03 binding_label_tests_13.f03 
binding_label_tests_26a.f90 coarray_29_1.f90 test_common_binding_labels_2.f03 
test_common_binding_labels_3.f03 whole_file_28.f90 whole_file_30.f90 
class_45a.f03 class_4b.f03 class_4c.f03'
where the latter would keep around tons of non-cleaned up modules and
the former would mostly fail.
The patch introduces a new dg-compile-aux-modules directive which instructs
dejagnu to compile the in there named test first (that test shouldn't
need to have keep-modules; but you probably need cleanup-modules in the
test that uses dg-compile-aux-modules because the tests won't be automatically
discovered (perhaps can be changed later)).

2014-09-15  Jakub Jelinek  ja...@redhat.com

PR fortran/56408
* gfortran.dg/dg.exp (gfortran_test_path, gfortran_aux_module_flags):
New global vars.
(dg-compile-aux-modules): New procedure.
* gfortran.dg/binding_label_tests_10.f03: Remove comment
and keep-modules.
* gfortran.dg/binding_label_tests_10_main.f03: Remove comment,
use dg-compile-aux-modules.
* gfortran.dg/binding_label_tests_11.f03: Remove comment
and keep-modules.
* gfortran.dg/binding_label_tests_11_main.f03: Remove comment,
use dg-compile-aux-modules.
* gfortran.dg/binding_label_tests_13.f03: Remove comment
and keep-modules.
* gfortran.dg/binding_label_tests_13_main.f03: Remove comment,
use dg-compile-aux-modules.
* gfortran.dg/binding_label_tests_26a.f90: Remove comment
and keep-modules.
* gfortran.dg/binding_label_tests_26b.f90: Remove comment,
use dg-compile-aux-modules.
* gfortran.dg/class_45a.f03: Remove keep-modules.
* gfortran.dg/class_45b.f03: Use dg-compile-aux-modules
and cleanup-modules.
* gfortran.dg/class_4a.f03: Use dg-do link, use
dg-additional-sources and cleanup-modules, remove keep-modules
and update comment.
* gfortran.dg/class_4b.f03: Don't compile anywhere, remove
keep-modules, adjust comment.
* gfortran.dg/class_4c.f03: Don't compile anywhere, remove
dg-additional-sources and cleanup-modules.
* gfortran.dg/coarray_29_1.f90: Remove keep-modules and
associated comment.
* gfortran.dg/coarray_29_2.f90: Use dg-compile-aux-modules,
remove comment.
* gfortran.dg/test_common_binding_labels_2.f03: Remove keep-modules.
* gfortran.dg/test_common_binding_labels_2_main.f03: Remove comment,
use dg-compile-aux-modules.
* gfortran.dg/test_common_binding_labels_3.f03: Remove keep-modules.
* gfortran.dg/test_common_binding_labels_3_main.f03: Remove comment,
use dg-compile-aux-modules.
* gfortran.dg/whole_file_28.f90: Remove comment and keep-modules.
* gfortran.dg/whole_file_29.f90: Remove comment, use
dg-compile-aux-modules.
* gfortran.dg/whole_file_30.f90: Remove comment and keep-modules.
* gfortran.dg/whole_file_31.f90: Remove comment, use
dg-compile-aux-modules.

--- gcc/testsuite/gfortran.dg/dg.exp.jj 2014-07-04 10:20:35.0 +0200
+++ gcc/testsuite/gfortran.dg/dg.exp2014-09-15 17:05:04.038126245 +0200
@@ -28,6 +28,21 @@ if ![info exists DEFAULT_FFLAGS] then {
 # Initialize `dg'.
 dg-init
 
+global gfortran_test_path
+global gfortran_aux_module_flags
+set gfortran_test_path $srcdir/$subdir
+set gfortran_aux_module_flags $DEFAULT_FFLAGS
+proc dg-compile-aux-modules { args } {
+global gfortran_test_path
+global gfortran_aux_module_flags
+if { [llength $args] != 2 } {
+   error dg-set-target-env-var: needs one argument
+   return
+}
+dg-test $gfortran_test_path/[lindex $args 1]  $gfortran_aux_module_flags
+# cleanup-modules isn't intentionally invoked here.
+}
+
 # Main loop.
 gfortran-dg-runtest [lsort \
[glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ] ]  
$DEFAULT_FFLAGS
--- gcc/testsuite/gfortran.dg/binding_label_tests_10.f03.jj 2012-03-20 
08:51:24.0 +0100
+++ gcc/testsuite/gfortran.dg/binding_label_tests_10.f032014-09-15 
16:50:57.710322608 +0200
@@ -1,9 +1,6 @@
 ! { dg-do compile }
-! This file must be compiled BEFORE binding_label_tests_10_main.f03, which it 
-! should be because dejagnu will sort the files.
 module binding_label_tests_10
   use iso_c_binding
   implicit none
   integer(c_int), 

Re: [PATCH, Pointer Bounds Checker 23/x] Function split

2014-09-15 Thread Ilya Enkovich
2014-09-15 19:39 GMT+04:00 Jeff Law l...@redhat.com:
 On 09/15/14 03:51, Ilya Enkovich wrote:

 2014-08-15  Ilya Enkovich  ilya.enkov...@intel.com

  * ipa-split.c: Include tree-chkp.h.
  (find_retbnd): New.
  (consider_split): Do not split retbnd and retval
  producers.
  (split_function): Propagate Pointer Bounds Checker
  instrumentation marks and handle returned bounds.


 I don't think it's sufficient to just look at the SSA_NAME_DEFSTMT and
 verify that it's not in the header.

 You could easily have the SSA_NAME_DEF_STMT be a PHI which is in the same
 partition as the RETURN statement.  One of the PHI arguments might be fed
 from a statement in the header, right?

 Don't you have to look at the entire set of definitions which directly
 and
 indirectly feed the return statement and verify that each and every one
 is
 in the same partition as the return statement?


 A problem I'm trying to avoid is that bounds in return statement are
 not taken into account when checking for data dependencies between
 parts.  It means we may have a case when return statement with bounds
 is put into split part but bounds producer is not.  If
 SSA_NAME_DEFSTMT for returned bounds is in the same partition as a
 return then I do not think I should care about the rest of definitions
 chain because regular split point checks should make sure we have
 everything required.

 Is the data dependency in the gimple IL?  If so there shouldn't be anything
 particularly special we need to do.  If not, then how ugly would it be to
 use the bounds at the return statement to expose the missing dependency?

 Not asking you to make that change, just want to make sure that I understand
 the core issue and that if something is missing from a dependency standpoint
 that we consider what it would take to expose the missing dependency.

Gimple IL has required data dependencies to handle returns properly.
But split pass handles return basic block in a special way.  Return
basic block has to have a simple form and is not scanned using stmt
walkers as it is done for all other BBs by visit_bb.  It is assumed
that all dependencies for return BB are PHI args and returned value.
Thus returned bounds are just not taken into account.  That's how I
see the problem.

Ilya


 jeff



[obvious] Use LangEnabledBy for Wpsabi

2014-09-15 Thread Manuel López-Ibáñez
Bootstrapped and regression tested on x86_64-linux-gnu. Committed as
obvious at r215272.

gcc/c-family/ChangeLog:

2014-09-15  Manuel López-Ibáñez  m...@gcc.gnu.org

* c.opt (Wpsabi): Use LangEnabledBy.
* c-opts.c (c_common_handle_option): Do not handle here.

Index: gcc/c-family/c.opt
===
--- gcc/c-family/c.opt(revision 215252)
+++ gcc/c-family/c.opt(working copy)
@@ -263,11 +263,11 @@ Warn about things that change between th
 Wabi-tag
 C++ ObjC++ Var(warn_abi_tag) Warning
 Warn if a subobject has an abi_tag attribute that the complete object
type does not have

 Wpsabi
-C ObjC C++ ObjC++ LTO Var(warn_psabi) Init(1) Undocumented
+C ObjC C++ ObjC++ LTO Var(warn_psabi) Init(1) Undocumented
LangEnabledBy(C ObjC C++ ObjC++,Wabi)

 Waddress
 C ObjC C++ ObjC++ Var(warn_address) Warning LangEnabledBy(C ObjC C++
ObjC++,Wall)
 Warn about suspicious uses of memory addresses

Index: gcc/c-family/c-opts.c
===
--- gcc/c-family/c-opts.c(revision 215252)
+++ gcc/c-family/c-opts.c(working copy)
@@ -683,14 +683,10 @@ c_common_handle_option (size_t scode, co
   break;

 case OPT_v:
   verbose = true;
   break;
-
-case OPT_Wabi:
-  warn_psabi = value;
-  break;
 }

   switch (c_language)
 {
 case clk_c:


Re: [C++14 PATCH] Do not diagnose lambda default arguments in c++14 modes.

2014-09-15 Thread Ville Voutilainen
On 15 September 2014 18:51, Jason Merrill ja...@redhat.com wrote:
 On 09/14/2014 10:55 AM, Ville Voutilainen wrote:

  * g++.dg/cpp0x/lambda/lambda-defarg.C: Enable in c++11_only.
  * g++.dg/cpp1y/lambda-defarg.C: New.


 Instead of adding a second test, make only the dg-error c++11_only.


Ok.

/cp
2014-09-15  Ville Voutilainen  ville.voutilai...@gmail.com

Do not diagnose lambda default arguments in c++14 modes.
* parser.c (cp_parser_lambda_declarator_opt): Make the pedwarn
conditional.

/testsuite
2014-09-15  Ville Voutilainen  ville.voutilai...@gmail.com

Do not diagnose lambda default arguments in c++14 modes.
* g++.dg/cpp0x/lambda/lambda-defarg.C: dg-error in c++11_only.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index c696fd2..de61eb9 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -9220,7 +9220,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
   /* Default arguments shall not be specified in the
 	 parameter-declaration-clause of a lambda-declarator.  */
   for (tree t = param_list; t; t = TREE_CHAIN (t))
-	if (TREE_PURPOSE (t))
+	if (TREE_PURPOSE (t)  cxx_dialect  cxx14)
 	  pedwarn (DECL_SOURCE_LOCATION (TREE_VALUE (t)), OPT_Wpedantic,
 		   default argument specified for lambda parameter);
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg.C
index cefa24d..7f69ea1 100644
--- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg.C
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg.C
@@ -2,5 +2,5 @@
 
 int main()
 {
-  [](int a = 1) { return a; }(); // { dg-error  }
+  [](int a = 1) { return a; }(); // { dg-error default argument  { target { c++11_only } } }
 }


lambda-defarg-cxx14.changelog
Description: Binary data


Re: [PATCH] Add direct support for Linux kernel __fentry__ patching

2014-09-15 Thread Andi Kleen
Andi Kleen a...@firstfloor.org writes:

Ping!

 From: Andi Kleen a...@linux.intel.com

 The Linux kernel dynamically patches in __fentry__ calls in and
 out at runtime. This allows using function tracing for debugging
 in production kernels without (significant) performance penalty.

 For this it needs a table pointing to each __fentry__ call.

 The way it is currently implemented is that a special
 perl script scans the object file, generates the table in a special
 section. When the kernel boots up it nops the calls, and
 then later patches in the calls again as needed.

 The recordmcount.pl script in the kernel works, but it seems
 cleaner and faster to support the code generation of the patch table
 directly in gcc.

 This also allows to nop the calls directly at code generation
 time, which allows to skip a patching step at kernel boot.
 I also expect that a patchable production tracing facility is also useful
 for other applications.

 For example it could be used in ftracer
 (https://github.com/andikleen/ftracer)

 Having a nop area at the beginning of each function can be also
 also useful for other things. For example it can be used to patch
 functions at runtime to point to different functions, to do
 binary updates without restarting the program (like ksplice or
 similar)

 This patch implements two new options for the i386 target:

 -mrecord-mcount
 Generate a __mcount_loc section entry for each __fentry__ or mcount
 call. The section is compatible with the kernel convention
 and the data is put into a section loaded at runtime.

 -mnop-mcount
 Generate the mcount/__fentry__ call as 5 byte nop that can be
 patched in later. The nop is generated as a single instruction,
 as the Linux kernel run time patching relies on this.

 Limitations:
 - I didn't implement -mnop-mcount for -fPIC. This
 would need a good single instruction 6 byte NOP and it seems a
 bit pointless, as the patching would prevent text sharing.
 - I didn't implement noping for targets that pass a variable
 to mcount.
 - The facility could be useful on architectures too. Currently
 the mcount code is target specific, so I made it a i386 option.

 Passes bootstrap and testing on x86_64-linux.

 Cc: rost...@goodmis.org

 gcc/:

 2014-09-01  Andi Kleen  a...@linux.intel.com

   * config/i386/i386.c (x86_print_call_or_nop): New function.
   (x86_function_profiler): Support -mnop-mcount and
   -mrecord-mcount.
   * config/i386/i386.opt (-mnop-mcount, -mrecord-mcount): Add
   * doc/invoke.texi: Document -mnop-mcount, -mrecord-mcount
   * testsuite/gcc/gcc.target/i386/nop-mcount.c: New file.
   * testsuite/gcc/gcc.target/i386/record-mcount.c: New file.
 ---
  gcc/config/i386/i386.c| 34 
 +++
  gcc/config/i386/i386.opt  |  9 +++
  gcc/doc/invoke.texi   | 17 +-
  gcc/testsuite/gcc.target/i386/nop-mcount.c| 24 +++
  gcc/testsuite/gcc.target/i386/record-mcount.c | 24 +++
  5 files changed, 102 insertions(+), 6 deletions(-)
  create mode 100644 gcc/testsuite/gcc.target/i386/nop-mcount.c
  create mode 100644 gcc/testsuite/gcc.target/i386/record-mcount.c

 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
 index 61b33782..a651aa1 100644
 --- a/gcc/config/i386/i386.c
 +++ b/gcc/config/i386/i386.c
 @@ -3974,6 +3974,13 @@ ix86_option_override_internal (bool main_args_p,
   }
  }
  
 +#ifndef NO_PROFILE_COUNTERS
 +  if (flag_nop_mcount)
 +error (-mnop-mcount is not compatible with this target);
 +#endif
 +  if (flag_nop_mcount  flag_pic)
 +error (-mnop-mcount is not implemented for -fPIC);
 +
/* Accept -msseregparm only if at least SSE support is enabled.  */
if (TARGET_SSEREGPARM_P (opts-x_target_flags)
 ! TARGET_SSE_P (opts-x_ix86_isa_flags))
 @@ -39042,6 +39049,17 @@ x86_field_alignment (tree field, int computed)
return computed;
  }
  
 +/* Print call to TARGET to FILE.  */
 +
 +static void
 +x86_print_call_or_nop (FILE *file, const char *target)
 +{
 +  if (flag_nop_mcount)
 +fprintf (file, 1:\tnopl 0x00(%%eax,%%eax,1)\n); /* 5 byte nop.  */
 +  else
 +fprintf (file, 1:\tcall\t%s\n, target);
 +}
 +
  /* Output assembler code to FILE to increment profiler label # LABELNO
 for profiling a function entry.  */
  void
 @@ -39049,7 +39067,6 @@ x86_function_profiler (FILE *file, int labelno 
 ATTRIBUTE_UNUSED)
  {
const char *mcount_name = (flag_fentry ? MCOUNT_NAME_BEFORE_PROLOGUE
: MCOUNT_NAME);
 -
if (TARGET_64BIT)
  {
  #ifndef NO_PROFILE_COUNTERS
 @@ -39057,9 +39074,9 @@ x86_function_profiler (FILE *file, int labelno 
 ATTRIBUTE_UNUSED)
  #endif
  
if (!TARGET_PECOFF  flag_pic)
 - fprintf (file, \tcall\t*%s@GOTPCREL(%%rip)\n, mcount_name);
 + fprintf (file, 1:\tcall\t*%s@GOTPCREL(%%rip)\n, mcount_name);
else
 - fprintf (file, \tcall\t%s\n, 

[PATCH 1/n] OpenMP 4.0 offloading infrastructure

2014-09-15 Thread Ilya Verbin
Hello,

This patch contains necessary changes for the build system to support 
offloading.
It adds 2 new options for configure:
* --enable-as-accelerator-for=ARG is intended for the offload target compiler.
* --enable-offload-targets=LIST is intended for the offload host compiler.
Some more info: 
https://gcc.gnu.org/wiki/Offloading#Building_host_and_accel_compilers

Bootstrapped and regtested on i686-linux and x86_64-linux.  Is it OK for trunk?


2014-09-15  Bernd Schmidt  ber...@codesourcery.com
Thomas Schwinge  tho...@codesourcery.com
Ilya Verbin  ilya.ver...@intel.com
Andrey Turetskiy  andrey.turets...@intel.com

* configure: Regenerate.
* configure.ac (--enable-as-accelerator-for)
(--enable-offload-targets): New configure options.
gcc/
* Makefile.in (real_target_noncanonical, accel_dir_suffix)
(enable_as_accelerator): New variables substituted by configure.
(libsubdir, libexecsubdir, unlibsubdir, install_driver): Tweak for the
possibility of being configured as an offload compiler.
(DRIVER_DEFINES): Pass new defines DEFAULT_REAL_TARGET_MACHINE and
ACCEL_DIR_SUFFIX.
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac (real_target_noncanonical, accel_dir_suffix)
(enable_as_accelerator, enable_offload_targets): Compute new variables.
(--enable-as-accelerator-for, --enable-offload-targets): New options.
(ACCEL_COMPILER): Define if the compiler is built as the accel compiler.
(OFFLOAD_TARGETS): List of target names suitable for offloading.
(ENABLE_OFFLOADING): Define if list of offload targets is not empty.
libgcc/
* Makefile.in (crtompbegin$(objext), crtompend$(objext)): New rule.
* configure: Regenerate.
* configure.ac (--enable-offload-targets): New configure option.
(extra_parts): Add crtompbegin.o and crtompend.o if
enable_offload_targets is not empty.
* ompstuff.c: New file.
libgomp/
* Makefile.in: Regenerate.
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac: Check for libdl, required for plugin support.
(PLUGIN_SUPPORT): Define if plugins are supported.
(--enable-as-accelerator-for, --enable-offload-targets): New options.
(OFFLOAD_LIBRARY): Define if libgomp is built as offload target library.
(enable_offload_targets): Support Intel MIC targets.
(OFFLOAD_TARGETS): List of target names suitable for offloading.
* testsuite/Makefile.in: Regenerate.

Thanks,
  -- Ilya

---

diff --git a/configure b/configure
index 55fca62..fb40a2f 100755
--- a/configure
+++ b/configure
@@ -747,6 +747,8 @@ ospace_frag'
 ac_user_opts='
 enable_option_checking
 with_build_libsubdir
+enable_as_accelerator_for
+enable_offload_targets
 enable_gold
 enable_ld
 enable_libquadmath
@@ -1466,6 +1468,11 @@ Optional Features:
   --disable-option-checking  ignore unrecognized --enable/--with options
   --disable-FEATURE   do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --enable-as-accelerator-for=ARG
+  build as offload target compiler. Specify offload
+  host triple by ARG.
+  --enable-offload-targets=LIST
+  enable offloading to devices from LIST
   --enable-gold[=ARG] build gold [ARG={default,yes,no}]
   --enable-ld[=ARG]   build ld [ARG={default,yes,no}]
   --disable-libquadmath   do not build libquadmath directory
@@ -2893,6 +2900,26 @@ case ${with_newlib} in
   yes) skipdirs=`echo  ${skipdirs}  | sed -e 's/ target-newlib / /'` ;;
 esac
 
+# Check whether --enable-as-accelerator-for was given.
+if test ${enable_as_accelerator_for+set} = set; then :
+  enableval=$enable_as_accelerator_for; ENABLE_AS_ACCELERATOR_FOR=$enableval
+else
+  ENABLE_AS_ACCELERATOR_FOR=no
+fi
+
+
+# Check whether --enable-offload-targets was given.
+if test ${enable_offload_targets+set} = set; then :
+  enableval=$enable_offload_targets;
+  if test x$enable_offload_targets = x; then
+as_fn_error no offload targets specified $LINENO 5
+  fi
+
+else
+  enable_offload_targets=
+fi
+
+
 # Handle --enable-gold, --enable-ld.
 # --disable-gold [--enable-ld]
 # Build only ld.  Default option.
diff --git a/configure.ac b/configure.ac
index 2dc657f..69e2d14 100644
--- a/configure.ac
+++ b/configure.ac
@@ -286,6 +286,22 @@ case ${with_newlib} in
   yes) skipdirs=`echo  ${skipdirs}  | sed -e 's/ target-newlib / /'` ;;
 esac
 
+AC_ARG_ENABLE(as-accelerator-for,
+[AS_HELP_STRING([--enable-as-accelerator-for=ARG],
+   [build as offload target compiler.
+   Specify offload host triple by ARG.])],
+ENABLE_AS_ACCELERATOR_FOR=$enableval,
+ENABLE_AS_ACCELERATOR_FOR=no)
+
+AC_ARG_ENABLE(offload-targets,
+[AS_HELP_STRING([--enable-offload-targets=LIST],
+   [enable 

[C PATCH] Better diagnostics for C++ comments in C90 (PR c/61854)

2014-09-15 Thread Marek Polacek
PR 61854 points out that using // comments in C90 mode without
GNU extensions enabled results in a suboptimal error such as:
error: expected expression before ‘/’ token
This patch improves this diagnostics, so that the compiler now says
C++ style comments are forbidden in C90.

We must be careful to properly handle code such as 1 //**/ 2, which
has a different meaning in C90 and GNU90 mode.  New testcases test this.
Next, the error must not trigger in system headers (test added).
Next, the // comments aren't allowed in C94 (test added).
This patch makes the cplusplus_comments variable unnecessary, so I just
removed this variable from lang_defaults table.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2014-09-14  Marek Polacek  pola...@redhat.com

PR c/61854
* init.c (struct lang_flags): Remove cplusplus_comments.
(cpp_set_lang): Likewise.
(post_options): Likewise.
* lex.c (_cpp_lex_direct): Disallow C++ style comments in C90/C94.

* gcc.dg/cpp/pr61854-1.c: New test.
* gcc.dg/cpp/pr61854-2.c: New test.
* gcc.dg/cpp/pr61854-3.c: New test.
* gcc.dg/cpp/pr61854-3.h: New test.
* gcc.dg/cpp/pr61854-c90.c: New test.
* gcc.dg/cpp/pr61854-c94.c: New test.

diff --git gcc/gcc/testsuite/gcc.dg/cpp/pr61854-1.c 
gcc/gcc/testsuite/gcc.dg/cpp/pr61854-1.c
index e69de29..364a511 100644
--- gcc/gcc/testsuite/gcc.dg/cpp/pr61854-1.c
+++ gcc/gcc/testsuite/gcc.dg/cpp/pr61854-1.c
@@ -0,0 +1,15 @@
+/* PR c/61854 */
+/* { dg-do run } */
+/* { dg-options -std=c89 } */
+
+int
+main (void)
+{
+  int i = 1 //**/ 2
+  ;
+  int j = 1 //**/ 2
+  ;
+  if (i != 0 || j != 0)
+__builtin_abort ();  
+  return 0;
+}
diff --git gcc/gcc/testsuite/gcc.dg/cpp/pr61854-2.c 
gcc/gcc/testsuite/gcc.dg/cpp/pr61854-2.c
index e69de29..883db21 100644
--- gcc/gcc/testsuite/gcc.dg/cpp/pr61854-2.c
+++ gcc/gcc/testsuite/gcc.dg/cpp/pr61854-2.c
@@ -0,0 +1,15 @@
+/* PR c/61854 */
+/* { dg-do run } */
+/* { dg-options -std=gnu89 } */
+
+int
+main (void)
+{
+  int i = 1 //**/ 2
+  ;
+  int j = 1 //**/ 2
+  ;
+  if (i != 1 || j != 1)
+__builtin_abort ();  
+  return 0;
+}
diff --git gcc/gcc/testsuite/gcc.dg/cpp/pr61854-3.c 
gcc/gcc/testsuite/gcc.dg/cpp/pr61854-3.c
index e69de29..916c12e 100644
--- gcc/gcc/testsuite/gcc.dg/cpp/pr61854-3.c
+++ gcc/gcc/testsuite/gcc.dg/cpp/pr61854-3.c
@@ -0,0 +1,6 @@
+/* PR c/61854 */
+/* { dg-do preprocess } */
+/* { dg-options -std=c89 } */
+
+#include pr61854-3.h
+int i;
diff --git gcc/gcc/testsuite/gcc.dg/cpp/pr61854-3.h 
gcc/gcc/testsuite/gcc.dg/cpp/pr61854-3.h
index e69de29..fd798bd 100644
--- gcc/gcc/testsuite/gcc.dg/cpp/pr61854-3.h
+++ gcc/gcc/testsuite/gcc.dg/cpp/pr61854-3.h
@@ -0,0 +1,4 @@
+#pragma GCC system_header
+// X
+// Y
+// Z
diff --git gcc/gcc/testsuite/gcc.dg/cpp/pr61854-c90.c 
gcc/gcc/testsuite/gcc.dg/cpp/pr61854-c90.c
index e69de29..f9918ce 100644
--- gcc/gcc/testsuite/gcc.dg/cpp/pr61854-c90.c
+++ gcc/gcc/testsuite/gcc.dg/cpp/pr61854-c90.c
@@ -0,0 +1,13 @@
+/* PR c/61854 */
+/* { dg-do preprocess } */
+/* { dg-options -std=iso9899:1990 } */
+
+void
+foo (void)
+{
+  // 1st
+  /* { dg-error C\\+\\+ style comments are forbidden in C90 comments  { 
target *-*-*} 8 } */
+  /* { dg-error reported only once   { target *-*-*} 8 } */
+  // 2nd
+  // 3rd
+}
diff --git gcc/gcc/testsuite/gcc.dg/cpp/pr61854-c94.c 
gcc/gcc/testsuite/gcc.dg/cpp/pr61854-c94.c
index e69de29..f329a12 100644
--- gcc/gcc/testsuite/gcc.dg/cpp/pr61854-c94.c
+++ gcc/gcc/testsuite/gcc.dg/cpp/pr61854-c94.c
@@ -0,0 +1,13 @@
+/* PR c/61854 */
+/* { dg-do preprocess } */
+/* { dg-options -std=iso9899:199409 } */
+
+void
+foo (void)
+{
+  // 1st
+  /* { dg-error C\\+\\+ style comments are forbidden in C90 comments  { 
target *-*-*} 8 } */
+  /* { dg-error reported only once   { target *-*-*} 8 } */
+  // 2nd
+  // 3rd
+}
diff --git gcc/libcpp/init.c gcc/libcpp/init.c
index d612374..1121962 100644
--- gcc/libcpp/init.c
+++ gcc/libcpp/init.c
@@ -83,7 +83,6 @@ struct lang_flags
   char extended_identifiers;
   char c11_identifiers;
   char std;
-  char cplusplus_comments;
   char digraphs;
   char uliterals;
   char rliterals;
@@ -94,23 +93,23 @@ struct lang_flags
 };
 
 static const struct lang_flags lang_defaults[] =
-{ /*  c99 c++ xnum xid c11 std // digr ulit rlit udlit bincst 
digsep trig */
-  /* GNUC89   */  { 0,  0,  1,  0,  0,  0,  1,  1,  0,   0,   0,0, 0,  
   0 },
-  /* GNUC99   */  { 1,  0,  1,  0,  0,  0,  1,  1,  1,   1,   0,0, 0,  
   0 },
-  /* GNUC11   */  { 1,  0,  1,  0,  1,  0,  1,  1,  1,   1,   0,0, 0,  
   0 },
-  /* STDC89   */  { 0,  0,  0,  0,  0,  1,  0,  0,  0,   0,   0,0, 0,  
   1 },
-  /* STDC94   */  { 0,  0,  0,  0,  0,  1,  0,  1,  0,   0,   0,0, 0,  
   1 },
-  /* STDC99   */  { 1,  0,  1,  0,  0,  1,  1,  1,  0,   0,   0,0, 0,  
   1 },
-  /* STDC11   */  { 1,  0,  1,  0,  1,  1,  1,  1,  1,   0,   0,0, 0,  
   1 },
-  /* GNUCXX   */  { 0,  1,  1,  0,  

Re: [PATCH, Fortran] Wrong invocation of caf_atomic_op

2014-09-15 Thread Alessandro Fanfarillo
New patch after the update.

Cheers

2014-09-09 0:30 GMT-06:00 Tobias Burnus bur...@net-b.de:
 Alessandro Fanfarillo wrote:

 This email follows the previous without subject (sorry about that).


 I think I'd prefer the following patch, which avoids a temporary if none is
 required. value is a pointer if the kind is the same (see kind check
 before) and if it is not a literal. Otherwise, it isn't a pointer and one
 needs to generate a temporary.

 I do not quite understand why the current check doesn't work as both are
 integer(kind=4) but for some reasons one has a variant.

 Additionally, I wonder whether one should add a test case – one probably
 should do – and of which kind (run test + fdump-tree-original?).

 Tobias

 --- a/gcc/fortran/trans-intrinsic.c
 +++ b/gcc/fortran/trans-intrinsic.c
 @@ -8398,3 +8398,3 @@ conv_intrinsic_atomic_op (gfc_code *code)

 - if (TREE_TYPE (TREE_TYPE (atom)) != TREE_TYPE (TREE_TYPE (value)))
 + if (!POINTER_TYPE_P (TREE_TYPE (value)))

 {




 The attached patch solves the problem raised by the following code:

 program atomic
 use iso_fortran_env
 implicit none

 integer :: me
 integer(atomic_int_kind) :: atom[*]
 me = this_image()
 call atomic_define(atom[1],0)
 sync all
 call ATOMIC_ADD (atom[1], me)
 if(me == 1) call atomic_ref(me,atom[1])
 sync all
 write(*,*) me

 end program


 Ok for trunk?


2014-09-15  Alessandro Fanfarillo  fanfarillo@gmail.com
Tobias Burnus  bur...@net-b.de

* trans-intrinsic.c (conv_intrinsic_atomic_op):
Check for indirect reference for caf_atomic_op value.

diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index a13b113..2d7241a 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -8396,9 +8396,11 @@ conv_intrinsic_atomic_op (gfc_code *code)
   else
image_index = integer_zero_node;
 
-  if (TREE_TYPE (TREE_TYPE (atom)) != TREE_TYPE (TREE_TYPE (value)))
+   if (!POINTER_TYPE_P (TREE_TYPE (value)))
{
  tmp = gfc_create_var (TREE_TYPE (TREE_TYPE (atom)), value);
+ if (POINTER_TYPE_P (TREE_TYPE (value)))
+   value = build_fold_indirect_ref_loc (input_location, value);
  gfc_add_modify (block, tmp, fold_convert (TREE_TYPE (tmp), value));
   value = gfc_build_addr_expr (NULL_TREE, tmp);
}


Re: [PATCH] gcc parallel make check

2014-09-15 Thread Mike Stump
On Sep 15, 2014, at 9:05 AM, Jakub Jelinek ja...@redhat.com wrote:

All the updates sound good.

 Regtested on x86_64-linux, without the patch toplevel make -k check
 took 8hrs3minutes (don't have time data for that run),

This confuses me, but, no matter.  Isn’t 8hrs time data?  :-)

 patch toplevel make -j48 -k check took:
 real40m21.984s
 user341m51.675s
 sys 112m46.993s
 and with the patch make -j48 -k check took:
 real32m22.066s
 user355m1.788s
 sys 117m5.809s

These numbers are useful to try and ensure the overhead (scaling factor) is 
reasonable, thanks.

 Is this version ok for trunk?

Ok.

Thanks for all your work.

Re: [PATCH] Avoid inter-test dependencies in gfortran.dg (PR fortran/56408)

2014-09-15 Thread Mike Stump
On Sep 15, 2014, at 9:13 AM, Jakub Jelinek ja...@redhat.com wrote:
 Here is an attempt to fix gfortran dg.exp testing in case of very
 fine-grained parallelization.

Ok.


Re: [C PATCH] Better diagnostics for C++ comments in C90 (PR c/61854)

2014-09-15 Thread Joseph S. Myers
On Mon, 15 Sep 2014, Marek Polacek wrote:

 We must be careful to properly handle code such as 1 //**/ 2, which
 has a different meaning in C90 and GNU90 mode.  New testcases test this.

I don't think there's sufficient allowance here for other valid cases.  
It's valid to have // inside #if 0 in C90, for example, so that must not 
be diagnosed (must not have a pedwarn or error, at least, that is).  It's 
also valid to have it in a macro expansion; e.g.:

#define h(x) #x
#define s(x) h(x)
#define foo //

and then s(foo) must expand to the string //.

Clearly, in any case, with or without the diagnostics, these cases should 
have testcases in the testsuite.  But because // is only invalid in C90 if 
it actually results in two consecutive / tokens (not just preprocessing 
tokens), as such consecutive tokens are not part of any valid C90 program, 
a more conservative approach may be needed to avoid errors for valid 
cases.

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


Re: [debug-early] reuse variable DIEs and fix their context

2014-09-15 Thread Jason Merrill

On 09/15/2014 05:32 AM, Richard Biener wrote:

Btw, if the VTV stuff really needs to come afterwards how does VTV
work with LTO then?


It's conservatively correct: it emits information for all the vtables 
that are actually generated for the TU.  If LTO optimizes some of them 
away, the VTV information is not updated, but that only means a missed 
optimization.



Eventually the VTV stuff can be integrated with the cgraph instead.


That would be ideal, yes.

Jason




[match-and-simplify] remove dt_node::level_max

2014-09-15 Thread Prathamesh Kulkarni
* genmatch.c (dt_node::level_max): Remove.

Thanks,
Prathamesh
Index: genmatch.c
===
--- genmatch.c	(revision 215271)
+++ genmatch.c	(working copy)
@@ -466,7 +466,6 @@
 
 struct dt_simplify: public dt_node
 {
-  static const unsigned level_max = UINT_MAX;
   static const unsigned capture_max = 6;
   simplify *s; 
   unsigned pattern_no;


Re: [PATCH, Fortran] Wrong invocation of caf_atomic_op

2014-09-15 Thread Tobias Burnus

On 15.09.2014 19:18, Alessandro Fanfarillo wrote:

New patch after the update.


2014-09-09 0:30 GMT-06:00 Tobias Burnusbur...@net-b.de:

I think I'd prefer the following patch, which avoids a temporary if none is
required. value is a pointer if the kind is the same (see kind check
before) and if it is not a literal. Otherwise, it isn't a pointer and one
needs to generate a temporary.

I do not quite understand why the current check doesn't work as both are
integer(kind=4) but for some reasons one has a variant.

Additionally, I wonder whether one should add a test case – one probably
should do – and of which kind (run test + fdump-tree-original?).

@@ -8398,3 +8398,3 @@ conv_intrinsic_atomic_op (gfc_code *code)
- if (TREE_TYPE (TREE_TYPE (atom)) != TREE_TYPE (TREE_TYPE (value)))
+ if (!POINTER_TYPE_P (TREE_TYPE (value)))

2014-09-15  Alessandro Fanfarillofanfarillo@gmail.com
Tobias Burnusbur...@net-b.de

* trans-intrinsic.c (conv_intrinsic_atomic_op):
Check for indirect reference for caf_atomic_op value.

diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index a13b113..2d7241a 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -8396,9 +8396,11 @@ conv_intrinsic_atomic_op (gfc_code *code)
else
image_index = integer_zero_node;
  
-  if (TREE_TYPE (TREE_TYPE (atom)) != TREE_TYPE (TREE_TYPE (value)))

+   if (!POINTER_TYPE_P (TREE_TYPE (value)))
{
  tmp = gfc_create_var (TREE_TYPE (TREE_TYPE (atom)), value);
+ if (POINTER_TYPE_P (TREE_TYPE (value)))
+   value = build_fold_indirect_ref_loc (input_location, value);


The second part makes no sense: If value is not a pointer (which is 
the first condition), it can never be a pointer (second condition).


Otherwise, the patch is okay. The reason I hadn't committed it myself 
was that I wanted to include a test case; I was wondering whether it 
should be a run test – or a -fdump-tree-original + scan-tree test – or both.


Can you create a test case?

Tobias


[wwwdocs] Buildstat update for 4.9

2014-09-15 Thread Tom G. Christensen
Latest results for 4.9.x

There are no new results, this is just a rediff.

-tgc

Testresults for 4.9.1:
  aarch64-linux-gnu (cross)
  arm-unknown-linux-gnu
  hppa-unknown-linux-gnu
  i686-unknown-linux-gnu
  mips-unknown-linux-gnu
  mipsel-unknown-linux-gnu
  powerpc-unknown-linux-gnu
  sparc-unknown-linux-gnu
  x86_64-unknown-linux-gnu

Index: buildstat.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.9/buildstat.html,v
retrieving revision 1.7
diff -u -r1.7 buildstat.html
--- buildstat.html  12 Sep 2014 08:39:46 -  1.7
+++ buildstat.html  15 Sep 2014 18:59:39 -
@@ -24,7 +24,7 @@
 
 tr
 tdaarch64-linux-gnu/td
-tdnbsp;/td
+tdi686-pc-linux-gnu/td
 tdTest results:
 a 
href=https://gcc.gnu.org/ml/gcc-testresults/2014-09/msg00328.html;4.9.1/a
 /td
@@ -34,6 +34,7 @@
 tdarm-unknown-linux-gnueabi/td
 tdnbsp;/td
 tdTest results:
+a 
href=https://gcc.gnu.org/ml/gcc-testresults/2014-08/msg03094.html;4.9.1/a,
 a 
href=https://gcc.gnu.org/ml/gcc-testresults/2014-05/msg00051.html;4.9.0/a
 /td
 /tr
@@ -50,6 +51,7 @@
 tdhppa-unknown-linux-gnu/td
 tdnbsp;/td
 tdTest results:
+a 
href=https://gcc.gnu.org/ml/gcc-testresults/2014-08/msg03008.html;4.9.1/a,
 a 
href=https://gcc.gnu.org/ml/gcc-testresults/2014-05/msg00210.html;4.9.0/a
 /td
 /tr
@@ -108,6 +110,7 @@
 tdi686-unknown-linux-gnu/td
 tdnbsp;/td
 tdTest results:
+a 
href=https://gcc.gnu.org/ml/gcc-testresults/2014-08/msg02846.html;4.9.1/a,
 a 
href=https://gcc.gnu.org/ml/gcc-testresults/2014-04/msg02200.html;4.9.0/a
 /td
 /tr
@@ -116,6 +119,7 @@
 tdmips-unknown-linux-gnu/td
 tdnbsp;/td
 tdTest results:
+a 
href=https://gcc.gnu.org/ml/gcc-testresults/2014-08/msg03102.html;4.9.1/a,
 a 
href=https://gcc.gnu.org/ml/gcc-testresults/2014-05/msg00205.html;4.9.0/a
 /td
 /tr
@@ -124,6 +128,7 @@
 tdmipsel-unknown-linux-gnu/td
 tdnbsp;/td
 tdTest results:
+a 
href=https://gcc.gnu.org/ml/gcc-testresults/2014-08/msg03115.html;4.9.1/a,
 a 
href=https://gcc.gnu.org/ml/gcc-testresults/2014-05/msg00096.html;4.9.0/a
 /td
 /tr
@@ -141,6 +146,7 @@
 tdpowerpc-unknown-linux-gnu/td
 tdnbsp;/td
 tdTest results:
+a 
href=https://gcc.gnu.org/ml/gcc-testresults/2014-08/msg03148.html;4.9.1/a,
 a 
href=https://gcc.gnu.org/ml/gcc-testresults/2014-05/msg00841.html;4.9.0/a
 /td
 /tr
@@ -184,6 +190,7 @@
 tdsparc-unknown-linux-gnu/td
 tdnbsp;/td
 tdTest results:
+a 
href=https://gcc.gnu.org/ml/gcc-testresults/2014-08/msg03222.html;4.9.1/a,
 a 
href=https://gcc.gnu.org/ml/gcc-testresults/2014-05/msg00150.html;4.9.0/a
 /td
 /tr
@@ -192,6 +199,7 @@
 tdx86_64-unknown-linux-gnu/td
 tdnbsp;/td
 tdTest results:
+a 
href=https://gcc.gnu.org/ml/gcc-testresults/2014-08/msg02782.html;4.9.1/a,
 a 
href=https://gcc.gnu.org/ml/gcc-testresults/2014-07/msg02573.html;4.9.1/a,
 a 
href=https://gcc.gnu.org/ml/gcc-testresults/2014-04/msg02165.html;4.9.0/a,
 a 
href=https://gcc.gnu.org/ml/gcc-testresults/2014-04/msg01757.html;4.9.0/a,


[match-and-simplify] CSE with expression captures

2014-09-15 Thread Prathamesh Kulkarni
This patch attempts to performs CSE on expression captures.
I have reused captures[] to store the result of expression (capture::what).

* genmatch.c (operand::gen_transform): Add dt_operand ** default argument
to operand heirarchy.
  (expr::gen_transform): Adjust.
  (capture::gen_transform): Likewise.
  (dt_simplify::gen): Likewise.

* match-builtins.pd: Adjust pattern to use expression captures in
transform.

Thanks,
Prathamesh
Index: gcc/genmatch.c
===
--- gcc/genmatch.c	(revision 215271)
+++ gcc/genmatch.c	(working copy)
@@ -250,7 +250,7 @@
   enum op_type { OP_PREDICATE, OP_EXPR, OP_CAPTURE, OP_C_EXPR };
   operand (enum op_type type_) : type (type_) {}
   enum op_type type;
-  virtual void gen_transform (FILE *f, const char *, bool, int, const char *) = 0;
+  virtual void gen_transform (FILE *f, const char *, bool, int, const char *, dt_operand ** = 0) = 0;
 };
 
 struct predicate : public operand
@@ -257,7 +257,7 @@
 {
   predicate (const char *ident_) : operand (OP_PREDICATE), ident (ident_) {}
   const char *ident;
-  virtual void gen_transform (FILE *, const char *, bool, int, const char *)
+  virtual void gen_transform (FILE *, const char *, bool, int, const char *, dt_operand ** = 0)
 { gcc_unreachable (); }
 };
 
@@ -277,7 +277,7 @@
   e_operation *operation;
   vecoperand * ops;
   const char *expr_type;
-  virtual void gen_transform (FILE *f, const char *, bool, int, const char *);
+  virtual void gen_transform (FILE *f, const char *, bool, int, const char *, dt_operand ** = 0);
 };
 
 struct c_expr : public operand
@@ -300,7 +300,7 @@
   char *fname;
   vecid_tab ids;
 
-  virtual void gen_transform (FILE *f, const char *, bool, int, const char *);
+  virtual void gen_transform (FILE *f, const char *, bool, int, const char *, dt_operand **);
   void output_code (FILE *f, bool);
 };
 
@@ -310,7 +310,7 @@
   : operand (OP_CAPTURE), where (where_), what (what_) {}
   const char *where;
   operand *what;
-  virtual void gen_transform (FILE *f, const char *, bool, int, const char *);
+  virtual void gen_transform (FILE *f, const char *, bool, int, const char *, dt_operand ** = 0);
 };
 
 template
@@ -894,7 +894,7 @@
 
 void
 expr::gen_transform (FILE *f, const char *dest, bool gimple, int depth,
-		 const char *in_type)
+		 const char *in_type, dt_operand **indexes)
 {
   bool conversion_p = is_conversion (operation-op);
   const char *type = expr_type;
@@ -945,7 +945,7 @@
 is not unless we somehow discover what
 operand we can generate first and do it
 in the appropriate order.  */
-			 : (i == 0 ? in_type : type));
+			 : (i == 0 ? in_type : type), indexes); 
 }
 
   if (gimple)
@@ -1043,7 +1043,7 @@
 
 
 void
-c_expr::gen_transform (FILE *f, const char *dest, bool, int, const char *)
+c_expr::gen_transform (FILE *f, const char *dest, bool, int, const char *, dt_operand **) 
 {
   /* If this expression has an outlined function variant, call it.  */
   if (fname)
@@ -1063,8 +1063,19 @@
 }
 
 void
-capture::gen_transform (FILE *f, const char *dest, bool, int, const char *)
+capture::gen_transform (FILE *f, const char *dest, bool gimple, int depth, const char *in_type, dt_operand **indexes) 
 {
+  if (what  is_aexpr * (what))
+{ 
+  int index = atoi (where);
+  if (indexes[index] == 0)
+	{
+	  char buf[20];
+	  sprintf (buf, captures[%s], where);
+	  what-gen_transform (f, buf, gimple, depth, in_type, 0);
+	}
+}
+	   
   fprintf (f, %s = captures[%s];\n, dest, where); 
 }
 
@@ -1806,7 +1817,7 @@
 	  snprintf (dest, 32,   res_ops[%d], j);
 	  e-ops[j]-gen_transform (f, dest, true, 1,
 	is_conversion (e-operation-op)
-	? NULL : type);
+	? NULL : type, indexes); 
 	}
 	  /* Re-fold the toplevel result.  It's basically an embedded
 	 gimple_build w/o actually building the stmt.  */
@@ -1816,7 +1827,7 @@
   else if (s-result-type == operand::OP_CAPTURE
 	   || s-result-type == operand::OP_C_EXPR)
 	{
-	  s-result-gen_transform (f, res_ops[0], true, 1, type);
+	  s-result-gen_transform (f, res_ops[0], true, 1, type, indexes); 
 	  fprintf (f, *res_code = TREE_CODE (res_ops[0]);\n);
 	}
   else
@@ -1835,7 +1846,7 @@
 	  snprintf (dest, 32,   res_op%d, j);
 	  e-ops[j]-gen_transform (f, dest, false, 1,
 	is_conversion (e-operation-op)
-	? NULL : type);
+	? NULL : type, indexes);
 	}
 	  /* Re-fold the toplevel result.  */
 	  if (e-operation-op-kind == id_base::CODE)
@@ -1852,7 +1863,7 @@
 	   || s-result-type == operand::OP_C_EXPR)
 	{
 	  fprintf (f,   tree res;\n);
-	  s-result-gen_transform (f,  res, false, 1, type);
+	  s-result-gen_transform (f,  res, false, 1, type, indexes); 
 	  fprintf (f,   return res;\n);
 	}
   else
Index: gcc/match-builtin.pd
===
--- gcc/match-builtin.pd	(revision 215271)
+++ gcc/match-builtin.pd	(working copy)
@@ -44,8 

Re: [PATCH, Fortran] Wrong invocation of caf_atomic_op

2014-09-15 Thread Alessandro Fanfarillo
In attachment a test case which fails with the current gcc-trunk
version but works when the patch is applied. coarray_35.f90 is my
attempt to write a gcc test case.
The problem is related with atomic_add.

2014-09-15 12:55 GMT-06:00 Tobias Burnus bur...@net-b.de:
 On 15.09.2014 19:18, Alessandro Fanfarillo wrote:

 New patch after the update.


 2014-09-09 0:30 GMT-06:00 Tobias Burnus bur...@net-b.de:

 I think I'd prefer the following patch, which avoids a temporary if none
 is
 required. value is a pointer if the kind is the same (see kind check
 before) and if it is not a literal. Otherwise, it isn't a pointer and one
 needs to generate a temporary.

 I do not quite understand why the current check doesn't work as both are
 integer(kind=4) but for some reasons one has a variant.

 Additionally, I wonder whether one should add a test case – one probably
 should do – and of which kind (run test + fdump-tree-original?).

 @@ -8398,3 +8398,3 @@ conv_intrinsic_atomic_op (gfc_code *code)
 - if (TREE_TYPE (TREE_TYPE (atom)) != TREE_TYPE (TREE_TYPE (value)))
 + if (!POINTER_TYPE_P (TREE_TYPE (value)))

 2014-09-15  Alessandro Fanfarillo  fanfarillo@gmail.com
   Tobias Burnus  bur...@net-b.de

   * trans-intrinsic.c (conv_intrinsic_atomic_op):
   Check for indirect reference for caf_atomic_op value.

 diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
 index a13b113..2d7241a 100644
 --- a/gcc/fortran/trans-intrinsic.c
 +++ b/gcc/fortran/trans-intrinsic.c
 @@ -8396,9 +8396,11 @@ conv_intrinsic_atomic_op (gfc_code *code)
else
   image_index = integer_zero_node;

 -  if (TREE_TYPE (TREE_TYPE (atom)) != TREE_TYPE (TREE_TYPE (value)))
 +   if (!POINTER_TYPE_P (TREE_TYPE (value)))
   {
 tmp = gfc_create_var (TREE_TYPE (TREE_TYPE (atom)), value);
 +   if (POINTER_TYPE_P (TREE_TYPE (value)))
 + value = build_fold_indirect_ref_loc (input_location, value);


 The second part makes no sense: If value is not a pointer (which is the
 first condition), it can never be a pointer (second condition).

 Otherwise, the patch is okay. The reason I hadn't committed it myself was
 that I wanted to include a test case; I was wondering whether it should be a
 run test – or a -fdump-tree-original + scan-tree test – or both.

 Can you create a test case?

 Tobias
! { dg-do compile }
! { dg-options -fcoarray=lib }
!
use iso_fortran_env
implicit none

integer :: me,np,res
integer(atomic_int_kind) :: atom[*]

me = this_image()
np = num_images()

call atomic_define(atom[1],0)

sync all

call ATOMIC_ADD (atom[1], me)

sync all

if(me == 1) then
  call atomic_ref(res,atom[1])
  if(res /= (np*(np+1))/2) then
{ dg-error Passing pointer address }
  endif
endif

end
program atomic
use iso_fortran_env
implicit none

integer :: me,np,res
integer(atomic_int_kind) :: atom[*]

me = this_image()
np = num_images()

call atomic_define(atom[1],0)

sync all

call ATOMIC_ADD (atom[1], me)

sync all

if(me == 1) then
  call atomic_ref(res,atom[1])
  if(res /= (np*(np+1))/2) then
write(*,*) 'res',res
call abort()
  endif
  write(*,*) 'OK'  
endif

end program


Re: Fix pr61848, linux kernel miscompile

2014-09-15 Thread Joseph S. Myers
On Mon, 15 Sep 2014, Alan Modra wrote:

 This patch cures the linux kernel boot failure when compiled using
 trunk gcc.  (Andrew, apologies for hijacking your bugzilla, I started
 work on this before finding the bugzilla..)

Please include testcases in your patch for each case that you fix.

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


[google/gcc-4_9] Fix static var promotion handling for LIPO

2014-09-15 Thread Sharad Singhai
This patch is for the google/gcc-4_9 branch to fix a LIPO issue.

This patch addresses handling for static initializer data during
static variable promotion in LIPO optimize phase. This is useful for
those targets which access initializer data via TOC, such as powerpc.

After static var promotion in two different modules, we have the
following which leads to multiple definition of ._41 error during
link time.

Module 1 Module 2
 .hidden ._41.cmo.1   .hidden ._41.cmo.3
 .globl ._41  .globl ._41
._41:._41:
  ...  ...


Instead we should use the appropriate unique names for initializer
data as in the following.

Module 1 Module 2
 .hidden ._41.cmo.1   .hidden ._41.cmo.3
 .globl ._41.cmo.1.globl ._41.cmo.3
._41.cmo.1:  ._41.cmo.3:
...  ...


Tested on powerpc as well as ran manual tests. Okay for google/4_9 branch?

Thanks,
Sharad
2014-09-15  Sharad Singhai  sing...@google.com

Google Ref b/17114943

* l-ipo.c (promote_static_var_func): Update RTL with the unique name.

testsuite/ChangeLog:
* g++.dg/tree-prof/lipo/static1_0.C: New test.
* g++.dg/tree-prof/lipo/static1_1.C: New file.
* g++.dg/tree-prof/lipo/static1_2.C: New file.


Index: l-ipo.c
===
--- l-ipo.c (revision 215144)
+++ l-ipo.c (working copy)
@@ -47,6 +47,8 @@ along with GCC; see the file COPYING3.  If not see
 #include timevar.h
 #include vec.h
 #include params.h
+#include rtl.h
+#include varasm.h
 
 unsigned ggc_total_memory; /* in KB */
 
@@ -1909,6 +1911,9 @@ promote_static_var_func (unsigned module_id, tree
 }
   varpool_link_node (node);
   insert_to_assembler_name_hash (node, false);
+  /* Possibly update the RTL name as well. */
+  if (DECL_RTL_SET_P (decl))
+XSTR (XEXP (DECL_RTL (decl), 0), 0) = IDENTIFIER_POINTER (assemb_id);
 }
 
   if (is_extern)
Index: testsuite/g++.dg/tree-prof/lipo/static1_0.C
===
--- testsuite/g++.dg/tree-prof/lipo/static1_0.C (revision 0)
+++ testsuite/g++.dg/tree-prof/lipo/static1_0.C (working copy)
@@ -0,0 +1,48 @@
+// { dg-options -std=c++11 -O2 }
+
+// A test case for static var promotion on targets like powerpc, where
+// the static initializer data is loaded via indirection through
+// TOC. Ensure that the global label for static initializer data is
+// unique via *.cmo* suffix.
+
+// Bug: after static var promotion in two different modules, we have
+// the following which leads to multiple definition of ._41 error during
+// link time.
+
+// Module 1 Module 2
+//  .hidden ._41.cmo.1   .hidden ._41.cmo.3
+//  .globl ._41  .globl ._41
+// ._41:._41:
+//   ...  ...
+
+
+// Instead we should use the appropriate unique names for initializer
+// data as in the following.
+
+// Module 1 Module 2
+//  .hidden ._41.cmo.1   .hidden ._41.cmo.3
+//  .globl ._41.cmo.1.globl ._41.cmo.3
+// ._41.cmo.1:  ._41.cmo.3:
+// ...  ...
+
+class A {
+ public:
+  int f(int x) const;
+};
+
+class B {
+ public:
+  int f(int x) const;
+};
+
+int main()
+{
+  A *a = new A();
+  B *b = new B();
+  int total = 0;
+  for (int i=0; i3; ++i) {
+total += a-f(1);
+total += b-f(1);
+  }
+  return (total  0) ? 0 : 1;
+}
Index: testsuite/g++.dg/tree-prof/lipo/static1_1.C
===
--- testsuite/g++.dg/tree-prof/lipo/static1_1.C (revision 0)
+++ testsuite/g++.dg/tree-prof/lipo/static1_1.C (working copy)
@@ -0,0 +1,14 @@
+/* { dg-options -std=c++11 -O2 } */
+
+#include vector
+
+class A {
+ public:
+  int f(int x) const;
+};
+
+static const std::vectorint point1_{42};
+
+int A::f(int x) const {
+  return x+1;
+}
Index: testsuite/g++.dg/tree-prof/lipo/static1_2.C
===
--- testsuite/g++.dg/tree-prof/lipo/static1_2.C (revision 0)
+++ testsuite/g++.dg/tree-prof/lipo/static1_2.C (working copy)
@@ -0,0 +1,14 @@
+/* { dg-options -std=c++11 -O2 } */
+
+#include vector
+
+class B {
+ public:
+  int f(int x) const;
+};
+
+static const std::vectorint point2_{43};
+
+int B::f(int x) const {
+  return x+1;
+}


Re: [match-and-simplify] CSE with expression captures

2014-09-15 Thread Marc Glisse

On Tue, 16 Sep 2014, Prathamesh Kulkarni wrote:


--- gcc/match-builtin.pd(revision 215271)
+++ gcc/match-builtin.pd(working copy)
@@ -44,8 +44,8 @@
  /* ???  There is no way to CSE here.  We'd need to support
 expression captures here, like with
  (mult (realpart@1 @0) @1) */
- (mult (realpart @0) (realpart @0))
- (mult (imagpart @0) (imagpart @0)))
+	  (mult (realpart@1 @0) @1) 
+	  (mult (imagpart@2 @0) @2))


Maybe remove the comment above?

You seem to have trailing spaces on most of your new lines.

--
Marc Glisse


Re: [google/gcc-4_9] Fix static var promotion handling for LIPO

2014-09-15 Thread Xinliang David Li
ok.

David

On Mon, Sep 15, 2014 at 1:43 PM, Sharad Singhai sing...@google.com wrote:
 This patch is for the google/gcc-4_9 branch to fix a LIPO issue.

 This patch addresses handling for static initializer data during
 static variable promotion in LIPO optimize phase. This is useful for
 those targets which access initializer data via TOC, such as powerpc.

 After static var promotion in two different modules, we have the
 following which leads to multiple definition of ._41 error during
 link time.

 Module 1 Module 2
  .hidden ._41.cmo.1   .hidden ._41.cmo.3
  .globl ._41  .globl ._41
 ._41:._41:
   ...  ...


 Instead we should use the appropriate unique names for initializer
 data as in the following.

 Module 1 Module 2
  .hidden ._41.cmo.1   .hidden ._41.cmo.3
  .globl ._41.cmo.1.globl ._41.cmo.3
 ._41.cmo.1:  ._41.cmo.3:
 ...  ...


 Tested on powerpc as well as ran manual tests. Okay for google/4_9 branch?

 Thanks,
 Sharad


Re: [C PATCH] Better diagnostics for C++ comments in C90 (PR c/61854)

2014-09-15 Thread Marek Polacek
On Mon, Sep 15, 2014 at 05:49:25PM +, Joseph S. Myers wrote:
 On Mon, 15 Sep 2014, Marek Polacek wrote:
 
  We must be careful to properly handle code such as 1 //**/ 2, which
  has a different meaning in C90 and GNU90 mode.  New testcases test this.
 
 I don't think there's sufficient allowance here for other valid cases.  
 It's valid to have // inside #if 0 in C90, for example, so that must not 
 be diagnosed (must not have a pedwarn or error, at least, that is).  It's 

Good point, sorry about that.  Luckily this can be fixed just by
checking pfile-state.skipping.  New test added.

 also valid to have it in a macro expansion; e.g.:
 
 #define h(x) #x
 #define s(x) h(x)
 #define foo //
 
 and then s(foo) must expand to the string //.
 
 Clearly, in any case, with or without the diagnostics, these cases should 
 have testcases in the testsuite.  But because // is only invalid in C90 if 
 it actually results in two consecutive / tokens (not just preprocessing 
 tokens), as such consecutive tokens are not part of any valid C90 program, 
 a more conservative approach may be needed to avoid errors for valid 
 cases.

I added a test for that and disabled the error for case we're in a
directive.  Thanks.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2014-09-15  Marek Polacek  pola...@redhat.com

PR c/61854
libcpp/
* init.c (struct lang_flags): Remove cplusplus_comments.
(cpp_set_lang): Likewise.
(post_options): Likewise.
* lex.c (_cpp_lex_direct): Disallow C++ style comments in C90/C94.
testsuite/
* gcc.dg/cpp/pr61854-1.c: New test.
* gcc.dg/cpp/pr61854-2.c: New test.
* gcc.dg/cpp/pr61854-3.c: New test.
* gcc.dg/cpp/pr61854-3.h: New test.
* gcc.dg/cpp/pr61854-4.c: New test.
* gcc.dg/cpp/pr61854-5.c: New test.
* gcc.dg/cpp/pr61854-c90.c: New test.
* gcc.dg/cpp/pr61854-c94.c: New test.

diff --git gcc/gcc/testsuite/gcc.dg/cpp/pr61854-1.c 
gcc/gcc/testsuite/gcc.dg/cpp/pr61854-1.c
index e69de29..364a511 100644
--- gcc/gcc/testsuite/gcc.dg/cpp/pr61854-1.c
+++ gcc/gcc/testsuite/gcc.dg/cpp/pr61854-1.c
@@ -0,0 +1,15 @@
+/* PR c/61854 */
+/* { dg-do run } */
+/* { dg-options -std=c89 } */
+
+int
+main (void)
+{
+  int i = 1 //**/ 2
+  ;
+  int j = 1 //**/ 2
+  ;
+  if (i != 0 || j != 0)
+__builtin_abort ();  
+  return 0;
+}
diff --git gcc/gcc/testsuite/gcc.dg/cpp/pr61854-2.c 
gcc/gcc/testsuite/gcc.dg/cpp/pr61854-2.c
index e69de29..883db21 100644
--- gcc/gcc/testsuite/gcc.dg/cpp/pr61854-2.c
+++ gcc/gcc/testsuite/gcc.dg/cpp/pr61854-2.c
@@ -0,0 +1,15 @@
+/* PR c/61854 */
+/* { dg-do run } */
+/* { dg-options -std=gnu89 } */
+
+int
+main (void)
+{
+  int i = 1 //**/ 2
+  ;
+  int j = 1 //**/ 2
+  ;
+  if (i != 1 || j != 1)
+__builtin_abort ();  
+  return 0;
+}
diff --git gcc/gcc/testsuite/gcc.dg/cpp/pr61854-3.c 
gcc/gcc/testsuite/gcc.dg/cpp/pr61854-3.c
index e69de29..916c12e 100644
--- gcc/gcc/testsuite/gcc.dg/cpp/pr61854-3.c
+++ gcc/gcc/testsuite/gcc.dg/cpp/pr61854-3.c
@@ -0,0 +1,6 @@
+/* PR c/61854 */
+/* { dg-do preprocess } */
+/* { dg-options -std=c89 } */
+
+#include pr61854-3.h
+int i;
diff --git gcc/gcc/testsuite/gcc.dg/cpp/pr61854-3.h 
gcc/gcc/testsuite/gcc.dg/cpp/pr61854-3.h
index e69de29..fd798bd 100644
--- gcc/gcc/testsuite/gcc.dg/cpp/pr61854-3.h
+++ gcc/gcc/testsuite/gcc.dg/cpp/pr61854-3.h
@@ -0,0 +1,4 @@
+#pragma GCC system_header
+// X
+// Y
+// Z
diff --git gcc/gcc/testsuite/gcc.dg/cpp/pr61854-4.c 
gcc/gcc/testsuite/gcc.dg/cpp/pr61854-4.c
index e69de29..25cc4b2 100644
--- gcc/gcc/testsuite/gcc.dg/cpp/pr61854-4.c
+++ gcc/gcc/testsuite/gcc.dg/cpp/pr61854-4.c
@@ -0,0 +1,16 @@
+/* PR c/61854 */
+/* { dg-do preprocess } */
+/* { dg-options -std=c89 } */
+
+void
+foo (void)
+{
+#if 0
+  // Don't error here.
+#endif
+#if 1
+  // But error here.
+#endif
+  /* { dg-error C\\+\\+ style comments are not allowed in ISO C90 comments 
 { target *-*-*} 12 } */
+  /* { dg-error reported only once   { target *-*-*} 12 } */
+}
diff --git gcc/gcc/testsuite/gcc.dg/cpp/pr61854-5.c 
gcc/gcc/testsuite/gcc.dg/cpp/pr61854-5.c
index e69de29..a7628dc 100644
--- gcc/gcc/testsuite/gcc.dg/cpp/pr61854-5.c
+++ gcc/gcc/testsuite/gcc.dg/cpp/pr61854-5.c
@@ -0,0 +1,15 @@
+/* PR c/61854 */
+/* { dg-do run } */
+/* { dg-options -std=c89 } */
+
+#define h(x) #x
+#define s(x) h(x)
+#define foo //
+
+int
+main (void)
+{
+  if (__builtin_memcmp (s(foo), //, 3) != 0)
+__builtin_abort ();
+  return 0;
+}
diff --git gcc/gcc/testsuite/gcc.dg/cpp/pr61854-c90.c 
gcc/gcc/testsuite/gcc.dg/cpp/pr61854-c90.c
index e69de29..37eecbe 100644
--- gcc/gcc/testsuite/gcc.dg/cpp/pr61854-c90.c
+++ gcc/gcc/testsuite/gcc.dg/cpp/pr61854-c90.c
@@ -0,0 +1,13 @@
+/* PR c/61854 */
+/* { dg-do preprocess } */
+/* { dg-options -std=iso9899:1990 } */
+
+void
+foo (void)
+{
+  // 1st
+  /* { dg-error C\\+\\+ style comments are not allowed in ISO C90 comments 
 { target *-*-*} 8 } */
+  /* { dg-error reported only once   { target *-*-*} 8 } */
+  // 

PATCH [testsuite]: Update gcc.dg/pr61053.c for x32

2014-09-15 Thread H.J. Lu
Hi,

gcc.dg/pr61053.c fails on x32, which has the same alignments for
floating point types and the integer types with the same size as
x86-64.  This patch is needed for x32.

Tested on ia32, x32 and x86-64.  OK for trunk and 4.8 branch?

Thanks.


H.J.
---
2014-09-15  H.J. Lu  hongjiu...@intel.com

* gcc.dg/pr61053.c: Updated for x32.

diff --git a/gcc/testsuite/gcc.dg/pr61053.c b/gcc/testsuite/gcc.dg/pr61053.c
index 4fd5319..e270420 100644
--- a/gcc/testsuite/gcc.dg/pr61053.c
+++ b/gcc/testsuite/gcc.dg/pr61053.c
@@ -31,17 +31,17 @@ _Alignas (long double) int ild;
 
 _Alignas (char) long int lic; /* { dg-error cannot reduce alignment } */
 _Alignas (short int) long int lis; /* { dg-error cannot reduce alignment } */
-_Alignas (int) long int lii; /* { dg-error cannot reduce alignment  { 
target { ! { ia32 } } } } */
+_Alignas (int) long int lii; /* { dg-error cannot reduce alignment  { 
target { ! { ilp32 } } } } */
 _Alignas (long int) long int lil;
 _Alignas (long long int) long int lill;
-_Alignas (float) long int lif; /* { dg-error cannot reduce alignment  { 
target { ! { ia32 } } } } */
+_Alignas (float) long int lif; /* { dg-error cannot reduce alignment  { 
target { ! { ilp32 } } } } */
 _Alignas (double) long int lid;
 _Alignas (long double) long int lild;
 
 _Alignas (char) long long int llic; /* { dg-error cannot reduce alignment } 
*/
 _Alignas (short int) long long int llis; /* { dg-error cannot reduce 
alignment } */
 _Alignas (int) long long int llii; /* { dg-error cannot reduce alignment  
{ target { ! { ia32 } } } } */
-_Alignas (long int) long long int llil;
+_Alignas (long int) long long int llil; /* { dg-error cannot reduce 
alignment  { target { x32 } } } */
 _Alignas (long long int) long long int llill;
 _Alignas (float) long long int llif; /* { dg-error cannot reduce alignment 
 { target { ! { ia32 } } } } */
 _Alignas (double) long long int llid;
@@ -59,7 +59,7 @@ _Alignas (long double) float fld;
 _Alignas (char) double dc; /* { dg-error cannot reduce alignment } */
 _Alignas (short int) double ds; /* { dg-error cannot reduce alignment } */
 _Alignas (int) double di; /* { dg-error cannot reduce alignment  { target 
{ ! { ia32 } } } } */
-_Alignas (long int) double dl;
+_Alignas (long int) double dl; /* { dg-error cannot reduce alignment  { 
target { x32 } } } */
 _Alignas (long long int) double dll;
 _Alignas (float) double df; /* { dg-error cannot reduce alignment  { 
target { ! { ia32 } } } } */
 _Alignas (double) double dd;


Re: [PATCH, Pointer Bounds Checker 23/x] Function split

2014-09-15 Thread Jeff Law

On 09/15/14 10:20, Ilya Enkovich wrote:


A problem I'm trying to avoid is that bounds in return statement are
not taken into account when checking for data dependencies between
parts.  It means we may have a case when return statement with bounds
is put into split part but bounds producer is not.  If
SSA_NAME_DEFSTMT for returned bounds is in the same partition as a
return then I do not think I should care about the rest of definitions
chain because regular split point checks should make sure we have
everything required.


Is the data dependency in the gimple IL?  If so there shouldn't be anything
particularly special we need to do.  If not, then how ugly would it be to
use the bounds at the return statement to expose the missing dependency?

Not asking you to make that change, just want to make sure that I understand
the core issue and that if something is missing from a dependency standpoint
that we consider what it would take to expose the missing dependency.


Gimple IL has required data dependencies to handle returns properly.
But split pass handles return basic block in a special way.  Return
basic block has to have a simple form and is not scanned using stmt
walkers as it is done for all other BBs by visit_bb.  It is assumed
that all dependencies for return BB are PHI args and returned value.
Thus returned bounds are just not taken into account.  That's how I
see the problem.
I must be misunderstanding something then.  I fundamentally don't see 
how the return bounds are any different here than the return value.  If 
we have exposed the bounds in the IL, then aren't they going to be 
handled just like any other object in the IL?


Maybe you should post the IL for a case where this all matters and walk 
me through the key issues.


jeff


Re: [PATCH, Pointer Bounds Checker 26/x] CCP

2014-09-15 Thread Jeff Law

On 09/15/14 09:57, Ilya Enkovich wrote:

On 15 Sep 09:20, Jeff Law wrote:

On 09/15/14 01:20, Ilya Enkovich wrote:



2014-06-05  Ilya Enkovich  ilya.enkov...@intel.com

 * tree-ssa-ccp.c: Include tree-chkp.h.
 (insert_clobber_before_stack_restore): Handle
 BUILT_IN_CHKP_BNDRET calls.


diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index eeefeaf..e99bcf5 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -144,6 +144,7 @@ along with GCC; see the file COPYING3.  If not see
  #include diagnostic-core.h
  #include dbgcnt.h
  #include params.h
+#include tree-chkp.h


  /* Possible lattice values.  */
@@ -1880,6 +1881,9 @@ insert_clobber_before_stack_restore (tree saved_val, tree 
var,
  else if (gimple_assign_ssa_name_copy_p (stmt))
insert_clobber_before_stack_restore (gimple_assign_lhs (stmt), var,
visited);
+else if (gimple_code (stmt) == GIMPLE_CALL
+ chkp_gimple_call_builtin_p (stmt, BUILT_IN_CHKP_BNDRET))
+  continue;
  else
gcc_assert (is_gimple_debug (stmt));

I think Richi also wanted the

gimple_code (stmt) == GIMPLE_CALL

Turned into:

is_gimple_call (stmt)


Presumably using chkp_gimple_call_builtin_p rather than
gimple_call_builtin_p is related to using different codes for the
instrumented builtin calls?  Otherwise why use
chkp_gimple_call_builtin_p rather than gimple_call_builtin_p?


jeff



The reason is that target may provide own version of builtin (and currently 
does it) for instrumentation.  Therefore we should obtain fndecl from target 
and then compare.  That is what chkp_gimple_call_builtin_p does.  I just moved 
gimple code check into chkp_gimple_call_builtin_p to make similar to 
gimple_call_builtin_p.

Thanks,
Ilya
--
2014-09-15  Ilya Enkovich  ilya.enkov...@intel.com

* tree-ssa-ccp.c: Include tree-chkp.h.
(insert_clobber_before_stack_restore): Handle
BUILT_IN_CHKP_BNDRET calls.

OK.
Jeff



Re: [PATCH, Pointer Bounds Checker 6/x] New static constructor types

2014-09-15 Thread Jeff Law

On 09/15/14 01:14, Ilya Enkovich wrote:

Ping

2014-06-05 15:03 GMT+04:00 Ilya Enkovich enkovich@gmail.com:

2014-06-04 17:35 GMT+04:00 Richard Biener richard.guent...@gmail.com:

On Wed, Jun 4, 2014 at 3:13 PM, Ilya Enkovich enkovich@gmail.com wrote:

2014-06-04 13:58 GMT+04:00 Richard Biener richard.guent...@gmail.com:

On Wed, Apr 16, 2014 at 2:33 PM, Ilya Enkovich enkovich@gmail.com wrote:

Hi,

This patch add new static constructor types used by Pointer Bounds Checker.  It 
was approved earlier for 4.9 and I'll assume patch is OK for trunk if no 
objections arise.

Patch was bootstrapped and tested for linux-x86_64.

Thanks,
Ilya
--
gcc/

2014-04-16  Ilya Enkovich  ilya.enkov...@intel.com

 * ipa.c (cgraph_build_static_cdtor_1): Support contructors
 with chkp ctor and bnd_legacy attributes.
 * gimplify.c (gimplify_init_constructor): Avoid infinite
 loop during gimplification of bounds initializer.


diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 7441784..67ab515 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -3803,10 +3803,19 @@ gimplify_init_constructor (tree *expr_p, gimple_seq 
*pre_p, gimple_seq *post_p,
individual element initialization.  Also don't do this for small
all-zero initializers (which aren't big enough to merit
clearing), and don't try to make bitwise copies of
-  TREE_ADDRESSABLE types.  */
+  TREE_ADDRESSABLE types.
+
+  We cannot apply such transformation when compiling chkp static
+  initializer because creation of initializer image in the memory
+  will require static initialization of bounds for it.  It should
+  result in another gimplification of similar initializer and we
+  may fall into infinite loop.  */
 if (valid_const_initializer
  !(cleared || num_nonzero_elements == 0)
-!TREE_ADDRESSABLE (type))
+!TREE_ADDRESSABLE (type)
+(!current_function_decl
+   || !lookup_attribute (chkp ctor,
+ DECL_ATTRIBUTES (current_function_decl


Simply make the type TREE_ADDRESSABLE?


Wouldn't it be a hack to mark it addressable just to not hit this
condition? It would also require to have an unshared copy of the type
to not affect other statements with that type.




   {
 HOST_WIDE_INT size = int_size_in_bytes (type);
 unsigned int align;
diff --git a/gcc/ipa.c b/gcc/ipa.c
index 26e9b03..5ab3aed 100644
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -1345,9 +1345,11 @@ make_pass_ipa_whole_program_visibility (gcc::context 
*ctxt)
  }

  /* Generate and emit a static constructor or destructor.  WHICH must
-   be one of 'I' (for a constructor) or 'D' (for a destructor).  BODY
-   is a STATEMENT_LIST containing GENERIC statements.  PRIORITY is the
-   initialization priority for this constructor or destructor.
+   be one of 'I' (for a constructor), 'D' (for a destructor), 'P'
+   (for chp static vars constructor) or 'B' (for chkp static bounds
+   constructor).  BODY is a STATEMENT_LIST containing GENERIC
+   statements.  PRIORITY is the initialization priority for this
+   constructor or destructor.

 FINAL specify whether the externally visible name for collect2 should
 be produced. */
@@ -1406,6 +1408,20 @@ cgraph_build_static_cdtor_1 (char which, tree body, int 
priority, bool final)
DECL_STATIC_CONSTRUCTOR (decl) = 1;
decl_init_priority_insert (decl, priority);
break;
+case 'P':
+  DECL_STATIC_CONSTRUCTOR (decl) = 1;
+  DECL_ATTRIBUTES (decl) = tree_cons (get_identifier (chkp ctor),
+ NULL,
+ NULL_TREE);


Ick.  Please try to avoid using attributes for this.  Rather adjust the
caller of this function to set a flag in the cgraph node.


It is too late because all early local passes are executed by that
time and I need this attribute to be set before them.


Ok, so where do you call this from?  It should be possible to create
the function in GIMPLE form directly, avoiding the need to go through
gimplification.


I create constructors at the end of unit compilation in
chkp_finish_file. Constructor body in this case is MODIFY_EXPRs for
all statically initialized pointers. chkp ctor attribute is used to
instrument this constructor properly - all pointer modifications
should be replaced with corresponding bounds initialization. Thus
gimplification is not the only place where this attribute is used.
This patch is fine.  I know Richi didn't like it, but I don't see a 
really good way around this.


Jeff



Re: [PATCH] Improve prepare_shrink_wrap to sink more instructions

2014-09-15 Thread Jeff Law

On 09/11/14 14:58, Wang Jiong wrote:


the reg_found will record the # of registers, and there will be a
check to make sure no register or just 1 register in the src.
so if reg_found is bigger than 1, then src will be assigned to
NULL_RTX, that we just stop the move.

   +  if (arg.nonconst_found
   +  || arg.reg_found  1)
   +src = NULL_RTX;

   am I missing something here?
No, I was just reiterating that you are going to need that code, so some 
kind of walker would still be necessary.  Sorry I wasn't clear about that.


jeff



Re: [PATCH, Fortran] Wrong invocation of caf_atomic_op

2014-09-15 Thread Tobias Burnus

On 15.09.2014 22:23, Alessandro Fanfarillo wrote:

In attachment a test case which fails with the current gcc-trunk
version but works when the patch is applied. coarray_35.f90 is my
attempt to write a gcc test case.
The problem is related with atomic_add.


Well, if it is a dg-do compile test, it won't exercise the issue: Even 
without the patch, it was compiling.


It should either be a run test (dg-do run) – and then under 
gfortran.dg/coarray/ - which will automatically link libcaf_single to 
it. (And do another run with -fcoarray=single). – Or you have to 
additionally use -fdump-tree-original and scan for the strings, using 
dg-final { scan-tree-dump-times ... or scan-tree-dump-not. See other 
test cases there.


I think ATOMIC_ADD should also fail without the patch, i.e. the run test 
really would test whether it works. Thus, that might be the simpler 
option. Or you do both – but the dump one shouldn't be under 
gfortran.dg/coarray/ as that is also run with -fcoarray=single, but 
under gfortran.dg/ directly.


Tobias


Re: [Patch] PR 61692 - Fix for inline asm ICE

2014-09-15 Thread Jeff Law

On 09/14/14 02:13, David Wohlferd wrote:

I sent you the file you requested (off list), but never heard back from
you about the valgrind results.
Just haven't got back to it yet...  There's always more to get done on 
any given day than I have the time for, so I have to prioritize and some 
things get put on the back burner until I can get back to them.




In an effort to move this along, I installed ubuntu under virtualbox and
did a build of gcc.  When running the output of this build with
valgrind, I saw a number of memory *leaks* reported, but no overruns,
despite having maxed out the operands + clobbers in a variety of ways.
OK.  Something else must be in play here.  Clobbers can be somewhat 
special in that they may not always been an operand in the usual sense. 
 ie, often they'll just be attached to the insn as an explicit blob of 
RTL, that's the only thing I can think of that would be preventing us 
from losing here.




If you are also out of ideas, I can re-send the patch for the original
ninputs + noutputs + nlabels problem (along with the testcase you
requested), and we can at least fix the known ICE.
Let's go with your original inputs + outputs + labels change and punt 
the clobbers stuff for now.


jeff



Re: [PATCH] Fix PR debug/60433: Handle TEMPLATE_TYPE_PARM in dbxout_type

2014-09-15 Thread Jeff Law

On 09/11/14 15:36, John David Anglin wrote:

On 9/11/2014 4:18 PM, Jeff Law wrote:

On 09/07/14 11:52, John David Anglin wrote:

The attached change fixes an ICE in dbxout_type on hppa2.0w-hp-hpux11.11
compiling auto-fn24.C.

Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.

OK for trunk and 4.9?

Is dbxout.c allowed to look at language specific nodes?  Isn't
TEMPLATE_TYPE_PARM defined by the C++ front-end .def file?

It's been eons since I looked at dbxout.c -- does it have hooks to
deal with language specific nodes?


I don't have an answer to your questions but in dbxout_type_methods we
skip TEMPLATE_DECLs.  I stuck
the TEMPLATE_TYPE_PARM with void type because of this.  It already
includes LANG_TYPE.
Yea, but the implementation around TEMPLATE_DECLs is to skip anything 
that isn't a FUNCTION_DECL.


I can't find anything in dbxout.c which references language specific 
nodes, so I'm hesitant to add them, even in something as rarely used as 
dbxout.c.


Can we take inspiration from dwarf2out.c here?

See is_ccx_auto and how it gets used in the type code.

jeff


Re: [PATCH] microblaze: microblaze.md: Use 'SI' instead of 'VOID' for operand 1 of 'call_value_intern'

2014-09-15 Thread Chen Gang
On 09/15/2014 11:30 PM, Michael Eager wrote:
 On 09/14/14 21:19, Chen Gang wrote:

 On 9/15/14 11:03, Michael Eager wrote:
 On 09/14/14 00:51, Chen Gang wrote:
 Hello maintainers:

 I also find some warnings during compiling microblaze, I also shall try
 to fix them, but excuse me, I am not quite familiar the testsuite for
 microblaze, could you provide any related information for it?

 Hi Chen --

 This is the gcc DejaGNU test suite.  You can find info about DejaGNU
 at http://www.gnu.org/software/dejagnu.  There is also info about
 testing GCC here: https://gcc.gnu.org/wiki/Testing_GCC


 OK, thanks. I finished about x86_64 testsuite, and also tried microblaze
 testsuite under x86_64 machine, but failed. Do I need any additional
 information for microblaze testsuite?
 
 I run tests using these options:
 -mno-xl-soft-mul -mxl-barrel-shift -mcpu=v6.00.a
 

OK, thank you for your information.

 Configuring DejaGNU for cross-target testing requires creating a configuration
 file describing the target board.
 

OK, thank you very much. And could you share your configuration file,
which I can reference to?


Thanks.
-- 
Chen Gang

Open share and attitude like air water and life which God blessed


Re: [PATCH] Avoid inter-test dependencies in gfortran.dg (PR fortran/56408)

2014-09-15 Thread Bernhard Reutner-Fischer

On 15 September 2014 19:49:03 Mike Stump mikest...@comcast.net wrote:


On Sep 15, 2014, at 9:13 AM, Jakub Jelinek ja...@redhat.com wrote:
 Here is an attempt to fix gfortran dg.exp testing in case of very
 fine-grained parallelization.

Ok.


Looks like the right approach, yes.
Many thanks for doing this!
Cheers,

Sent with AquaMail for Android
http://www.aqua-mail.com




[gomp4] OpenACC routine directive

2014-09-15 Thread Cesar Philippidis
This patch adds initial support for the OpenACC routine directive. It's
not complete just yet because it doesn't implement any of the optional
clauses, except for the optional function/subroutine name. As such, it
doesn't go beyond marking functions with the omp declare target attribute.

According to the OpenACC technical committee, the routine clause will be
revised in the next OpenACC 2.x release. In particular, function
definitions must have an 'acc routine' associated with it. My
understanding is 'acc routine' should also be visible at the call site,
but if it's not the compiler can treat it as a regular function call.
Furthermore, I've been told that it's not sufficient to place the
routine directive in an interface block by itself. E.g.

  interface
recursive function fact (x)
  !$acc routine
  integer, intent(in) :: x
  integer :: fact
end function fact
  end interface
  integer, parameter :: n = 10
  integer :: a(n), i
  !$acc parallel
  !$acc loop
  do i = 1, n
 a(i) = fact (i)
  end do
  !$acc end parallel
  do i = 1, n
 write (*, (I10)) a(i)
  end do
end
recursive function fact (x) result (res)
  integer, intent(in) :: x
  integer :: res
  if (x  1) then
 res = 1
  else
 res = x * fact (x - 1)
  end if
end function fact

This will result in a runtime failure because gcc will not generate an
accelerated version of fact. The justification for this is that fortran
lacks a file scope, so 'acc routine' wouldn't be visible to fact.

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

Thanks,
Cesar
2014-09-15  Cesar Philippidis  ce...@codesourcery.com

	gcc/c-family/
	* c-pragma.c (oacc_pragmas): Add the routine pragma.
	* c-pragma.h (pragma_kind): Add PRAGMA_OACC_ROUTINE.

	gcc/c/
	* c-parser.c (struct c_parser): New oacc_routines member.
	(c_parser_external_declaration): Update call to
	c_parser_declaration_or_fndef.
	(c_parser_declaration_or_fndef): Add oacc_routine_clauses and
	oacc_routine_named parameters. Use them in calls to
	c_finish_oacc_routine and c_parser_declaration_or_fndef.
	(c_parser_compound_statement_nostart): Update call to
	c_parser_declaration_or_fndef.
	(c_parser_label): Likewise.
	(c_parser_for_statement): Likewise.
	(c_parser_objc_methodprotolist): Likewise.
	(c_parser_pragma): Handle PRAGMA_OACC_ROUTINE.
	(OACC_ROUTINE_CLAUSE_MASK): New macro. 
	(c_parser_oacc_routine): New function.
	(c_finish_oacc_routine): New function.
	(c_parser_omp_for_loop): Update calls to c_parser_declaration_or_fndef.
	(c_parser_omp_declare_simd): Likewise.
	(c_parse_file): Initialize oacc_routines.

	gcc/fortran/
	* gfortran.h (ST_OACC_ROUTINE): New statement enum.
	* match.h (gfc_match_oacc_routine): New prototype.
	* openmp.c (gfc_match_oacc_routine): New function.
	* parse.c (decode_oacc_directive): Handle the routine directive.
	(next_statement): Handle ST_OACC_ROUTINE.
	(gfc_ascii_statement): Likewise.

	gcc/testsuite/
	* c-c++-common/goacc/routine-1.c: New test.
	* c-c++-common/goacc/routine-2.c: New test.
	* gfortran.dg/goacc/routine-1.f90: New test.
	* gfortran.dg/goacc/routine-2.f90: New test.


diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c
index 2d9071a..2ff99f5 100644
--- a/gcc/c-family/c-pragma.c
+++ b/gcc/c-family/c-pragma.c
@@ -1177,6 +1177,7 @@ static const struct omp_pragma_def oacc_pragmas[] = {
   { kernels, PRAGMA_OACC_KERNELS },
   { loop, PRAGMA_OACC_LOOP },
   { parallel, PRAGMA_OACC_PARALLEL },
+  { routine, PRAGMA_OACC_ROUTINE },
   { update, PRAGMA_OACC_UPDATE },
   { wait, PRAGMA_OACC_WAIT },
 };
diff --git a/gcc/c-family/c-pragma.h b/gcc/c-family/c-pragma.h
index 4722d51..c097857 100644
--- a/gcc/c-family/c-pragma.h
+++ b/gcc/c-family/c-pragma.h
@@ -32,6 +32,7 @@ typedef enum pragma_kind {
   PRAGMA_OACC_KERNELS,
   PRAGMA_OACC_LOOP,
   PRAGMA_OACC_PARALLEL,
+  PRAGMA_OACC_ROUTINE,
   PRAGMA_OACC_UPDATE,
   PRAGMA_OACC_WAIT,
   PRAGMA_OMP_ATOMIC,
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 09df223..0632c69 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -215,6 +215,10 @@ typedef struct GTY(()) c_parser {
   /* Buffer to hold all the tokens from parsing the vector attribute for the
  SIMD-enabled functions (formerly known as elemental functions).  */
   vec c_token, va_gc *cilk_simd_fn_tokens;
+
+  /* OpenACC specific parser information.  */
+
+  vec tree, va_gc *oacc_routines;
 } c_parser;
 
 
@@ -1150,7 +1154,8 @@ enum c_parser_prec {
 static void c_parser_external_declaration (c_parser *);
 static void c_parser_asm_definition (c_parser *);
 static void c_parser_declaration_or_fndef (c_parser *, bool, bool, bool,
-	   bool, bool, tree *, vecc_token);
+	   bool, bool, tree *, vecc_token,
+	   tree, bool);
 static void c_parser_static_assert_declaration_no_semi (c_parser *);
 static void c_parser_static_assert_declaration (c_parser *);
 static void c_parser_declspecs (c_parser *, struct c_declspecs *, bool, bool,
@@ -1238,6 +1243,8 @@ static bool c_parser_pragma (c_parser *, enum pragma_context);
 

[PATCH] Do not allow non-allocatable registers in scratch_operand

2014-09-15 Thread Segher Boessenkool
Currently, scratch_operand allows all hard registers, also those that
cannot be allocated and are only generated explicitly by the backend.

This causes problems.  Consider the case where combine combines
instructions A and B, where B clobbers such a non-allocatable hard reg X,
into an instruction C that has a clobber of a match_scratch.  Concretely
for example:

A is  (set (reg:SI 98) (eq:SI ...))
B is  (parallel [(set (reg:SI 99) (minus (const_int 1) (reg:SI 98)))
 (clobber (reg:SI CA_REGNO))])

so that combine tries an insn C
(parallel [(set (reg:SI 99) (ne:SI ...))
   (clobber (reg:SI CA_REGNO))])

which matches the pattern
(parallel [(set (match_operand:SI 0 ... =r) (ne:SI ...))
   (clobber (match_scratch:SI 3 =r))])

which is not going to work; it is not a valid insn.  (In my testcase,
reload eventually replaces CA_REGNO with a GPR that is not dead.  Oops.)

Combine shouldn't keep the original clobbers.  But also, scratch_operand
should not allow non-allocatable registers, since that can never work.
This patch does the latter.

Bootstrapped and regression checked on powerpc64-linux, with options
-m32,-m32/-mpowerpc64,-m64,-m64/-mlra.  No regressions, and testcase
fixed (the testcase is forall_4.f90, it requires some backend patches
to fail).

Is this okay for mainline?


Segher


2014-09-15  Segher Boessenkool  seg...@kernel.crashing.org

* recog.c (scratch_operand): Do not simply allow all hard registers:
only allow those that are allocatable.

---
 gcc/recog.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/recog.c b/gcc/recog.c
index 2150b7a..6987afb 100644
--- a/gcc/recog.c
+++ b/gcc/recog.c
@@ -1143,7 +1143,9 @@ scratch_operand (rtx op, enum machine_mode mode)
 
   return (GET_CODE (op) == SCRATCH
  || (REG_P (op)
-  (lra_in_progress || REGNO (op)  FIRST_PSEUDO_REGISTER)));
+  (lra_in_progress
+ || (REGNO (op)  FIRST_PSEUDO_REGISTER
+  REGNO_REG_CLASS (REGNO (op)) != NO_REGS;
 }
 
 /* Return 1 if OP is a valid immediate operand for mode MODE.
-- 
1.8.1.4



C++ PATCH to template argument abi_tag handling

2014-09-15 Thread Jason Merrill
Jon sent me a test that crashed with an abi_tag on a template argument. 
 We need to propagate tags from template arguments when we first look 
up the specialization, not wait until instantiation.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 44db0cad1ad6b651616ab144896c358274eacf4f
Author: Jason Merrill ja...@redhat.com
Date:   Sat Sep 13 10:52:56 2014 -0400

	* pt.c (lookup_template_class_1): Splice out abi_tag attribute if
	necessary.  Call inherit_targ_abi_tags here.
	* class.c (check_bases_and_members): Not here.
	(inherit_targ_abi_tags): Check CLASS_TYPE_P.
	* cp-tree.h: Declare inherit_targ_abi_tags.

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 09f946f..6b86ef4 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -1441,7 +1441,8 @@ check_abi_tags (tree t, tree subob)
 void
 inherit_targ_abi_tags (tree t)
 {
-  if (CLASSTYPE_TEMPLATE_INFO (t) == NULL_TREE)
+  if (!CLASS_TYPE_P (t)
+  || CLASSTYPE_TEMPLATE_INFO (t) == NULL_TREE)
 return;
 
   mark_type_abi_tags (t, true);
@@ -5460,9 +5461,6 @@ check_bases_and_members (tree t)
   bool saved_nontrivial_dtor;
   tree fn;
 
-  /* Pick up any abi_tags from our template arguments before checking.  */
-  inherit_targ_abi_tags (t);
-
   /* By default, we use const reference arguments and generate default
  constructors.  */
   cant_have_const_ctor = 0;
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 19f5232..5d8badc 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -5206,6 +5206,7 @@ extern bool type_has_user_declared_move_assign(tree);
 extern bool type_build_ctor_call		(tree);
 extern bool type_build_dtor_call		(tree);
 extern void explain_non_literal_class		(tree);
+extern void inherit_targ_abi_tags		(tree);
 extern void defaulted_late_check		(tree);
 extern bool defaultable_fn_check		(tree);
 extern void fixup_type_variants			(tree);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 008879b..b3a9c95 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -7823,9 +7823,18 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context,
 
   if (OVERLOAD_TYPE_P (t)
 	   !DECL_ALIAS_TEMPLATE_P (gen_tmpl))
-	if (tree attributes
-	= lookup_attribute (abi_tag, TYPE_ATTRIBUTES (template_type)))
-	  TYPE_ATTRIBUTES (t) = attributes;
+	{
+	  if (tree attributes
+	  = lookup_attribute (abi_tag, TYPE_ATTRIBUTES (template_type)))
+	{
+	  if (!TREE_CHAIN (attributes))
+		TYPE_ATTRIBUTES (t) = attributes;
+	  else
+		TYPE_ATTRIBUTES (t)
+		  = build_tree_list (TREE_PURPOSE (attributes),
+ TREE_VALUE (attributes));
+	}
+	}
 
   /* Let's consider the explicit specialization of a member
  of a class template specialization that is implicitly instantiated,
@@ -7950,6 +7959,8 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context,
   TREE_PUBLIC (type_decl) = 1;
   determine_visibility (type_decl);
 
+  inherit_targ_abi_tags (t);
+
   return t;
 }
 }
diff --git a/gcc/testsuite/g++.dg/abi/abi-tag10.C b/gcc/testsuite/g++.dg/abi/abi-tag10.C
new file mode 100644
index 000..f320828
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/abi-tag10.C
@@ -0,0 +1,28 @@
+#ifndef ABI_TAG
+#define ABI_TAG __attribute__((__abi_tag__(cxx11)))
+#endif
+
+typedef unsigned long size_t;
+
+templatetypename C
+struct char_traits { };
+templatetypename C
+struct allocator { };
+
+templatetypename C, typename T = char_traitsC, typename A = allocatorC 
+struct ABI_TAG basic_string { };
+
+typedef basic_stringchar string;
+
+templatetypename T
+struct hash
+{
+  size_t
+  operator()(T val) const;
+};
+
+template
+size_t
+hashstring::operator()(string) const { return 0; }
+
+// { dg-final { scan-assembler _ZNK4hashI12basic_stringB5cxx11Ic11char_traitsIcE9allocatorIcEEEclES5_ } }


RE: [PATCH 3/3,ARM,libgcc]Code size optimization for the fmul/fdiv and dmul/ddiv function in libgcc

2014-09-15 Thread Tony Wang
Ping?

 -Original Message-
 From: Tony Wang [mailto:tony.w...@arm.com]
 Sent: Thursday, September 04, 2014 10:16 AM
 To: 'gcc-patches@gcc.gnu.org'
 Cc: Richard Earnshaw; Ramana Radhakrishnan
 Subject: RE: [PATCH 3/3,ARM,libgcc]Code size optimization for the fmul/fdiv 
 and dmul/ddiv function in libgcc
 
 Ping 2?
 
  -Original Message-
  From: Tony Wang [mailto:tony.w...@arm.com]
  Sent: Thursday, August 28, 2014 2:02 PM
  To: 'gcc-patches@gcc.gnu.org'
  Cc: Richard Earnshaw; Ramana Radhakrishnan
  Subject: RE: [PATCH 3/3,ARM,libgcc]Code size optimization for the fmul/fdiv 
  and dmul/ddiv function in
libgcc
 
  Ping?
 
   -Original Message-
   From: Tony Wang [mailto:tony.w...@arm.com]
   Sent: Thursday, August 21, 2014 2:15 PM
   To: 'gcc-patches@gcc.gnu.org'
   Subject: [PATCH 3/3,ARM,libgcc]Code size optimization for the fmul/fdiv 
   and dmul/ddiv function in libgcc
  
   Step 3: Test cases to verify the code size reduction.
  
   gcc/gcc/testsuite/ChangeLog:
   2014-08-21  Tony Wang  tony.w...@arm.com
  
   * gcc.target/arm/size-optimization-ieee-1.c: New test case
   * gcc.target/arm/size-optimization-ieee-2.c: New test case
   * lib/gcc-dg.exp: Add new function scan-symbol-common, 
   scan-symbol-yes,
   scan-symbol-no to scan a user defined symbol in final elf file
  
   BR,
   Tony
  
   diff --git a/gcc/testsuite/gcc.target/arm/size-optimization-ieee-1.c
b/gcc/testsuite/gcc.target/arm/size-
   optimization-ieee-1.c
   new file mode 100644
   index 000..46e9cdf
   --- /dev/null
   +++ b/gcc/testsuite/gcc.target/arm/size-optimization-ieee-1.c
   @@ -0,0 +1,30 @@
   +/* { dg-do link { target { arm_thumb2_ok } } } */
   +/* { dg-options -Wl,--gc-sections } */
   +int
   +foo ()
   +{
   +  volatile float a;
   +  volatile float b;
   +  volatile float c = a * b;
   +  return 0;
   +}
   +
   +int
   +bar ()
   +{
   +  volatile double a;
   +  volatile double b;
   +  volatile double c = a * b;
   +  return 0;
   +}
   +
   +int
   +main ()
   +{
   +  foo ();
   +  bar ();
   +  return 0;
   +}
   +/* { dg-final { scan-symbol-no __aeabi_fdiv } } */
   +/* { dg-final { scan-symbol-no __aeabi_ddiv } } */
   +
   diff --git a/gcc/testsuite/gcc.target/arm/size-optimization-ieee-2.c
b/gcc/testsuite/gcc.target/arm/size-
   optimization-ieee-2.c
   new file mode 100644
   index 000..5007d62
   --- /dev/null
   +++ b/gcc/testsuite/gcc.target/arm/size-optimization-ieee-2.c
   @@ -0,0 +1,30 @@
   +/* { dg-do link { target { arm_thumb2_ok } } } */
   +/* { dg-options -Wl,--gc-sections } */
   +int
   +foo ()
   +{
   +  volatile float a;
   +  volatile float b;
   +  volatile float c = a / b;
   +  return 0;
   +}
   +
   +int
   +bar ()
   +{
   +  volatile double a;
   +  volatile double b;
   +  volatile double c = a / b;
   +  return 0;
   +}
   +
   +int
   +main ()
   +{
   +  foo ();
   +  bar ();
   +  return 0;
   +}
   +/* { dg-final { scan-symbol-yes __aeabi_fmul } } */
   +/* { dg-final { scan-symbol-yes __aeabi_dmul } } */
   +
   diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
   index 3390caa..0d52e95 100644
   --- a/gcc/testsuite/lib/gcc-dg.exp
   +++ b/gcc/testsuite/lib/gcc-dg.exp
   @@ -880,5 +880,57 @@ proc gdb-exists { args } {
return 0;
}
  
   +# Scan the OUTPUT_FILE for a symbol. Return 1 if it present, or
   +# return 0 if it doesn't present
   +
   +proc scan-symbol-common { args } {
   +global nm
   +global base_dir
   +
   +set testcase [testname-for-summary]
   +set output_file [file rootname [file tail $testcase]].exe
   +
   +# Find nm like we find g++ in g++.exp.
   +if ![info exists nm]  {
   +set nm [findfile $base_dir/../../../binutils/nm \
   +$base_dir/../../../binutils/nm \
   +[findfile $base_dir/../../nm $base_dir/../../nm \
   +  [findfile $base_dir/nm $base_dir/nm \
   +   [transform nm
   +verbose -log nm is $nm
   +}
   +
   +if { $output_file ==  } {
   +fail scan-symbol-not $args: dump file does not exist
   +return
   +}
   +
   +set fd [open | $nm $output_file r]
   +set text [read $fd]
   +close $fd
   +
   +if [regexp -- [lindex $args 0] $text] {
   +return 1
   +} else {
   +return 0
   +}
   +}
   +
   +proc scan-symbol-yes { args } {
   +if { [scan-symbol-common $args] == 1 } {
   + pass scan-symbol-yes $args exists
   +} else {
   + fail scan-symbol-yes $args does not exist
   +}
   +}
   +
   +proc scan-symbol-no { args } {
   +if { [scan-symbol-common $args] != 1 } {
   +pass scan-symbol-no $args does not exist
   +} else {
   +fail scan-symbol-no $args exists
   +}
   +}
   +
set additional_prunes 
set dg_runtest_extra_prunes 





RE: [PATCH 1/3,ARM,libgcc]Code size optimization for the fmul/fdiv and dmul/ddiv function in libgcc

2014-09-15 Thread Tony Wang
Ping?

 -Original Message-
 From: Tony Wang [mailto:tony.w...@arm.com]
 Sent: Thursday, September 04, 2014 10:15 AM
 To: 'gcc-patches@gcc.gnu.org'
 Cc: Richard Earnshaw; Ramana Radhakrishnan
 Subject: RE: [PATCH 1/3,ARM,libgcc]Code size optimization for the fmul/fdiv 
 and dmul/ddiv function in libgcc
 
 Ping 2?
 
  -Original Message-
  From: Tony Wang [mailto:tony.w...@arm.com]
  Sent: Thursday, August 28, 2014 2:02 PM
  To: 'gcc-patches@gcc.gnu.org'
  Cc: Richard Earnshaw; Ramana Radhakrishnan
  Subject: RE: [PATCH 1/3,ARM,libgcc]Code size optimization for the fmul/fdiv 
  and dmul/ddiv function in
libgcc
 
  Ping?
 
   -Original Message-
   From: Tony Wang [mailto:tony.w...@arm.com]
   Sent: Thursday, August 21, 2014 2:15 PM
   To: 'gcc-patches@gcc.gnu.org'
   Subject: [PATCH 1/3,ARM,libgcc]Code size optimization for the fmul/fdiv 
   and dmul/ddiv function in libgcc
  
   Hi there,
  
   In libgcc the file ieee754-sf.S and ieee754-df.S have some function pairs 
   which will be bundled into one
.o file
  and
   sharing the same .text section. For example, the fmul and fdiv, the 
   libgcc makefile will build them into
one .o
  file
   and archived into libgcc.a. So when user only call single float point 
   multiply functions, the fdiv
function will
 also
  be
   linked, and as fmul and fdiv share the same .text section, linker option 
   --gc-sections or -flot can't
remove the
   dead code.
  
   So this optimization just separates the function pair(fmul/fdiv and 
   dmul/ddiv) into different sections,
 following
   the naming pattern of -ffunction-sections(.text.__functionname), through 
   which the unused sections of
   fdiv/ddiv can be eliminated through option --gcc-sections when users only 
   use fmul/dmul.The solution is
to
  add
   a conditional statement in the macro FUNC_START, which will conditional 
   change the section of a function
   from .text to .text.__\name. when compiling with the L_arm_muldivsf3 or 
   L_arm_muldivdf3 macro.
  
   GCC regression test has been done on QEMU for Cortex-M3. No new 
   regressions when turn on this patch.
  
   The code reduction for thumb2 on cortex-m3 is:
   1. When user only use single float point multiply:
   fmul+fdiv = fmul will have a code size reduction of 318 bytes.
  
   2. When user only use double float point multiply:
   dmul+ddiv = dmul will have a code size reduction of 474 bytes.
  
   Ok for trunk?
  
   BR,
   Tony
  
   Step 1: Provide another option: sp-scetion to control whether to split 
   the section of a function pair
into two
  part.
  
   gcc/libgcc/ChangeLog:
   2014-08-21  Tony Wang  tony.w...@arm.com
  
   * config/arm/lib1funcs.S (FUNC_START): Add conditional section
   redefine for macro L_arm_muldivsf3 and L_arm_muldivdf3
   (SYM_END, ARM_SYM_START): Add macros used to expose function
   Symbols
  
   diff --git a/libgcc/config/arm/lib1funcs.S b/libgcc/config/arm/lib1funcs.S
   index b617137..0f87111 100644
   --- a/libgcc/config/arm/lib1funcs.S
   +++ b/libgcc/config/arm/lib1funcs.S
   @@ -418,8 +418,12 @@ SYM (\name):
#define THUMB_SYNTAX
#endif
  
   -.macro FUNC_START name
   +.macro FUNC_START name sp_section=
   +  .ifc \sp_section, function_section
   + .section.text.__\name,ax,%progbits
   +  .else
 .text
   +  .endif
 .globl SYM (__\name)
 TYPE (__\name)
 .align 0
   @@ -429,14 +433,24 @@ SYM (\name):
SYM (__\name):
.endm
  
   +.macro ARM_SYM_START name
   +   TYPE (\name)
   +   .align 0
   +SYM (\name):
   +.endm
   +
   +.macro SYM_END name
   +   SIZE (\name)
   +.endm
   +
/* Special function that will always be coded in ARM assembly, even if
   in Thumb-only compilation.  */
  
#if defined(__thumb2__)
  
/* For Thumb-2 we build everything in thumb mode.  */
   -.macro ARM_FUNC_START name
   -   FUNC_START \name
   +.macro ARM_FUNC_START name sp_section=
   +   FUNC_START \name \sp_section
   .syntax unified
.endm
#define EQUIV .thumb_set
   @@ -467,8 +481,12 @@ _L__\name:
#ifdef __ARM_ARCH_6M__
#define EQUIV .thumb_set
#else
   -.macro   ARM_FUNC_START name
   +.macro   ARM_FUNC_START name sp_section=
   +  .ifc \sp_section, function_section
   + .section.text.__\name,ax,%progbits
   +  .else
 .text
   +  .endif
 .globl SYM (__\name)
 TYPE (__\name)
 .align 0





RE: [PATCH 2/3,ARM,libgcc]Code size optimization for the fmul/fdiv and dmul/ddiv function in libgcc

2014-09-15 Thread Tony Wang
Ping?

 -Original Message-
 From: Tony Wang [mailto:tony.w...@arm.com]
 Sent: Thursday, September 04, 2014 10:16 AM
 To: 'gcc-patches@gcc.gnu.org'
 Cc: Richard Earnshaw; Ramana Radhakrishnan
 Subject: RE: [PATCH 2/3,ARM,libgcc]Code size optimization for the fmul/fdiv 
 and dmul/ddiv function in libgcc
 
 Ping 2?
 
  -Original Message-
  From: Tony Wang [mailto:tony.w...@arm.com]
  Sent: Thursday, August 28, 2014 2:02 PM
  To: 'gcc-patches@gcc.gnu.org'
  Cc: Richard Earnshaw; Ramana Radhakrishnan
  Subject: RE: [PATCH 2/3,ARM,libgcc]Code size optimization for the fmul/fdiv 
  and dmul/ddiv function in
libgcc
 
  Ping?
 
   -Original Message-
   From: Tony Wang [mailto:tony.w...@arm.com]
   Sent: Thursday, August 21, 2014 2:15 PM
   To: 'gcc-patches@gcc.gnu.org'
   Subject: [PATCH 2/3,ARM,libgcc]Code size optimization for the fmul/fdiv 
   and dmul/ddiv function in libgcc
  
   Step 2: Mark all the symbols around the fragment boundaries as function 
   symbols, so as to generate
veneer
   when the two section is too far away from each other. Also, I have both 
   manually and using some test
cases
 to
   verify that IP and PSR are not alive at such point.
  
   gcc/libgcc/ChangeLog:
   2014-8-21   Tony Wang tony.w...@arm.com
  
   * config/arm/ieee754-sf.S: Expose symbols around fragment 
   boundaries as function symbols.
   * config/arm/ieee754-df.S: Same with above
  
   BR,
   Tony





Updated no_reorder patchkit

2014-09-15 Thread Andi Kleen
This version addresses earlier comments and has an updated testsuite
(still no LTO tests however). The assembler statements also
no stay in order with ordered statements.

It doesn't disable sorting of paritions with ordered symbols. I think
that's an existing bug and is best addressed separately.

Passed LTO boot strap and test on x86_64-linux, plus build
of a large project that needs LTO order.

-Andi



[PATCH 2/2] Add test cases for noreorder

2014-09-15 Thread Andi Kleen
From: Andi Kleen a...@linux.intel.com

Add some simple test cases for noreorder behaving like
-fno-toplevel-reorder and -fno-toplevel-reorder still working.
Unfortunately there's no easy way to check for output order in DG,
so we just check for existence.

gcc/testsuite/:

2014-09-15  Andi Kleen  a...@linux.intel.com

* gcc.dg/noreorder.c: New test.
* gcc.dg/noreorder2.c: New test.
* gcc.dg/noreorder3.c: New test.
* gcc.dg/noreorder4.c: New test.
---
 gcc/testsuite/gcc.dg/noreorder.c  | 38 ++
 gcc/testsuite/gcc.dg/noreorder2.c | 11 +++
 gcc/testsuite/gcc.dg/noreorder3.c | 10 ++
 gcc/testsuite/gcc.dg/noreorder4.c |  5 +
 4 files changed, 64 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/noreorder.c
 create mode 100644 gcc/testsuite/gcc.dg/noreorder2.c
 create mode 100644 gcc/testsuite/gcc.dg/noreorder3.c
 create mode 100644 gcc/testsuite/gcc.dg/noreorder4.c

diff --git a/gcc/testsuite/gcc.dg/noreorder.c b/gcc/testsuite/gcc.dg/noreorder.c
new file mode 100644
index 000..7d40a29
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/noreorder.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-options -O2 } */
+
+/* The function order in this file is opposite from what the cgraph
+   topological sort would output. So we can check the order is preserved. */
+
+extern void f2(int);
+static int func2(void);
+
+#ifndef NOREORDER
+#define NOREORDER __attribute__((no_reorder))
+#endif
+
+asm(firstasm);
+
+NOREORDER __attribute__((noinline)) int bozo(void)
+{
+  f2(3);
+  func2();
+}
+
+asm(jukjuk);
+
+NOREORDER __attribute__((noinline)) static int func1(void)
+{
+  f2(1);
+}
+
+asm(barbar);
+
+NOREORDER __attribute__((noinline)) static int func2(void)
+{
+  func1();
+}
+
+asm(lastasm);
+
+/* { dg-final { scan-assembler 
firstasm.*bozo.*jukjuk.*func1.*barbar.*func2.*lastasm } } */
diff --git a/gcc/testsuite/gcc.dg/noreorder2.c 
b/gcc/testsuite/gcc.dg/noreorder2.c
new file mode 100644
index 000..558361b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/noreorder2.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options -O2 -fno-toplevel-reorder } */
+
+__attribute__((no_reorder)) int foobar;
+
+static int barbar;
+int bozo;
+
+/* { dg-final { scan-assembler foobar } } */
+/* { dg-final { scan-assembler bozo } } */
+/* { dg-final { scan-assembler barbar } } */
diff --git a/gcc/testsuite/gcc.dg/noreorder3.c 
b/gcc/testsuite/gcc.dg/noreorder3.c
new file mode 100644
index 000..a0b637f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/noreorder3.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options -O2 } */
+
+__attribute__((no_reorder)) int foobar;
+static int barbar;
+int bozo;
+
+/* { dg-final { scan-assembler foobar } } */
+/* { dg-final { scan-assembler bozo } } */
+/* { dg-final { scan-assembler-not barbar } } */
diff --git a/gcc/testsuite/gcc.dg/noreorder4.c 
b/gcc/testsuite/gcc.dg/noreorder4.c
new file mode 100644
index 000..632fc33
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/noreorder4.c
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options -O2 -fno-toplevel-reorder } */
+#define NOREORDER
+#include noreorder.c
+/* { dg-final { scan-assembler bozo.*jukjuk.*func1.*barbar.*func2 } } */
-- 
2.1.0



[PATCH 1/2] Add an no_reorder attribute for LTO

2014-09-15 Thread Andi Kleen
From: Andi Kleen a...@linux.intel.com

Some projects need to prevent reordering of specific top level
declarations with LTO, in particular declarations defining init calls.

The only way to do that with LTO was to use -fno-toplevel-reorder,
which stops reordering for all declarations and makes LTO partitioning
less efficient.

This patch adds a new no_reorder attribute that stops reordering only
for the marked declaration. The program can then only mark e.g. the
initcalls and leave all the other declarations alone.

The patch does:

- Adds the new no_reorder attribute for the C family.
- Initializes a new no_reorder flag in the symtab_nodes in the
function visibility flag.
- Maintains the no_reorder flag when creating new nodes.
- Changes the partition code to always keep a separate
sorted queue of ordered nodes and flush them in order with the other
nodes. This is used by all nodes with -fno-toplevel-reorder,
and only the marked ones without it.
Parts of the old -fno-toplevel-reorder code paths are reused.
- Adds various checks throughout the tree to make no_reorder
marked functions behave the same as with -fno-toplevel-reorder
- Changes the LTO streamer to serialize the no_reorder attribute.

Bootstrapped and tested with LTO + -fno-toplevel-reorder, plain LTO
and bootstrap w/o LTO on x86_64-linux. Also fixes the reordering in
the other large project.

gcc/c-family/:

2014-09-15  Andi Kleen  a...@linux.intel.com

* c-common.c (handle_no_reorder_attribute): New function.
(c_common_attribute_table): Add no_reorder attribute.

gcc/:

2014-09-14  Andi Kleen  a...@linux.intel.com

* cgraph.h (symtab_node): Add no_reorder attribute.
(symbol_table::output_asm_statements): Remove.
* cgraphclones.c (cgraph_node::create_clone): Copy no_reorder.
(cgraph_node::create_version_clone): Dito.
(symbol_table::output_asm_statements): Remove.
* trans-mem.c (ipa_tm_create_version_alias): Dito.
* cgraphunit.c (varpool_node::finalize_decl): Check no_reorder.
(output_in_order): Add no_reorder flag. Only handle no_reorder
nodes when set.
(symbol_table::compile): Add separate pass for no_reorder nodes.
* doc/extend.texi (no_reorder): Document no_reorder attribute.
* ipa-visibility.c (function_and_variable_visibility): Set
no_reorder flag in symtab_node from declaration.
* lto-cgraph.c (lto_output_node): Serialize no_reorder.
(lto_output_varpool_node): Dito.
(input_overwrite_node): Dito.
(input_varpool_node): Dito.
* varpool.c (varpool_node::add): Set no_reorder attribute.
(symbol_table::remove_unreferenced_decls): Handle no_reorder.
(symbol_table::output_variables): Dito.
* symtab.c (symtab_node::dump_base): Print no_reorder.

gcc/lto/:

2014-09-13  Andi Kleen  a...@linux.intel.com

* lto-partition.c (node_cmp): Update comment.
(varpool_node_cmp): Use symtab_node for comparison.
(add_sorted_nodes): New function.
(lto_balanced_map): Change to keep ordered queue
of ordered node. Handle no_reorder attribute.
---
 gcc/c-family/c-common.c |  28 
 gcc/cgraph.h|   5 +--
 gcc/cgraphclones.c  |   2 +
 gcc/cgraphunit.c|  38 +++-
 gcc/doc/extend.texi |  12 +-
 gcc/ipa-visibility.c|   6 +++
 gcc/lto-cgraph.c|   4 ++
 gcc/lto/lto-partition.c | 112 ++--
 gcc/symtab.c|   2 +
 gcc/trans-mem.c |   1 +
 gcc/varpool.c   |  21 +++--
 11 files changed, 159 insertions(+), 72 deletions(-)

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 39be956..d0845d1 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -328,6 +328,8 @@ static tree handle_used_attribute (tree *, tree, tree, int, 
bool *);
 static tree handle_unused_attribute (tree *, tree, tree, int, bool *);
 static tree handle_externally_visible_attribute (tree *, tree, tree, int,
 bool *);
+static tree handle_no_reorder_attribute (tree *, tree, tree, int,
+bool *);
 static tree handle_const_attribute (tree *, tree, tree, int, bool *);
 static tree handle_transparent_union_attribute (tree *, tree, tree,
int, bool *);
@@ -652,6 +654,8 @@ const struct attribute_spec c_common_attribute_table[] =
  handle_unused_attribute, false },
   { externally_visible, 0, 0, true,  false, false,
  handle_externally_visible_attribute, false },
+  { no_reorder,0, 0, true, false, false,
+  handle_no_reorder_attribute, false },
   /* The same comments as for noreturn attributes apply to const ones.  */
   { const,  0, 0, true,  false, false,
 

Re: [GOOGLE] Fix LIPO COMDAT fixup and gcov-tool interactions

2014-09-15 Thread Xinliang David Li
Is it necessary to declare zero_counts array at all?  Can a flag field
be added to dyn_cgraph_node structure to indicate if it is fixed up?

David

On Fri, Sep 12, 2014 at 4:31 PM, Teresa Johnson tejohn...@google.com wrote:
 This patch addresses issues when running gcov-tool after performing
 COMDAT fixup during dyn-ipa. Functions that were previously all zero
 counts are marked, and the counts are discarded when being read in
 by gcov-tool before recalculating module groups and summary info.

 While here, cleaned up the gcov-tool output (remove an overly-verbose output,
 make all output consistently go to stderr).

 Passes regression tests and manual tests. Ok for google branches?

 2014-09-12  Teresa Johnson  tejohn...@google.com

 * gcc/coverage.c (read_counts_file): Handle new section.
 * gcc/gcov.c (read_count_file): Ditto.
 * gcc/gcov-dump.c (dump_gcov_file): Ditto.
 (tag_function): Ditto.
 (tag_zero_fixup): New function.
 * gcc/gcov-io.c (gcov_read_comdat_zero_fixup): Ditto.
 * gcc/gcov-io.h (gcov_read_comdat_zero_fixup): Ditto.
 * libgcc/dyn-ipa.c (struct checksum_alias): Change flag to pointer.
 (new_checksum_alias): Ditto.
 (cfg_checksum_insert): Ditto.
 (checksum_set_insert): Ditto.
 (gcov_build_callgraph): New parameter.
 (gcov_collect_imported_modules): Add assert for duplicate gcda reads.
 (gcov_fixup_counters_checksum): Change flag to pointer to flag, set 
 it.
 (__gcov_compute_module_groups): New parameter.
 * libgcc/libgcov-driver.c (set_gcov_fn_fixed_up): New function.
 (get_gcov_fn_fixed_up): Ditto.
 (gcov_exit_merge_gcda): Handle new section.
 (gcov_write_comdat_zero_fixup): Ditto.
 (gcov_write_build_info): Ditto.
 (gcov_write_comdat_zero_fixup): New function.
 (gcov_write_func_counters): Fix indent.
 (gcov_dump_module_info): Write new flag section.
 * libgcc/libgcov.h (gcov_get_counter): Clear fixed-up counters.
 (gcov_get_counter_target): Ditto.
 * libgcc/libgcov-util.c (tag_function): Annotate fixed-up functions,
 remove overly verbose output.
 (tag_counters): Clear fixed-up counters.
 (lipo_process_substitute_string_1): Send all verbose output to stderr.
 (tag_zero_fixup): New function.
 (read_gcda_file): Deallocate flag array.
 (gcov_profile_scale): Send all verbose output to stderr.
 (gcov_profile_normalize): Ditto.

 Index: gcc/coverage.c
 ===
 --- gcc/coverage.c  (revision 215230)
 +++ gcc/coverage.c  (working copy)
 @@ -820,6 +820,14 @@ read_counts_file (const char *da_file_name, unsign
  free (build_info_strings[i]);
free (build_info_strings);
  }
 +  else if (tag == GCOV_TAG_COMDAT_ZERO_FIXUP)
 +{
 +  /* Zero-profile fixup flags are not used by the compiler, read and
 + ignore.  */
 +  gcov_unsigned_t num_fn;
 +  int *zero_fixup_flags = gcov_read_comdat_zero_fixup
 (length, num_fn);
 +  free (zero_fixup_flags);
 +}
else if (GCOV_TAG_IS_COUNTER (tag)  fn_ident)
 {
   counts_entry_t **slot, *entry, elt;
 Index: gcc/gcov.c
 ===
 --- gcc/gcov.c  (revision 215230)
 +++ gcc/gcov.c  (working copy)
 @@ -1441,6 +1441,12 @@ read_count_file (function_t *fns)
  free (build_info_strings[i]);
free (build_info_strings);
  }
 +  else if (tag == GCOV_TAG_COMDAT_ZERO_FIXUP)
 +{
 +  gcov_unsigned_t num_fn;
 +  int *zero_fixup_flags = gcov_read_comdat_zero_fixup
 (length, num_fn);
 +  free (zero_fixup_flags);
 +}
else if (tag == GCOV_TAG_FUNCTION  !length)
 ; /* placeholder  */
else if (tag == GCOV_TAG_FUNCTION  length == 
 GCOV_TAG_FUNCTION_LENGTH)
 Index: gcc/gcov-dump.c
 ===
 --- gcc/gcov-dump.c (revision 215230)
 +++ gcc/gcov-dump.c (working copy)
 @@ -42,6 +42,7 @@ static void tag_summary (const char *, unsigned, u
  static void tag_module_info (const char *, unsigned, unsigned);
  static void dump_working_sets (const char *filename ATTRIBUTE_UNUSED,
 const struct gcov_ctr_summary *summary);
 +static void tag_zero_fixup (const char *, unsigned, unsigned);
  static void tag_build_info (const char *, unsigned, unsigned);
  extern int main (int, char **);

 @@ -57,6 +58,9 @@ static int flag_dump_positions = 0;
  static int flag_dump_aux_modules_only = 0;
  static int flag_dump_working_sets = 0;

 +static unsigned num_fn_info;
 +static int *zero_fixup_flags = NULL;
 +
  static const struct option options[] =
  {
{ help, no_argument,   NULL, 'h' },
 @@ -79,6 

Re: [PATCH] SPARC: add mcpu=leon3v7 target

2014-09-15 Thread Sebastian Huber

Ping.

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.


[PATCH i386 AVX512] [41/n] Extend extract insn patterns.

2014-09-15 Thread Kirill Yukhin
Hello,
This patch extends extract insn patterns.
It also fixes ICE on testsuite when F16C switched off.
Also it fixes condition in old xtract pattern.

Bootstrapped.
AVX-512* tests on top of patch-set all pass
under simulator.

Is it ok for trunk?

gcc/
* config/i386/i386.c
(ix86_expand_vector_extract): Handle V32HI and V64QI modes.
* config/i386/sse.md
(define_mode_iterator VI48F_256): New.
(define_mode_attr extract_type): Ditto.
(define_mode_attr extract_suf): Ditto.
(define_mode_iterator AVX512_VEC): Ditto.
(define_expand
extract_type_vextractshuffletypeextract_suf_mask): Use
AVX512_VEC.
(define_insn avx512dq_vextractshuffletype64x2_1_maskm): New.
(define_insn
mask_codeforavx512dq_vextractshuffletype64x2_1mask_name):
Ditto.
(define_mode_attr extract_type_2): Ditto.
(define_mode_attr extract_suf_2): Ditto.
(define_mode_iterator AVX512_VEC_2): Ditto.
(define_expand
extract_type_2_vextractshuffletypeextract_suf_2_mask): Use
AVX512_VEC_2 mode iterator.
(define_insn vec_extract_hi_mode_maskm): Ditto.
(define_expand avx512vl_vextractf128mode): Ditto.
(define_insn_and_split vec_extract_lo_mode): Delete.
(define_insn vec_extract_lo_modemask_name): New.
(define_split for V16FI mode): Ditto.
(define_insn_and_split vec_extract_lo_mode): Delete.
(define_insn vec_extract_lo_modemask_name): New.
(define_split for VI8F_256 mode): Ditto.
(define_insn vec_extract_hi_modemask_name): Add masking.
(define_insn_and_split vec_extract_lo_mode): Delete.
(define_insn vec_extract_lo_modemask_name): New.
(define_split for VI4F_256 mode): Ditto.
(define_insn vec_extract_lo_mode_maskm): Ditto.
(define_insn vec_extract_hi_mode_maskm): Ditto.
(define_insn vec_extract_hi_modemask_name): Add masking.
(define_mode_iterator VEC_EXTRACT_MODE): Add V64QI and V32HI modes.
(define_insn vcvtph2psmask_name): Fix pattern condition.
(define_insn avx512f_vextractshuffletype32x4_1_maskm): Ditto.

--
Thanks, K

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 30120a5..ccfd47d 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -40979,6 +40979,32 @@ ix86_expand_vector_extract (bool mmx_ok, rtx target, 
rtx vec, int elt)
}
   break;
 
+case V32HImode:
+  if (TARGET_AVX512BW)
+   {
+ tmp = gen_reg_rtx (V16HImode);
+ if (elt  16)
+   emit_insn (gen_vec_extract_lo_v32hi (tmp, vec));
+ else
+   emit_insn (gen_vec_extract_hi_v32hi (tmp, vec));
+ ix86_expand_vector_extract (false, target, tmp, elt  15);
+ return;
+   }
+  break;
+
+case V64QImode:
+  if (TARGET_AVX512BW)
+   {
+ tmp = gen_reg_rtx (V32QImode);
+ if (elt  32)
+   emit_insn (gen_vec_extract_lo_v64qi (tmp, vec));
+ else
+   emit_insn (gen_vec_extract_hi_v64qi (tmp, vec));
+ ix86_expand_vector_extract (false, target, tmp, elt  31);
+ return;
+   }
+  break;
+
 case V16SFmode:
   tmp = gen_reg_rtx (V8SFmode);
   if (elt  8)
diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
index bd321fc..0e21031 100644
--- a/gcc/config/i386/sse.md
+++ b/gcc/config/i386/sse.md
@@ -534,6 +534,7 @@
(V4DI TARGET_AVX512VL) (V4DF TARGET_AVX512VL)
(V4SI TARGET_AVX512VL) (V4SF TARGET_AVX512VL)
(V2DI TARGET_AVX512VL) (V2DF TARGET_AVX512VL)])
+(define_mode_iterator VI48F_256 [V8SI V8SF V4DI V4DF])
 
 ;; Mapping from float mode to required SSE level
 (define_mode_attr sse
@@ -6319,44 +6320,64 @@
   operands[1] = adjust_address (operands[1], SFmode, INTVAL (operands[2]) * 4);
 })
 
-(define_expand avx512f_vextractshuffletype32x4_mask
+(define_mode_attr extract_type
+  [(V16SF avx512f) (V16SI avx512f) (V8DF avx512dq) (V8DI avx512dq)])
+
+(define_mode_attr extract_suf
+  [(V16SF 32x4) (V16SI 32x4) (V8DF 64x2) (V8DI 64x2)])
+
+(define_mode_iterator AVX512_VEC
+  [(V8DF TARGET_AVX512DQ) (V8DI TARGET_AVX512DQ) V16SF V16SI])
+
+(define_expand extract_type_vextractshuffletypeextract_suf_mask
   [(match_operand:ssequartermode 0 nonimmediate_operand)
-   (match_operand:V16FI 1 register_operand)
+   (match_operand:AVX512_VEC 1 register_operand)
(match_operand:SI 2 const_0_to_3_operand)
(match_operand:ssequartermode 3 nonimmediate_operand)
(match_operand:QI 4 register_operand)]
   TARGET_AVX512F
 {
+  int mask;
+  mask = INTVAL (operands[2]);
+
   if (MEM_P (operands[0])  GET_CODE (operands[3]) == CONST_VECTOR)
 operands[0] = force_reg (ssequartermodemode, operands[0]);
-  switch (INTVAL (operands[2]))
-{
-case 0:
-  emit_insn (gen_avx512f_vextractshuffletype32x4_1_mask (operands[0],
-  operands[1], GEN_INT (0), GEN_INT (1), GEN_INT (2),
-  GEN_INT (3), 

Re: [PR libfortran/62768] Handle filenames with embedded nulls

2014-09-15 Thread Janne Blomqvist
Ping.

On Fri, Sep 5, 2014 at 3:54 AM, Janne Blomqvist
blomqvist.ja...@gmail.com wrote:
 Hi,

 when opening a file with a name containing an ASCII null character,
 the name is truncated at the first null since the IO API's take
 null-terminated C strings. By storing such a C string in gfc_unit
 instead of the original Fortran string INQUIRE for the file name will
 return the correct name, and the code is simplified slightly. It also
 fixes an bug in open.c(already_open) for the !HAVE_UNLINK_OPEN_FILE
 case in that the file is unlinked before freeing the name (which I
 can't test but seems obvious).

 Regtested on x86_64-unknown-linux-gnu, Ok for trunk?

 2014-09-05  Janne Blomqvist  j...@gcc.gnu.org

 PR libfortran/62768
 * io/io.h (gfc_unit): Store C string for the filename.
 * io/close.c (st_close): Use gfc_unit.filename.
 * io/inquire.c (inquire_via_unit): Likewise.
 * io/open.c (new_unit): Likewise.
 (already_open): Likewise, unlink file before freeing filename.
 * io/unit.c (init_units): Likewise.
 (close_unit_1): Likewise.
 (filename_from_unit): Likewise.
 * io/unix.c (compare_file_filename): Likewise.
 (find_file0): Likewise.
 (delete_file): Likewise.


 --
 Janne Blomqvist



-- 
Janne Blomqvist