lanza created this revision.
lanza added a reviewer: bruno.
Herald added subscribers: wlei, wenlei, arphaman.
Herald added a project: All.
lanza requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If we're using an old instrprof profile and the user passes
`-Wno-profile-instr-out-of-date` then we can get Decls with children
decl counts not matching the what the profile was written against. In
a particular case I was debugging we have 24 decls in the AST and 22
decls in the profile.

There probably isn't a "right" thing to do other than override the users
wish to force using the profiles, but that't the point of that flag in
the first place.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149504

Files:
  clang/lib/CodeGen/CodeGenPGO.h


Index: clang/lib/CodeGen/CodeGenPGO.h
===================================================================
--- clang/lib/CodeGen/CodeGenPGO.h
+++ clang/lib/CodeGen/CodeGenPGO.h
@@ -114,7 +114,10 @@
       return 0;
     if (!haveRegionCounts())
       return 0;
-    return RegionCounts[(*RegionCounterMap)[S]];
+    auto Index = (*RegionCounterMap)[S];
+    if (Index >= RegionCounts.size())
+      return 0;
+    return RegionCounts[Index];
   }
 };
 


Index: clang/lib/CodeGen/CodeGenPGO.h
===================================================================
--- clang/lib/CodeGen/CodeGenPGO.h
+++ clang/lib/CodeGen/CodeGenPGO.h
@@ -114,7 +114,10 @@
       return 0;
     if (!haveRegionCounts())
       return 0;
-    return RegionCounts[(*RegionCounterMap)[S]];
+    auto Index = (*RegionCounterMap)[S];
+    if (Index >= RegionCounts.size())
+      return 0;
+    return RegionCounts[Index];
   }
 };
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to