[PATCH] Add a lock() function in PassRegistry to speed up multi-thread synchronization.

Mehdi AMINI mehdi.amini at apple.com
Fri Feb 27 10:14:01 PST 2015


The patch LGTM.
However Chandler was not convinced in the first place, and asked "Do you have a test case that shows a severe problem without asserts?". 
You are mentioning 5% perf improvement in single-threaded release build, can you tell how to reproduce?


================
Comment at: lib/IR/PassRegistry.cpp:46
@@ +45,3 @@
+  Optional<sys::SmartScopedReader<true>> Guard;
+  if (!locked)
+    Guard.emplace(Lock);
----------------
"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.

http://reviews.llvm.org/D7787

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list