[PATCH] D107989: Fix bad assert in print-changed code

Jamie Schmeiser via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 12 12:00:27 PDT 2021


jamieschmeiser created this revision.
jamieschmeiser added a reviewer: aeubanks.
Herald added a subscriber: hiraditya.
jamieschmeiser requested review of this revision.
Herald added a project: LLVM.

The assertion that both functions were not missing was incorrect and would
fail when one of the functions was missing.  Fixed it and moved the
assertion earlier to check the input parameters to better capture
first-failure.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107989

Files:
  llvm/lib/Passes/StandardInstrumentations.cpp


Index: llvm/lib/Passes/StandardInstrumentations.cpp
===================================================================
--- llvm/lib/Passes/StandardInstrumentations.cpp
+++ llvm/lib/Passes/StandardInstrumentations.cpp
@@ -647,13 +647,12 @@
 
   ChangedIRData::report(
       Before, After, [&](const ChangedFuncData *B, const ChangedFuncData *A) {
+        assert((B || A) && "Both functions cannot be missing.");
         ChangedFuncData Missing;
         if (!B)
           B = &Missing;
         else if (!A)
           A = &Missing;
-        assert(B != &Missing && A != &Missing &&
-               "Both functions cannot be missing.");
         handleFunctionCompare(Name, Prefix, PassID, true, *B, *A);
       });
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107989.366061.patch
Type: text/x-patch
Size: 723 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210812/0d15f5ce/attachment.bin>


More information about the llvm-commits mailing list