[llvm-commits] [llvm] r116489 - /llvm/trunk/include/llvm/PassSupport.h
Jakob Stoklund Olesen
stoklund at 2pi.dk
Thu Oct 14 10:44:06 PDT 2010
On Oct 14, 2010, at 10:26 AM, Owen Anderson wrote:
> Author: resistor
> Date: Thu Oct 14 12:26:06 2010
> New Revision: 116489
>
> URL: http://llvm.org/viewvc/llvm-project?rev=116489&view=rev
> Log:
> Apparently MSVC doesn't support thread-safe static local initialization. Roll our own solution instead.
> void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
> + static sys::cas_flag initialized = 0; \
> + sys::cas_flag old_val = sys::CompareAndSwap(&initialized, 1, 0); \
> + if (old_val == 0) initialize##passName##PassOnce(Registry); \
> + }
Hi Owen,
AFAICT, this guarantees that initialize*PassOnce is called only once, but it doesn't guarantee that initialize*PassOnce has completed when initialize*Pass returns.
Wouldn't threads expect initialization to be complete after initialize*Pass returns?
/jakob
More information about the llvm-commits
mailing list