From owner-freebsd-hackers@freebsd.org Sun Feb 25 20:48:23 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 38588F279BC; Sun, 25 Feb 2018 20:48:23 +0000 (UTC) (envelope-from tijl@freebsd.org) Received: from mailrelay101.isp.belgacom.be (mailrelay101.isp.belgacom.be [195.238.20.128]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "relay.skynet.be", Issuer "GlobalSign Organization Validation CA - SHA256 - G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 596DA6FE0E; Sun, 25 Feb 2018 20:48:22 +0000 (UTC) (envelope-from tijl@freebsd.org) X-Belgacom-Dynamic: yes IronPort-PHdr: =?us-ascii?q?9a23=3ABxWDYRKkFurs+5XLudmcpTZWNBhigK39O0sv0rFi?= =?us-ascii?q?tYgRLfrxwZ3uMQTl6Ol3ixeRBMOHs6kC07KempujcFRI2YyGvnEGfc4EfD4+ou?= =?us-ascii?q?JSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47xaFLIv3K98yMZFAnhOgpp?= =?us-ascii?q?POT1HZPZg9iq2+yo9JDffwtFiCChbb9uMR67sRjfus4KjIV4N60/0AHJonxGe+?= =?us-ascii?q?RXwWNnO1eelAvi68mz4ZBu7T1et+ou+MBcX6r6eb84TaFDAzQ9L281/szrugLd?= =?us-ascii?q?QgaJ+3ART38ZkhtMAwjC8RH6QpL8uTb0u+ZhxCWXO9D9QKsqUjq+8ahkVB7oiD?= =?us-ascii?q?8GNzEn9mHXltdwh79frB64uhBz35LYbISTOfFjfK3SYMkaSHJPUMhRSSJPH4Cy?= =?us-ascii?q?YIkBD+UOIelWoJLwp0cMoBeiGQWgGP/jxiFOi3Tr3aM6yeMhEQTe0QI+HtIOsn?= =?us-ascii?q?DUp8jrOacVVuC117fHzTDZYPNQwjf29Y/FcgwgofGOWbJ9asrfyVMxGAzbk1ie?= =?us-ascii?q?tILrMymS1uQXvGiW9uxtXv+shW4/swx8oSWjyt0yhoTGh48Z0E3I+Ct3zYovON?= =?us-ascii?q?G1RkF2bNi5G5VKrS6aLZF5QsY6TmFtvyY116MJtIagfCgP1JQn3xnfa+Gbc4SQ?= =?us-ascii?q?4hLsSuKRITBgiXJmYr2/gxey8U2+xe3mUcm4ykpKritHktnIrHwCyxvT6s+cSv?= =?us-ascii?q?Rj+0euwzCP1xvJ5uFDO0A0mrLXK58nwrEuipoeqUfOEjLslEnog6Kbd18o9vWm?= =?us-ascii?q?5unpeLnqu5GROoBshgH7KKsum8i/AeoiMggJWmiW4fi81Lzh/U39W7hKgOc2nb?= =?us-ascii?q?fHv5/BPsQUu7S1AwhP0oYs8xq/FSup0MwEnXkbK1JIYBGHj4/yO1HSIfD4Duyw?= =?us-ascii?q?jEqokDpwyPDGO6fuApTJLnTZjLjherN9uAZgz18QytZE+5tSFrAHaNj+Xkjsr9?= =?us-ascii?q?vGRks6NBeowuXtBdFV2YYXWGbJCaicZvD8q1iNs94uIe3ET4gSozv4Iv4+r6ry?= =?us-ascii?q?jH09sXEHcKSD5rdRb2q3SKc1a36FaGbh149SWVwBuRAzGamz0AWP?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2B9AQANIJNa/4aF9lFcGgEBAQEBAgEBA?= =?us-ascii?q?QEIAQEBAYNPVoEAKI12dI0GAQGCATIBY4dtjhiCFoU9AoI3VRgBAgEBAQEBAQI?= =?us-ascii?q?BaiiCOCQBgkcBBTocIxALDgoJJQ8SGB4GE4R4Axmtd4cjDYEyghQBAQEBAQEEA?= =?us-ascii?q?QEBASSOLIJqiCkFoS8yCY81hF6BBJFpjRmKCx44gVFNMAiCfYJDHIF8PzeMbAE?= =?us-ascii?q?BAQ?= X-IPAS-Result: =?us-ascii?q?A2B9AQANIJNa/4aF9lFcGgEBAQEBAgEBAQEIAQEBAYNPVoE?= =?us-ascii?q?AKI12dI0GAQGCATIBY4dtjhiCFoU9AoI3VRgBAgEBAQEBAQIBaiiCOCQBgkcBB?= =?us-ascii?q?TocIxALDgoJJQ8SGB4GE4R4Axmtd4cjDYEyghQBAQEBAQEEAQEBASSOLIJqiCk?= =?us-ascii?q?FoS8yCY81hF6BBJFpjRmKCx44gVFNMAiCfYJDHIF8PzeMbAEBAQ?= Received: from 134.133-246-81.adsl-dyn.isp.belgacom.be (HELO kalimero.tijl.coosemans.org) ([81.246.133.134]) by relay.skynet.be with ESMTP; 25 Feb 2018 21:48:15 +0100 Received: from kalimero.tijl.coosemans.org (kalimero.tijl.coosemans.org [127.0.0.1]) by kalimero.tijl.coosemans.org (8.15.2/8.15.2) with ESMTP id w1PKmDJt045352; Sun, 25 Feb 2018 21:48:14 +0100 (CET) (envelope-from tijl@FreeBSD.org) Date: Sun, 25 Feb 2018 21:48:13 +0100 From: Tijl Coosemans To: Konstantin Belousov Cc: Eitan Adler , FreeBSD Standards , FreeBSD Hackers , Kevin Lo Subject: Re: Marking select(2) as restrict Message-ID: <20180225214813.776a9f58@kalimero.tijl.coosemans.org> In-Reply-To: <20180222105608.GE94212@kib.kiev.ua> References: <20180221032247.GA81670@ns.kevlo.org> <20180221104400.GU94212@kib.kiev.ua> <20180222112752.10da7e51@kalimero.tijl.coosemans.org> <20180222105608.GE94212@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Feb 2018 20:48:23 -0000 On Thu, 22 Feb 2018 12:56:08 +0200 Konstantin Belousov wrote: > Consider the recently changed devd code: > select(n + 1, &fd, &fd, &fd); > There, compiler can see that restrict is applied to arguments which are > given same values. Since this leads to the self-contradicting statement > fd != fd > which cannot be true, compliler in its optimizing wisdom can assume that > the code is never executing and remove it. I do not know whether clang > actually makes such transformation, but it does not sound unfeasible > looking at its other advances. There's an example in the C99 standard that indicates such a call is not necessarily undefined so compilers cannot optimise it away: EXAMPLE 3 The function parameter declarations void h(int n, int * restrict p, int * restrict q, int * restrict r) { int i; for (i = 0; i < n; i++) p[i] = q[i] + r[i]; } illustrate how an unmodified object can be aliased through two restricted pointers. In particular, if a and b are disjoint arrays, a call of the form h(100, a, b, b) has defined behavior, because array b is not modified within function h.