[llvm] r243146 - Add const to some Type* parameters which didn't need to be mutable. NFC.

David Blaikie dblaikie at gmail.com
Sat Jul 25 10:52:39 PDT 2015


On Sat, Jul 25, 2015 at 9:57 AM, Pete Cooper <peter_cooper at apple.com> wrote:

>
> On Jul 25, 2015, at 9:20 AM, Craig Topper <craig.topper at gmail.com> wrote:
>
> I thought we prefered not to put const on Types.
>
> Yep, that's correct - in fact one of my first contributions to the project
was to provide patches to make that transition after the great 3.0 type
system rewrite Chris did.

http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20110711/124192.html

I can't seem to find the actual commit(s) that applied the main changes
there - maybe it never made it to the mailing list because it was too big.

> I didn’t know that.  Thanks for the tip.
>
> I did a quick search of LLVM and there’s 44 hits for ‘const Type *’.  I’m
> sure if I searched without the const there would be 1000’s of hits so looks
> like we’re reasonably consistent about leaving out the const.  I’ll revert
> this when i’m next at a recent checkout to do so.
>
> They don't have any non-const methods anyway do they?
>
> Only one (PointerType *getPointerTo(unsigned AddrSpace = 0);) and I don’t
> think it needs to be non-const.  I’ll also see if i can fix that.  I think
> its only non-const because PointerType::get takes a non-const Type*.
>
> Cheers,
> Pete
>
>
> On Fri, Jul 24, 2015 at 12:19 PM, Pete Cooper <peter_cooper at apple.com>
> wrote:
>
>> Author: pete
>> Date: Fri Jul 24 14:19:26 2015
>> New Revision: 243146
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=243146&view=rev
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D243146-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=LNcHPhSuKFzNIaAsh-ZdJc_EoC2PglYRL1VjEmtEayY&s=9zpmd61-FGaft7oTzQxLCKItiR8J3wUVABWDz_w5soc&e=>
>> Log:
>> Add const to some Type* parameters which didn't need to be mutable.  NFC.
>>
>> We were only getting the size of the type which doesn't need to modify
>> the type.
>>
>> Modified:
>>     llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
>>     llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
>>
>> Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=243146&r1=243145&r2=243146&view=diff
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_Target_PowerPC_PPCISelLowering.cpp-3Frev-3D243146-26r1-3D243145-26r2-3D243146-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=LNcHPhSuKFzNIaAsh-ZdJc_EoC2PglYRL1VjEmtEayY&s=GhCkUabblkOywo8akktGbrCkmQdNzJLPoUspcGeO8Wc&e=>
>>
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original)
>> +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Fri Jul 24 14:19:26
>> 2015
>> @@ -925,22 +925,22 @@ PPCTargetLowering::PPCTargetLowering(con
>>
>>  /// getMaxByValAlign - Helper for getByValTypeAlignment to determine
>>  /// the desired ByVal argument alignment.
>> -static void getMaxByValAlign(Type *Ty, unsigned &MaxAlign,
>> +static void getMaxByValAlign(const Type *Ty, unsigned &MaxAlign,
>>                               unsigned MaxMaxAlign) {
>>    if (MaxAlign == MaxMaxAlign)
>>      return;
>> -  if (VectorType *VTy = dyn_cast<VectorType>(Ty)) {
>> +  if (const VectorType *VTy = dyn_cast<VectorType>(Ty)) {
>>      if (MaxMaxAlign >= 32 && VTy->getBitWidth() >= 256)
>>        MaxAlign = 32;
>>      else if (VTy->getBitWidth() >= 128 && MaxAlign < 16)
>>        MaxAlign = 16;
>> -  } else if (ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
>> +  } else if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
>>      unsigned EltAlign = 0;
>>      getMaxByValAlign(ATy->getElementType(), EltAlign, MaxMaxAlign);
>>      if (EltAlign > MaxAlign)
>>        MaxAlign = EltAlign;
>> -  } else if (StructType *STy = dyn_cast<StructType>(Ty)) {
>> -    for (auto *EltTy : STy->elements()) {
>> +  } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
>> +    for (const auto *EltTy : STy->elements()) {
>>        unsigned EltAlign = 0;
>>        getMaxByValAlign(EltTy, EltAlign, MaxMaxAlign);
>>        if (EltAlign > MaxAlign)
>>
>> Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=243146&r1=243145&r2=243146&view=diff
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_Target_X86_X86ISelLowering.cpp-3Frev-3D243146-26r1-3D243145-26r2-3D243146-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=LNcHPhSuKFzNIaAsh-ZdJc_EoC2PglYRL1VjEmtEayY&s=2YGstlsad0mCnM-vBzAt8oU0zAxjhqPiLicDB2Z5ZsM&e=>
>>
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
>> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Jul 24 14:19:26 2015
>> @@ -1806,19 +1806,19 @@ EVT X86TargetLowering::getSetCCResultTyp
>>
>>  /// Helper for getByValTypeAlignment to determine
>>  /// the desired ByVal argument alignment.
>> -static void getMaxByValAlign(Type *Ty, unsigned &MaxAlign) {
>> +static void getMaxByValAlign(const Type *Ty, unsigned &MaxAlign) {
>>    if (MaxAlign == 16)
>>      return;
>> -  if (VectorType *VTy = dyn_cast<VectorType>(Ty)) {
>> +  if (const VectorType *VTy = dyn_cast<VectorType>(Ty)) {
>>      if (VTy->getBitWidth() == 128)
>>        MaxAlign = 16;
>> -  } else if (ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
>> +  } else if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
>>      unsigned EltAlign = 0;
>>      getMaxByValAlign(ATy->getElementType(), EltAlign);
>>      if (EltAlign > MaxAlign)
>>        MaxAlign = EltAlign;
>> -  } else if (StructType *STy = dyn_cast<StructType>(Ty)) {
>> -    for (auto *EltTy : STy->elements()) {
>> +  } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
>> +    for (const auto *EltTy : STy->elements()) {
>>        unsigned EltAlign = 0;
>>        getMaxByValAlign(EltTy, EltAlign);
>>        if (EltAlign > MaxAlign)
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>
>
>
> --
> ~Craig
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150725/4b202b55/attachment.html>


More information about the llvm-commits mailing list