[llvm] 478ad94 - [GCOV] Skip artificial functions from being emitted
Alexandre Ganea via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 15 11:23:31 PST 2019
Author: Alexandre Ganea
Date: 2019-11-15T14:23:11-05:00
New Revision: 478ad94c8e1457a707f41fa64cf0967b219d2806
URL: https://github.com/llvm/llvm-project/commit/478ad94c8e1457a707f41fa64cf0967b219d2806
DIFF: https://github.com/llvm/llvm-project/commit/478ad94c8e1457a707f41fa64cf0967b219d2806.diff
LOG: [GCOV] Skip artificial functions from being emitted
This is a patch to support D66328, which was reverted until this lands.
Enable a compiler-rt test that used to fail previously with D66328.
Differential Revision: https://reviews.llvm.org/D67283
Added:
Modified:
compiler-rt/test/asan/TestCases/asan_and_llvm_coverage_test.cpp
llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
Removed:
################################################################################
diff --git a/compiler-rt/test/asan/TestCases/asan_and_llvm_coverage_test.cpp b/compiler-rt/test/asan/TestCases/asan_and_llvm_coverage_test.cpp
index 2ba5a42d1b7b..776684fd8045 100644
--- a/compiler-rt/test/asan/TestCases/asan_and_llvm_coverage_test.cpp
+++ b/compiler-rt/test/asan/TestCases/asan_and_llvm_coverage_test.cpp
@@ -1,9 +1,6 @@
// RUN: %clangxx_asan -coverage -O0 %s -o %t
// RUN: %env_asan_opts=check_initialization_order=1 %run %t 2>&1 | FileCheck %s
-// We don't really support running tests using profile runtime on Windows.
-// UNSUPPORTED: windows-msvc
-
#include <stdio.h>
int foo() { return 1; }
int XXX = foo();
diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
index bda32878400c..bf3e4ed3e31f 100644
--- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -714,7 +714,10 @@ void GCOVProfiler::emitProfileNotes() {
// to have a counter for the function definition.
uint32_t Line = SP->getLine();
auto Filename = getFilename(SP);
- Func.getBlock(&EntryBlock).getFile(Filename).addLine(Line);
+
+ // Artificial functions such as global initializers
+ if (!SP->isArtificial())
+ Func.getBlock(&EntryBlock).getFile(Filename).addLine(Line);
for (auto &BB : F) {
GCOVBlock &Block = Func.getBlock(&BB);
More information about the llvm-commits
mailing list