[PATCH] D34680: Fix clang-cl build -fprofile-instr-use flag

Ivan Donchevskii via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 27 04:16:10 PDT 2017


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34680.104132.patch
Type: text/x-patch
Size: 683 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170627/42ace93e/attachment.bin>


More information about the cfe-commits mailing list