[llvm-commits] [llvm] r148941 - in /llvm/trunk: lib/Analysis/InlineCost.cpp test/Transforms/Inline/alloca-bonus.ll

Nick Lewycky nicholas at mxc.ca
Thu Jan 26 01:27:07 PST 2012


Eli Friedman wrote:
> On Wed, Jan 25, 2012 at 10:58 AM, Nick Lewycky<nicholas at mxc.ca>  wrote:
>> Eli Friedman wrote:
>>>
>>> On Wed, Jan 25, 2012 at 12:27 AM, Nick Lewycky<nicholas at mxc.ca>    wrote:
>>>>
>>>> Author: nicholas
>>>> Date: Wed Jan 25 02:27:40 2012
>>>> New Revision: 148941
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=148941&view=rev
>>>> Log:
>>>> Support pointer comparisons against constants, when looking at the
>>>> inline-cost
>>>> savings from a pointer argument becoming an alloca. Sometimes callees
>>>> will even
>>>> compare a pointer to null and then branch to an otherwise unreachable
>>>> block!
>>>> Detect these cases and compute the number of saved instructions, instead
>>>> of
>>>> bailing out and reporting no savings.
>>>
>>>
>>> [Comments inlined.]
>>>
>>>> +      } else if (ICmpInst *ICI = dyn_cast<ICmpInst>(I)) {
>>>> +        if (!isa<Constant>(ICI->getOperand(1)))
>>>> +          return 0;
>>>> +        ICmpInsts.push_back(ICI);
>>>
>>>
>>> You probably want to restrict this to equality comparisons; I don't
>>> think we fold relational comparisons between an alloca and a constant
>>> in general.
>>
>>
>> We do. This fits in with the rule that you aren't allowed to guess an
>> alloca.
>
> Is that rule documented somewhere?

Nope. More generally, while we document the semantics of the 'alloca' 
instruction and the 'icmp' instruction, we don't document secondary 
rules like this which fall out of our as-if interpretation of those 
semantics.

Cue Dan Gohman. ;)

Nick



More information about the llvm-commits mailing list