This is an archive of the discontinued LLVM Phabricator instance.

[Coverage] Fix an assertion failure if the definition of an unused function spans multiple files.
ClosedPublic

Authored by ikudrin on Jun 4 2016, 4:36 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

ikudrin updated this revision to Diff 59648.Jun 4 2016, 4:36 AM
ikudrin retitled this revision from to [Coverage] Fix an assertion failure if the definition of an unused function spans multiple files..
ikudrin updated this object.
ikudrin added reviewers: vsk, bogner, davidxl.
ikudrin set the repository for this revision to rL LLVM.
ikudrin added a subscriber: cfe-commits.
vsk edited edge metadata.Jun 6 2016, 2:36 PM

Thanks, this looks good overall. I just have a few minor comments.

lib/CodeGen/CoverageMappingGen.cpp
329 ↗(On Diff #59648)

SM.getFileID() can be expensive if there's a miss in the SourceManager's cache. Seeing as End isn't updated in this loop, it might be profitable/cleaner to maintain dedicated StartFileID and EndFileID variables. Wdyt?

331 ↗(On Diff #59648)

Please add a string here, e.g "Declaration start loc not nested within a known region".

336 ↗(On Diff #59648)

^ ditto.

ikudrin updated this revision to Diff 59806.Jun 6 2016, 5:05 PM
ikudrin updated this object.
ikudrin edited edge metadata.
ikudrin removed rL LLVM as the repository for this revision.
  • Use StartFileID and EndFileID variables to eliminate redundant calls to SM.getFileID().
  • Add comment strings to asserts.
vsk accepted this revision.Jun 6 2016, 5:17 PM
vsk edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Jun 6 2016, 5:17 PM
This revision was automatically updated to reflect the committed changes.
chapuni added a subscriber: chapuni.Jun 6 2016, 9:27 PM

FYI :)

--- a/clang/test/CoverageMapping/unused_function.cpp
+++ b/clang/test/CoverageMapping/unused_function.cpp
@@ -3,34 +3,34 @@
 #define START_SCOPE {
 #define END_SCOPE }

-// CHECK: _Z2f0v:
+// CHECK: {{_Z2f0v|\?f0@@YAXXZ}}:
 // CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:20 = 0
 inline void f0() {}

-// CHECK: _Z2f1v:
+// CHECK: {{_Z2f1v|\?f1@@YAXXZ}}:
 // CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:31 = 0
 inline void f1() START_SCOPE }

-// CHECK: _Z2f2v:
+// CHECK: {{_Z2f2v|\?f2@@YAXXZ}}:
 // CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:29 = 0
 inline void f2() { END_SCOPE

-// CHECK: _Z2f3v:
+// CHECK: {{_Z2f3v|\?f3@@YAXXZ}}:
 // CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:39 = 0
 inline void f3() START_SCOPE END_SCOPE

-// CHECK: _Z2f4v:
+// CHECK: {{_Z2f4v|\?f4@@YAXXZ}}:
 // CHECK-NEXT: File 0, [[@LINE+2]]:10 -> [[@LINE+3]]:2 = 0
 inline void f4()
 #include "Inputs/starts_a_scope_only"
 }

-// CHECK: _Z2f5v:
+// CHECK: {{_Z2f5v|\?f5@@YAXXZ}}:
 // CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+2]]:36 = 0
 inline void f5() {
 #include "Inputs/ends_a_scope_only"

-// CHECK: _Z2f6v:
+// CHECK: {{_Z2f6v|\?f6@@YAXXZ}}:
 // CHECK-NEXT: File 0, [[@LINE+2]]:10 -> [[@LINE+3]]:36 = 0
 inline void f6()
 #include "Inputs/starts_a_scope_only"