Skip to content

Commit

Permalink
Fix bad assert in print-changed code
Browse files Browse the repository at this point in the history
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 <schmeise@ca.ibm.com>
Reviewed By: aeubanks (Arthur Eubanks)
Differential Revision: https://reviews.llvm.org/D107989
  • Loading branch information
jamieschmeiser committed Aug 13, 2021
1 parent 0dc6b59 commit 64f29e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 1 addition & 2 deletions llvm/lib/Passes/StandardInstrumentations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand Down
13 changes: 13 additions & 0 deletions llvm/test/Other/ChangePrinters/print-changed-D107989.ll
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 64f29e2

Please sign in to comment.