diff --git a/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp b/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp --- a/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp +++ b/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp @@ -34,12 +34,7 @@ } template -bool isTaggedAllocation(AllocatorT *Allocator, scudo::uptr Size, - scudo::uptr Alignment) { - if (!Allocator->useMemoryTagging() || - !scudo::systemDetectsMemoryTagFaultsTestOnly()) - return false; - +bool isPrimaryAllocation(scudo::uptr Size, scudo::uptr Alignment) { const scudo::uptr MinAlignment = 1UL << SCUDO_MIN_ALIGNMENT_LOG; if (Alignment < MinAlignment) Alignment = MinAlignment; @@ -49,6 +44,14 @@ return AllocatorT::PrimaryT::canAllocate(NeededSize); } +template +bool isTaggedAllocation(AllocatorT *Allocator, scudo::uptr Size, + scudo::uptr Alignment) { + return Allocator->useMemoryTagging() && + scudo::systemDetectsMemoryTagFaultsTestOnly() && + isPrimaryAllocation(Size, Alignment); +} + template void checkMemoryTaggingMaybe(AllocatorT *Allocator, void *P, scudo::uptr Size, scudo::uptr Alignment) { @@ -158,7 +161,7 @@ EXPECT_NE(P, nullptr); for (scudo::uptr I = 0; I < Size; I++) { unsigned char V = (reinterpret_cast(P))[I]; - if (AllocatorT::PrimaryT::canAllocate(Size)) + if (isPrimaryAllocation(Size, 1U << MinAlignLog)) ASSERT_EQ(V, scudo::PatternFillByte); else ASSERT_TRUE(V == scudo::PatternFillByte || V == 0);