[llvm-commits] [llvm] r123533 - in /llvm/trunk: include/llvm/IntrinsicInst.h lib/Analysis/LazyValueInfo.cpp

Nick Lewycky nicholas at mxc.ca
Sun Jan 16 13:02:50 PST 2011


Chris Lattner wrote:
>
> On Jan 15, 2011, at 1:16 AM, Nick Lewycky wrote:
>
>> Author: nicholas
>> Date: Sat Jan 15 03:16:12 2011
>> New Revision: 123533
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=123533&view=rev
>> Log:
>> Teach LazyValueInfo that allocas aren't NULL. Over all of llvm-test, this saves
>> half a million non-local queries, each of which would otherwise have triggered a
>> linear scan over a basic block.
>>
>> Also fix a fixme for memory intrinsics which dereference pointers. With this,
>> we prove that a pointer is non-null because it was dereferenced by an intrinsic
>> 112 times in llvm-test.
>
> Cool.  Please add a testcase for this, one other thing:

Will do.

>> +    if (MI->getRawDest() == Ptr || MI->getDest() == Ptr)
>> +      return true;
>> +    if (MemTransferInst *MTI = dyn_cast<MemTransferInst>(MI))
>> +      return MTI->getRawSource() == Ptr || MTI->getSource() == Ptr;
>
> Would it be better to do something like:
>
> Ptr = Ptr->stripPointerCasts();
>
> and then use MI->getDest()?

I'm not sure. The calling code is doing a linear walk through a basic 
block. I'm worried that stripPointerCasts will cause another linear walk 
through the basic block walking through bitcast/gep instructions, as we 
do a linear walk through the BB. That's an ugly O(n^2). That said, I'm 
not entirely satisfied that this is the best code either, I intend to 
mull it over some more.

Nick



More information about the llvm-commits mailing list