summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/PartialInlining.cpp
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2017-04-23 21:40:58 +0000
committerXinliang David Li <davidxl@google.com>2017-04-23 21:40:58 +0000
commit15744ad87b65bd7c28a5573e28550398deba1378 (patch)
treec9aa0defb2aeb3b0bbaa5089a0c935d36c05594f /llvm/lib/Transforms/IPO/PartialInlining.cpp
parent06d626330988d81ce33d4d9512d5727998240cb5 (diff)
downloadbcm5719-llvm-15744ad87b65bd7c28a5573e28550398deba1378.tar.gz
bcm5719-llvm-15744ad87b65bd7c28a5573e28550398deba1378.zip
[PartialInlining] Add optimization remark support
Differential Revision: http://reviews.llvm.org/D32387 llvm-svn: 301143
Diffstat (limited to 'llvm/lib/Transforms/IPO/PartialInlining.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/PartialInlining.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/IPO/PartialInlining.cpp b/llvm/lib/Transforms/IPO/PartialInlining.cpp
index f5e5775da55..6a9a6a272da 100644
--- a/llvm/lib/Transforms/IPO/PartialInlining.cpp
+++ b/llvm/lib/Transforms/IPO/PartialInlining.cpp
@@ -17,7 +17,9 @@
#include "llvm/Analysis/BlockFrequencyInfo.h"
#include "llvm/Analysis/BranchProbabilityInfo.h"
#include "llvm/Analysis/LoopInfo.h"
+#include "llvm/Analysis/OptimizationDiagnosticInfo.h"
#include "llvm/IR/CFG.h"
+#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
@@ -27,7 +29,7 @@
#include "llvm/Transforms/Utils/CodeExtractor.h"
using namespace llvm;
-#define DEBUG_TYPE "partialinlining"
+#define DEBUG_TYPE "partial-inlining"
STATISTIC(NumPartialInlined, "Number of functions partially inlined");
@@ -152,11 +154,25 @@ Function *PartialInlinerImpl::unswitchFunction(Function *F) {
// Inline the top-level if test into all callers.
std::vector<User *> Users(DuplicateFunction->user_begin(),
DuplicateFunction->user_end());
- for (User *User : Users)
+
+ for (User *User : Users) {
+ CallSite CS;
if (CallInst *CI = dyn_cast<CallInst>(User))
- InlineFunction(CI, IFI);
+ CS = CallSite(CI);
else if (InvokeInst *II = dyn_cast<InvokeInst>(User))
- InlineFunction(II, IFI);
+ CS = CallSite(II);
+ else
+ llvm_unreachable("All uses must be calls");
+
+ OptimizationRemarkEmitter ORE(CS.getCaller());
+ DebugLoc DLoc = CS.getInstruction()->getDebugLoc();
+ BasicBlock *Block = CS.getParent();
+ ORE.emit(OptimizationRemark(DEBUG_TYPE, "PartiallyInlined", DLoc, Block)
+ << ore::NV("Callee", F) << " partially inlined into "
+ << ore::NV("Caller", CS.getCaller()));
+
+ InlineFunction(CS, IFI);
+ }
// Ditch the duplicate, since we're done with it, and rewrite all remaining
// users (function pointers, etc.) back to the original function.
OpenPOWER on IntegriCloud