From: Claudiu Zissulescu <claz...@gmail.com> Make sure we check the constants in all cases.
gcc/ 2017-10-14 Claudiu Zissulescu <claz...@synopsys.com> * config/arc/arc.c (arc_legitimate_constant_p): Always check all constants. testsuite/ 2017-10-14 Claudiu Zissulescu <claz...@synopsys.com> * gcc.target/arc/tls-1.c: New test. --- gcc/config/arc/arc.c | 6 ------ gcc/testsuite/gcc.target/arc/tls-1.c | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.target/arc/tls-1.c diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 4d7a282..42ea921 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -6185,12 +6185,6 @@ arc_return_addr_rtx (int count, ATTRIBUTE_UNUSED rtx frame) bool arc_legitimate_constant_p (machine_mode mode, rtx x) { - if (GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_TLS_MODEL (x)) - return false; - - if (!flag_pic && mode != Pmode) - return true; - switch (GET_CODE (x)) { case CONST: diff --git a/gcc/testsuite/gcc.target/arc/tls-1.c b/gcc/testsuite/gcc.target/arc/tls-1.c new file mode 100644 index 0000000..3f7a6d4 --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/tls-1.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target tls } */ +/* { dg-options "-O3 -std=gnu99" } */ + +/* Check if addressing the `pos` member of struct is done via tls + mechanism. */ + +struct callchain_cursor { + int last; + long long pos; +} __thread a; +void fn1(struct callchain_cursor *p1) +{ + p1->pos++; +} + +extern void fn3 (void); + +void fn2(void) { + struct callchain_cursor *b = &a; + while (1) { + fn3(); + fn1(b); + } +} +/* { dg-final { scan-assembler "r25,@a@tpoff" } } */ -- 1.9.1