diff options
-rw-r--r-- | lib/Core/StatsTracker.cpp | 9 | ||||
-rw-r--r-- | test/Feature/SourceMapping.c | 8 |
2 files changed, 13 insertions, 4 deletions
diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp index e664d1ae..54dd0df8 100644 --- a/lib/Core/StatsTracker.cpp +++ b/lib/Core/StatsTracker.cpp @@ -501,6 +501,15 @@ void StatsTracker::writeIStats() { for (Module::iterator fnIt = m->begin(), fn_ie = m->end(); fnIt != fn_ie; ++fnIt) { if (!fnIt->isDeclaration()) { + // Always try to write the filename before the function name, as otherwise + // KCachegrind can create two entries for the function, one with an + // unnamed file and one without. + const InstructionInfo &ii = executor.kmodule->infos->getFunctionInfo(fnIt); + if (ii.file != sourceFile) { + of << "fl=" << ii.file << "\n"; + sourceFile = ii.file; + } + of << "fn=" << fnIt->getName().str() << "\n"; for (Function::iterator bbIt = fnIt->begin(), bb_ie = fnIt->end(); bbIt != bb_ie; ++bbIt) { diff --git a/test/Feature/SourceMapping.c b/test/Feature/SourceMapping.c index 0462ba0b..9835d701 100644 --- a/test/Feature/SourceMapping.c +++ b/test/Feature/SourceMapping.c @@ -9,13 +9,14 @@ // CHECK: positions: instr line // CHECK: ob={{.*}}/SourceMapping.c{{.*}}/assembly.ll -// Assuming the compiler doesn't reorder things, f0 should be first. -// CHECK: fn=f0 +// Assuming the compiler doesn't reorder things, f0 should be first, and it +// should immediately follow the first file name marker. +// CHECK: fl={{.*}}/SourceMapping.c +// CHECK-NEXT: fn=f0 // Ensure we have a known position for the first instruction (instr and line // should be non-zero). -// CHECK-NEXT: fl={{.*}}/SourceMapping.c // CHECK-NEXT: {{[1-9][0-9]*}} {{[1-9][0-9]*}} @@ -36,7 +37,6 @@ - // KEEP THIS AS LINE 40 int f0(int a, int b) { |