summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenAction.cpp
diff options
context:
space:
mode:
authorAdam Nemet <anemet@apple.com>2016-09-12 23:48:16 +0000
committerAdam Nemet <anemet@apple.com>2016-09-12 23:48:16 +0000
commita340eff335cfa88403afc2ee81babceaba101965 (patch)
tree19404cbdd04bb9a21b2f3b17c24003346680e316 /clang/lib/CodeGen/CodeGenAction.cpp
parentd2a4da09ad3f4a632cd4de61406c57ca66ccde50 (diff)
downloadbcm5719-llvm-a340eff335cfa88403afc2ee81babceaba101965.tar.gz
bcm5719-llvm-a340eff335cfa88403afc2ee81babceaba101965.zip
Add -fdiagnostics-show-hotness
Summary: I've recently added the ability for optimization remarks to include the hotness of the corresponding code region. This uses PGO and allows filtering of the optimization remarks by relevance. The idea was first discussed here: http://thread.gmane.org/gmane.comp.compilers.llvm.devel/98334 The general goal is to produce a YAML file with the remarks. Then, an external tool could dynamically filter these by hotness and perhaps by other things. That said it makes sense to also expose this at the more basic level where we just include the hotness info with each optimization remark. For example, in D22694, the clang flag was pretty useful to measure the overhead of the additional analyses required to include hotness. (Without the flag we don't even run the analyses.) For the record, Hal has already expressed support for the idea of this patch on IRC. Differential Revision: https://reviews.llvm.org/D23284 llvm-svn: 281276
Diffstat (limited to 'clang/lib/CodeGen/CodeGenAction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenAction.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp
index dd803909f03..6a3b9c6efbd 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -179,6 +179,7 @@ namespace clang {
Ctx.getDiagnosticHandler();
void *OldDiagnosticContext = Ctx.getDiagnosticContext();
Ctx.setDiagnosticHandler(DiagnosticHandler, this);
+ Ctx.setDiagnosticHotnessRequested(CodeGenOpts.DiagnosticsWithHotness);
// Link LinkModule into this module if present, preserving its validity.
for (auto &I : LinkModules) {
@@ -511,9 +512,16 @@ void BackendConsumer::EmitOptimizationMessage(
FullSourceLoc Loc = getBestLocationFromDebugLoc(D, BadDebugInfo, Filename,
Line, Column);
+ std::string Msg;
+ raw_string_ostream MsgStream(Msg);
+ MsgStream << D.getMsg().str();
+
+ if (D.getHotness())
+ MsgStream << " (hotness: " << *D.getHotness() << ")";
+
Diags.Report(Loc, DiagID)
<< AddFlagValue(D.getPassName() ? D.getPassName() : "")
- << D.getMsg().str();
+ << MsgStream.str();
if (BadDebugInfo)
// If we were not able to translate the file:line:col information
OpenPOWER on IntegriCloud