From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3877BC433DF for ; Fri, 21 Aug 2020 21:39:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 11D6B20724 for ; Fri, 21 Aug 2020 21:39:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598045980; bh=vAAK9azzXa5gPwVxfFEruL0FinYrMS+hdV3DboMVukc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=ah0WNw/Ycni4EoY2xqNmVKdKO3OWN2onNJACxdyVPVNTxTvOiMLv3XhLz9hYOIqGN Ui7uOvypTQWNTaOwsFZ2hMwy5LAWOd/bspQLdw3Hr1/gqtAkfPvJVMT/XYaZudfpRk mkDYMOaf10tEwugI9EqjisIQTzGVNmQBIrNMjMzk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726752AbgHUVjj (ORCPT ); Fri, 21 Aug 2020 17:39:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726747AbgHUVjj (ORCPT ); Fri, 21 Aug 2020 17:39:39 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C06E0C061573 for ; Fri, 21 Aug 2020 14:39:38 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id t23so3418301ljc.3 for ; Fri, 21 Aug 2020 14:39:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fmQQDVMXbn1xkliDoKeEU74auHxtHQpL4ZkAUewHmqw=; b=gfwHC9xeYNz7EUpsz/d5a69ffJsRioVxivkh2vW/TF4IoWRw3IP7tqtfK1M2BdovRD BqR5TXoGfgnoGPiVUutu4293iBXetWkpFRZW47K9qMBDXtc3lD7qcD5MTZFqIHAqEy7Z fvQROxcppyhgOJ17j77yZkQ1SOQxSLwO/qOY0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fmQQDVMXbn1xkliDoKeEU74auHxtHQpL4ZkAUewHmqw=; b=EGfcwaHy5xkrOo6jLFaoNwtPr3Y1nZi0c6zMsoYdiHger95gYX9UmnVlvKjs2IJdAw 9XVcdwYo4bC+GbRTgNRGevgrf4SvPU4WB2xmb4SX0lylhTr5zEZHihkY8aolfP7ddci8 vzh4acMj/R2U0isaHBLXQLmIDaqHONj3tdOxRRqXtBTvNfVT5R1iAcUdfgVrmh3tKibJ 5yGqtrMGOxqvZLx6apPuOdG3i5L9zyEDgjIPher8Ju9j1cLF4Q0SpnzjW8GAwGS3NYVR 08xgkzYgN06zfDD2bbcCfhrfHEPn5hFMDB+0XD7VOI4gkWz5E33tHAr7DAfEGaX/doa7 bDVQ== X-Gm-Message-State: AOAM530koHq8aZrRxLn3dMLhRoJMdYEYEQI9gC7XFsv5EaUhkf6XRXMb kH6WO7SNisbIixXK+ZLceHIWZgRf5yOhQw== X-Google-Smtp-Source: ABdhPJzGBkK8HeVBX67VdWYdu3hUX27cXW7R/TyyGP7x9w2y7KmiaU1nyv2oNBq04gjpcCY0hsaQXw== X-Received: by 2002:a2e:a49c:: with SMTP id h28mr2438099lji.234.1598045974997; Fri, 21 Aug 2020 14:39:34 -0700 (PDT) Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com. [209.85.208.182]) by smtp.gmail.com with ESMTPSA id x14sm627042ljd.1.2020.08.21.14.39.32 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Aug 2020 14:39:33 -0700 (PDT) Received: by mail-lj1-f182.google.com with SMTP id i10so3419034ljn.2 for ; Fri, 21 Aug 2020 14:39:32 -0700 (PDT) X-Received: by 2002:a2e:7615:: with SMTP id r21mr2253045ljc.371.1598045972531; Fri, 21 Aug 2020 14:39:32 -0700 (PDT) MIME-Version: 1.0 References: <20200818202407.GA3143683@rani.riverdale.lan> <20200818214146.GA3196105@rani.riverdale.lan> <20200820175617.GA604994@rani.riverdale.lan> <20200821172935.GA1411923@rani.riverdale.lan> <20200821195712.GB1475504@rani.riverdale.lan> In-Reply-To: <20200821195712.GB1475504@rani.riverdale.lan> From: Linus Torvalds Date: Fri, 21 Aug 2020 14:39:16 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 0/4] -ffreestanding/-fno-builtin-* patches To: Arvind Sankar Cc: Rasmus Villemoes , Nick Desaulniers , =?UTF-8?B?RMOhdmlkIEJvbHZhbnNrw70=?= , Eli Friedman , "H. Peter Anvin" , Masahiro Yamada , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Michal Marek , Linux Kbuild mailing list , LKML , Kees Cook , Tony Luck , Dmitry Vyukov , Michael Ellerman , Joe Perches , Joel Fernandes , Daniel Axtens , Andy Shevchenko , Alexandru Ardelean , Yury Norov , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Ard Biesheuvel , "Paul E . McKenney" , Daniel Kiper , Bruce Ashfield , Marco Elver , Vamshi K Sthambamkadi Content-Type: text/plain; charset="UTF-8" Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org On Fri, Aug 21, 2020 at 12:57 PM Arvind Sankar wrote: > > Look, four stores into memset(), yeah that's a bit weird. I didn't think > you meant "four" literally. But in any case, that has nothing to do with > the topic at hand. It would be just as bad if it was a 16-byte structure > being initialized with an out-of-line memset() call. Actually, I mis-remembered. It wasn't four stores. It was two. We have this lovely "sas_ss_reset()" function that initializes three fields in a structure (two to zero, one to '2'). And we used it in a critical place that didn't allow function calls (because we have magic rules with the SMAP instructions). And clang turned the initalization into a memset(). Which then triggered our "you can't do that here" check on the generated code. This is the kind of special rules we sometimes can have for code generation, where the compiler really doesn't understand that no, you can't just replace this code sequence with a function call, because there are things going on around it that really mean that the code should be generated the way we wrote it. > But coming back to the actual topic: it is fine if the compiler turns > four stores into __builtin_memset(). A size-16 or -32 __builtin_memset() > will get inlined anyway. There's a lot of garbage here if you look > closely: check out what gcc does to initialize a 7-character array with > zeros at -Os. Yeah. The reason we had to make -Os be a non-preferred thing is because gcc has some really sad things it does when optimizing for size. I happen to believe that I$ matters, but -Os made _such_ a mess of things that it was untenable to use ;( Linus