Change Function::getIntrinsicID() to return an Intrinsic::ID. NFC.
authorPete Cooper <peter_cooper@apple.com>
Wed, 20 May 2015 17:16:39 +0000 (17:16 +0000)
committerPete Cooper <peter_cooper@apple.com>
Wed, 20 May 2015 17:16:39 +0000 (17:16 +0000)
Now that Intrinsic::ID is a typed enum, we can forward declare it and so return it from this method.

This updates all users which were either using an unsigned to store it, or had a now unnecessary cast.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237810 91177308-0d34-0410-b5e6-96231b3b80d8

17 files changed:
include/llvm/Analysis/TargetTransformInfoImpl.h
include/llvm/IR/Function.h
include/llvm/IR/IRBuilder.h
include/llvm/IR/InstVisitor.h
include/llvm/IR/IntrinsicInst.h
lib/Analysis/BasicAliasAnalysis.cpp
lib/Analysis/InstructionSimplify.cpp
lib/CodeGen/GCRootLowering.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
lib/IR/AutoUpgrade.cpp
lib/IR/IRBuilder.cpp
lib/IR/Verifier.cpp
lib/Target/AArch64/AArch64FastISel.cpp
lib/Transforms/ObjCARC/ARCInstKind.cpp
lib/Transforms/Utils/SimplifyLibCalls.cpp
lib/Transforms/Vectorize/BBVectorize.cpp
lib/Transforms/Vectorize/SLPVectorizer.cpp

index 3902b0de0a2b1f6aeb35caf3eced3d38f134ed08..253319ccd4417fa67cee0e100a974c78a19f4a73 100644 (file)
@@ -365,7 +365,7 @@ public:
       // function.
       NumArgs = F->arg_size();
 
