Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751476AbdILOnW (ORCPT ); Tue, 12 Sep 2017 10:43:22 -0400 Received: from mail-io0-f179.google.com ([209.85.223.179]:38390 "EHLO mail-io0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751426AbdILOnR (ORCPT ); Tue, 12 Sep 2017 10:43:17 -0400 X-Google-Smtp-Source: AOwi7QCqjbMTeA2LyBjLUPMFBbxePU0wXtswrM6zFpUfNrx+qqmjiBP75rn6CNnB3KEeQfONPjuDnXj3OBYokKO6YFQ= MIME-Version: 1.0 From: Dmitry Vyukov Date: Tue, 12 Sep 2017 16:42:56 +0200 Message-ID: Subject: "KVM: x86: generalize guest_cpuid_has_ helpers" breaks clang To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , David Hildenbrand , Paolo Bonzini , LKML , KVM list Cc: llvmlinux@lists.linuxfoundation.org, Alexander Potapenko , andreyknvl , Michael Davidson , Greg Hackmann , Nick Desaulniers Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 731 Lines: 25 Hi Radim, I've just noticed that your commit "KVM: x86: generalize guest_cpuid_has_ helpers" breaks clang build on this assert: static __always_inline struct cpuid_reg x86_feature_cpuid(unsigned x86_feature) { unsigned x86_leaf = x86_feature / 32; BUILD_BUG_ON(!__builtin_constant_p(x86_leaf)); In clang __builtin_constant_p is never true for function arguments, it's true only for compile-time constants (what you can use as stack array size, or C++ template argument). What would work is an additional macro along the lines of: #define x86_feature_cpuid(x) (BUILD_BUG_ON(!__builtin_constant_p(x), __x86_feature_cpuid(x)) But again assuming that caller pass the constant directly. Could you please fix it? Thanks