[PATCH] D149504: [clang][CodeGenPGO] Don't use an invalid index when region counts disagree
Nathan Lanza via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 28 18:11:14 PDT 2023
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];
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149504.518108.patch
Type: text/x-patch
Size: 453 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230429/e1170aa3/attachment.bin>
More information about the cfe-commits
mailing list