-    if (Intrinsic::ID IID = (Intrinsic::ID)F->getIntrinsicID()) {
+    if (Intrinsic::ID IID = F->getIntrinsicID()) {
       FunctionType *FTy = F->getFunctionType();
       SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
       return static_cast<T *>(this)
index 955d77c0aefa88b4eaee0f8f0a6a14b62f3f11b5..99e4d55f266f76f8392f0a76340b3f39535bbbcd 100644 (file)
@@ -144,7 +144,7 @@ public:
   /// zero to allow easy checking for whether a function is intrinsic or not.
   /// The particular intrinsic functions which correspond to this value are
   /// defined in llvm/Intrinsics.h.
-  unsigned getIntrinsicID() const LLVM_READONLY { return IntID; }
+  Intrinsic::ID getIntrinsicID() const LLVM_READONLY { return IntID; }
   bool isIntrinsic() const { return getName().startswith("llvm."); }
 
   /// \brief Recalculate the ID for this function if it is an Intrinsic defined
index 31344c8d4a7692a9a548b1e49ed0d2accaf5d4c1..13ed18684381895ce7bf796866370468996f8969 100644 (file)
@@ -500,7 +500,7 @@ public:
 private:
   /// \brief Create a call to a masked intrinsic with given Id.
   /// Masked intrinsic has only one overloaded type - data type.
-  CallInst *CreateMaskedIntrinsic(unsigned Id, ArrayRef<Value *> Ops,
+  CallInst *CreateMaskedIntrinsic(Intrinsic::ID Id, ArrayRef<Value *> Ops,
                                   Type *DataTy, const Twine &Name = "");
 
   Value *getCastedInt8PtrValue(Value *Ptr);
index 1cdcd55448c93a69fe4f1804d8b551027ae87871..581e860b8382d582da5724c6dd516ae80cfe3be5 100644 (file)
@@ -259,7 +259,7 @@ private:
   // Special helper function to delegate to CallInst subclass visitors.
   RetTy delegateCallInst(CallInst &I) {
     if (const Function *F = I.getCalledFunction()) {
-      switch ((Intrinsic::ID)F->getIntrinsicID()) {
+      switch (F->getIntrinsicID()) {
       default:                     DELEGATE(IntrinsicInst);
       case Intrinsic::dbg_declare: DELEGATE(DbgDeclareInst);
       case Intrinsic::dbg_value:   DELEGATE(DbgValueInst);
index 6d981349edd85e175d56d161615d48aa43afb31f..2c8b6eb6f39aed5f8a8805b6f56677c7d12ff699 100644 (file)
@@ -42,7 +42,7 @@ namespace llvm {
     /// getIntrinsicID - Return the intrinsic ID of this intrinsic.
     ///
     Intrinsic::ID getIntrinsicID() const {
-      return (Intrinsic::ID)getCalledFunction()->getIntrinsicID();
+      return getCalledFunction()->getIntrinsicID();
     }
 
     // Methods for support type inquiry through isa, cast, and dyn_cast:
index bbb74a2c454030d42daebc0233fb40a6462bba93..311b43c7c3aa663042adab2beb91f4d4c9496342 100644 (file)
@@ -775,7 +775,7 @@ BasicAliasAnalysis::getModRefBehavior(const Function *F) {
     return DoesNotAccessMemory;
 
   // For intrinsics, we can check the table.
-  if (unsigned iid = F->getIntrinsicID()) {
+  if (Intrinsic::ID iid = F->getIntrinsicID()) {
 #define GET_INTRINSIC_MODREF_BEHAVIOR
 #include "llvm/IR/Intrinsics.gen"
 #undef GET_INTRINSIC_MODREF_BEHAVIOR
index ab216ae94db1b90b0806ae9883396a460f509e4c..11e24e5e3e97b7b396e55e7bdd95ced6ced950a0 100644 (file)
@@ -3587,9 +3587,9 @@ static Value *SimplifyCall(Value *V, IterTy ArgBegin, IterTy ArgEnd,
   if (!F)
     return nullptr;
 
-  if (unsigned IID = F->getIntrinsicID())
+  if (Intrinsic::ID IID = F->getIntrinsicID())
     if (Value *Ret =
-        SimplifyIntrinsic((Intrinsic::ID) IID, ArgBegin, ArgEnd, Q, MaxRecurse))
+        SimplifyIntrinsic(IID, ArgBegin, ArgEnd, Q, MaxRecurse))
       return Ret;
 
   if (!canConstantFoldCallTo(F))
index e6fd79c9798d7f0602be5c9cd73374a2bd544a26..d8edd7e4063fc9758f33374dbe00e89f7797c357 100644 (file)
@@ -142,7 +142,7 @@ static bool CouldBecomeSafePoint(Instruction *I) {
   // llvm.gcroot is safe because it doesn't do anything at runtime.
   if (CallInst *CI = dyn_cast<CallInst>(I))
     if (Function *F = CI->getCalledFunction())
-      if (unsigned IID = F->getIntrinsicID())
+      if (Intrinsic::ID IID = F->getIntrinsicID())
         if (IID == Intrinsic::gcroot)
           return false;
 
index 4fe7bfbc6b4de9dbbb5fd32199e88a05698b9132..85303d27dcf8f88199c008b94007fd00ea3ab254 100644 (file)
@@ -5450,7 +5450,7 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) {
             return;
         }
       }
-      if (unsigned IID = F->getIntrinsicID()) {
+      if (Intrinsic::ID IID = F->getIntrinsicID()) {
         RenameFn = visitIntrinsicCall(I, IID);
         if (!RenameFn)
           return;
index 8910564493ee4386cac5eb07ef3a0673beb90b3d..43abdd2d1e8ecc1d637fedb691f79bb1c5e5c234 100644 (file)
@@ -233,9 +233,8 @@ bool llvm::UpgradeIntrinsicFunction(Function *F, Function *&NewFn) {
   // Upgrade intrinsic attributes.  This does not change the function.
   if (NewFn)
     F = NewFn;
-  if (unsigned id = F->getIntrinsicID())
-    F->setAttributes(Intrinsic::getAttributes(F->getContext(),
-                                              (Intrinsic::ID)id));
+  if (Intrinsic::ID id = F->getIntrinsicID())
+    F->setAttributes(Intrinsic::getAttributes(F->getContext(), id));
   return Upgraded;
 }
 
index a0b61494e2611e7254b9727c67dde12220e7929b..335cf363c367544d696c3ab1731a70bbe25261f0 100644 (file)
@@ -235,13 +235,13 @@ CallInst *IRBuilderBase::CreateMaskedStore(Value *Val, Value *Ptr,
 
 /// Create a call to a Masked intrinsic, with given intrinsic Id,
 /// an array of operands - Ops, and one overloaded type - DataTy
-CallInst *IRBuilderBase::CreateMaskedIntrinsic(unsigned Id,
+CallInst *IRBuilderBase::CreateMaskedIntrinsic(Intrinsic::ID Id,
                                                ArrayRef<Value *> Ops,
                                                Type *DataTy,
                                                const Twine &Name) {
   Module *M = BB->getParent()->getParent();
   Type *OverloadedTypes[] = { DataTy };
-  Value *TheFn = Intrinsic::getDeclaration(M, (Intrinsic::ID)Id, OverloadedTypes);
+  Value *TheFn = Intrinsic::getDeclaration(M, Id, OverloadedTypes);
   return createCallHelper(TheFn, Ops, this, Name);
 }
 
index 5dae4e08ced1b2c5b98b63c823acab09433de1fa..40c950044498ad00eead8536c697255d14aa7534 100644 (file)
@@ -2390,7 +2390,7 @@ void Verifier::visitCallInst(CallInst &CI) {
     verifyMustTailCall(CI);
 
   if (Function *F = CI.getCalledFunction())
-    if (Intrinsic::ID ID = (Intrinsic::ID)F->getIntrinsicID())
+    if (Intrinsic::ID ID = F->getIntrinsicID())
       visitIntrinsicFunctionCall(ID, CI);
 }
 
index b80e2f88baef0e7c6708a2afda06fd9ecb561279..9977e2b84a73a4c02cd24027b87b8398c59f1f5e 100644 (file)
@@ -3269,7 +3269,7 @@ bool AArch64FastISel::foldXALUIntrinsic(AArch64CC::CondCode &CC,
     std::swap(LHS, RHS);
 
   // Simplify multiplies.
-  unsigned IID = II->getIntrinsicID();
+  Intrinsic::ID IID = II->getIntrinsicID();
   switch (IID) {
   default:
     break;
@@ -3537,7 +3537,7 @@ bool AArch64FastISel::fastLowerIntrinsicCall(const IntrinsicInst *II) {
       std::swap(LHS, RHS);
 
     // Simplify multiplies.
-    unsigned IID = II->getIntrinsicID();
+    Intrinsic::ID IID = II->getIntrinsicID();
     switch (IID) {
     default:
       break;
index 72df9ab1c8141bb51099a20164d2b556f5a168bc..afb873a355a7e33931ee425004d134a4368ab537 100644 (file)
@@ -239,7 +239,7 @@ ARCInstKind llvm::objcarc::GetARCInstKind(const Value *V) {
         ARCInstKind Class = GetFunctionClass(F);
         if (Class != ARCInstKind::CallOrUser)
           return Class;
-        unsigned ID = F->getIntrinsicID();
+        Intrinsic::ID ID = F->getIntrinsicID();
         if (isInertIntrinsic(ID))
           return ARCInstKind::None;
         if (isUseOnlyIntrinsic(ID))
index 82bf1b1cb8a857c58cada8443b0246d3d4f12f9f..6bbf8287e22330a88cdd92f3f8bf7fecab1bbe9f 100644 (file)
@@ -973,7 +973,7 @@ Value *LibCallSimplifier::optimizeUnaryDoubleFP(CallInst *CI, IRBuilder<> &B,
   // floor((double)floatval) -> (double)floorf(floatval)
   if (Callee->isIntrinsic()) {
     Module *M = CI->getParent()->getParent()->getParent();
-    Intrinsic::ID IID = (Intrinsic::ID) Callee->getIntrinsicID();
+    Intrinsic::ID IID = Callee->getIntrinsicID();
     Function *F = Intrinsic::getDeclaration(M, IID, B.getFloatTy());
     V = B.CreateCall(F, V);
   } else {
index 6f0180e7db0784f220a2d17cfe6f9c01304aeb4c..215d6f9a1eb6abf07d4ee62ddfb22bb519eda897 100644 (file)
@@ -662,7 +662,7 @@ namespace {
       Function *F = I->getCalledFunction();
       if (!F) return false;
 
-      Intrinsic::ID IID = (Intrinsic::ID) F->getIntrinsicID();
+      Intrinsic::ID IID = F->getIntrinsicID();
       if (!IID) return false;
 
       switch(IID) {
@@ -1098,7 +1098,7 @@ namespace {
     CallInst *CI = dyn_cast<CallInst>(I);
     Function *FI;
     if (CI && (FI = CI->getCalledFunction())) {
-      Intrinsic::ID IID = (Intrinsic::ID) FI->getIntrinsicID();
+      Intrinsic::ID IID = FI->getIntrinsicID();
       if (IID == Intrinsic::powi || IID == Intrinsic::ctlz ||
           IID == Intrinsic::cttz) {
         Value *A1I = CI->getArgOperand(1),
@@ -2770,7 +2770,7 @@ namespace {
         continue;
       } else if (isa<CallInst>(I)) {
         Function *F = cast<CallInst>(I)->getCalledFunction();
-        Intrinsic::ID IID = (Intrinsic::ID) F->getIntrinsicID();
+        Intrinsic::ID IID = F->getIntrinsicID();
         if (o == NumOperands-1) {
           BasicBlock &BB = *I->getParent();
 
index 7267f58d1c9ba9fc9903d08f5d356afb1e130299..504425eae406b09448e5f4b46b3b6f4e47075b77 100644 (file)
@@ -2382,7 +2382,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
       Intrinsic::ID IID  = Intrinsic::not_intrinsic;
       Value *ScalarArg = nullptr;
       if (CI && (FI = CI->getCalledFunction())) {
-        IID = (Intrinsic::ID) FI->getIntrinsicID();
+        IID = FI->getIntrinsicID();
       }
       std::vector<Value *> OpVecs;
       for (int j = 0, e = CI->getNumArgOperands(); j < e; ++j) {