[llvm] r279113 - Add a version of Intrinsic::getName which is more efficient when there are no overloads.

Pete Cooper via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 20 13:27:02 PDT 2016



Sent from my iPhone

> On Aug 20, 2016, at 11:52 AM, Philip Reames <listmail at philipreames.com> wrote:
> 
>> On 08/18/2016 11:30 AM, Pete Cooper via llvm-commits wrote:
>> Author: pete
>> Date: Thu Aug 18 13:30:54 2016
>> New Revision: 279113
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=279113&view=rev
>> Log:
>> Add a version of Intrinsic::getName which is more efficient when there are no overloads.
>> 
>> When running 'opt -O2 verify-uselistorder-nodbg.lto.bc', there are 33m allocations.  8.2m
>> come from std::string allocations in Intrinsic::getName().  Turns out this method only
>> returns a std::string because it needs to handle overloads, but that is not the common case.
>> 
>> This adds an overload of getName which just returns a StringRef when there are no overloads
>> and so saves on the allocations.
>> 
>> Modified:
>>     llvm/trunk/include/llvm/IR/Intrinsics.h
>>     llvm/trunk/lib/IR/Function.cpp
>> 
>> Modified: llvm/trunk/include/llvm/IR/Intrinsics.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Intrinsics.h?rev=279113&r1=279112&r2=279113&view=diff
>> ==============================================================================
>> --- llvm/trunk/include/llvm/IR/Intrinsics.h (original)
>> +++ llvm/trunk/include/llvm/IR/Intrinsics.h Thu Aug 18 13:30:54 2016
>> @@ -45,7 +45,10 @@ namespace Intrinsic {
>>    };
>>      /// Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
>> -  std::string getName(ID id, ArrayRef<Type*> Tys = None);
>> +  StringRef getName(ID id);
>> +
>> +  /// Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
>> +  std::string getName(ID id, ArrayRef<Type*> Tys);
> Can you add clarifying comments to explain when each should be used?
Sure. Can do.
>>      /// Return the function type for an intrinsic.
>>    FunctionType *getType(LLVMContext &Context, ID id,
>> 
>> Modified: llvm/trunk/lib/IR/Function.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Function.cpp?rev=279113&r1=279112&r2=279113&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/IR/Function.cpp (original)
>> +++ llvm/trunk/lib/IR/Function.cpp Thu Aug 18 13:30:54 2016
>> @@ -551,6 +551,11 @@ static std::string getMangledTypeStr(Typ
>>    return Result;
>>  }
>>  +StringRef Intrinsic::getName(ID id) {
>> +  assert(id < num_intrinsics && "Invalid intrinsic ID!");
>> +  return IntrinsicNameTable[id];
> Can we add an assert that this intrinsic is not overloaded?
Good idea. I'll add that too.

Cheers
Pete
>> +}
>> +
>>  std::string Intrinsic::getName(ID id, ArrayRef<Type*> Tys) {
>>    assert(id < num_intrinsics && "Invalid intrinsic ID!");
>>    std::string Result(IntrinsicNameTable[id]);
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> 
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160820/e6cab20f/attachment.html>


More information about the llvm-commits mailing list