diff --git a/llvm/include/llvm/ProfileData/SampleProf.h b/llvm/include/llvm/ProfileData/SampleProf.h --- a/llvm/include/llvm/ProfileData/SampleProf.h +++ b/llvm/include/llvm/ProfileData/SampleProf.h @@ -473,9 +473,10 @@ static SampleProfileFormat Format; /// GUIDToFuncNameMap saves the mapping from GUID to the symbol name, for - /// all the function symbols defined or declared in CurrentModule. - static DenseMap GUIDToFuncNameMap; - static Module *CurrentModule; + /// all the function symbols defined or declared in CurrentModule. These + /// need to be thread_local because we can have parallel ThinLTO backends. + thread_local static DenseMap GUIDToFuncNameMap; + thread_local static Module *CurrentModule; class GUIDToFuncNameMapper { public: diff --git a/llvm/lib/ProfileData/SampleProf.cpp b/llvm/lib/ProfileData/SampleProf.cpp --- a/llvm/lib/ProfileData/SampleProf.cpp +++ b/llvm/lib/ProfileData/SampleProf.cpp @@ -28,8 +28,8 @@ namespace llvm { namespace sampleprof { SampleProfileFormat FunctionSamples::Format; -DenseMap FunctionSamples::GUIDToFuncNameMap; -Module *FunctionSamples::CurrentModule; +thread_local DenseMap FunctionSamples::GUIDToFuncNameMap; +thread_local Module *FunctionSamples::CurrentModule; } // namespace sampleprof } // namespace llvm