[llvm-profgen] CSProfileGenerator::generateLineNumBasedProfile - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The pointer is always dereferenced immediately below, so assert the cast is correct instead of returning nullptr
This commit is contained in:
Simon Pilgrim 2022-01-14 14:10:07 +00:00
parent 0af1808f9b
commit 86bbf01d89

View File

@ -614,8 +614,8 @@ void CSProfileGenerator::computeSizeForProfiledFunctions() {
void CSProfileGenerator::generateLineNumBasedProfile() {
for (const auto &CI : SampleCounters) {
const StringBasedCtxKey *CtxKey =
dyn_cast<StringBasedCtxKey>(CI.first.getPtr());
const auto *CtxKey = cast<StringBasedCtxKey>(CI.first.getPtr());
// Get or create function profile for the range
FunctionSamples &FunctionProfile =
getFunctionProfileForContext(CtxKey->Context, CtxKey->WasLeafInlined);