This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Optimize case of degenerate `do-while` loops.
AbandonedPublic

Authored by ymandel on May 1 2023, 7:11 AM.

Details

Summary

In general, the iteration algorithm would be closer to optimal if it stabilized
loop bodies before visiting their successors. There is a special case of this
situation which is particularly problematic in practice: degenerate loops of the
form do { ... } while(0), which are used in some macro definitions, for
syntactic reasons. When a series of these loops appear in sequence, as in uses
of logging or tracing macro, the resulting iteration can become exponential in
running time.

This patch is a short term fix for the particular degenerate case. Long-term, we
intend to implement an iteration order (like Bourdoncle's WTO) which takes loop
stabilization into account.

Issue #60273.

Diff Detail

Event Timeline

ymandel created this revision.May 1 2023, 7:11 AM
Herald added a project: Restricted Project. · View Herald Transcript
ymandel requested review of this revision.May 1 2023, 7:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 1 2023, 7:11 AM
ymandel abandoned this revision.May 1 2023, 8:04 AM

This approach is buggy. Pulling back until I have a proper fix.