* Claudiu Zissulescu <claudiu.zissule...@synopsys.com> [2017-07-24 10:42:56 
+0200]:

> From: Claudiu Zissulescu <claz...@gmail.com>
> 
> We don't want to use anchors for small data: the GP register acts as an 
> anchor in that
> case.  We also don't want to use them for PC-relative accesses,
> where the PC acts as an anchor.  TLS symbols require special accesses as 
> well, don't use
> anchors for such symbols.
> 
> gcc/
> 2017-04-28  Claudiu Zissulescu  <claz...@synopsys.com>
> 
>       * config/arc/arc.c (arc_use_anchors_for_symbol_p): New function.
>       (TARGET_USE_ANCHORS_FOR_SYMBOL_P): Define.
> 
> gcc/testsuite
> 2017-04-28  Claudiu Zissulescu  <claz...@synopsys.com>
> 
>       * gcc.target/arc/pr9001184797.c: New test.

Looks good.

Thanks,
Andrew


> ---
>  gcc/config/arc/arc.c                        | 24 ++++++++++++++++++++++++
>  gcc/testsuite/gcc.target/arc/pr9001184797.c | 19 +++++++++++++++++++
>  2 files changed, 43 insertions(+)
>  create mode 100644 gcc/testsuite/gcc.target/arc/pr9001184797.c
> 
> diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
> index 3980a0f..c94b187 100644
> --- a/gcc/config/arc/arc.c
> +++ b/gcc/config/arc/arc.c
> @@ -10687,6 +10687,30 @@ arc_builtin_setjmp_frame_value (void)
>    return gen_raw_REG (Pmode, FRAME_POINTER_REGNUM);
>  }
>  
> +/* Implement TARGET_USE_ANCHORS_FOR_SYMBOL_P.  We don't want to use
> +   anchors for small data: the GP register acts as an anchor in that
> +   case.  We also don't want to use them for PC-relative accesses,
> +   where the PC acts as an anchor.  Prohibit also TLS symbols to use
> +   anchors.  */
> +
> +static bool
> +arc_use_anchors_for_symbol_p (const_rtx symbol)
> +{
> +  if (SYMBOL_REF_TLS_MODEL (symbol))
> +    return false;
> +
> +  if (flag_pic)
> +    return false;
> +
> +  if (SYMBOL_REF_SMALL_P (symbol))
> +    return false;
> +
> +  return default_use_anchors_for_symbol_p (symbol);
> +}
> +
> +#undef TARGET_USE_ANCHORS_FOR_SYMBOL_P
> +#define TARGET_USE_ANCHORS_FOR_SYMBOL_P arc_use_anchors_for_symbol_p
> +
>  struct gcc_target targetm = TARGET_INITIALIZER;
>  
>  #include "gt-arc.h"
> diff --git a/gcc/testsuite/gcc.target/arc/pr9001184797.c 
> b/gcc/testsuite/gcc.target/arc/pr9001184797.c
> new file mode 100644
> index 0000000..e76c676
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/arc/pr9001184797.c
> @@ -0,0 +1,19 @@
> +/* { dg-do compile } */
> +/* { dg-require-effective-target tls } */
> +/* { dg-options "-Os -w -mno-ll64" } */
> +
> +/* This test studies the use of anchors and tls symbols. */
> +
> +struct a b;
> +struct a {
> +  long c;
> +  long d
> +} e() {
> +  static __thread struct a f;
> +  static __thread g;
> +  g = 5;
> +  h();
> +  if (f.c)
> +    g = g & 5;
> +  f = b;
> +}
> -- 
> 1.9.1
> 

Reply via email to