Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4918437ybi; Tue, 30 Jul 2019 10:24:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKVbhqxTxIqrBwIxkXGza+7fES4Y9CNo18q/aV78AyiVohR+wQZyyZLtmT2KrdxSrnTkrz X-Received: by 2002:a17:90a:601:: with SMTP id j1mr115902998pjj.96.1564507494403; Tue, 30 Jul 2019 10:24:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564507494; cv=none; d=google.com; s=arc-20160816; b=D7tm6dKvy+UxGBFLk7LKzzYigKNc7p9FQUDYmPGj7CAS34fi4paPH+ME854s1W7rnn 6FERJ1w1PTJ6CIAuKsWpi9up+CmVfTkj7Qj8MppewDTTfInfb3Vtzj3w7pxU05hnIT7L Lv8HBBHq/z/X02yy7C9YCSvH9Ta205Xuj+S5+ZBMx5GBqmOXYLnV1NjKb3+H8w1Z+NoF KoM/pdvjI1b/LYRbLrjPovzq/8mDZiFgDXqkndQdgjut0RCJKp25uqkPMM7unIqllcM6 S9t+92B+nd58RZ6ucntPJt4Svdv1/4kHjtcZ868EWX5WgFabin4GKjimg/wTDVbSnu5m 2s7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=OlG6XRFI+KKRN+NFzLQV6U2fRslRWhDuWUpHJLDqM58=; b=cgVyO42MpySg4j6v5BhIsjftXH4ssHAYTVeGCafqqIXvjuYSExO9QTLV4zz9mvCsuq sm2+nvd195iJFN9DROAoU9Xzxa/mmA9Z+qw1ILKFgOBDcP70/0c/+lYLx46CNuzPni4/ MykVYflRBriNvjsJ+OERgXM+PuqS338G+0z5pbW52H9XNZPS3Vk7Gn+2PnsEtx+B3aWt uiGYzZrKkXyk2WnQZwdoDfPPme013/3TFD0eB3wAl2nQQCmFqW60z9Uw0H/Il6pvft/K A96/I63e38vSoEvdQO8uCIFv1PmNJ1UlzjjHoG8jaiyPUFLoKlqsHCkObMrCj9F+1BhK 3Sqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f32si26876450pjg.42.2019.07.30.10.24.39; Tue, 30 Jul 2019 10:24:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727472AbfG3Ntp (ORCPT + 99 others); Tue, 30 Jul 2019 09:49:45 -0400 Received: from gate.crashing.org ([63.228.1.57]:41407 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725871AbfG3Nto (ORCPT ); Tue, 30 Jul 2019 09:49:44 -0400 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id x6UDmwB5006744; Tue, 30 Jul 2019 08:48:58 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id x6UDmu7O006742; Tue, 30 Jul 2019 08:48:56 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Tue, 30 Jul 2019 08:48:56 -0500 From: Segher Boessenkool To: Arnd Bergmann Cc: Nathan Chancellor , Nick Desaulniers , Michael Ellerman , christophe leroy , kbuild test robot , Benjamin Herrenschmidt , Paul Mackerras , linuxppc-dev , Linux Kernel Mailing List , clang-built-linux Subject: Re: [PATCH] powerpc: workaround clang codegen bug in dcbz Message-ID: <20190730134856.GO31406@gate.crashing.org> References: <20190729202542.205309-1-ndesaulniers@google.com> <20190729203246.GA117371@archlinux-threadripper> <20190729215200.GN31406@gate.crashing.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 30, 2019 at 09:34:28AM +0200, Arnd Bergmann wrote: > Upon a second look, I think the issue is that the "Z" is an input argument > when it should be an output. clang decides that it can make a copy of the > input and pass that into the inline asm. This is not the most efficient > way, but it seems entirely correct according to the constraints. Most dcb* (and all icb*) do not change the memory pointed to. The memory is an input here, logically as well, and that is obvious. > Changing it to an output "=Z" constraint seems to make it work: > > https://godbolt.org/z/FwEqHf > > Clang still doesn't use the optimum form, but it passes the correct pointer. As I said many times already, LLVM does not seem to treat all asm operands as lvalues. That is a bug. And it is critical for memory operands for example, as should be obvious if you look at at for a few seconds (you pass *that* memory, not a copy of it). The thing you pass has an identity. It's an lvalue. This is true for *all* inline asm operands, not just output operands and memory operands, but it is most obvious there. Or, LLVM might have a bug elsewhere. Either way, the asm is fine, and it has worked fine in GCC since forever. Changing this constraint to be an output constraint would just be obfuscation (we could change *all* operands to *everything* to be inout ("+") constraints, and it won't affect correctness, just the reader's sanity). Segher