[all-commits] [llvm/llvm-project] da2855: [SampleProfile] Potential use after move in Sample...
William Junda Huang via All-commits
all-commits at lists.llvm.org
Wed Aug 16 13:32:33 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: da2855c0bad09a53c122797ecc18bdd02505e1c0
https://github.com/llvm/llvm-project/commit/da2855c0bad09a53c122797ecc18bdd02505e1c0
Author: William Huang <williamjhuang at google.com>
Date: 2023-08-16 (Wed, 16 Aug 2023)
Changed paths:
M llvm/include/llvm/ProfileData/SampleProfReader.h
M llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h
M llvm/lib/Transforms/IPO/SampleProfile.cpp
Log Message:
-----------
[SampleProfile] Potential use after move in SampleProfileLoader::promoteMergeNotInlinedContextSamples
SampleProfileLoader::promoteMergeNotInlinedContextSample adds
certain uninlined functions to the sample profile map (unordered_map, which is
previously read from a profile file). This action may cause the map to
be rehashed, invalidating all pointers to FunctionSamples used by many
members of SampleProfileLoader, while the existing code did nothing to
guard against that. This bug is theoretical since adding a few
new functions to a large profile usually won't trigger a rehash, or even
if there's a rehash std::unordered_map tries its best to expand its
capacity in-place.
This bug will trigger if the container type of sample profile map is
changed to llvm::DenseMap or other implementation, such as in D147740,
for SampleProfReader's performance reason.
Reviewed By: wenlei
Differential Revision: https://reviews.llvm.org/D157061
More information about the All-commits
mailing list