[clang][CodeGenPGO] Don't use an invalid index when region counts disagree
authorNathan Lanza <nathanlanza@gmail.com>
Thu, 11 May 2023 02:48:43 +0000 (22:48 -0400)
committerNathan Lanza <nathanlanza@gmail.com>
Thu, 11 May 2023 02:53:53 +0000 (22:53 -0400)
commit220e77a83af19b3f6c47472596fdaaef8e305927
tree39d1ea459dcbbe91973fd59937f3a651f3ab792c
parent9a35c0cb452ae403c9a19a7e02f273c62e77304a
[clang][CodeGenPGO] Don't use an invalid index when region counts disagree

If we're using an old instrprof profile and the user passes 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. Avoid crashing in this case.

Differential Revision: https://reviews.llvm.org/D149504
clang/lib/CodeGen/CodeGenPGO.h