summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorIvan Krasin <krasin@chromium.org>2016-08-05 19:45:16 +0000
committerIvan Krasin <krasin@chromium.org>2016-08-05 19:45:16 +0000
commitb05e06e4fd1c7635bb0575b201b3a9912fd16c33 (patch)
treefbca3891f1ca74d25521841e25cd5e7487f9cf94 /llvm/lib/Transforms
parent45e442ebaa1e626174d93380914d9f1133a06d25 (diff)
downloadbcm5719-llvm-b05e06e4fd1c7635bb0575b201b3a9912fd16c33.tar.gz
bcm5719-llvm-b05e06e4fd1c7635bb0575b201b3a9912fd16c33.zip
WholeProgramDevirt: print remarks with devirtualized method names.
Summary: Chrome on Linux uses WholeProgramDevirt for speed ups, and it's important to detect regressions on both sides: the toolchain, if fewer methods get devirtualized after an update, and Chrome, if an innocently looking change caused many hot methods become virtual again. The need to track devirtualized methods is not Chrome-specific, but it's probably the only user of the pass at this time. Reviewers: kcc Differential Revision: https://reviews.llvm.org/D23219 llvm-svn: 277856
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
index 53eb4e2c907..b14bfa36f41 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/DebugInfoMetadata.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
@@ -610,6 +611,16 @@ bool DevirtModule::tryVirtualConstProp(
return true;
}
+static void emitTargetsRemarks(const std::vector<VirtualCallTarget> &TargetsForSlot) {
+ for (const VirtualCallTarget &Target : TargetsForSlot) {
+ Function *F = Target.Fn;
+ DISubprogram *SP = F->getSubprogram();
+ DebugLoc DL = SP ? DebugLoc::get(SP->getScopeLine(), 0, SP) : DebugLoc();
+ emitOptimizationRemark(F->getContext(), DEBUG_TYPE, *F, DL,
+ std::string("devirtualized ") + F->getName().str());
+ }
+}
+
void DevirtModule::rebuildGlobal(VTableBits &B) {
if (B.Before.Bytes.empty() && B.After.Bytes.empty())
return;
@@ -815,10 +826,15 @@ bool DevirtModule::run() {
S.first.ByteOffset))
continue;
- if (trySingleImplDevirt(TargetsForSlot, S.second))
+ if (trySingleImplDevirt(TargetsForSlot, S.second)) {
+ emitTargetsRemarks(TargetsForSlot);
continue;
+ }
- DidVirtualConstProp |= tryVirtualConstProp(TargetsForSlot, S.second);
+ if (tryVirtualConstProp(TargetsForSlot, S.second)) {
+ emitTargetsRemarks(TargetsForSlot);
+ DidVirtualConstProp = true;
+ }
}
// If we were able to eliminate all unsafe uses for a type checked load,
OpenPOWER on IntegriCloud