[{"id":1762731,"web_url":"http://patchwork.ozlabs.org/comment/1762731/","msgid":"<CAFULd4arFjGJZETOMzHxr9LVXv1S9pp=iidRw=Cnqg+HGh7NxQ@mail.gmail.com>","list_archive_url":null,"date":"2017-09-04T15:42:28","subject":"Re: [RFC PATCH,\n\ti386]: Convert TLS location to DEFAULT_TLS_SEG_REG address space","submitter":{"id":808,"url":"http://patchwork.ozlabs.org/api/people/808/","name":"Uros Bizjak","email":"ubizjak@gmail.com"},"content":"On Thu, Aug 31, 2017 at 9:32 PM, Uros Bizjak <ubizjak@gmail.com> wrote:\n> Hello!\n>\n> Using following testcase:\n>\n> --cut here--\n> __thread int a;\n>\n> int foo (void)\n> {\n>   return a;\n> }\n> --cut here--\n>\n> Attached patch converts TLS location in the form of:\n>\n>         (mem/c:SI (plus:DI (unspec:DI [\n>                         (const_int 0 [0])\n>                     ] UNSPEC_TP)\n>                 (const:DI (unspec:DI [\n>                             (symbol_ref:DI (\"a\") [flags 0x2a]\n> <var_decl 0x7f8c3acd5e10 a>)\n>                         ] UNSPEC_NTPOFF))) [1 a+0 S4 A32]))\n> \"thread.c\":5 82 {*movsi_internal}\n> to:\n>\n>         (mem/c:SI (const:DI (unspec:DI [\n>                         (symbol_ref:DI (\"a\") [flags 0x2a]  <var_decl\n> 0x7f8c3acd5e10 a>)\n>                     ] UNSPEC_NTPOFF)) [1 a+0 S4 A32 AS1])) \"thread.c\":5 -1\n>\n> avoiding the UNSPEC_TP tag and instead mark the location with AS.\n>\n> This way, address space becomes the property of the memory location,\n> not of the address itself, so we don't need ugly hacks when the\n> address is moved to a register (LEA ignores segment overrides, c.f.\n> split_long_move function in i386.c).\n>\n> Please note that some instructions (e.g. prefetchX) operate on\n> prefixed *address*, so we can't just rip out non-AS code from\n> print_operand. The above amended example:\n>\n> --cut here--\n> __thread int a;\n>\n> int foo (void)\n> {\n>   __builtin_prefetch (&a, 0);\n>   return a;\n> }\n> --cut here--\n>\n> compiles to:\n>\n>         prefetcht0      %fs:a@tpoff\n>         movl    %fs:a@tpoff, %eax\n>\n> where prefetch operand remains:\n>\n> (insn 7 6 16 2 (prefetch (plus:DI (unspec:DI [\n>                     (const_int 0 [0])\n>                 ] UNSPEC_TP)\n>             (const:DI (unspec:DI [\n>                         (symbol_ref:DI (\"a\") [flags 0x2a]  <var_decl\n> 0x7fe994a14e10 a>)\n>                     ] UNSPEC_NTPOFF)))\n>         (const_int 0 [0])\n>         (const_int 3 [0x3])) \"thread.c\":5 1010 {*prefetch_sse}\n>      (nil))\n>\n> 2017-08-31  Uros Bizjak  <ubizjak@gmail.com>\n>\n>     * config/i386/i386-protos.h (ix86_tls_address_pattern_p) New prototype.\n>     (ix86_rewrite_tls_address): Ditto.\n>     * config/i386/i386.c (ix86_tls_address_pattern_p) New function.\n>     (ix86_rewrite_tls_address_1): Ditto.\n>     (ix86_rewrite_tls_address): Ditto.\n>     * config/i386/predicates.md (tls_address_pattern): New predicate.\n>     * config/i386/i386.md (TLS address splitter): New splitter.\n>\n> Patch was bootstrapped and regression tested on x86_64-linux-gnu\n> {,-m32}, all default languages plus go.\n>\n> I plan to commit the patch to the mainline early next week.\n\nCommitted to mainline SVN.\n\nUros","headers":{"Return-Path":"<gcc-patches-return-461431-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-461431-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"l7vakdt8\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xmDd42b4lz9s7C\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue,  5 Sep 2017 01:42:46 +1000 (AEST)","(qmail 32837 invoked by alias); 4 Sep 2017 15:42:37 -0000","(qmail 32710 invoked by uid 89); 4 Sep 2017 15:42:36 -0000","from mail-ua0-f195.google.com (HELO mail-ua0-f195.google.com)\n\t(209.85.217.195) by sourceware.org\n\t(qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tMon, 04 Sep 2017 15:42:31 +0000","by mail-ua0-f195.google.com with SMTP id c27so299221uah.1 for\n\t<gcc-patches@gcc.gnu.org>; Mon, 04 Sep 2017 08:42:30 -0700 (PDT)","by 10.103.55.28 with HTTP; Mon, 4 Sep 2017 08:42:28 -0700 (PDT)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender\n\t:mime-version:in-reply-to:references:from:date:message-id\n\t:subject:to:content-type; q=dns; s=default; b=tPnt4je5RZdq1kbG7U\n\tZNbTMzVnbZgonb7i0nihIUyFBZ4vSK0231+Y8uTfSuwKqRINkbZ2dHY0veLeRTAR\n\tSgXlks1Gi2WJW6O5Ibagv0WTtc3A/abkNtW+LjzEIxR+iWHbHhyUYJOav59WY7A6\n\tWn89phTlwUJxJqTPmRwwOoq8k=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender\n\t:mime-version:in-reply-to:references:from:date:message-id\n\t:subject:to:content-type; s=default; bh=uWcvd0QgFCOW6X0I7gqrc6SM\n\tung=; b=l7vakdt89hzveAxWVtZLyFosE9S/yJWk+wvl6ArsCqvv22k5ES6sZdTz\n\tkjUsTBKDiw/SQfTzHKfE6mVtdmOgxXkTX7b3AKDvgQBArwWhJBCX7STOQqfqRLC4\n\tOTBunRR8i1i2ylweJqP4hjjKakOX9mQ9wdpdmS00IUbIoZVDsRk=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-2.3 required=5.0 tests=AWL, BAYES_00,\n\tFREEMAIL_FROM, RCVD_IN_DNSWL_NONE,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=Hello!, splitter,\n\thello!","X-HELO":"mail-ua0-f195.google.com","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net;\n\ts=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to;\n\tbh=6cox7QZwS5jwkMBL6WGpyFsgj/BtCifi9N8YfVz4FEk=;\n\tb=TlZ63UTk35YIWEVklrs7NGmbbP4VTAhfofYvMWhymV6oEmYl9Uwub5FMWrMxrFuuv1\n\tAczG3ocB/gYJgpiH3Xq2dLBpN/FdPUmshQNv8+4Qgih6r7F6XOi9TG9xSPtAZrMSEUoV\n\ttvtSE4us+KQhz4FPTFGzsvRGRS2lebzPGYkQ1WAI3WVkJOu9Bj0otYL/8JrU/JIQNo6i\n\t1QY2vlF8ulCPja6JNNJYoFrRGZcWba5X7ONdCOH1JPnmnS+OhMt3Xrkm9d0XM+RkjtzQ\n\tjdyH+nfdlmLmYGOiCuhc/AmCoZmrK25uhinwrV5Ms3wS9+Z5MxE/8agYGpFx+K7FwY9p\n\t5oRQ==","X-Gm-Message-State":"AHPjjUialysTeYKCkC9iO6DtKTHl6aAWzEJNgXkewna6toLTWWgmwGn8\tJ8S3uWNsnAq9m+wZpXJMAZLhWuOZLQ==","X-Google-Smtp-Source":"ADKCNb63H3C2IPbaGSguUEQDsWfsgkFxjk2qLb4Gkt1sOvrtzAhEl7jx5yTysrwZDkQ90dq9/ZK5xMtWG90s19pwRZ0=","X-Received":"by 10.176.73.169 with SMTP id e38mr607863uad.132.1504539749069;\n\tMon, 04 Sep 2017 08:42:29 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<CAFULd4bW+ms-Vc_HV6tcbGkMroiw1NweqaSsepx2QF7zQRP-QA@mail.gmail.com>","References":"<CAFULd4bW+ms-Vc_HV6tcbGkMroiw1NweqaSsepx2QF7zQRP-QA@mail.gmail.com>","From":"Uros Bizjak <ubizjak@gmail.com>","Date":"Mon, 4 Sep 2017 17:42:28 +0200","Message-ID":"<CAFULd4arFjGJZETOMzHxr9LVXv1S9pp=iidRw=Cnqg+HGh7NxQ@mail.gmail.com>","Subject":"Re: [RFC PATCH,\n\ti386]: Convert TLS location to DEFAULT_TLS_SEG_REG address space","To":"\"gcc-patches@gcc.gnu.org\" <gcc-patches@gcc.gnu.org>","Content-Type":"text/plain; charset=\"UTF-8\""}}]