From 64f29e2dd12905b2d71e6f4b3d390c3df4cb0a80 Mon Sep 17 00:00:00 2001 From: Jamie Schmeiser Date: Fri, 13 Aug 2021 10:53:24 -0400 Subject: [PATCH] Fix bad assert in print-changed code Summary: 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. Added lit test. Author: Jamie Schmeiser Reviewed By: aeubanks (Arthur Eubanks) Differential Revision: https://reviews.llvm.org/D107989 --- llvm/lib/Passes/StandardInstrumentations.cpp | 3 +-- llvm/test/Other/ChangePrinters/print-changed-D107989.ll | 13 +++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 llvm/test/Other/ChangePrinters/print-changed-D107989.ll diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp index 5a48923..fbe4f25 100644 --- a/llvm/lib/Passes/StandardInstrumentations.cpp +++ b/llvm/lib/Passes/StandardInstrumentations.cpp @@ -647,13 +647,12 @@ void ChangedIRComparer::compare(Any IR, StringRef Prefix, StringRef PassID, 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); }); } diff --git a/llvm/test/Other/ChangePrinters/print-changed-D107989.ll b/llvm/test/Other/ChangePrinters/print-changed-D107989.ll new file mode 100644 index 0000000..9e56e43 --- /dev/null +++ b/llvm/test/Other/ChangePrinters/print-changed-D107989.ll @@ -0,0 +1,13 @@ +; D107989 This triggered an assert + +; RUN: opt -passes=globalopt < %s -disable-output -print-changed=diff-quiet + +define signext i32 @main() { +entry: + ret i32 0 +} + +define internal void @f() { +entry: + ret void +} -- 2.7.4