//===- MemoryProfileInfoTest.cpp - Memory Profile Info Unit Tests-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "llvm/Analysis/MemoryProfileInfo.h" #include "llvm/AsmParser/Parser.h" #include "llvm/IR/Constants.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/IR/ModuleSummaryIndex.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/SourceMgr.h" #include "gtest/gtest.h" #include <cstring> #include <sys/types.h> usingnamespacellvm; usingnamespacellvm::memprof; extern cl::opt<float> MemProfLifetimeAccessDensityColdThreshold; extern cl::opt<unsigned> MemProfAveLifetimeColdThreshold; extern cl::opt<unsigned> MemProfMinAveLifetimeAccessDensityHotThreshold; namespace { class MemoryProfileInfoTest : public testing::Test { … }; // Test getAllocType helper. // Basic checks on the allocation type for values just above and below // the thresholds. TEST_F(MemoryProfileInfoTest, GetAllocType) { … } // Test the hasSingleAllocType helper. TEST_F(MemoryProfileInfoTest, SingleAllocType) { … } // Test buildCallstackMetadata helper. TEST_F(MemoryProfileInfoTest, BuildCallStackMD) { … } // Test CallStackTrie::addCallStack interface taking allocation type and list of // call stack ids. // Check that allocations with a single allocation type along all call stacks // get an attribute instead of memprof metadata. TEST_F(MemoryProfileInfoTest, Attribute) { … } // Test CallStackTrie::addCallStack interface taking allocation type and list of // call stack ids. // Test that an allocation call reached by both cold and non cold call stacks // gets memprof metadata representing the different allocation type contexts. TEST_F(MemoryProfileInfoTest, ColdAndNotColdMIB) { … } // Test CallStackTrie::addCallStack interface taking allocation type and list of // call stack ids. // Test that an allocation call reached by both cold and hot call stacks // gets memprof metadata representing the different allocation type contexts. TEST_F(MemoryProfileInfoTest, ColdAndHotMIB) { … } // Test CallStackTrie::addCallStack interface taking allocation type and list of // call stack ids. // Test that an allocation call reached by both non cold and hot call stacks // gets memprof metadata representing the different allocation type contexts. TEST_F(MemoryProfileInfoTest, NotColdAndHotMIB) { … } // Test CallStackTrie::addCallStack interface taking allocation type and list of // call stack ids. // Test that an allocation call reached by both cold, non cold and hot call // stacks gets memprof metadata representing the different allocation type // contexts. TEST_F(MemoryProfileInfoTest, ColdAndNotColdAndHotMIB) { … } // Test CallStackTrie::addCallStack interface taking allocation type and list of // call stack ids. // Test that an allocation call reached by multiple call stacks has memprof // metadata with the contexts trimmed to the minimum context required to // identify the allocation type. TEST_F(MemoryProfileInfoTest, TrimmedMIBContext) { … } // Test CallStackTrie::addCallStack interface taking memprof MIB metadata. // Check that allocations annotated with memprof metadata with a single // allocation type get simplified to an attribute. TEST_F(MemoryProfileInfoTest, SimplifyMIBToAttribute) { … } // Test CallStackTrie::addCallStack interface taking memprof MIB metadata. // Test that allocations annotated with memprof metadata with multiple call // stacks gets new memprof metadata with the contexts trimmed to the minimum // context required to identify the allocation type. TEST_F(MemoryProfileInfoTest, ReTrimMIBContext) { … } TEST_F(MemoryProfileInfoTest, CallStackTestIR) { … } TEST_F(MemoryProfileInfoTest, CallStackTestSummary) { … } } // end anonymous namespace