[PATCH] D13427: RFC: faster isa<IntrinsicInst> (bugged tests?)

escha via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 4 22:20:31 PDT 2015


escha created this revision.
escha added reviewers: chandlerc, resistor.
escha added a subscriber: llvm-commits.
escha set the repository for this revision to rL LLVM.

isa<IntrinsicInst> actually performed a string comparison on the function name instead of just checking that the ID wasn't not_intrinsic, which was ~50 cycles per invocation instead of ~10. This should vastly reduce the number of wasteful string comparisons in intrinsic-heavy code. Furthermore, match() was *already doing this*; we actually had two different sets of behavior going on!

Unfortunately, this change seems to break three tests:

    LLVM :: Bitcode/function-local-metadata.3.5.ll
    LLVM :: Bitcode/metadata.3.5.ll
    LLVM :: Transforms/GlobalOpt/metadata.ll

All of which use intrinsics like "llvm.foo" that don't really exist. Does anyone know what's up with this? Are the tests just bogus?

Repository:
  rL LLVM

http://reviews.llvm.org/D13427

Files:
  include/llvm/IR/Function.h
  lib/IR/Function.cpp

Index: lib/IR/Function.cpp
===================================================================
--- lib/IR/Function.cpp
+++ lib/IR/Function.cpp
@@ -462,7 +462,7 @@
 
 void Function::recalculateIntrinsicID() {
   const ValueName *ValName = this->getValueName();
-  if (!ValName || !isIntrinsic()) {
+  if (!ValName || !getName().startswith("llvm.")) {
     IntID = Intrinsic::not_intrinsic;
     return;
   }
Index: include/llvm/IR/Function.h
===================================================================
--- include/llvm/IR/Function.h
+++ include/llvm/IR/Function.h
@@ -25,6 +25,7 @@
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/CallingConv.h"
 #include "llvm/IR/GlobalObject.h"
+#include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/OperandTraits.h"
 #include "llvm/Support/Compiler.h"
 
@@ -157,7 +158,9 @@
   /// The particular intrinsic functions which correspond to this value are
   /// defined in llvm/Intrinsics.h.
   Intrinsic::ID getIntrinsicID() const LLVM_READONLY { return IntID; }
-  bool isIntrinsic() const { return getName().startswith("llvm."); }
+  bool isIntrinsic() const {
+    return getIntrinsicID() != Intrinsic::not_intrinsic;
+  }
 
   /// \brief Recalculate the ID for this function if it is an Intrinsic defined
   /// in llvm/Intrinsics.h.  Sets the intrinsic ID to Intrinsic::not_intrinsic


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13427.36477.patch
Type: text/x-patch
Size: 1330 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151005/b0f4db9f/attachment.bin>


More information about the llvm-commits mailing list