This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Make limit on fixpoint-algorithm iterations proportional to size of CFG.
ClosedPublic

Authored by ymandel on May 24 2022, 12:11 PM.

Details

Summary

Currently, the maximum number of iterations of the loop for finding the fixpoint
of the dataflow analysis is set at 2^16. When things go wrong in an analysis,
this can be far too large. This patch changes the limit to be proportional to
the size of the CFG, which will generally be far smaller than 2^16 (while still
maintaining 2^16 as the absolute limit).

Diff Detail

Event Timeline

ymandel created this revision.May 24 2022, 12:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2022, 12:11 PM
ymandel requested review of this revision.May 24 2022, 12:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2022, 12:11 PM
gribozavr2 added inline comments.May 24 2022, 12:19 PM
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
339

Could you cap the computed number at 1<<16 still?

or min(MaxAverageVisitsPerBlock * BlockStates.size(), 2^16);

An alternative approach is to maintain separate counters for back edges and bail if those reach a certain limit. But this global limit is way simpler, so it looks good to me.

ymandel updated this revision to Diff 431761.May 24 2022, 12:34 PM

Reinstated absolute limit of 2^16.

ymandel edited the summary of this revision. (Show Details)May 24 2022, 12:35 PM
ymandel marked an inline comment as done.

or min(MaxAverageVisitsPerBlock * BlockStates.size(), 2^16);

Good idea, thx.

An alternative approach is to maintain separate counters for back edges and bail if those reach a certain limit. But this global limit is way simpler, so it looks good to me.

Agreed -- this seems a better approach. Added as a FIXME. We should revisit...

xazax.hun accepted this revision.May 24 2022, 12:36 PM
This revision is now accepted and ready to land.May 24 2022, 12:36 PM
This revision was landed with ongoing or failed builds.May 24 2022, 1:20 PM
This revision was automatically updated to reflect the committed changes.