From: Nick Lewycky Date: Tue, 3 Jun 2014 04:25:36 +0000 (+0000) Subject: Ignore line numbers on debug intrinsics. Add an assert to ensure that we aren't emitt... X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=c69c42240ef96fcde3e6299f5c8f388643b1d840;p=oota-llvm.git Ignore line numbers on debug intrinsics. Add an assert to ensure that we aren't emitting line number zero, the .gcno format uses this to indicate that the next field is a filename. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210068 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 8330a9bc335..1dfe5886804 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -211,6 +211,7 @@ namespace { class GCOVLines : public GCOVRecord { public: void addLine(uint32_t Line) { + assert(Line != 0 && "Line zero is not a valid real line number."); Lines.push_back(Line); } @@ -453,10 +454,10 @@ static bool functionHasLines(Function *F) { for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) { for (BasicBlock::iterator I = BB->begin(), IE = BB->end(); I != IE; ++I) { + if (isa(I)) continue; const DebugLoc &Loc = I->getDebugLoc(); if (Loc.isUnknown()) continue; - if (Loc.getLine() != 0) - return true; + return true; } } return false; @@ -515,6 +516,7 @@ void GCOVProfiler::emitProfileNotes() { uint32_t Line = 0; for (BasicBlock::iterator I = BB->begin(), IE = BB->end(); I != IE; ++I) { + if (isa(I)) continue; const DebugLoc &Loc = I->getDebugLoc(); if (Loc.isUnknown()) continue; if (Line == Loc.getLine()) continue; diff --git a/test/Transforms/GCOVProfiling/linezero.ll b/test/Transforms/GCOVProfiling/linezero.ll new file mode 100644 index 00000000000..e2f83249842 --- /dev/null +++ b/test/Transforms/GCOVProfiling/linezero.ll @@ -0,0 +1,143 @@ +; RUN: sed -e 's@PATTERN@\%T@g' < %s > %t1 +; RUN: opt -insert-gcov-profiling -disable-output < %t1 +; RUN: rm %T/linezero.gcno %t1 +; REQUIRES: shell + +; This is a crash test. + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%struct.vector = type { i8 } + +; Function Attrs: nounwind +define i32 @_Z4testv() #0 { +entry: + %retval = alloca i32, align 4 + %__range = alloca %struct.vector*, align 8 + %ref.tmp = alloca %struct.vector, align 1 + %undef.agg.tmp = alloca %struct.vector, align 1 + %__begin = alloca i8*, align 8 + %__end = alloca i8*, align 8 + %spec = alloca i8, align 1 + call void @llvm.dbg.declare(metadata !{%struct.vector** %__range}, metadata !27), !dbg !30 + br label %0 + +;