From: Simon Pilgrim Date: Fri, 14 Jan 2022 14:10:07 +0000 (+0000) Subject: [llvm-profgen] CSProfileGenerator::generateLineNumBasedProfile - use cast<> instead... X-Git-Tag: upstream/15.0.7~20460 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=86bbf01d896cfe82acd4379be436a0417976000b;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/llvm/tools/llvm-profgen/ProfileGenerator.cpp b/llvm/tools/llvm-profgen/ProfileGenerator.cpp index 7155ec4..4fd649d 100644 --- a/llvm/tools/llvm-profgen/ProfileGenerator.cpp +++ b/llvm/tools/llvm-profgen/ProfileGenerator.cpp @@ -614,8 +614,8 @@ void CSProfileGenerator::computeSizeForProfiledFunctions() { void CSProfileGenerator::generateLineNumBasedProfile() { for (const auto &CI : SampleCounters) { - const StringBasedCtxKey *CtxKey = - dyn_cast(CI.first.getPtr()); + const auto *CtxKey = cast(CI.first.getPtr()); + // Get or create function profile for the range FunctionSamples &FunctionProfile = getFunctionProfileForContext(CtxKey->Context, CtxKey->WasLeafInlined);