Commit 4e8e8a9f by Eric Botcazou

re PR target/84010 (problematic TLS code generation on 64-bit SPARC)

	PR target/84010
	* config/sparc/sparc.c (sparc_legitimize_tls_address): Only use Pmode
	consistently in TLS address generation and adjust code to the renaming
	of patterns.  Mark calls to __tls_get_addr as const.
	* config/sparc/sparc.md (tgd_hi22): Turn into...
	(tgd_hi22<P:mode>): ...this and use Pmode throughout.
	(tgd_lo10): Turn into...
	(tgd_lo10<P:mode>): ...this and use Pmode throughout.
	(tgd_add32): Merge into...
	(tgd_add64): Likewise.
	(tgd_add<P:mode>): ...this and use Pmode throughout.
	(tldm_hi22): Turn into...
	(tldm_hi22<P:mode>): ...this and use Pmode throughout.
	(tldm_lo10): Turn into...
	(tldm_lo10<P:mode>): ...this and use Pmode throughout.
	(tldm_add32): Merge into...
	(tldm_add64): Likewise.
	(tldm_add<P:mode>): ...this and use Pmode throughout.
	(tldm_call32): Merge into...
	(tldm_call64): Likewise.
	(tldm_call<P:mode>): ...this and use Pmode throughout.
	(tldo_hix22): Turn into...
	(tldo_hix22<P:mode>): ...this and use Pmode throughout.
	(tldo_lox10): Turn into...
	(tldo_lox10<P:mode>): ...this and use Pmode throughout.
	(tldo_add32): Merge into...
	(tldo_add64): Likewise.
	(tldo_add<P:mode>): ...this and use Pmode throughout.
	(tie_hi22): Turn into...
	(tie_hi22<P:mode>): ...this and use Pmode throughout.
	(tie_lo10): Turn into...
	(tie_lo10<P:mode>): ...this and use Pmode throughout.
	(tie_ld64): Use DImode throughout.
	(tie_add32): Merge into...
	(tie_add64): Likewise.
	(tie_add<P:mode>): ...this and use Pmode throughout.
	(tle_hix22_sp32): Merge into...
	(tle_hix22_sp64): Likewise.
	(tle_hix22<P:mode>): ...this and use Pmode throughout.
	(tle_lox22_sp32): Merge into...
	(tle_lox22_sp64): Likewise.
	(tle_lox22<P:mode>): ...this and use Pmode throughout.
	(*tldo_ldub_sp32): Merge into...
	(*tldo_ldub_sp64): Likewise.
	(*tldo_ldub<P:mode>): ...this and use Pmode throughout.
	(*tldo_ldub1_sp32): Merge into...
	(*tldo_ldub1_sp64): Likewise.
	(*tldo_ldub1<P:mode>): ...this and use Pmode throughout.
	(*tldo_ldub2_sp32): Merge into...
	(*tldo_ldub2_sp64): Likewise.
	(*tldo_ldub2<P:mode>): ...this and use Pmode throughout.
	(*tldo_ldsb1_sp32): Merge into...
	(*tldo_ldsb1_sp64): Likewise.
	(*tldo_ldsb1<P:mode>): ...this and use Pmode throughout.
	(*tldo_ldsb2_sp32): Merge into...
	(*tldo_ldsb2_sp64): Likewise.
	(*tldo_ldsb2<P:mode>): ...this and use Pmode throughout.
	(*tldo_ldub3_sp64): Use DImode throughout.
	(*tldo_ldsb3_sp64): Likewise.
	(*tldo_lduh_sp32): Merge into...
	(*tldo_lduh_sp64): Likewise.
	(*tldo_lduh<P:mode>): ...this and use Pmode throughout.
	(*tldo_lduh1_sp32): Merge into...
	(*tldo_lduh1_sp64): Likewise.
	(*tldo_lduh1<P:mode>): ...this and use Pmode throughout.
	(*tldo_ldsh1_sp32): Merge into...
	(*tldo_ldsh1_sp64): Likewise.
	(*tldo_ldsh1<P:mode>): ...this and use Pmode throughout.
	(*tldo_lduh2_sp64): Use DImode throughout.
	(*tldo_ldsh2_sp64): Likewise.
	(*tldo_lduw_sp32): Merge into...
	(*tldo_lduw_sp64): Likewise.
	(*tldo_lduw<P:mode>): ...this and use Pmode throughout.
	(*tldo_lduw1_sp64): Use DImode throughout.
	(*tldo_ldsw1_sp64): Likewise.
	(*tldo_ldx_sp64): Likewise.
	(*tldo_stb_sp32): Merge into...
	(*tldo_stb_sp64): Likewise.
	(*tldo_stb<P:mode>): ...this and use Pmode throughout.
	(*tldo_sth_sp32): Merge into...
	(*tldo_sth_sp64): Likewise.
	(*tldo_sth<P:mode>): ...this and use Pmode throughout.
	(*tldo_stw_sp32): Merge into...
	(*tldo_stw_sp64): Likewise.
	(*tldo_stw<P:mode>): ...this and use Pmode throughout.
	(*tldo_stx_sp64): Use DImode throughout.

