[LLVMdev] Small problem in BitVector.h

Chris Lattner clattner at apple.com
Fri Jan 23 08:17:45 PST 2009


On Jan 23, 2009, at 6:43 AM, heisenbug wrote:

> On Jan 23, 1:51 pm, Roman Levenstein <romix.l... at googlemail.com>
> wrote:
>> Hi,
>>
>> Doing some profiling of llc, I noticed that some bitvector operations
>> took longer than usual. Then I noticed that too many copies of
>> BitVector obejcts are created, even when such operations like &=, ^=,
>> |= are performed on those bit vectors.
>>
>> I looked at the BitVector ADT implementation in BitVector.h and
>> figured out that all assignment operations (except the usual
>> assignment operator) return a copy of the bit vector, instead of a
>> reference!
>> I guess it was just overlooked.
>>
>> Below is the patch to fix it. Is it OK to commit?
>
> Yes. Please note in the commit message that the old
> semantics probably did not meet the expectations.
> With your patch, chained assignments happen to the right
> object.

Yes, please apply!

> A very good catch, and a nice demonstration of how
> C++'s performance characteristics can be spoiled
> by small bugs like these.

Too much subtlety :(

-Chris



More information about the llvm-dev mailing list