[llvm] [OpenMP] Implement EnumSet container (PR #211323)
Tom Eccles via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 23 07:50:09 PDT 2026
================
@@ -17,11 +17,118 @@
#include "llvm/Support/Compiler.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Bitset.h"
#include "llvm/ADT/Sequence.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
namespace llvm::omp {
+template <typename Enum, size_t Size> struct EnumSet;
+
+namespace detail {
+template <size_t Size>
+static constexpr inline size_t findFirstSet(size_t Begin, size_t End,
+ const llvm::Bitset<Size> &Set) {
+ unsigned FirstWord = Begin / 64;
+ unsigned LastWord = End / 64;
+
+ for (unsigned I = FirstWord; I <= LastWord; ++I) {
+ uint64_t Word = Set.getWord64(I);
----------------
tblah wrote:
For EnumSet<E, 64>, findFirstSet will be called with End == 64 and so LastWord == 1 and it will fetch Set.getWord64(1). But `llvm::Bitset<64>` only has word 0.
I think either LastWord should be (end - 1)/64, or this should only iterate to `I < LastWord`.
https://github.com/llvm/llvm-project/pull/211323
More information about the llvm-commits
mailing list