From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E8817BAEC for ; Tue, 31 Dec 2024 05:08:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735621734; cv=none; b=nK6HOr9GH6l7Q07NRv/UF4f1qrn3DMSG49jSBK2Sl/z05qmkZr3nvqjcTxnyWfLRHX0ATuiXyxfF8u+9yQBqcDb+HJYBeW9xB3MvppZMMp4Z76sYCVsGXIBxMLqp2q/VbW6i+XXeem8kq3flulwbFmZNRbMMx5iGiHZWg/+8Mt8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735621734; c=relaxed/simple; bh=ichSyoTfs8aFM/7781904WZUY8f1+1bxpOyEcuisl0c=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=NAb4wy+4NBwxYug6jNOLS5SNjyZIrA/osBkLaUTEOQtcaA0SCc9xdaDaagXhxRHoonTHLtTwgkRliF2jSTg/nug6jr2kQ57oqWwv948Q1AkWBkzf9JCoYeRGSyjLZAnZswkZE2QZkFOAKcp+aAiymI2zFdEMUQraicWQft0cCEs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=jIfFp16C; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jIfFp16C" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735621732; x=1767157732; h=date:from:to:cc:subject:message-id:mime-version; bh=ichSyoTfs8aFM/7781904WZUY8f1+1bxpOyEcuisl0c=; b=jIfFp16CIXiHbeupi0vX+JSWM/+01Kk9aV1+8EcSy3P34U0qn0ClWSnB tAgO4VSLo5qJhundqSFSN2Kx0/4v926L11y+VnffXYv9CGfciMzZ1soxe aGw1098nZiTTgcy4/taK/jNMeUjdf46k+3zOFWYnqviKTb75n90hNAnne mUOu7KSckTyL4KJItDzGioi+HOGGCXxDqbuKK/3ns7h12VwaL9KZdy0S3 QJTcul8Z+DLuDdja1ZaG35cUzyiToWlDPQ1m9zaM6Oy7jrW1yKeDfFlLG hnFt8Ro/7pxepFNfaVWS1VvKkEdTtZ3lrkqjoyBCxrZrIn35dLNiWbeuF A==; X-CSE-ConnectionGUID: 9JbJx07pRWe3xhOVbCu1mg== X-CSE-MsgGUID: PpXi81xgSU+X8LUR3apV6Q== X-IronPort-AV: E=McAfee;i="6700,10204,11301"; a="46396814" X-IronPort-AV: E=Sophos;i="6.12,278,1728975600"; d="scan'208";a="46396814" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Dec 2024 21:08:52 -0800 X-CSE-ConnectionGUID: 41YYKxSOThe7D95LdRbBxg== X-CSE-MsgGUID: jw7w9mrgRrWunCF7b0XzyA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,278,1728975600"; d="scan'208";a="101379377" Received: from lkp-server01.sh.intel.com (HELO d63d4d77d921) ([10.239.97.150]) by fmviesa010.fm.intel.com with ESMTP; 30 Dec 2024 21:08:50 -0800 Received: from kbuild by d63d4d77d921 with local (Exim 4.96) (envelope-from ) id 1tSUUp-0006lV-1s; Tue, 31 Dec 2024 05:08:47 +0000 Date: Tue, 31 Dec 2024 13:07:47 +0800 From: kernel test robot To: Alexander Lobakin Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org, Przemek Kitszel , Yury Norov Subject: lib/test_bitmap.c:1278:2: error: call to '__compiletime_assert_333' declared with 'error' attribute: BUILD_BUG_ON failed: !__builtin_constant_p(~var) Message-ID: <202412311316.PpmprtIk-lkp@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Alexander, FYI, the error/warning still remains. tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: ccb98ccef0e543c2bd4ef1a72270461957f3d8d0 commit: 7adaf37f7f104a7ee5f150af491674ccbbfc4114 lib/bitmap: add compile-time test for __assign_bit() optimization date: 9 months ago config: x86_64-buildonly-randconfig-005-20241231 (https://download.01.org/0day-ci/archive/20241231/202412311316.PpmprtIk-lkp@intel.com/config) compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241231/202412311316.PpmprtIk-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202412311316.PpmprtIk-lkp@intel.com/ All errors (new ones prefixed by >>): >> lib/test_bitmap.c:1278:2: error: call to '__compiletime_assert_333' declared with 'error' attribute: BUILD_BUG_ON failed: !__builtin_constant_p(~var) 1278 | BUILD_BUG_ON(!__builtin_constant_p(~var)); | ^ include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON' 50 | BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) | ^ include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG' 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) | ^ include/linux/compiler_types.h:460:2: note: expanded from macro 'compiletime_assert' 460 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) | ^ include/linux/compiler_types.h:448:2: note: expanded from macro '_compiletime_assert' 448 | __compiletime_assert(condition, msg, prefix, suffix) | ^ include/linux/compiler_types.h:441:4: note: expanded from macro '__compiletime_assert' 441 | prefix ## suffix(); \ | ^ :163:1: note: expanded from here 163 | __compiletime_assert_333 | ^ 1 error generated. vim +1278 lib/test_bitmap.c 291f93ca339f5b Barry Song 2021-08-06 1227 2356d198d2b4dd Yury Norov 2023-07-17 1228 /* 2356d198d2b4dd Yury Norov 2023-07-17 1229 * FIXME: Clang breaks compile-time evaluations when KASAN and GCOV are enabled. 2356d198d2b4dd Yury Norov 2023-07-17 1230 * To workaround it, GCOV is force-disabled in Makefile for this configuration. 2356d198d2b4dd Yury Norov 2023-07-17 1231 */ dc34d5036692c6 Alexander Lobakin 2022-06-24 1232 static void __init test_bitmap_const_eval(void) dc34d5036692c6 Alexander Lobakin 2022-06-24 1233 { dc34d5036692c6 Alexander Lobakin 2022-06-24 1234 DECLARE_BITMAP(bitmap, BITS_PER_LONG); dc34d5036692c6 Alexander Lobakin 2022-06-24 1235 unsigned long initvar = BIT(2); dc34d5036692c6 Alexander Lobakin 2022-06-24 1236 unsigned long bitopvar = 0; dc34d5036692c6 Alexander Lobakin 2022-06-24 1237 unsigned long var = 0; dc34d5036692c6 Alexander Lobakin 2022-06-24 1238 int res; dc34d5036692c6 Alexander Lobakin 2022-06-24 1239 dc34d5036692c6 Alexander Lobakin 2022-06-24 1240 /* dc34d5036692c6 Alexander Lobakin 2022-06-24 1241 * Compilers must be able to optimize all of those to compile-time dc34d5036692c6 Alexander Lobakin 2022-06-24 1242 * constants on any supported optimization level (-O2, -Os) and any dc34d5036692c6 Alexander Lobakin 2022-06-24 1243 * architecture. Otherwise, trigger a build bug. dc34d5036692c6 Alexander Lobakin 2022-06-24 1244 * The whole function gets optimized out then, there's nothing to do dc34d5036692c6 Alexander Lobakin 2022-06-24 1245 * in runtime. dc34d5036692c6 Alexander Lobakin 2022-06-24 1246 */ dc34d5036692c6 Alexander Lobakin 2022-06-24 1247 7adaf37f7f104a Alexander Lobakin 2024-03-27 1248 /* Equals to `unsigned long bitmap[1] = { GENMASK(6, 5), }` */ dc34d5036692c6 Alexander Lobakin 2022-06-24 1249 bitmap_clear(bitmap, 0, BITS_PER_LONG); dc34d5036692c6 Alexander Lobakin 2022-06-24 1250 if (!test_bit(7, bitmap)) dc34d5036692c6 Alexander Lobakin 2022-06-24 1251 bitmap_set(bitmap, 5, 2); dc34d5036692c6 Alexander Lobakin 2022-06-24 1252 dc34d5036692c6 Alexander Lobakin 2022-06-24 1253 /* Equals to `unsigned long bitopvar = BIT(20)` */ dc34d5036692c6 Alexander Lobakin 2022-06-24 1254 __change_bit(31, &bitopvar); dc34d5036692c6 Alexander Lobakin 2022-06-24 1255 bitmap_shift_right(&bitopvar, &bitopvar, 11, BITS_PER_LONG); dc34d5036692c6 Alexander Lobakin 2022-06-24 1256 dc34d5036692c6 Alexander Lobakin 2022-06-24 1257 /* Equals to `unsigned long var = BIT(25)` */ dc34d5036692c6 Alexander Lobakin 2022-06-24 1258 var |= BIT(25); dc34d5036692c6 Alexander Lobakin 2022-06-24 1259 if (var & BIT(0)) dc34d5036692c6 Alexander Lobakin 2022-06-24 1260 var ^= GENMASK(9, 6); dc34d5036692c6 Alexander Lobakin 2022-06-24 1261 dc34d5036692c6 Alexander Lobakin 2022-06-24 1262 /* __const_hweight<32|64>(GENMASK(6, 5)) == 2 */ dc34d5036692c6 Alexander Lobakin 2022-06-24 1263 res = bitmap_weight(bitmap, 20); dc34d5036692c6 Alexander Lobakin 2022-06-24 1264 BUILD_BUG_ON(!__builtin_constant_p(res)); dc34d5036692c6 Alexander Lobakin 2022-06-24 1265 BUILD_BUG_ON(res != 2); dc34d5036692c6 Alexander Lobakin 2022-06-24 1266 dc34d5036692c6 Alexander Lobakin 2022-06-24 1267 /* !(BIT(31) & BIT(18)) == 1 */ dc34d5036692c6 Alexander Lobakin 2022-06-24 1268 res = !test_bit(18, &bitopvar); dc34d5036692c6 Alexander Lobakin 2022-06-24 1269 BUILD_BUG_ON(!__builtin_constant_p(res)); dc34d5036692c6 Alexander Lobakin 2022-06-24 1270 BUILD_BUG_ON(!res); dc34d5036692c6 Alexander Lobakin 2022-06-24 1271 dc34d5036692c6 Alexander Lobakin 2022-06-24 1272 /* BIT(2) & GENMASK(14, 8) == 0 */ dc34d5036692c6 Alexander Lobakin 2022-06-24 1273 res = initvar & GENMASK(14, 8); dc34d5036692c6 Alexander Lobakin 2022-06-24 1274 BUILD_BUG_ON(!__builtin_constant_p(res)); dc34d5036692c6 Alexander Lobakin 2022-06-24 1275 BUILD_BUG_ON(res); dc34d5036692c6 Alexander Lobakin 2022-06-24 1276 dc34d5036692c6 Alexander Lobakin 2022-06-24 1277 /* ~BIT(25) */ dc34d5036692c6 Alexander Lobakin 2022-06-24 @1278 BUILD_BUG_ON(!__builtin_constant_p(~var)); dc34d5036692c6 Alexander Lobakin 2022-06-24 1279 BUILD_BUG_ON(~var != ~BIT(25)); 7adaf37f7f104a Alexander Lobakin 2024-03-27 1280 7adaf37f7f104a Alexander Lobakin 2024-03-27 1281 /* ~BIT(25) | BIT(25) == ~0UL */ 7adaf37f7f104a Alexander Lobakin 2024-03-27 1282 bitmap_complement(&var, &var, BITS_PER_LONG); 7adaf37f7f104a Alexander Lobakin 2024-03-27 1283 __assign_bit(25, &var, true); 7adaf37f7f104a Alexander Lobakin 2024-03-27 1284 7adaf37f7f104a Alexander Lobakin 2024-03-27 1285 /* !(~(~0UL)) == 1 */ 7adaf37f7f104a Alexander Lobakin 2024-03-27 1286 res = bitmap_full(&var, BITS_PER_LONG); 7adaf37f7f104a Alexander Lobakin 2024-03-27 1287 BUILD_BUG_ON(!__builtin_constant_p(res)); 7adaf37f7f104a Alexander Lobakin 2024-03-27 1288 BUILD_BUG_ON(!res); dc34d5036692c6 Alexander Lobakin 2022-06-24 1289 } dc34d5036692c6 Alexander Lobakin 2022-06-24 1290 :::::: The code at line 1278 was first introduced by commit :::::: dc34d5036692c614eef23c1130ee42a201c316bf lib: test_bitmap: add compile-time optimization/evaluations assertions :::::: TO: Alexander Lobakin :::::: CC: Yury Norov -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki