Skip to content

Commit 478ad94

Browse files
committed
[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
1 parent e06f3e0 commit 478ad94

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

compiler-rt/test/asan/TestCases/asan_and_llvm_coverage_test.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// RUN: %clangxx_asan -coverage -O0 %s -o %t
22
// RUN: %env_asan_opts=check_initialization_order=1 %run %t 2>&1 | FileCheck %s
33

4-
// We don't really support running tests using profile runtime on Windows.
5-
// UNSUPPORTED: windows-msvc
6-
74
#include <stdio.h>
85
int foo() { return 1; }
96
int XXX = foo();

llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,10 @@ void GCOVProfiler::emitProfileNotes() {
714714
// to have a counter for the function definition.
715715
uint32_t Line = SP->getLine();
716716
auto Filename = getFilename(SP);
717-
Func.getBlock(&EntryBlock).getFile(Filename).addLine(Line);
717+
718+
// Artificial functions such as global initializers
719+
if (!SP->isArtificial())
720+
Func.getBlock(&EntryBlock).getFile(Filename).addLine(Line);
718721

719722
for (auto &BB : F) {
720723
GCOVBlock &Block = Func.getBlock(&BB);

0 commit comments

Comments
 (0)