From-SVN: r267771
parent c7ff4f0f
2019-01-09 Eric Botcazou <ebotcazou@adacore.com>
James Clarke <jrtc27@jrtc27.com>
PR target/84010
* config/sparc/sparc.c (sparc_legitimize_tls_address): Only use Pmode
consistently in TLS address generation and adjust code to the renaming
of patterns. Mark calls to __tls_get_addr as const.
* config/sparc/sparc.md (tgd_hi22): Turn into...
(tgd_hi22<P:mode>): ...this and use Pmode throughout.
(tgd_lo10): Turn into...
(tgd_lo10<P:mode>): ...this and use Pmode throughout.
(tgd_add32): Merge into...
(tgd_add64): Likewise.
(tgd_add<P:mode>): ...this and use Pmode throughout.
(tldm_hi22): Turn into...
(tldm_hi22<P:mode>): ...this and use Pmode throughout.
(tldm_lo10): Turn into...
(tldm_lo10<P:mode>): ...this and use Pmode throughout.
(tldm_add32): Merge into...
(tldm_add64): Likewise.
(tldm_add<P:mode>): ...this and use Pmode throughout.
(tldm_call32): Merge into...
(tldm_call64): Likewise.
(tldm_call<P:mode>): ...this and use Pmode throughout.
(tldo_hix22): Turn into...
(tldo_hix22<P:mode>): ...this and use Pmode throughout.
(tldo_lox10): Turn into...
(tldo_lox10<P:mode>): ...this and use Pmode throughout.
(tldo_add32): Merge into...
(tldo_add64): Likewise.
(tldo_add<P:mode>): ...this and use Pmode throughout.
(tie_hi22): Turn into...
(tie_hi22<P:mode>): ...this and use Pmode throughout.
(tie_lo10): Turn into...
(tie_lo10<P:mode>): ...this and use Pmode throughout.
(tie_ld64): Use DImode throughout.
(tie_add32): Merge into...
(tie_add64): Likewise.
(tie_add<P:mode>): ...this and use Pmode throughout.
(tle_hix22_sp32): Merge into...
(tle_hix22_sp64): Likewise.
(tle_hix22<P:mode>): ...this and use Pmode throughout.
(tle_lox22_sp32): Merge into...
(tle_lox22_sp64): Likewise.
(tle_lox22<P:mode>): ...this and use Pmode throughout.
(*tldo_ldub_sp32): Merge into...
(*tldo_ldub_sp64): Likewise.
(*tldo_ldub<P:mode>): ...this and use Pmode throughout.
(*tldo_ldub1_sp32): Merge into...
(*tldo_ldub1_sp64): Likewise.
(*tldo_ldub1<P:mode>): ...this and use Pmode throughout.
(*tldo_ldub2_sp32): Merge into...
(*tldo_ldub2_sp64): Likewise.
(*tldo_ldub2<P:mode>): ...this and use Pmode throughout.
(*tldo_ldsb1_sp32): Merge into...
(*tldo_ldsb1_sp64): Likewise.
(*tldo_ldsb1<P:mode>): ...this and use Pmode throughout.
(*tldo_ldsb2_sp32): Merge into...
(*tldo_ldsb2_sp64): Likewise.
(*tldo_ldsb2<P:mode>): ...this and use Pmode throughout.
(*tldo_ldub3_sp64): Use DImode throughout.
(*tldo_ldsb3_sp64): Likewise.
(*tldo_lduh_sp32): Merge into...
(*tldo_lduh_sp64): Likewise.
(*tldo_lduh<P:mode>): ...this and use Pmode throughout.
(*tldo_lduh1_sp32): Merge into...
(*tldo_lduh1_sp64): Likewise.
(*tldo_lduh1<P:mode>): ...this and use Pmode throughout.
(*tldo_ldsh1_sp32): Merge into...
(*tldo_ldsh1_sp64): Likewise.
(*tldo_ldsh1<P:mode>): ...this and use Pmode throughout.
(*tldo_lduh2_sp64): Use DImode throughout.
(*tldo_ldsh2_sp64): Likewise.
(*tldo_lduw_sp32): Merge into...
(*tldo_lduw_sp64): Likewise.
(*tldo_lduw<P:mode>): ...this and use Pmode throughout.
(*tldo_lduw1_sp64): Use DImode throughout.
(*tldo_ldsw1_sp64): Likewise.
(*tldo_ldx_sp64): Likewise.
(*tldo_stb_sp32): Merge into...
(*tldo_stb_sp64): Likewise.
(*tldo_stb<P:mode>): ...this and use Pmode throughout.
(*tldo_sth_sp32): Merge into...
(*tldo_sth_sp64): Likewise.
(*tldo_sth<P:mode>): ...this and use Pmode throughout.
(*tldo_stw_sp32): Merge into...
(*tldo_stw_sp64): Likewise.
(*tldo_stw<P:mode>): ...this and use Pmode throughout.
(*tldo_stx_sp64): Use DImode throughout.
2018-01-09 Sudakshina Das <sudi.das@arm.com> 2018-01-09 Sudakshina Das <sudi.das@arm.com>
* config/aarch64/aarch64.c (aarch64_override_options): Add case to * config/aarch64/aarch64.c (aarch64_override_options): Add case to
...@@ -11,7 +101,7 @@ ...@@ -11,7 +101,7 @@
Ramana Radhakrishnan <ramana.radhakrishnan@arm.com> Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
* config.gcc (aarch64*-*-*): Add aarch64-bti-insert.o. * config.gcc (aarch64*-*-*): Add aarch64-bti-insert.o.
* gcc/config/aarch64/aarch64.h: Update comment for TRAMPOLINE_SIZE. * config/aarch64/aarch64.h: Update comment for TRAMPOLINE_SIZE.
* config/aarch64/aarch64.c (aarch64_asm_trampoline_template): Update * config/aarch64/aarch64.c (aarch64_asm_trampoline_template): Update
if bti is enabled. if bti is enabled.
* config/aarch64/aarch64-bti-insert.c: New file. * config/aarch64/aarch64-bti-insert.c: New file.
......
...@@ -4644,30 +4644,38 @@ sparc_legitimize_tls_address (rtx addr) ...@@ -4644,30 +4644,38 @@ sparc_legitimize_tls_address (rtx addr)
gcc_assert (can_create_pseudo_p ()); gcc_assert (can_create_pseudo_p ());
if (GET_CODE (addr) == SYMBOL_REF) if (GET_CODE (addr) == SYMBOL_REF)
/* Although the various sethi/or sequences generate SImode values, many of
them can be transformed by the linker when relaxing and, if relaxing to
local-exec, will become a sethi/xor pair, which is signed and therefore
a full DImode value in 64-bit mode. Thus we must use Pmode, lest these
values be spilled onto the stack in 64-bit mode. */
switch (SYMBOL_REF_TLS_MODEL (addr)) switch (SYMBOL_REF_TLS_MODEL (addr))
{ {
case TLS_MODEL_GLOBAL_DYNAMIC: case TLS_MODEL_GLOBAL_DYNAMIC:
start_sequence (); start_sequence ();
temp1 = gen_reg_rtx (SImode); temp1 = gen_reg_rtx (Pmode);
temp2 = gen_reg_rtx (SImode); temp2 = gen_reg_rtx (Pmode);
ret = gen_reg_rtx (Pmode); ret = gen_reg_rtx (Pmode);
o0 = gen_rtx_REG (Pmode, 8); o0 = gen_rtx_REG (Pmode, 8);
got = sparc_tls_got (); got = sparc_tls_got ();
emit_insn (gen_tgd_hi22 (temp1, addr));
emit_insn (gen_tgd_lo10 (temp2, temp1, addr));
if (TARGET_ARCH32) if (TARGET_ARCH32)
{ {
emit_insn (gen_tgd_add32 (o0, got, temp2, addr)); emit_insn (gen_tgd_hi22si (temp1, addr));
insn = emit_call_insn (gen_tgd_call32 (o0, sparc_tls_get_addr (), emit_insn (gen_tgd_lo10si (temp2, temp1, addr));
emit_insn (gen_tgd_addsi (o0, got, temp2, addr));
insn = emit_call_insn (gen_tgd_callsi (o0, sparc_tls_get_addr (),
addr, const1_rtx)); addr, const1_rtx));
} }
else else
{ {
emit_insn (gen_tgd_add64 (o0, got, temp2, addr)); emit_insn (gen_tgd_hi22di (temp1, addr));
insn = emit_call_insn (gen_tgd_call64 (o0, sparc_tls_get_addr (), emit_insn (gen_tgd_lo10di (temp2, temp1, addr));
emit_insn (gen_tgd_adddi (o0, got, temp2, addr));
insn = emit_call_insn (gen_tgd_calldi (o0, sparc_tls_get_addr (),
addr, const1_rtx)); addr, const1_rtx));
} }
use_reg (&CALL_INSN_FUNCTION_USAGE (insn), o0); use_reg (&CALL_INSN_FUNCTION_USAGE (insn), o0);
RTL_CONST_CALL_P (insn) = 1;
insn = get_insns (); insn = get_insns ();
end_sequence (); end_sequence ();
emit_libcall_block (insn, ret, o0, addr); emit_libcall_block (insn, ret, o0, addr);
...@@ -4675,61 +4683,78 @@ sparc_legitimize_tls_address (rtx addr) ...@@ -4675,61 +4683,78 @@ sparc_legitimize_tls_address (rtx addr)
case TLS_MODEL_LOCAL_DYNAMIC: case TLS_MODEL_LOCAL_DYNAMIC:
start_sequence (); start_sequence ();
temp1 = gen_reg_rtx (SImode); temp1 = gen_reg_rtx (Pmode);
temp2 = gen_reg_rtx (SImode); temp2 = gen_reg_rtx (Pmode);
temp3 = gen_reg_rtx (Pmode); temp3 = gen_reg_rtx (Pmode);
ret = gen_reg_rtx (Pmode); ret = gen_reg_rtx (Pmode);
o0 = gen_rtx_REG (Pmode, 8); o0 = gen_rtx_REG (Pmode, 8);
got = sparc_tls_got (); got = sparc_tls_got ();
emit_insn (gen_tldm_hi22 (temp1));
emit_insn (gen_tldm_lo10 (temp2, temp1));
if (TARGET_ARCH32) if (TARGET_ARCH32)
{ {
emit_insn (gen_tldm_add32 (o0, got, temp2)); emit_insn (gen_tldm_hi22si (temp1));
insn = emit_call_insn (gen_tldm_call32 (o0, sparc_tls_get_addr (), emit_insn (gen_tldm_lo10si (temp2, temp1));
emit_insn (gen_tldm_addsi (o0, got, temp2));
insn = emit_call_insn (gen_tldm_callsi (o0, sparc_tls_get_addr (),
const1_rtx)); const1_rtx));
} }
else else
{ {
emit_insn (gen_tldm_add64 (o0, got, temp2)); emit_insn (gen_tldm_hi22di (temp1));
insn = emit_call_insn (gen_tldm_call64 (o0, sparc_tls_get_addr (), emit_insn (gen_tldm_lo10di (temp2, temp1));
emit_insn (gen_tldm_adddi (o0, got, temp2));
insn = emit_call_insn (gen_tldm_calldi (o0, sparc_tls_get_addr (),
const1_rtx)); const1_rtx));
} }
use_reg (&CALL_INSN_FUNCTION_USAGE (insn), o0); use_reg (&CALL_INSN_FUNCTION_USAGE (insn), o0);
RTL_CONST_CALL_P (insn) = 1;
insn = get_insns (); insn = get_insns ();
end_sequence (); end_sequence ();
/* Attach a unique REG_EQUAL, to allow the RTL optimizers to
share the LD_BASE result with other LD model accesses. */
emit_libcall_block (insn, temp3, o0, emit_libcall_block (insn, temp3, o0,
gen_rtx_UNSPEC (Pmode, gen_rtvec (1, const0_rtx), gen_rtx_UNSPEC (Pmode, gen_rtvec (1, const0_rtx),
UNSPEC_TLSLD_BASE)); UNSPEC_TLSLD_BASE));
temp1 = gen_reg_rtx (SImode); temp1 = gen_reg_rtx (Pmode);
temp2 = gen_reg_rtx (SImode); temp2 = gen_reg_rtx (Pmode);
emit_insn (gen_tldo_hix22 (temp1, addr));
emit_insn (gen_tldo_lox10 (temp2, temp1, addr));
if (TARGET_ARCH32) if (TARGET_ARCH32)
emit_insn (gen_tldo_add32 (ret, temp3, temp2, addr)); {
emit_insn (gen_tldo_hix22si (temp1, addr));
emit_insn (gen_tldo_lox10si (temp2, temp1, addr));
emit_insn (gen_tldo_addsi (ret, temp3, temp2, addr));
}
else else
emit_insn (gen_tldo_add64 (ret, temp3, temp2, addr)); {
emit_insn (gen_tldo_hix22di (temp1, addr));
emit_insn (gen_tldo_lox10di (temp2, temp1, addr));
emit_insn (gen_tldo_adddi (ret, temp3, temp2, addr));
}
break; break;
case TLS_MODEL_INITIAL_EXEC: case TLS_MODEL_INITIAL_EXEC:
temp1 = gen_reg_rtx (SImode); temp1 = gen_reg_rtx (Pmode);
temp2 = gen_reg_rtx (SImode); temp2 = gen_reg_rtx (Pmode);
temp3 = gen_reg_rtx (Pmode); temp3 = gen_reg_rtx (Pmode);
got = sparc_tls_got (); got = sparc_tls_got ();
emit_insn (gen_tie_hi22 (temp1, addr));
emit_insn (gen_tie_lo10 (temp2, temp1, addr));
if (TARGET_ARCH32) if (TARGET_ARCH32)
emit_insn (gen_tie_ld32 (temp3, got, temp2, addr)); {
emit_insn (gen_tie_hi22si (temp1, addr));
emit_insn (gen_tie_lo10si (temp2, temp1, addr));
emit_insn (gen_tie_ld32 (temp3, got, temp2, addr));
}
else else
emit_insn (gen_tie_ld64 (temp3, got, temp2, addr)); {
emit_insn (gen_tie_hi22di (temp1, addr));
emit_insn (gen_tie_lo10di (temp2, temp1, addr));
emit_insn (gen_tie_ld64 (temp3, got, temp2, addr));
}
if (TARGET_SUN_TLS) if (TARGET_SUN_TLS)
{ {
ret = gen_reg_rtx (Pmode); ret = gen_reg_rtx (Pmode);
if (TARGET_ARCH32) if (TARGET_ARCH32)
emit_insn (gen_tie_add32 (ret, gen_rtx_REG (Pmode, 7), emit_insn (gen_tie_addsi (ret, gen_rtx_REG (Pmode, 7),
temp3, addr)); temp3, addr));
else else
emit_insn (gen_tie_add64 (ret, gen_rtx_REG (Pmode, 7), emit_insn (gen_tie_adddi (ret, gen_rtx_REG (Pmode, 7),
temp3, addr)); temp3, addr));
} }
else else
...@@ -4741,13 +4766,13 @@ sparc_legitimize_tls_address (rtx addr) ...@@ -4741,13 +4766,13 @@ sparc_legitimize_tls_address (rtx addr)
temp2 = gen_reg_rtx (Pmode); temp2 = gen_reg_rtx (Pmode);
if (TARGET_ARCH32) if (TARGET_ARCH32)
{ {
emit_insn (gen_tle_hix22_sp32 (temp1, addr)); emit_insn (gen_tle_hix22si (temp1, addr));
emit_insn (gen_tle_lox10_sp32 (temp2, temp1, addr)); emit_insn (gen_tle_lox10si (temp2, temp1, addr));
} }
else else
{ {
emit_insn (gen_tle_hix22_sp64 (temp1, addr)); emit_insn (gen_tle_hix22di (temp1, addr));
emit_insn (gen_tle_lox10_sp64 (temp2, temp1, addr)); emit_insn (gen_tle_lox10di (temp2, temp1, addr));
} }
ret = gen_rtx_PLUS (Pmode, gen_rtx_REG (Pmode, 7), temp2); ret = gen_rtx_PLUS (Pmode, gen_rtx_REG (Pmode, 7), temp2);
break; break;
......
2019-01-09 Eric Botcazou <ebotcazou@adacore.com>
* gcc.target/sparc/tls-ld-int8.c: New test.
* gcc.target/sparc/tls-ld-int16.c: Likewise.
* gcc.target/sparc/tls-ld-int32.c: Likewise.
* gcc.target/sparc/tls-ld-uint8.c: Likewise.
* gcc.target/sparc/tls-ld-uint16.c: Likewise.
* gcc.target/sparc/tls-ld-uint32.c: Likewise.
2018-01-09 Sudakshina Das <sudi.das@arm.com> 2018-01-09 Sudakshina Das <sudi.das@arm.com>
* gcc.target/aarch64/bti-1.c: Update test to not add command line * gcc.target/aarch64/bti-1.c: Update test to not add command line
......
/* { dg-do compile } */
/* { dg-options "-O2" }
/* { dg-add-options tls } */
#include <stdint.h>
__thread int16_t var1 __attribute__((tls_model("local-dynamic")));
__thread int16_t var2 __attribute__((tls_model("local-dynamic")));
int16_t sum (void)
{
return var1 + var2;
}
int32_t ext32_sum (void)
{
return (int32_t)var1 + (int32_t)var2;
}
long ext_sum (void)
{
return (long)var1 + (long)var2;
}
void set (int16_t i)
{
var1 = i;
var2 = i;
}
/* { dg-final { scan-assembler-times "__tls_get_addr" 4 } } */
/* { dg-final { scan-assembler-times "lduh\t\[^\n\]*tldo_add" 2 } } */
/* { dg-final { scan-assembler-times "ldsh\t\[^\n\]*tldo_add" 4 } } */
/* { dg-final { scan-assembler-times "sth\t\[^\n\]*tldo_add" 2 } } */
/* { dg-do compile } */
/* { dg-options "-O2" }
/* { dg-add-options tls } */
#include <stdint.h>
__thread int32_t var1 __attribute__((tls_model("local-dynamic")));
__thread int32_t var2 __attribute__((tls_model("local-dynamic")));
int32_t sum (void)
{
return var1 + var2;
}
#if defined(__sparcv9) || defined(__arch64__)
long ext_sum (void)
{
return (long)var1 + (long)var2;
}
#else
void *addr (void)
{
return &var1;
}
#endif
void set (int32_t i)
{
var1 = i;
var2 = i;
}
/* { dg-final { scan-assembler-times "__tls_get_addr" 3 } } */
/* { dg-final { scan-assembler-times "ld\t\[^\n\]*tldo_add" 2 } } */
/* { dg-final { scan-assembler-times "ldsw\t\[^\n\]*tldo_add" 2 { target lp64 } } } */
/* { dg-final { scan-assembler-times "st\t\[^\n\]*tldo_add" 2 } } */
/* { dg-do compile } */
/* { dg-options "-O2" }
/* { dg-add-options tls } */
/* { dg-require-effective-target lp64 } */
#include <stdint.h>
__thread int64_t var1 __attribute__((tls_model("local-dynamic")));
__thread int64_t var2 __attribute__((tls_model("local-dynamic")));
int64_t sum (void)
{
return var1 + var2;
}
void set (int64_t i)
{
var1 = i;
var2 = i;
}
/* { dg-final { scan-assembler-times "__tls_get_addr" 2 } } */
/* { dg-final { scan-assembler-times "ldx\t\[^\n\]*tldo_add" 2 } } */
/* { dg-final { scan-assembler-times "stx\t\[^\n\]*tldo_add" 2 } } */
/* { dg-do compile } */
/* { dg-options "-O2" }
/* { dg-add-options tls } */
#include <stdint.h>
__thread int8_t var1 __attribute__((tls_model("local-dynamic")));
__thread int8_t var2 __attribute__((tls_model("local-dynamic")));
int8_t sum (void)
{
return var1 + var2;
}
int16_t ext16_sum (void)
{
return (int16_t)var1 + (int16_t)var2;
}
int32_t ext32_sum (void)
{
return (int32_t)var1 + (int32_t)var2;
}
long ext_sum (void)
{
return (long)var1 + (long)var2;
}
void set (int8_t i)
{
var1 = i;
var2 = i;
}
/* { dg-final { scan-assembler-times "__tls_get_addr" 5 } } */
/* { dg-final { scan-assembler-times "ldub\t\[^\n\]*tldo_add" 2 } } */
/* { dg-final { scan-assembler-times "ldsb\t\[^\n\]*tldo_add" 6 } } */
/* { dg-final { scan-assembler-times "stb\t\[^\n\]*tldo_add" 2 } } */
/* { dg-do compile } */
/* { dg-options "-O2" }
/* { dg-add-options tls } */
#include <stdint.h>
__thread uint16_t var1 __attribute__((tls_model("local-dynamic")));
__thread uint16_t var2 __attribute__((tls_model("local-dynamic")));
uint16_t sum (void)
{
return var1 + var2;
}
uint32_t ext32_sum (void)
{
return (uint32_t)var1 + (uint32_t)var2;
}
unsigned long ext_sum (void)
{
return (unsigned long)var1 + (unsigned long)var2;
}
void set (uint16_t i)
{
var1 = i;
var2 = i;
}
/* { dg-final { scan-assembler-times "__tls_get_addr" 4 } } */
/* { dg-final { scan-assembler-times "lduh\t\[^\n\]*tldo_add" 6 } } */
/* { dg-final { scan-assembler-times "sth\t\[^\n\]*tldo_add" 2 } } */
/* { dg-do compile } */
/* { dg-options "-O2" }
/* { dg-add-options tls } */
#include <stdint.h>
__thread uint32_t var1 __attribute__((tls_model("local-dynamic")));
__thread uint32_t var2 __attribute__((tls_model("local-dynamic")));
uint32_t sum (void)
{
return var1 + var2;
}
#if defined(__sparcv9) || defined(__arch64__)
unsigned long ext_sum (void)
{
return (unsigned long)var1 + (unsigned long)var2;
}
#else
void *addr (void)
{
return &var1;
}
#endif
void set (int32_t i)
{
var1 = i;
var2 = i;
}
/* { dg-final { scan-assembler-times "__tls_get_addr" 3 } } */
/* { dg-final { scan-assembler-times "ld\t\[^\n\]*tldo_add" 2 } } */
/* { dg-final { scan-assembler-times "lduw\t\[^\n\]*tldo_add" 2 { target lp64 } } } */
/* { dg-final { scan-assembler-times "st\t\[^\n\]*tldo_add" 2 } } */
/* { dg-do compile } */
/* { dg-options "-O2" }
/* { dg-add-options tls } */
#include <stdint.h>
__thread uint8_t var1 __attribute__((tls_model("local-dynamic")));
__thread uint8_t var2 __attribute__((tls_model("local-dynamic")));
uint8_t sum (void)
{
return var1 + var2;
}
uint16_t ext16_sum (void)
{
return (uint16_t)var1 + (uint16_t)var2;
}
uint32_t ext32_sum (void)
{
return (uint32_t)var1 + (uint32_t)var2;
}
unsigned long ext_sum (void)
{
return (unsigned long)var1 + (unsigned long)var2;
}
void set (uint8_t i)
{
var1 = i;
var2 = i;
}
/* { dg-final { scan-assembler-times "__tls_get_addr" 5 } } */
/* { dg-final { scan-assembler-times "ldub\t\[^\n\]*tldo_add" 8 } } */
/* { dg-final { scan-assembler-times "stb\t\[^\n\]*tldo_add" 2 } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment