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

Chris Lattner clattner at apple.com
Mon May 17 12:52:15 PDT 2010


On May 17, 2010, at 12:01 PM, Jakob Stoklund Olesen wrote:

> 
> 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.

I think this is a good idea, please do (with a comment).  Please also add a comment to your regalloc saying why iterating in densemap order really is deterministic :)

-Chris



More information about the llvm-commits mailing list