[PATCH] Add a lock() function in PassRegistry to speed up multi-thread synchronization.
Erik Eckstein
eeckstein at apple.com
Wed Mar 4 11:03:12 PST 2015
Committed in r231276.
Thanks all for reviewing!
================
Comment at: lib/IR/PassRegistry.cpp:46
@@ +45,3 @@
+ Optional<sys::SmartScopedReader<true>> Guard;
+ if (!locked)
+ Guard.emplace(Lock);
----------------
joker.eph wrote:
> "Pedantic" comment: since your motivation is purely performance here, you may want to replace all uses of ```locked``` with ```locked.load(memory_order_consume)```. Maybe in a separate private method like that:
> ```
> bool isLocked() { return locked.load(memory_order_consume); }
> ```
> Especially since I don't think there is a guarantee that atomic<bool> is lock_free.
Thanks for this suggestion. But I'm not sure if memory_order_consume is OK here. I think it must be memory_order_acquire.
I prefer to be conservative in this case and let it as it is now.
http://reviews.llvm.org/D7787
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list