[llvm] r301090 - [PartialInlining] Using existing hasAddressTaken interface to legality check/NFC

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 22 12:24:19 PDT 2017


Author: davidxl
Date: Sat Apr 22 14:24:19 2017
New Revision: 301090

URL: http://llvm.org/viewvc/llvm-project?rev=301090&view=rev
Log:
[PartialInlining] Using existing hasAddressTaken interface to legality check/NFC

Modified:
    llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp

Modified: llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp?rev=301090&r1=301089&r2=301090&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp Sat Apr 22 14:24:19 2017
@@ -66,6 +66,9 @@ struct PartialInlinerLegacyPass : public
 
 Function *PartialInlinerImpl::unswitchFunction(Function *F) {
   // First, verify that this function is an unswitching candidate...
+  if (F->hasAddressTaken())
+    return nullptr;
+
   BasicBlock *EntryBlock = &F->front();
   BranchInst *BR = dyn_cast<BranchInst>(EntryBlock->getTerminator());
   if (!BR || BR->isUnconditional())
@@ -85,25 +88,6 @@ Function *PartialInlinerImpl::unswitchFu
   if (ReturnCount != 1)
     return nullptr;
 
-  auto canAllUsesBeReplaced = [](Function *F) {
-    std::vector<User *> Users(F->user_begin(), F->user_end());
-    for (User *User : Users) {
-      Function *Callee = nullptr;
-      if (CallInst *CI = dyn_cast<CallInst>(User))
-        Callee = CallSite(CI).getCalledFunction();
-      else if (InvokeInst *II = dyn_cast<InvokeInst>(User))
-        Callee = CallSite(II).getCalledFunction();
-
-      if (Callee != F)
-        return false;
-    }
-
-    return true;
-  };
-
-  if (!canAllUsesBeReplaced(F))
-    return nullptr;
-
   // Clone the function, so that we can hack away on it.
   ValueToValueMapTy VMap;
   Function *DuplicateFunction = CloneFunction(F, VMap);




More information about the llvm-commits mailing list