]> granicus.if.org Git - llvm/commit
[ThinLTO][AutoFDO] Fix memory corruption due to race condition from thin backends
authorWenlei He <aktoon@gmail.com>
Mon, 12 Aug 2019 17:45:14 +0000 (17:45 +0000)
committerWenlei He <aktoon@gmail.com>
Mon, 12 Aug 2019 17:45:14 +0000 (17:45 +0000)
commit7f61636e257bf19a34b9b435e18100726a7acaf3
tree6f9121530d8a1e2fcf5811c892597705127d5cd7
parenteb1f253790ff3fb4f36f2730da44a784a452cbe3
[ThinLTO][AutoFDO] Fix memory corruption due to race condition from thin backends

Summary:
This commit fixed a race condition from multi-threaded thinLTO backends that causes non-deterministic memory corruption for a data structure used only by AutoFDO with compact binary profile.
GUIDToFuncNameMap, a static data member of type DenseMap in FunctionSamples is used as a per-module mapping from function name MD5 to name string when input AutoFDO profile is in compact binary format. However with ThinLTO, we can have parallel backends modifying and accessing the class static map concurrently. The fix is to make GUIDToFuncNameMap a member of SampleProfileLoader instead of a file static data.

Reviewers: wmi, davidxl, danielcdh

Subscribers: mehdi_amini, inglorion, hiraditya, dexonsmith, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D65848

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368596 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/ProfileData/SampleProf.h
lib/ProfileData/SampleProf.cpp
lib/Transforms/IPO/SampleProfile.cpp