From ff114dae5afadfc95ab8f670402ba8f141d52de2 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Thu, 5 Jun 2014 04:31:43 +0000 Subject: Fix coverage for files with global constructors again. Adds a testcase to the commit from r206671, as requested by David Blaikie. llvm-svn: 210239 --- llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'llvm/lib') diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 583a0944689..cfeb62eb1f9 100644 --- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -457,8 +457,13 @@ static bool functionHasLines(Function *F) { // Debug intrinsic locations correspond to the location of the // declaration, not necessarily any statements or expressions. if (isa(I)) continue; + const DebugLoc &Loc = I->getDebugLoc(); if (Loc.isUnknown()) continue; + + // Artificial lines such as calls to the global constructors. + if (Loc.getLine() == 0) continue; + return true; } } @@ -521,8 +526,13 @@ void GCOVProfiler::emitProfileNotes() { // Debug intrinsic locations correspond to the location of the // declaration, not necessarily any statements or expressions. if (isa(I)) continue; + const DebugLoc &Loc = I->getDebugLoc(); if (Loc.isUnknown()) continue; + + // Artificial lines such as calls to the global constructors. + if (Loc.getLine() == 0) continue; + if (Line == Loc.getLine()) continue; Line = Loc.getLine(); if (SP != getDISubprogram(Loc.getScope(*Ctx))) continue; -- cgit v1.2.3