summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
diff options
context:
space:
mode:
authorIvan Krasin <krasin@chromium.org>2016-07-12 02:38:37 +0000
committerIvan Krasin <krasin@chromium.org>2016-07-12 02:38:37 +0000
commit5474645dc88279a2a441c3ae915634f88d3391b8 (patch)
tree7be3ead60c1c416a263f1ec79a311d96858268c6 /llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
parente92e2124f6624a1cd91183ba70a303ce89b80a5d (diff)
downloadbcm5719-llvm-5474645dc88279a2a441c3ae915634f88d3391b8.tar.gz
bcm5719-llvm-5474645dc88279a2a441c3ae915634f88d3391b8.zip
Print remarks from WholeProgramDevirt pass for each call site.
Summary: It's useful to have some visibility about which call sites are devirtualized, especially for debug purposes. Another use case is a regression test on the application side (like, Chromium). Reviewers: pcc Differential Revision: http://reviews.llvm.org/D22252 llvm-svn: 275145
Diffstat (limited to 'llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
index e6f4fa29224..53eb4e2c907 100644
--- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -35,6 +35,7 @@
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
+#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
@@ -215,7 +216,15 @@ struct VirtualCallSite {
// of that field for details.
unsigned *NumUnsafeUses;
+ void emitRemark() {
+ Function *F = CS.getCaller();
+ emitOptimizationRemark(F->getContext(), DEBUG_TYPE, *F,
+ CS.getInstruction()->getDebugLoc(),
+ "devirtualized call");
+ }
+
void replaceAndErase(Value *New) {
+ emitRemark();
CS->replaceAllUsesWith(New);
if (auto II = dyn_cast<InvokeInst>(CS.getInstruction())) {
BranchInst::Create(II->getNormalDest(), CS.getInstruction());
@@ -394,6 +403,7 @@ bool DevirtModule::trySingleImplDevirt(
// If so, update each call site to call that implementation directly.
for (auto &&VCallSite : CallSites) {
+ VCallSite.emitRemark();
VCallSite.CS.setCalledFunction(ConstantExpr::getBitCast(
TheFn, VCallSite.CS.getCalledValue()->getType()));
// This use is no longer unsafe.
OpenPOWER on IntegriCloud