[CSSPGO] Fix an invalid hash table reference issue in the CS preinliner.
authorHongtao Yu <hoy@fb.com>
Wed, 16 Jun 2021 18:51:39 +0000 (11:51 -0700)
committerHongtao Yu <hoy@fb.com>
Fri, 18 Jun 2021 18:54:23 +0000 (11:54 -0700)
commitc60f1d5d98ebf1cec20b80f5a94d733290dd6556
tree0a61fe0baa6b4c52fe2e5603948a56d1ea27ff84
parent14407332de6185462ceda785c620bb1206e7ca40
[CSSPGO] Fix an invalid hash table reference issue in the CS preinliner.

We were using a `StringMap` object to store all profiles to be emitted. The object is basically an unordered hash table, therefore updating it in the process of trasvering it may cause issue since the underlying bucket array could change.

I'm also moving the `csspgo-preinliner` switch around so that no context tri will be constructed (by the constructor of `CSPreInliner`) when the switch is off.

Reviewed By: wenlei

Differential Revision: https://reviews.llvm.org/D104267
llvm/lib/ProfileData/SampleProf.cpp
llvm/tools/llvm-profgen/CSPreInliner.cpp
llvm/tools/llvm-profgen/ProfileGenerator.cpp