[llvm-commits] [llvm] r71427 - /llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp

Chris Lattner clattner at apple.com
Tue May 12 09:52:30 PDT 2009


On May 12, 2009, at 4:57 AM, Jay Foad wrote:

>>> +// Return the integer value Val zero-extended or truncated (if  
>>> necessary) to
>>> +// type ITy. Any new instructions are inserted at InsertBefore.
>>
>> this sounds like a generally useful thing, so shouldn't be here.
>
>> Doesn't the IRBuilder stuff already do this?  If so, why not just
>> use a builder here?
>
> You're right; IRBuilder::CreateIntCast() already does everything that
> my helper function does. How about this patch, which converts the
> whole of IntrinsicLowering.cpp to use IRBuilder? It passes "make
> check".

Patch looks great!  Please apply.

> Incidentally, is there any reason why all the IRBuilder::CreateXXX
> functions take "const char *Name" instead of "const std::string &Name"
> (like the underlying XXXInst::Create() functions)? It's a bit of a
> pain, because it means I can't write:
>
>  New = Builder.CreateXXX(..., Old->getName());

The reason is that most clients of IRBuilder pass in literal strings  
like "tmp".  If IRBuilder took an std::string&, this would require a  
temporary std::string to be allocated which would copy the literal  
into a temporary on the heap.  Passing down const char* allows us to  
avoid the extra copy.

The whole naming situation in the low level IR methods is something of  
a mess, it's somewhere on my todo list to clean it up.

-Chris



More information about the llvm-commits mailing list