Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp909031ybi; Fri, 12 Jul 2019 06:34:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRtc6WoGO4aUcKrq2a63wvLrKZuVEirvCdHrwB1U3vUHbaOpBXA/gY6ze9pfgaaigB3uKR X-Received: by 2002:a17:902:6b86:: with SMTP id p6mr11857755plk.14.1562938469248; Fri, 12 Jul 2019 06:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562938469; cv=none; d=google.com; s=arc-20160816; b=tWIZFlfy0/YwDjarG2fEak5+c5C4XPhvIjq3HxQPMx/YXhGSrKsY9mg5lMb5fdUTsi UO8nNodsOicMn12f40OUInu3whbZrdfacj6mXy0v7uLKzb0jKGdJH7ZUmut5OdZGvBi/ 8F9tm3Sl4ze0fL3rt78JpAjcwvTSVPqhZMCzlTyCOQmoELoBdj0ZDv1FsvPvlAm1yMJo iagEfbfMvqMYE7K+jq2sVsAW+qfGSgmxj4JxjLj7Ga0tjQPCaR/1599f9mS6fuTDtyVp ZdWnpyXa1GNVcshBmaTGGEnYU7aingyTwk46KZYUaiUc+HaXghnP9Gb1xc7bk5hSbFL+ cLbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=JM+xRcXXQLHHmgjag8FydAcUh6ZsxVdozmIdMl6zvCI=; b=ZbGSVzCRW40+lNbwiOIA30/xpHXqSPypedUWQLZ0R8rHcXJPzurM0m3nIYj/bjifg+ uu6YPFo03RBFyNHxgqGhlw+cNtx251E4PNLATdo8EaWJGdm7y8hNKxiTgJ3FZifT8PcH 5inv4m/Aq2bHvL5dms2rS9mONiNdKhAIFqQRwJzWhGxNCbtbVdtlf8v5TXfcutQkA6R/ 53TaYEaWV3bMERxqpuu2J9KFJsWi+bB/YQB6pr4/gtTp3naxEqI2NiNLTx9WHuIWZUQx ovfbY1I3snLXtVFpTuw45PdjriHzFUFbQt+Hmufr/JMeLSv+4iLj/JbUOArAJ6jtGzLi eJLg== 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 x8si8194063pgj.322.2019.07.12.06.34.12; Fri, 12 Jul 2019 06:34:29 -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 S1727753AbfGLNch (ORCPT + 99 others); Fri, 12 Jul 2019 09:32:37 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:37359 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726466AbfGLNch (ORCPT ); Fri, 12 Jul 2019 09:32:37 -0400 Received: by mail-qt1-f196.google.com with SMTP id y26so8059699qto.4; Fri, 12 Jul 2019 06:32:36 -0700 (PDT) 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=JM+xRcXXQLHHmgjag8FydAcUh6ZsxVdozmIdMl6zvCI=; b=ncDNJL1/AGOalU51T9+OUXd8y8ehu2STjZFIR99KAuQJ/2u5eCIPMxkt4/Ob3+EWqD h9qSk0tgr3NnUBe2FQbRQyfpacqCP+04lzv5u1GbAxkjWii4vfM7miFXTQkIy3cRfQwZ 9ST0APRWF/SHopBGj94U/dLObasW1I6uPNIwks5j7hgZ7NeiGBmSIfg3r/PVIYnNnnKU 4RjI9O/5Lx7yrP+8qzXSqE5mCF1FFvFfauk2XMgTfwPAGY4iHdzcxaNW/X80+aRzlK+t aHBhqDslQ1IWxA1bBRUFkr/wewMXfB74n4k3LKjQMip/05i07gVkWq+2bvUc8g0Xnate koPA== X-Gm-Message-State: APjAAAV2jpBMqmWM9VSzTEVp62rFfq+6r7a6X/qTSPqLRHGHk20W1TRT Aix9tq24UesuZfkuOVQTpgjHggbaPKpeNfLucM0= X-Received: by 2002:ac8:f99:: with SMTP id b25mr929340qtk.142.1562938356233; Fri, 12 Jul 2019 06:32:36 -0700 (PDT) MIME-Version: 1.0 References: <20190712091239.716978-1-arnd@arndb.de> <20190712120249.GA27820@rkaganb.sw.ru> In-Reply-To: From: Arnd Bergmann Date: Fri, 12 Jul 2019 15:32:19 +0200 Message-ID: Subject: Re: [PATCH 1/2] x86: kvm: avoid -Wsometimes-uninitized warning To: Paolo Bonzini Cc: Roman Kagan , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "x86@kernel.org" , "H. Peter Anvin" , Vitaly Kuznetsov , Liran Alon , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "clang-built-linux@googlegroups.com" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 12, 2019 at 3:14 PM Paolo Bonzini wrote: > > On 12/07/19 15:02, Arnd Bergmann wrote: > > I think what happens here is that clang does not treat the return > > code of track the return code of is_64_bit_mode() as a constant > > expression, and therefore assumes that the if() condition > > may or may not be true, for the purpose of determining whether > > the variable is used without an inialization. This would hold even > > if it later eliminates the code leading up to the if() in an optimization > > stage. IS_ENABLED(CONFIG_X86_64) however is a constant > > expression, so with the patch, it understands this. > > > > In contrast, gcc seems to perform all the inlining first, and > > then see if some variable is used uninitialized in the final code. > > This gives additional information to the compiler, but makes the > > outcome less predictable since it depends on optimization flags > > and architecture specific behavior. > > > > Both approaches have their own sets of false positive and false > > negative warnings. > > True, on the other hand constant returns are not really rocket science. :) > > Maybe change is_long_mode to a macro if !CONFIG_X86_64? That would be > better if clang likes it. I had to also get rid of the temporary variable to make it work. Sending v2 now. Arnd