[llvm-commits] [llvm] r61552 - in /llvm/trunk: lib/Transforms/IPO/FunctionAttrs.cpp test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll
Nick Lewycky
nicholas at mxc.ca
Sat Jan 3 08:58:34 PST 2009
Duncan Sands wrote:
> Hi Nick,
>
>
>> + // Does not escape if the callee is readonly and doesn't return a
>> + // copy through its own return value.
>> + if (CS.onlyReadsMemory() && I->getType() == Type::VoidTy)
>> + continue;
>>
>
> such function calls are trivially dead, so shouldn't occur. Does this turn
> up in practice?
>
FunctionAttrs just went through and added the readnone/readonly
attributes. Nobody's had the chance to eliminate dead calls yet.
I had started with a patch that did "CS.onlyReadsMemory() &&
!isa<PointerType>(I->getType())" which doubled the number of nocaptures,
but before committing, your testcase showed an example of leaking a bit
of pointer out a non-pointer return type.
I haven't redone the metrics with the new change. The answer is
"probably not much" but I don't think it hurts to leave it in.
>> + // If the function is readonly and doesn't return any value, we
>> + // know that the pointer value can't escape. Mark all of its pointer
>> + // arguments nocapture.
>>
>
> Because of this, the above nocapture logic enhancement shouldn't be needed.
>
Yep, we can remove this one. Those functions will just be eliminated anyway.
>
>> - NumNoCapture++;
>> + ++NumNoCapture;
>>
>
> If this is an improvement, please change NumReadOnly++ etc.
>
Ok!
Nick
More information about the llvm-commits
mailing list