[LLVMdev] Unreachable code in Mutex.cpp

Chris Lattner clattner at apple.com
Fri Jan 13 23:58:08 PST 2012


On Jan 13, 2012, at 11:17 PM, David Blaikie wrote:

>> On some (linux?) implementations, various pthread APIs are defined as "weak extern" symbols in libc and strong definitions in libpthreads.  The idea of this check is thus to detect if pthreads is linked into the app and enable threads if so.
> 
> Sorry, right - I should've been more clear. I understand that that's
> what the declaration/boolean used to do:
> 
> 
> static const bool pthread_enabled = static_cast<bool>(pthread_mutex_init);
> 
> But that's not what the code does now - the change you made 5 years
> ago changed it to a constant:
> 
> static const bool pthread_enabled = true;
> 
> (I found this because the return outside the 'if (pthread_unabled) {
> ... return }' was marked as unreachable by -Wunreachable-code). Since
> it hasn't actually been doing anything for 5 years - should we just
> remove the variable & all the conditions (unconditionally using
> pthreads), or reinstate the smarts it used to have (testing the weak
> symbol)?

Aha, I'm completely fine with constant folding this all away.  Simple is good.

-Chris



More information about the llvm-dev mailing list