diff options
author | Xinliang David Li <davidxl@google.com> | 2017-04-22 19:24:19 +0000 |
---|---|---|
committer | Xinliang David Li <davidxl@google.com> | 2017-04-22 19:24:19 +0000 |
commit | 016a82ba51d2a3574130423b27ffbdc24326ed5d (patch) | |
tree | 738164e5557053cb91ab7b46b5b9929b2fb20f59 /llvm/lib/Transforms/IPO/PartialInlining.cpp | |
parent | 5de7f2d7b8e96dc6c243033ccd32685d9ac30d4c (diff) | |
download | bcm5719-llvm-016a82ba51d2a3574130423b27ffbdc24326ed5d.tar.gz bcm5719-llvm-016a82ba51d2a3574130423b27ffbdc24326ed5d.zip |
[PartialInlining] Using existing hasAddressTaken interface to legality check/NFC
llvm-svn: 301090
Diffstat (limited to 'llvm/lib/Transforms/IPO/PartialInlining.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/PartialInlining.cpp | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/llvm/lib/Transforms/IPO/PartialInlining.cpp b/llvm/lib/Transforms/IPO/PartialInlining.cpp index d8111688d1d..f5e5775da55 100644 --- a/llvm/lib/Transforms/IPO/PartialInlining.cpp +++ b/llvm/lib/Transforms/IPO/PartialInlining.cpp @@ -66,6 +66,9 @@ struct PartialInlinerLegacyPass : public ModulePass { 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::unswitchFunction(Function *F) { 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); |