[llvm-commits] [llvm] r103940 - /llvm/trunk/lib/CodeGen/RegAllocFast.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Mon May 17 12:01:58 PDT 2010


On May 17, 2010, at 11:53 AM, Bill Wendling wrote:

> On May 17, 2010, at 8:30 AM, Jakob Stoklund Olesen wrote:
> 
>> Author: stoklund
>> Date: Mon May 17 10:30:37 2010
>> New Revision: 103940
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=103940&view=rev
>> Log:
>> Minor optimizations. DenseMap::begin() is surprisingly slow on an empty map.
>> 
> Really?! Is there a good reason, or should that be fixed?

The DenseMap typically holds 64 or more buckets. The iterator constructor skips the empty buckets which is all of them when the map is empty. The scan is really necessary when the map is not empty.

Changing begin() to return end() when empty() would avoid this issue:

  inline iterator begin() {
     return empty() ? end() : iterator(Buckets, Buckets+NumBuckets);
  }

The fast allocator happens to be iterating over empty maps a lot, but it might be worth fixing in the general case too.





More information about the llvm-commits mailing list