[compiler-rt] [scudo] Relax MemtagTag.SelectRandomTag. (PR #68048)
Christopher Ferris via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 9 15:18:38 PDT 2023
================
@@ -120,7 +120,15 @@ TEST_F(MemtagTest, SelectRandomTag) {
uptr Tags = 0;
for (uptr I = 0; I < 100000; ++I)
Tags = Tags | (1u << extractTag(selectRandomTag(Ptr, 0)));
- EXPECT_EQ(0xfffeull, Tags);
+ // std::popcnt is C++20
+ int PopCnt = 0;
+ while (Tags) {
+ PopCnt += Tags & 1;
+ Tags >>= 1;
+ }
+ // Random tags are not always very random, and this test is not about PRNG
+ // quality. Anything above half would be satisfactory.
+ EXPECT_GE(PopCnt, 8);
----------------
cferris1000 wrote:
Do you expect that this code will be compiled by something other than clang or gcc?
I don't feel very strongly about this, so leaving it like this is fine with me.
https://github.com/llvm/llvm-project/pull/68048
More information about the llvm-commits
mailing list