[PATCH] D32406: [Coverage][Windows] Null pointer dereference in CodeGenPGO::skipRegionMappingForDecl (fixes PR32761)

Adam Folwarczny via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 24 13:24:46 PDT 2017


adamf updated this revision to Diff 96454.
adamf added a comment.

Thanks for your comments!

Updated test case according to @vsk comment about test case reduction.

@rnk, your compilation command probably exposes another issue (with your compilation command the test still failure). I don't have time to analyze it now.

I don't have write access to svn so if you think this change is ok please commit it.


https://reviews.llvm.org/D32406

Files:
  lib/CodeGen/CodeGenPGO.cpp
  lib/CodeGen/CodeGenPGO.h
  test/CoverageMapping/empty-destructor.cpp


Index: test/CoverageMapping/empty-destructor.cpp
===================================================================
--- test/CoverageMapping/empty-destructor.cpp
+++ test/CoverageMapping/empty-destructor.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -cc1 -triple i686-pc-windows-msvc19.0.0 -emit-obj -fprofile-instrument=clang -fdelayed-template-parsing -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name empty-destructor.cpp -o - %s
+
+struct A {
+  virtual ~A();
+};
+
+void PR32761() {
+  A a;
+}
Index: lib/CodeGen/CodeGenPGO.h
===================================================================
--- lib/CodeGen/CodeGenPGO.h
+++ lib/CodeGen/CodeGenPGO.h
@@ -40,14 +40,11 @@
   std::unique_ptr<llvm::InstrProfRecord> ProfRecord;
   std::vector<uint64_t> RegionCounts;
   uint64_t CurrentRegionCount;
-  /// \brief A flag that is set to true when this function doesn't need
-  /// to have coverage mapping data.
-  bool SkipCoverageMapping;
 
 public:
   CodeGenPGO(CodeGenModule &CGM)
       : CGM(CGM), NumValueSites({{0}}), NumRegionCounters(0),
-        FunctionHash(0), CurrentRegionCount(0), SkipCoverageMapping(false) {}
+        FunctionHash(0), CurrentRegionCount(0) {}
 
   /// Whether or not we have PGO region data for the current function. This is
   /// false both when we have no data at all and when our data has been
Index: lib/CodeGen/CodeGenPGO.cpp
===================================================================
--- lib/CodeGen/CodeGenPGO.cpp
+++ lib/CodeGen/CodeGenPGO.cpp
@@ -666,7 +666,7 @@
 }
 
 bool CodeGenPGO::skipRegionMappingForDecl(const Decl *D) {
-  if (SkipCoverageMapping)
+  if (!D->hasBody())
     return true;
 
   // Don't map the functions in system headers.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32406.96454.patch
Type: text/x-patch
Size: 1722 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170424/b28bb4b3/attachment.bin>


More information about the cfe-commits mailing list