This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Fix symbol simplification assertion failure
ClosedPublic

Authored by martong on May 24 2022, 2:47 AM.

Details

Summary

Fixes https://github.com/llvm/llvm-project/issues/55546

The assertion mentioned in the issue is triggered because an
inconsistency is formed in the Sym->Class and Class->Sym relations. A
simpler but similar inconsistency is demonstrated here:
https://reviews.llvm.org/D114887 .

Previously in removeMember, we didn't remove the old symbol's
Sym->Class relation. Back then, we explained it with the following two
bullet points:

  1. This way constraints for the old symbol can still be found via it's

equivalence class that it used to be the member of.

  1. Performance and resource reasons. We can spare one removal and thus one

additional tree in the forest of ClassMap.

This patch do remove the old symbol's Sym->Class relation in order to
keep the Sym->Class relation consistent with the Class->Sym relations.
Point 2) above has negligible performance impact, empirical measurements
do not show any noticeable difference in the run-time. Point 1) above
seems to be a not well justified statement. This is because we cannot
create a new symbol that would be equal to the old symbol after the
simplification had happened. The reason for this is that the SValBuilder
uses the available constant constraints for each sub-symbol.

Diff Detail

Event Timeline

martong created this revision.May 24 2022, 2:47 AM
Herald added a project: Restricted Project. · View Herald Transcript
martong requested review of this revision.May 24 2022, 2:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2022, 2:47 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
martong added inline comments.May 24 2022, 2:48 AM
clang/test/Analysis/symbol-simplification-assertion.c
16–19

TODO remove.

martong added a comment.EditedMay 24 2022, 3:06 AM

Point 2) above has negligible performance impact, empirical measurements do not show any noticeable difference in the run-time.

Attaching the measurement results that show the run-time difference is not noticeable, or rather it is within the margin of measurement error.

Point 2) above has negligible performance impact, empirical measurements do not show any noticeable difference in the run-time.

Attaching the measurement results that show the run-time difference is not noticeable, or rather it is within the margin of measurement error.

Can C++ projects behave differently?

Please add the Fixes #55546 comment into the commit message, to let GitHub recognize this.

clang/test/Analysis/symbol-simplification-assertion.c
28

Is this statement still reachable? Demonstrate it by using the clang_analyzer_warnIfReached().

martong updated this revision to Diff 431635.May 24 2022, 3:39 AM
martong marked an inline comment as done.
  • Add clang_analyzer_warnIfReached() to the test and remove unused debug function decls
clang/test/Analysis/symbol-simplification-assertion.c
28

Ok, I've added that.

steakhal accepted this revision.May 24 2022, 5:24 AM
This revision is now accepted and ready to land.May 24 2022, 5:24 AM
This revision was landed with ongoing or failed builds.May 25 2022, 2:02 AM
This revision was automatically updated to reflect the committed changes.