[llvm-profgen] CSProfileGenerator::generateLineNumBasedProfile - use cast<> instead...
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 14 Jan 2022 14:10:07 +0000 (14:10 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 14 Jan 2022 14:49:57 +0000 (14:49 +0000)
The pointer is always dereferenced immediately below, so assert the cast is correct instead of returning nullptr

llvm/tools/llvm-profgen/ProfileGenerator.cpp

index 7155ec4..4fd649d 100644 (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);