From 73f1289e49d2c1c6d23278dc7a1c70f80cd1e6b4 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 24 Apr 2019 17:49:36 +0200 Subject: [PATCH] re PR target/90193 (asm goto with TLS "m" input operand generates incorrect assembler in O1 and O2) PR target/90193 * rtl.c (classify_insn): Return JUMP_INSN for asm goto. * emit-rtl.c (try_split): Copy over REG_LABEL_TARGET. * gcc.target/i386/pr90193.c: New test. From-SVN: r270550 --- gcc/ChangeLog | 6 ++++++ gcc/emit-rtl.c | 1 + gcc/rtl.c | 5 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/i386/pr90193.c | 21 +++++++++++++++++++++ 5 files changed, 38 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/pr90193.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6d09649c1d0..a8f5212aca5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-04-24 Jakub Jelinek + + PR target/90193 + * rtl.c (classify_insn): Return JUMP_INSN for asm goto. + * emit-rtl.c (try_split): Copy over REG_LABEL_TARGET. + 2019-04-24 Andreas Krebbel PR target/89952 diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 4b0aa7cee06..15dffa58a2e 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -3940,6 +3940,7 @@ try_split (rtx pat, rtx_insn *trial, int last) break; case REG_NON_LOCAL_GOTO: + case REG_LABEL_TARGET: for (insn = insn_last; insn != NULL_RTX; insn = PREV_INSN (insn)) { if (JUMP_P (insn)) diff --git a/gcc/rtl.c b/gcc/rtl.c index 8a897777041..d7b8e9877c3 100644 --- a/gcc/rtl.c +++ b/gcc/rtl.c @@ -746,6 +746,8 @@ classify_insn (rtx x) return CALL_INSN; if (ANY_RETURN_P (x)) return JUMP_INSN; + if (GET_CODE (x) == ASM_OPERANDS && ASM_OPERANDS_LABEL_VEC (x)) + return JUMP_INSN; if (GET_CODE (x) == SET) { if (GET_CODE (SET_DEST (x)) == PC) @@ -772,6 +774,9 @@ classify_insn (rtx x) return CALL_INSN; if (has_return_p) return JUMP_INSN; + if (GET_CODE (XVECEXP (x, 0, 0)) == ASM_OPERANDS + && ASM_OPERANDS_LABEL_VEC (XVECEXP (x, 0, 0))) + return JUMP_INSN; } #ifdef GENERATOR_FILE if (GET_CODE (x) == MATCH_OPERAND diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6a34f20da3a..70ffb8d1e1e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-04-24 Jakub Jelinek + + PR target/90193 + * gcc.target/i386/pr90193.c: New test. + 2019-04-24 Andreas Krebbel PR target/89952 diff --git a/gcc/testsuite/gcc.target/i386/pr90193.c b/gcc/testsuite/gcc.target/i386/pr90193.c new file mode 100644 index 00000000000..194cffe539b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr90193.c @@ -0,0 +1,21 @@ +/* PR target/90193 * +/* { dg-do link } */ +/* { dg-options "-O1" } */ +/* { dg-require-effective-target tls } */ + +__thread int var; + +static int +foo (void) +{ + asm goto ("jmp %l[l]\n\t" : : "m" (var) : : l); + return 0; +l: + return 1; +} + +int +main () +{ + return foo (); +} -- 2.30.2