[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
Wed May 10 20:00:43 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG220e77a83af1: [clang][CodeGenPGO] Don't use an invalid index when region counts disagree (authored by lanza).
Changed prior to commit:
https://reviews.llvm.org/D149504?vs=518108&id=521200#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149504/new/
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,12 @@
return 0;
if (!haveRegionCounts())
return 0;
- return RegionCounts[(*RegionCounterMap)[S]];
+ // With profiles from a differing version of clang we can have mismatched
+ // decl counts. Don't crash in such a case.
+ auto Index = (*RegionCounterMap)[S];
+ if (Index >= RegionCounts.size())
+ return 0;
+ return RegionCounts[Index];
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149504.521200.patch
Type: text/x-patch
Size: 581 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230511/b3104c35/attachment.bin>
More information about the cfe-commits
mailing list