[llvm-commits] [llvm] r167111 - in /llvm/trunk: include/llvm/IRBuilder.h unittests/VMCore/IRBuilderTest.cpp

Chandler Carruth chandlerc at google.com
Wed Oct 31 03:40:42 PDT 2012


On Wed, Oct 31, 2012 at 3:37 AM, Duncan Sands <baldrick at free.fr> wrote:
> Hi Chandler,
>
>
> On 31/10/12 11:35, Chandler Carruth wrote:
>>
>> On Wed, Oct 31, 2012 at 3:28 AM, Duncan Sands <baldrick at free.fr> wrote:
>>>
>>> Hi Evgeniy,
>>>
>>>> Add IRBuilderBase::getIntPtrTy.
>>>
>>>
>>>
>>>> --- llvm/trunk/include/llvm/IRBuilder.h (original)
>>>> +++ llvm/trunk/include/llvm/IRBuilder.h Wed Oct 31 04:50:01 2012
>>>> @@ -266,6 +267,10 @@
>>>>        return Type::getInt8PtrTy(Context, AddrSpace);
>>>>      }
>>>>
>>>> +  IntegerType* getIntPtrTy(DataLayout *DL, unsigned AddrSpace = 0) {
>>>> +    return DL->getIntPtrType(Context, AddrSpace);
>>>> +  }
>>>> +
>>>>
>>>>
>>>> //===--------------------------------------------------------------------===//
>>>>      // Intrinsic creation methods
>>>>
>>>>
>>>> //===--------------------------------------------------------------------===//
>>>>
>>>
>>> I don't get it, why is this better than calling DataLayout directly?
>>
>>
>> Because a lot of code passes around the IRBuilder everywhere it goes.
>> It is very convenient to not have to pass around the DataLayout and
>> the IRBuilder.
>
>
> but you have to pass the data layout around even with this because it takes
> the
> datalayout as a parameter!  It would be different if a copy of the data
> layout
> was kept in the IRBuilder.

Ahem... right you are. For some reason, I didn't note that, and
kind-of assumed that we just had the DataLayout in the IRBuilder along
with the context.

Evgeniy? Thoughts? I assume you had immediate uses for this pattern.
What would be most convenient.

>
> Ciao, Duncan.
>
>
>> It is also a nice complement to the rest of the int type getting helpers.
>>
>> Keep in mind, everything in IRBuilder exists solely to shorten code.
>> There is nothing you can't do without the IRBuilder...
>>
>>> Also,
>>> I'm
>>> not sure that providing a default address space is wise.
>>>
>>> Ciao, Duncan.
>
>



More information about the llvm-commits mailing list