{"id":816183,"url":"http://patchwork.ozlabs.org/api/patches/816183/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/87shfhzgwc.fsf@linaro.org/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<87shfhzgwc.fsf@linaro.org>","list_archive_url":null,"date":"2017-09-20T12:36:03","name":"Don't query the frontend for unsupported types","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"51cd8ed8f4bcc2bd2f0237e2ce5c14a5ab23b2dd","submitter":{"id":5450,"url":"http://patchwork.ozlabs.org/api/people/5450/?format=json","name":"Richard Sandiford","email":"richard.sandiford@linaro.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/87shfhzgwc.fsf@linaro.org/mbox/","series":[{"id":4105,"url":"http://patchwork.ozlabs.org/api/series/4105/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=4105","date":"2017-09-20T12:36:03","name":"Don't query the frontend for unsupported types","version":1,"mbox":"http://patchwork.ozlabs.org/series/4105/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/816183/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/816183/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-return-462589-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-462589-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=\"FfE+Fz3/\"; 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 3xxzkj2gLvz9s82\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 20 Sep 2017 22:36:28 +1000 (AEST)","(qmail 91309 invoked by alias); 20 Sep 2017 12:36:18 -0000","(qmail 91170 invoked by uid 89); 20 Sep 2017 12:36:13 -0000","from mail-wm0-f42.google.com (HELO mail-wm0-f42.google.com)\n\t(74.125.82.42) by sourceware.org\n\t(qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tWed, 20 Sep 2017 12:36:11 +0000","by mail-wm0-f42.google.com with SMTP id e71so6767891wmg.4 for\n\t<gcc-patches@gcc.gnu.org>; Wed, 20 Sep 2017 05:36:11 -0700 (PDT)","from localhost (92.40.248.127.threembb.co.uk. [92.40.248.127]) by\n\tsmtp.gmail.com with ESMTPSA id\n\tf140sm1590786wmd.12.2017.09.20.05.36.07 for\n\t<gcc-patches@gcc.gnu.org> (version=TLS1_2\n\tcipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tWed, 20 Sep 2017 05:36:08 -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:from\n\t:to:subject:date:message-id:mime-version:content-type; q=dns; s=\n\tdefault; b=ucOj0S2mRJ7tC44FWqXte4zIaqMJbpqI4ouwYkTCoVb7U6xa4p+Ju\n\tnqMgagBWvld8IAWldh+bJZ7DwVAMQRIdO4E1m8j0YZe5aTP6A4yqGQBEmyezQ1ga\n\tFLqMjXwW32GjKmGnMopCfiGQByAAx0Y+rq/e7GtLamGhaFaDIbrtb8=","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:from\n\t:to:subject:date:message-id:mime-version:content-type; s=\n\tdefault; bh=m9wdc5f6s8GetE41gB7Ys6/A9Xc=; b=FfE+Fz3/WwtbDKN0kWF7\n\tv/syA0vdIp1gnXj6K8uygQbjQyegNgeqprL2a4PfpLn7Z0jeG4T8ooWNwRKIpvAM\n\tS6hoFpOG/4HhSNTqrKL1bBDGhR//cYNssdIh6m7xUj/iM+oE9d8mJ4qydXfYSJNd\n\t4kW3g+MEuP8UAb5I4XBBcnY=","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=-11.3 required=5.0 tests=AWL, BAYES_00,\n\tGIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_SORBS_SPAM,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:3055","X-HELO":"mail-wm0-f42.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:from:to:mail-followup-to:subject:date:message-id\n\t:user-agent:mime-version;\n\tbh=xgDcsoWSey1meWipASykuVjMjS5F4IeIxU/IK8Qj17A=;\n\tb=Hj3z8AgAn2iu10WSvIh8RRFYmBFkD8TCbkK6kz2YUDeMaDA2JRaqj+ytkrefa5E2mc\n\tbQgUw7L7rwpDN5B0dUBAdlknVegcQSiFO/So4pcNabY3KAIt4gbnPNv1NEHZnsnAeJRY\n\ts3MqJkA+m1t791TO5IYlCQcPJhDu7RdqTMirdPx7Xth4uS9V98p9NMLxNAijWY7UnYXA\n\tI5F4vx4OzmyfV8UGo2C6ntuwxnYM8z0H+Wh/RYhQdt6KMsg/Or+THbZ7rjGsVs7E6gK9\n\tPY7kz0+4vxIqnDjew0JOTjFcwpQWDKWhiLct0L3YRnpm1fSh9tr6+WjMX25kqvQ7MHKG\n\thKEA==","X-Gm-Message-State":"AHPjjUigFvCxgWfmcKw24gLxOQoG+vKL1YSwT76xaco+g08SOeSQix8n\tOL+vlPFoJjtwtagLIPyruPGilnmOPJs=","X-Google-Smtp-Source":"AOwi7QAXT3P2Mz7Y3d85ZZv+o+LClfoRcDV17En8b5YYr+6JLURW7uiqQhKMcmWhbJb3DKU7b1L1HA==","X-Received":"by 10.28.131.13 with SMTP id f13mr4206614wmd.157.1505910969064;\n\tWed, 20 Sep 2017 05:36:09 -0700 (PDT)","From":"Richard Sandiford <richard.sandiford@linaro.org>","To":"gcc-patches@gcc.gnu.org","Mail-Followup-To":"gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org","Subject":"Don't query the frontend for unsupported types","Date":"Wed, 20 Sep 2017 13:36:03 +0100","Message-ID":"<87shfhzgwc.fsf@linaro.org>","User-Agent":"Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)","MIME-Version":"1.0","Content-Type":"text/plain"},"content":"When forcing a constant of mode MODE into memory, force_const_mem\nasks the frontend to provide the type associated with that mode.\nIn principle type_for_mode is allowed to return null, and although\none use site correctly handled that, the other didn't.\n\nI think there's agreement that it's bogus to use type_for_mode for\nthis kind of thing, since it forces frontends to handle types that\ndon't exist in that language.  See e.g. http://gcc.gnu.org/PR46805\nwhere the Go frontend was forced to handle vector types even though\nGo doesn't have vector types.\n\nAlso, the frontends use code like:\n\n  else if (VECTOR_MODE_P (mode))\n    {\n      machine_mode inner_mode = GET_MODE_INNER (mode);\n      tree inner_type = c_common_type_for_mode (inner_mode, unsignedp);\n      if (inner_type != NULL_TREE)\n        return build_vector_type_for_mode (inner_type, mode);\n    }\n\nand there's no guarantee that every vector mode M used by backend\nrtl has an associated vector type whose TYPE_MODE is M.  I think\nreally the type_for_mode hook should only return trees that _do_ have\nthe requested TYPE_MODE, but PR46805 linked above shows that this is\nlikely to have too many knock-on consequences.  It doesn't make sense\nfor force_const_mem to ask about vector modes that aren't valid for\nvector types, so this patch handles the condition there instead.\n\nThis is needed for SVE multi-register modes, which are modelled as\nvector modes but are not usable as vector types.\n\nTested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linus-gnu.\nOK to install?\n\nRichard\n\n\n2017-09-20  Richard Sandiford  <richard.sandiford@linaro.org>\n\t    Alan Hayward  <alan.hayward@arm.com>\n\t    David Sherwood  <david.sherwood@arm.com>\n\ngcc/\n\t* varasm.c (force_const_mem): Don't ask the front end about\n\tvector modes that are not supported as vector types by the target.","diff":"Index: gcc/varasm.c\n===================================================================\n--- gcc/varasm.c\t2017-09-12 14:28:56.402824780 +0100\n+++ gcc/varasm.c\t2017-09-20 13:33:15.942547232 +0100\n@@ -3785,10 +3785,17 @@ force_const_mem (machine_mode mode, rtx\n   desc = ggc_alloc<constant_descriptor_rtx> ();\n   *slot = desc;\n \n+  tree type = NULL_TREE;\n+  if (mode != VOIDmode\n+      /* Don't ask the frontend about vector modes if there cannot be a\n+\t VECTOR_TYPE whose TYPE_MODE is MODE.  */\n+      && (!VECTOR_MODE_P (mode)\n+\t  || targetm.vector_mode_supported_p (mode)))\n+    type = lang_hooks.types.type_for_mode (mode, 0);\n+\n   /* Align the location counter as required by EXP's data type.  */\n   align = GET_MODE_ALIGNMENT (mode == VOIDmode ? word_mode : mode);\n \n-  tree type = lang_hooks.types.type_for_mode (mode, 0);\n   if (type != NULL_TREE)\n     align = CONSTANT_ALIGNMENT (make_tree (type, x), align);\n \n@@ -3832,7 +3839,8 @@ force_const_mem (machine_mode mode, rtx\n \n   /* Construct the MEM.  */\n   desc->mem = def = gen_const_mem (mode, symbol);\n-  set_mem_attributes (def, lang_hooks.types.type_for_mode (mode, 0), 1);\n+  if (type)\n+    set_mem_attributes (def, type, 1);\n   set_mem_align (def, align);\n \n   /* If we're dropping a label to the constant pool, make sure we\n","prefixes":[]}