[llvm] r277087 - Revert "Don't invoke getName() from Function::isIntrinsic().", rL276942.

Justin Lebar via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 28 16:58:15 PDT 2016


Author: jlebar
Date: Thu Jul 28 18:58:15 2016
New Revision: 277087

URL: http://llvm.org/viewvc/llvm-project?rev=277087&view=rev
Log:
Revert "Don't invoke getName() from Function::isIntrinsic().", rL276942.

This broke some out-of-tree AMDGPU tests that relied on the old behavior
wherein isIntrinsic() would return true for any function that starts
with "llvm.".  And in general that change will not play nicely with
out-of-tree backends.

Modified:
    llvm/trunk/include/llvm/IR/Function.h
    llvm/trunk/lib/CodeGen/WinEHPrepare.cpp
    llvm/trunk/lib/IR/AsmWriter.cpp
    llvm/trunk/lib/IR/Function.cpp
    llvm/trunk/lib/IR/Verifier.cpp

Modified: llvm/trunk/include/llvm/IR/Function.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Function.h?rev=277087&r1=277086&r2=277087&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Function.h (original)
+++ llvm/trunk/include/llvm/IR/Function.h Thu Jul 28 18:58:15 2016
@@ -137,13 +137,7 @@ public:
   /// 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 {
-    // Intrinsic::not_intrinsic must be 0.
-    return IntID != 0;
-  }
-  /// Return true if the function's name starts with "llvm.".  All intrinsics
-  /// have this prefix.
-  bool hasLLVMReservedName() const { return getName().startswith("llvm."); }
+  bool isIntrinsic() const { return getName().startswith("llvm."); }
 
   /// \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

Modified: llvm/trunk/lib/CodeGen/WinEHPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/WinEHPrepare.cpp?rev=277087&r1=277086&r2=277087&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/WinEHPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/WinEHPrepare.cpp Thu Jul 28 18:58:15 2016
@@ -949,14 +949,10 @@ void WinEHPrepare::removeImplausibleInst
           continue;
 
         // Skip call sites which are nounwind intrinsics or inline asm.
-        //
-        // FIXME: Should this check isIntrinsic() instead of
-        // hasLLVMReservedName?  The latter is conservative.
         auto *CalledFn =
             dyn_cast<Function>(CS.getCalledValue()->stripPointerCasts());
-        if (CalledFn &&
-            ((CalledFn->hasLLVMReservedName() && CS.doesNotThrow()) ||
-             CS.isInlineAsm()))
+        if (CalledFn && ((CalledFn->isIntrinsic() && CS.doesNotThrow()) ||
+                         CS.isInlineAsm()))
           continue;
 
         // This call site was not part of this funclet, remove it.

Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=277087&r1=277086&r2=277087&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Thu Jul 28 18:58:15 2016
@@ -905,7 +905,7 @@ void SlotTracker::processInstructionMeta
   // Process metadata used directly by intrinsics.
   if (const CallInst *CI = dyn_cast<CallInst>(&I))
     if (Function *F = CI->getCalledFunction())
-      if (F->hasLLVMReservedName())
+      if (F->isIntrinsic())
         for (auto &Op : I.operands())
           if (auto *V = dyn_cast_or_null<MetadataAsValue>(Op))
             if (MDNode *N = dyn_cast<MDNode>(V->getMetadata()))
@@ -3378,7 +3378,7 @@ void Type::print(raw_ostream &OS, bool /
 static bool isReferencingMDNode(const Instruction &I) {
   if (const auto *CI = dyn_cast<CallInst>(&I))
     if (Function *F = CI->getCalledFunction())
-      if (F->hasLLVMReservedName())
+      if (F->isIntrinsic())
         for (auto &Op : I.operands())
           if (auto *V = dyn_cast_or_null<MetadataAsValue>(Op))
             if (isa<MDNode>(V->getMetadata()))

Modified: llvm/trunk/lib/IR/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Function.cpp?rev=277087&r1=277086&r2=277087&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Function.cpp (original)
+++ llvm/trunk/lib/IR/Function.cpp Thu Jul 28 18:58:15 2016
@@ -488,7 +488,9 @@ static ArrayRef<const char *> findTarget
 
 /// \brief This does the actual lookup of an intrinsic ID which
 /// matches the given function name.
-static Intrinsic::ID lookupIntrinsicID(StringRef Name) {
+static Intrinsic::ID lookupIntrinsicID(const ValueName *ValName) {
+  StringRef Name = ValName->getKey();
+
   ArrayRef<const char *> NameTable = findTargetSubtable(Name);
   int Idx = Intrinsic::lookupLLVMIntrinsicByName(NameTable, Name);
   if (Idx == -1)
@@ -506,11 +508,12 @@ static Intrinsic::ID lookupIntrinsicID(S
 }
 
 void Function::recalculateIntrinsicID() {
-  if (!hasLLVMReservedName()) {
+  const ValueName *ValName = this->getValueName();
+  if (!ValName || !isIntrinsic()) {
     IntID = Intrinsic::not_intrinsic;
     return;
   }
-  IntID = lookupIntrinsicID(getName());
+  IntID = lookupIntrinsicID(ValName);
 }
 
 /// Returns a stable mangling for the type specified for use in the name

Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=277087&r1=277086&r2=277087&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Thu Jul 28 18:58:15 2016
@@ -3657,7 +3657,7 @@ void Verifier::visitInstruction(Instruct
       // Check to make sure that the "address of" an intrinsic function is never
       // taken.
       Assert(
-          !F->hasLLVMReservedName() ||
+          !F->isIntrinsic() ||
               i == (isa<CallInst>(I) ? e - 1 : isa<InvokeInst>(I) ? e - 3 : 0),
           "Cannot take the address of an intrinsic!", &I);
       Assert(




More information about the llvm-commits mailing list