OSDN Git Service

Don't invoke getName() from Function::isIntrinsic().
authorJustin Lebar <jlebar@google.com>
Wed, 27 Jul 2016 23:46:57 +0000 (23:46 +0000)
committerJustin Lebar <jlebar@google.com>
Wed, 27 Jul 2016 23:46:57 +0000 (23:46 +0000)
commit6d9563a0bcf0b97e97e09fd84982ee272afd6e77
treea29e56318f3132cba3cb14ba6dcc3eac0e1311d4
parent79e702086510fa7b52de178354eab34a7f641025
Don't invoke getName() from Function::isIntrinsic().

Summary:
getName() involves a hashtable lookup, so is expensive given how
frequently isIntrinsic() is called.  (In particular, many users cast to
IntrinsicInstr or one of its subclasses before calling
getIntrinsicID().)

This has an incidental functional change: Before, isIntrinsic() would
return true for any function whose name started with "llvm.", even if it
wasn't properly an intrinsic.  The new behavior seems more correct to
me, because it's strange to say that isIntrinsic() is true, but
getIntrinsicId() returns "not an intrinsic".

Some callers want the old behavior -- they want to know whether the
caller is a recognized intrinsic, or might be one in some other version
of LLVM.  For them, we added Function::hasLLVMReservedName(), which
checks whether the name starts with "llvm.".

This change is good for a 1.5% e2e speedup compiling a large Eigen
benchmark.

Reviewers: bogner

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D22065

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276942 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/IR/Function.h
lib/CodeGen/WinEHPrepare.cpp
lib/IR/AsmWriter.cpp
lib/IR/Function.cpp
lib/IR/Verifier.cpp