From fd082a66f8be44616584164672eeb8e2779c5593 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Mon, 25 Jun 2018 10:39:54 +0000 Subject: [PATCH] [i386/debug] Fix insn prefix in tls_global_dynamic_64_ 2018-06-25 Tom de Vries PR debug/86257 * config/i386/i386.md (define_insn "*tls_global_dynamic_64_"): Use data16 instead of .byte for insn prefix. * gcc.target/i386/pr86257.c: New test. From-SVN: r262006 --- gcc/ChangeLog | 6 ++++++ gcc/config/i386/i386.md | 13 ++++++++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/i386/pr86257.c | 14 ++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr86257.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f612c5b58c0..f4df7442de4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-06-25 Tom de Vries + + PR debug/86257 + * config/i386/i386.md (define_insn "*tls_global_dynamic_64_"): + Use data16 instead of .byte for insn prefix. + 2018-06-25 Andreas Krebbel PR C++/86082 diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index eb77ef3c08f..6f2300057aa 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -14733,7 +14733,18 @@ "TARGET_64BIT" { if (!TARGET_X32) - fputs (ASM_BYTE "0x66\n", asm_out_file); + /* The .loc directive has effect for 'the immediately following assembly + instruction'. So for a sequence: + .loc f l + .byte x + insn1 + the 'immediately following assembly instruction' is insn1. + We want to emit an insn prefix here, but if we use .byte (as shown in + 'ELF Handling For Thread-Local Storage'), a preceding .loc will point + inside the insn sequence, rather than to the start. After relaxation + of the sequence by the linker, the .loc might point inside an insn. + Use data16 prefix instead, which doesn't have this problem. */ + fputs ("\tdata16", asm_out_file); output_asm_insn ("lea{q}\t{%E1@tlsgd(%%rip), %%rdi|rdi, %E1@tlsgd[rip]}", operands); if (TARGET_SUN_TLS || flag_plt || !HAVE_AS_IX86_TLS_GET_ADDR_GOT) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4ca7d21f3ee..e8ab480febf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-06-25 Tom de Vries + + PR debug/86257 + * gcc.target/i386/pr86257.c: New test. + 2018-06-25 Andreas Krebbel PR C++/86082 diff --git a/gcc/testsuite/gcc.target/i386/pr86257.c b/gcc/testsuite/gcc.target/i386/pr86257.c new file mode 100644 index 00000000000..3287c190d36 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr86257.c @@ -0,0 +1,14 @@ +/* { dg-require-effective-target fpic } */ +/* { dg-require-effective-target tls } */ +/* { dg-options "-g -fPIC" } */ + +__thread int i; + +void +foo(void) +{ + i = 0; +} + +/* { dg-final { scan-assembler "data16\[ \t\]*leaq" } } */ +/* { dg-final { scan-assembler-not "\.byte\[ \t\]*0x66\n\[ \t\]*leaq" } } */ -- 2.30.2