This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo][LoopStrengthReduction] Prevent attempts to translate long SCEV expressions
ClosedPublic

Authored by chrisjackson on Sep 27 2021, 8:19 AM.

Details

Summary

As reported in pr51656 scev-based salvaging can use excessive resources to the point of crashing when large SCEV expressions are encountered. This patch places a limit on the length of expression for which an attempt to translate will be made.

Diff Detail

Event Timeline

chrisjackson created this revision.Sep 27 2021, 8:19 AM
chrisjackson requested review of this revision.Sep 27 2021, 8:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 27 2021, 8:19 AM

Applied clang-format.

Applied clang-format.

Looks like this didn't actually apply, the revision is showing this update as having applied no changes and the formatting issues are still present.

I also suppose it would be good if we could have the expression limit put as a variable with an explanatory comment, rather than a magic number. Other than that, this change LGTM.

Applied format.

Added a comment explaining the choice of maximum expression size.

Could the 64 be moved to a variable? Something similar to MaxIVUsers in the same file would be ideal - a static const variable at the top of the file with a comment explaining what it is used for.

Moved the expresion limit to a const.

Just a few nits inline. I otherwise defer to @StephenTozer's reviewing.

llvm/test/Transforms/LoopStrengthReduce/pr51656.ll
3

Is there a reason for this test to be X86 specific?

79

nit: I think the convention is to use a single ; for FileCheck directive comments.

Updated based on @Orlando 's comments

StephenTozer accepted this revision.Oct 5 2021, 4:47 AM

Two nits, other than that LGTM.

llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
142
llvm/test/Transforms/LoopStrengthReduce/pr51656.ll
77

Just for the sake of resiliency, it would be better to replace the metadata references here with variable matches. So essentially replace !20 with ![[VAR_E:[0-9]+]], and then insert another check directive ![[VAR_E]] = !DILocalVariable(name: "e" below.

This revision is now accepted and ready to land.Oct 5 2021, 4:47 AM

Updated based on final review comments.