There are some data races when merging multiple indexed profiles with multiple threads.
(1) the static variable RecordIndex in index profile reader needs to be thread_local.
Otherwise, multiple function entries with different hashes in the profile lead to segfault.
(2) thread partition in loading the profile does not seem to be right: we are submitting a separated thread for each input and multiple threads can access the same WriteContext.
This patch fixes the above issues.
Details
Details
Diff Detail
Diff Detail
Event Timeline
lib/ProfileData/InstrProfReader.cpp | ||
---|---|---|
736 | Why isn't this just a member variable? If we used "thread_local", wouldn't there still be a bug if you instantiated and used two IndexedInstrProfReaders? | |
tools/llvm-profdata/llvm-profdata.cpp | ||
230 | I don't understand the problem here. Each time a WriterContext is accessed, the accessing thread immediately acquires a unique lock on the context. Where does the racing access occur? |
Why isn't this just a member variable?
If we used "thread_local", wouldn't there still be a bug if you instantiated and used two IndexedInstrProfReaders?