Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

This patch tightens the static_assert. FirstBit and LastBit are
0-based bit indices of a bitfield, so they must be strictly less than
StorageBits.

This patch tightens the static_assert.  FirstBit and LastBit are
0-based bit indices of a bitfield, so they must be strictly less than
StorageBits.
@llvmbot
Copy link
Member

llvmbot commented Oct 25, 2025

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

Changes

This patch tightens the static_assert. FirstBit and LastBit are
0-based bit indices of a bitfield, so they must be strictly less than
StorageBits.


Full diff: https://github.com/llvm/llvm-project/pull/165099.diff

1 Files Affected:

  • (modified) llvm/include/llvm/ADT/Bitfields.h (+2-2)
diff --git a/llvm/include/llvm/ADT/Bitfields.h b/llvm/include/llvm/ADT/Bitfields.h
index 1fbc41c472581..be9546e9cc4cb 100644
--- a/llvm/include/llvm/ADT/Bitfields.h
+++ b/llvm/include/llvm/ADT/Bitfields.h
@@ -100,8 +100,8 @@ template <typename Bitfield, typename StorageType> struct Impl {
   using IntegerType = typename Bitfield::IntegerType;
 
   static constexpr size_t StorageBits = sizeof(StorageType) * CHAR_BIT;
-  static_assert(Bitfield::FirstBit <= StorageBits, "Data must fit in mask");
-  static_assert(Bitfield::LastBit <= StorageBits, "Data must fit in mask");
+  static_assert(Bitfield::FirstBit < StorageBits, "Data must fit in mask");
+  static_assert(Bitfield::LastBit < StorageBits, "Data must fit in mask");
   static constexpr StorageType LowMask =
       maskTrailingOnes<StorageType>(Bitfield::Bits);
   static constexpr StorageType Mask = LowMask << Bitfield::Shift;

@kazutakahirata kazutakahirata merged commit 7b9cf0f into llvm:main Oct 25, 2025
12 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20251025_ADT_Bitfields_tighter branch October 25, 2025 17:06
@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 25, 2025

LLVM Buildbot has detected a new failure on builder ppc64le-mlir-rhel-clang running on ppc64le-mlir-rhel-test while building llvm at step 3 "clean-build-dir".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/129/builds/32187

Here is the relevant piece of the build log for the reference
Step 3 (clean-build-dir) failure: Delete failed. (failure) (timed out)
Step 6 (test-build-check-mlir-build-only-check-mlir) failure: 1200 seconds without output running [b'ninja', b'check-mlir'], attempting to kill
...
PASS: MLIR-Unit :: IR/./MLIRIRTests/101/130 (3598 of 3609)
PASS: MLIR :: Pass/pipeline-parsing.mlir (3599 of 3609)
PASS: MLIR-Unit :: IR/./MLIRIRTests/100/130 (3600 of 3609)
PASS: MLIR-Unit :: IR/./MLIRIRTests/38/130 (3601 of 3609)
PASS: MLIR-Unit :: IR/./MLIRIRTests/39/130 (3602 of 3609)
PASS: MLIR-Unit :: Interfaces/./MLIRInterfacesTests/11/22 (3603 of 3609)
PASS: MLIR-Unit :: Interfaces/./MLIRInterfacesTests/12/22 (3604 of 3609)
PASS: MLIR-Unit :: Interfaces/./MLIRInterfacesTests/13/22 (3605 of 3609)
PASS: MLIR-Unit :: IR/./MLIRIRTests/0/130 (3606 of 3609)
PASS: MLIR :: mlir-reduce/dce-test.mlir (3607 of 3609)
command timed out: 1200 seconds without output running [b'ninja', b'check-mlir'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=2195.575427

dvbuka pushed a commit to dvbuka/llvm-project that referenced this pull request Oct 27, 2025
This patch tightens the static_assert.  FirstBit and LastBit are
0-based bit indices of a bitfield, so they must be strictly less than
StorageBits.
@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 28, 2025

LLVM Buildbot has detected a new failure on builder ppc64le-flang-rhel-clang running on ppc64le-flang-rhel-test while building llvm at step 6 "test-build-unified-tree-check-flang".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/157/builds/41902

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-flang) failure: 1200 seconds without output running [b'ninja', b'check-flang'], attempting to kill
...
PASS: Flang :: Driver/linker-flags.f90 (3944 of 3954)
PASS: Flang :: Transforms/debug-line-table.fir (3945 of 3954)
PASS: Flang :: Lower/OpenMP/rtl-flags.f90 (3946 of 3954)
PASS: Flang :: Driver/use-module-error.f90 (3947 of 3954)
PASS: Flang :: Transforms/tbaa3.fir (3948 of 3954)
PASS: Flang :: Transforms/debug-dwarf-version.fir (3949 of 3954)
PASS: Flang :: Transforms/tbaa-local-alloc-threshold.fir (3950 of 3954)
PASS: Flang :: Driver/fopenmp.f90 (3951 of 3954)
PASS: Flang :: Driver/omp-driver-offload.f90 (3952 of 3954)
PASS: Flang :: Intrinsics/math-codegen.fir (3953 of 3954)
command timed out: 1200 seconds without output running [b'ninja', b'check-flang'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=3502.037892

Lukacma pushed a commit to Lukacma/llvm-project that referenced this pull request Oct 29, 2025
This patch tightens the static_assert.  FirstBit and LastBit are
0-based bit indices of a bitfield, so they must be strictly less than
StorageBits.
aokblast pushed a commit to aokblast/llvm-project that referenced this pull request Oct 30, 2025
This patch tightens the static_assert.  FirstBit and LastBit are
0-based bit indices of a bitfield, so they must be strictly less than
StorageBits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants