Statistic and ManagedStatic both use mutexes. There was a lock order
inversion where, during initialization, Statistic's mutex would be
held while taking ManagedStatic's, and in llvm_shutdown,
ManagedStatic's mutex would be held while taking Statistic's
mutex. This change causes Statistic's initialization code to avoid
holding its mutex while calling ManagedStatic's methods, avoiding the
inversion.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
llvm/lib/Support/Statistic.cpp | ||
---|---|---|
97 ↗ | (On Diff #141465) | Are you sure llvm_shutdown() calls Statistic::RegisterStatistic()? It's surprising that it would be constructing and registering new Statistic objects in a function that's intended to destroy them. |
llvm/lib/Support/Statistic.cpp | ||
---|---|---|
97 ↗ | (On Diff #141465) | Ah, not RegisterStatic, but PrintStatistics. I had intended "us" to mean "functions in this part of the code", but seeing that that wasn't clear, I've changed the comment. |
Comment Actions
Sorry for the delay, I was out of the office for a few days.
I see how the inversion comes about now and this makes sense to me. LGTM.
Thanks