[llvm-commits] [llvm] r73620 - /llvm/trunk/lib/VMCore/Value.cpp

Owen Anderson resistor at mac.com
Wed Jun 17 13:01:48 PDT 2009


On Jun 17, 2009, at 11:49 AM, Chris Lattner wrote:

>
> On Jun 17, 2009, at 10:37 AM, Owen Anderson wrote:
>
>> Author: resistor
>> Date: Wed Jun 17 12:36:57 2009
>> New Revision: 73620
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=73620&view=rev
>> Log:
>> Protect the ValueHandle table.
>
> Owen, can you please add an RAII object to handle the locking and
> unlocking?
>
> Instead of:
>
>>
>>  // Get the linked list base, which is guaranteed to exist since the
>>  // HasValueHandle flag is set.
>> +  if (llvm_is_multithreaded()) ValueHandlesLock->reader_acquire();
>>  ValueHandleBase *Entry = (*ValueHandles)[V];
>> +  if (llvm_is_multithreaded()) ValueHandlesLock->reader_release();
>>  assert(Entry && "Value bit set but no entries exist");
>
>
> it would be very nice to have:
>
>   {
>     RWReaderLocker X(*ValueHandlesLock);
>     Entry = (*ValueHandles)[V];
>   }
> ...

Most of these examples are going away in the near future (by pushing  
the locking into the ValueMap from the callers), but I can certainly  
add it for the remaining cases.

--Owen



More information about the llvm-commits mailing list