<p dir="ltr">On 10 Jul 2014 14:24, "Aaron Ballman" <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>> wrote:<br>
><br>
> On Thu, Jul 10, 2014 at 5:15 PM, <a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a> <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>> wrote:<br>
> > Updated for changes in the LLVM patch (in response to Nick's review).<br>
> ><br>
> > There also need to be a lot of regression-test updates (not yet included here).<br>
> ><br>
> > <a href="http://reviews.llvm.org/D4450">http://reviews.llvm.org/D4450</a><br>
> ><br>
> > Files:<br>
> >   lib/CodeGen/CGCall.cpp<br>
> ><br>
> > Index: lib/CodeGen/CGCall.cpp<br>
> > ===================================================================<br>
> > --- lib/CodeGen/CGCall.cpp<br>
> > +++ lib/CodeGen/CGCall.cpp<br>
> > @@ -1200,8 +1200,16 @@<br>
> >      llvm_unreachable("Invalid ABI kind for return argument");<br>
> >    }<br>
> ><br>
> > -  if (RetTy->isReferenceType())<br>
> > +  if (RetTy->isReferenceType()) {<br>
> > +    QualType PTy = RetTy->getAs<ReferenceType>()->getPointeeType();<br>
> > +    if (PTy->isConstantSizeType()) {<br>
> > +      unsigned Bytes =<br>
> > +        std::min(4095u, (unsigned) getContext().getTypeSize(PTy)/8);<br>
><br>
> What about getTypeSizeInChars instead of getTypeSize / 8?<br>
><br>
> Where does the 4095 constant come from? Since it's used in two places,<br>
> I would feel slightly more comfortable if it was named (or at least<br>
> commented).</p>
<p dir="ltr">I believe this is the maximum value the attribute happens to support. Please provide this as a constant in an LLVM header rather than hardcoding it here.</p>
<p dir="ltr">> > +      RetAttrs.addDereferencableAttr(Bytes);<br>
> > +    }<br>
> > +<br>
> >      RetAttrs.addAttribute(llvm::Attribute::NonNull);<br>
> > +  }<br>
> ><br>
> >    if (RetAttrs.hasAttributes())<br>
> >      PAL.push_back(llvm::<br>
> > @@ -1291,8 +1299,16 @@<br>
> >      }<br>
> >      }<br>
> ><br>
> > -    if (ParamType->isReferenceType())<br>
> > +    if (ParamType->isReferenceType()) {<br>
> > +      QualType PTy = ParamType->getAs<ReferenceType>()->getPointeeType();<br>
> > +      if (PTy->isConstantSizeType()) {<br>
> > +        unsigned Bytes =<br>
> > +          std::min(4095u, (unsigned) getContext().getTypeSize(PTy)/8);<br>
> > +        Attrs.addDereferencableAttr(Bytes);<br>
> > +      }<br>
> > +<br>
> >        Attrs.addAttribute(llvm::Attribute::NonNull);<br>
> > +    }<br>
> ><br>
> >      if (Attrs.hasAttributes())<br>
> >        PAL.push_back(llvm::AttributeSet::get(getLLVMContext(), Index, Attrs));<br>
> ><br>
> > _______________________________________________<br>
> > cfe-commits mailing list<br>
> > <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> > <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
> ><br>
><br>
> ~Aaron<br>
</p>