/// Returns the allocation type from an MIB metadata node.
AllocationType getMIBAllocType(const MDNode *MIB);
+/// True if the AllocTypes bitmask contains just a single type.
+bool hasSingleAllocType(uint8_t AllocTypes);
+
/// Class to build a trie of call stack contexts for a particular profiled
/// allocation call, along with their associated allocation types.
/// The allocation will be at the root of the trie, which is then used to
CI->addFnAttr(A);
}
-static bool hasSingleAllocType(uint8_t AllocTypes) {
+bool llvm::memprof::hasSingleAllocType(uint8_t AllocTypes) {
const unsigned NumAllocTypes = llvm::popcount(AllocTypes);
assert(NumAllocTypes != 0);
return NumAllocTypes == 1;
AllocationType::NotCold);
}
+// Test the hasSingleAllocType helper.
+TEST_F(MemoryProfileInfoTest, SingleAllocType) {
+ uint8_t NotCold = (uint8_t)AllocationType::NotCold;
+ uint8_t Cold = (uint8_t)AllocationType::Cold;
+ EXPECT_TRUE(hasSingleAllocType(NotCold));
+ EXPECT_TRUE(hasSingleAllocType(Cold));
+ EXPECT_FALSE(hasSingleAllocType(NotCold | Cold));
+}
+
// Test buildCallstackMetadata helper.
TEST_F(MemoryProfileInfoTest, BuildCallStackMD) {
LLVMContext C;