[llvm-commits] CVS: llvm/lib/VMCore/Type.cpp

Reid Spencer reid at x10sys.com
Thu Jan 4 11:02:33 PST 2007


On Thu, 2007-01-04 at 10:58 -0800, Chris Lattner wrote:
> There is a typo in the function header (lossleslly) of  
> Type::canLosslesslyBitCastTo:
> 
> 
> // canLosslesllyBitCastTo - Return true if this type can be converted to
> // 'Ty' without any reinterpretation of bits.  For example, uint to int.
> //

Okay.

> 
> >    // At this point we have only various mismatches of the first  
> > class types
> >    // remaining and ptr->ptr. Just select the lossless conversions.  
> > Everything
> >    // else is not lossless.
> 
> This comment needs to be updated.
> 
> > -  switch (getTypeID()) {
> > -  case Type::UByteTyID:   return Ty == Type::SByteTy;
> > -  case Type::SByteTyID:   return Ty == Type::UByteTy;
> > -  case Type::UShortTyID:  return Ty == Type::ShortTy;
> > -  case Type::ShortTyID:   return Ty == Type::UShortTy;
> > -  case Type::UIntTyID:    return Ty == Type::IntTy;
> > -  case Type::IntTyID:     return Ty == Type::UIntTy;
> > -  case Type::ULongTyID:   return Ty == Type::LongTy;
> > -  case Type::LongTyID:    return Ty == Type::ULongTy;
> > -  case Type::PointerTyID: return isa<PointerType>(Ty);
> > -  default:
> > -    break;
> > -  }
> > +  if (getTypeID() == Type::PointerTyID)
> > +    return isa<PointerType>(Ty);
> >    return false;  // Other types have no identity values
> >  }
> 
> What is Type::canLosslesslyBitCastTo used by now?  Can we just  
> eliminate it?

InstCombine. 

> 
> 
> > +FunctionType::ParameterAttributes
> > +FunctionType::getParamAttrs(unsigned Idx) const {
> > +  if (!ParamAttrs)
> > +    return ParameterAttributes(0);
> > +  if (Idx > ParamAttrs->size())
> > +    return ParameterAttributes(0);
> > +  return (*ParamAttrs)[Idx];
> > +}
> 
> Why does this map an out-of-range index onto attr 0?  Shouldn't this  
> be an assert?

No, I'm trying to save space. If you don't set any attributes or don't
set them on all the parameters then it isn't an error, you just get
"none Set". In a subsequent patch I made this clear by returning
NoAttributeSet enum (has value 0).

This saves space by not requiring the ParamAttrs vector to have an entry
for each parameter and not requiring it to even be allocated if there
aren't any parameter attributes.



> 
> -Chris
> 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20070104/5149cca8/attachment.sig>


More information about the llvm-commits mailing list