yvvan created this revision.

Reproduced while building llvm with clang-cl.
I have trained profdata file. When I tried to use it I got crash complaining of 
nullptr casted inside visitor.

https://reviews.llvm.org/D34680

Files:
  lib/CodeGen/CodeGenPGO.cpp


Index: lib/CodeGen/CodeGenPGO.cpp
===================================================================
--- lib/CodeGen/CodeGenPGO.cpp
+++ lib/CodeGen/CodeGenPGO.cpp
@@ -249,9 +249,12 @@
 
   void VisitFunctionDecl(const FunctionDecl *D) {
     // Counter tracks entry to the function body.
-    uint64_t BodyCount = setCount(PGO.getRegionCount(D->getBody()));
-    CountMap[D->getBody()] = BodyCount;
-    Visit(D->getBody());
+    auto* body = D->getBody();
+    if (!body)
+      return;
+    uint64_t BodyCount = setCount(PGO.getRegionCount(body));
+    CountMap[body] = BodyCount;
+    Visit(body);
   }
 
   // Skip lambda expressions. We visit these as FunctionDecls when we're


Index: lib/CodeGen/CodeGenPGO.cpp
===================================================================
--- lib/CodeGen/CodeGenPGO.cpp
+++ lib/CodeGen/CodeGenPGO.cpp
@@ -249,9 +249,12 @@
 
   void VisitFunctionDecl(const FunctionDecl *D) {
     // Counter tracks entry to the function body.
-    uint64_t BodyCount = setCount(PGO.getRegionCount(D->getBody()));
-    CountMap[D->getBody()] = BodyCount;
-    Visit(D->getBody());
+    auto* body = D->getBody();
+    if (!body)
+      return;
+    uint64_t BodyCount = setCount(PGO.getRegionCount(body));
+    CountMap[body] = BodyCount;
+    Visit(body);
   }
 
   // Skip lambda expressions. We visit these as FunctionDecls when we're
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to