[llvm] r281589 - [llvm-cov] Hide instantiation views for unexecuted functions
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 14 23:44:52 PDT 2016
Author: vedantk
Date: Thu Sep 15 01:44:51 2016
New Revision: 281589
URL: http://llvm.org/viewvc/llvm-project?rev=281589&view=rev
Log:
[llvm-cov] Hide instantiation views for unexecuted functions
Copying in the full text of the function doesn't help at all when we
already know that it's never executed. Just say that it's unexecuted --
the relevant source text has already been printed.
Added:
llvm/trunk/test/tools/llvm-cov/Inputs/hideUnexecutedSubviews.proftext
llvm/trunk/test/tools/llvm-cov/hideUnexecutedSubviews.test
Modified:
llvm/trunk/tools/llvm-cov/CodeCoverage.cpp
llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp
llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp
Added: llvm/trunk/test/tools/llvm-cov/Inputs/hideUnexecutedSubviews.proftext
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/Inputs/hideUnexecutedSubviews.proftext?rev=281589&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/Inputs/hideUnexecutedSubviews.proftext (added)
+++ llvm/trunk/test/tools/llvm-cov/Inputs/hideUnexecutedSubviews.proftext Thu Sep 15 01:44:51 2016
@@ -0,0 +1,16 @@
+_Z4funcIbEiT_
+10
+2
+0
+0
+
+_Z4funcIiEiT_
+10
+2
+0
+0
+
+main
+0
+1
+0
Added: llvm/trunk/test/tools/llvm-cov/hideUnexecutedSubviews.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/hideUnexecutedSubviews.test?rev=281589&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/hideUnexecutedSubviews.test (added)
+++ llvm/trunk/test/tools/llvm-cov/hideUnexecutedSubviews.test Thu Sep 15 01:44:51 2016
@@ -0,0 +1,10 @@
+RUN: llvm-profdata merge %S/Inputs/hideUnexecutedSubviews.proftext -o %t.profdata
+
+RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %t.profdata -filename-equivalence %S/showTemplateInstantiations.cpp | FileCheck %s
+
+RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %t.profdata -format html -o %t.html.dir -filename-equivalence %S/showTemplateInstantiations.cpp
+RUN: FileCheck %s -input-file %t.html.dir/coverage/tmp/showTemplateInstantiations.cpp.html
+
+CHECK: Unexecuted instantiation: _Z4funcIbEiT_
+CHECK: Unexecuted instantiation: _Z4funcIiEiT_
+CHECK-NOT: Unexecuted instantiation
Modified: llvm/trunk/tools/llvm-cov/CodeCoverage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CodeCoverage.cpp?rev=281589&r1=281588&r2=281589&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CodeCoverage.cpp (original)
+++ llvm/trunk/tools/llvm-cov/CodeCoverage.cpp Thu Sep 15 01:44:51 2016
@@ -234,21 +234,23 @@ CodeCoverageTool::createSourceFileView(S
attachExpansionSubViews(*View, Expansions, Coverage);
for (const auto *Function : Coverage.getInstantiations(SourceFile)) {
- auto SubViewCoverage = Coverage.getCoverageForFunction(*Function);
- auto SubViewExpansions = SubViewCoverage.getExpansions();
- auto SubView = SourceCoverageView::create(
- getSymbolForHumans(Function->Name), SourceBuffer.get(), ViewOpts,
- std::move(SubViewCoverage));
- attachExpansionSubViews(*SubView, SubViewExpansions, Coverage);
+ std::unique_ptr<SourceCoverageView> SubView{nullptr};
- if (SubView) {
- unsigned FileID = Function->CountedRegions.front().FileID;
- unsigned Line = 0;
- for (const auto &CR : Function->CountedRegions)
- if (CR.FileID == FileID)
- Line = std::max(CR.LineEnd, Line);
- View->addInstantiation(Function->Name, Line, std::move(SubView));
+ if (Function->ExecutionCount > 0) {
+ auto SubViewCoverage = Coverage.getCoverageForFunction(*Function);
+ auto SubViewExpansions = SubViewCoverage.getExpansions();
+ SubView = SourceCoverageView::create(
+ getSymbolForHumans(Function->Name), SourceBuffer.get(), ViewOpts,
+ std::move(SubViewCoverage));
+ attachExpansionSubViews(*SubView, SubViewExpansions, Coverage);
}
+
+ unsigned FileID = Function->CountedRegions.front().FileID;
+ unsigned Line = 0;
+ for (const auto &CR : Function->CountedRegions)
+ if (CR.FileID == FileID)
+ Line = std::max(CR.LineEnd, Line);
+ View->addInstantiation(Function->Name, Line, std::move(SubView));
}
return View;
}
Modified: llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp?rev=281589&r1=281588&r2=281589&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp Thu Sep 15 01:44:51 2016
@@ -584,7 +584,15 @@ void SourceCoverageViewHTML::renderInsta
InstantiationView &ISV,
unsigned ViewDepth) {
OS << BeginExpansionDiv;
- ISV.View->print(OS, /*WholeFile=*/false, /*ShowSourceName=*/true, ViewDepth);
+ if (!ISV.View)
+ OS << BeginSourceNameDiv
+ << tag("pre",
+ escape("Unexecuted instantiation: " + ISV.FunctionName.str(),
+ getOptions()))
+ << EndSourceNameDiv;
+ else
+ ISV.View->print(OS, /*WholeFile=*/false, /*ShowSourceName=*/true,
+ ViewDepth);
OS << EndExpansionDiv;
}
Modified: llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp?rev=281589&r1=281588&r2=281589&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp Thu Sep 15 01:44:51 2016
@@ -215,7 +215,12 @@ void SourceCoverageViewText::renderInsta
unsigned ViewDepth) {
renderLinePrefix(OS, ViewDepth);
OS << ' ';
- ISV.View->print(OS, /*WholeFile=*/false, /*ShowSourceName=*/true, ViewDepth);
+ if (!ISV.View)
+ getOptions().colored_ostream(OS, raw_ostream::RED)
+ << "Unexecuted instantiation: " << ISV.FunctionName << "\n";
+ else
+ ISV.View->print(OS, /*WholeFile=*/false, /*ShowSourceName=*/true,
+ ViewDepth);
}
void SourceCoverageViewText::renderTitle(raw_ostream &OS, StringRef Title) {
More information about the llvm-commits
mailing list