This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Improve large stack frame diagnostic
ClosedPublic

Authored by paulkirth on Oct 21 2022, 12:49 PM.

Details

Summary

Add statistics about how much memory is used, in variables, spills, and
unsafestack.

Issue #58168 describes some of the difficulty diagnosing stack size issues
identified by -Wframe-larger-than. D135488 addresses some of those issues by
giving developers a method to view the stack layout and thereby understand
where and how stack memory is used.

However, that solution requires an additional pass, when a short summary about
how the compiler has allocated stack memory can inform developers about where
they should investigate. When they need the complete context, D135488 can
provide them with a more comprehensive set of diagnostics.

Diff Detail

Event Timeline

paulkirth created this revision.Oct 21 2022, 12:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 21 2022, 12:49 PM
paulkirth requested review of this revision.Oct 21 2022, 12:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 21 2022, 12:49 PM

Cool! Do you have an example of the diagnostic? Hard to visualize from the modified CHECK lines.

w/o SafeStack:

warning: stack frame size (100) exceeds limit (80) in function 'warn'
20/100 (20%) spills, 80/100 (80.00%) variables

w/ SafeStack

warning: stack frame size (100) exceeds limit (80) in function 'warn_safestack'
20/100 (20%) spills, 80/100 (80.00%) variables, 60/100 (60.00%) UnsafeStack

The lines w/ the % are the new additions. Looking, though it should probably just read unsafe stack instead of UnsafeStack

paulkirth updated this revision to Diff 469843.Oct 21 2022, 6:32 PM

Revise diagnostic message

This revision is now accepted and ready to land.Oct 24 2022, 11:18 AM

Those are good suggestions, so thanks for pointing those out. I'll upload a new version with those fixes when I get a chance.

paulkirth updated this revision to Diff 470327.Oct 24 2022, 5:14 PM

Address comments

  • use better casting discipline
  • replace auto w/ concrete types
  • update use of llvm::dbgs()
  • change "UnsafeStack" to "unsafe stack" in tests
  • update bracing to match LLVM sytle guide
nickdesaulniers accepted this revision.Oct 25 2022, 9:48 AM
This revision was landed with ongoing or failed builds.Oct 26 2022, 5:51 PM
This revision was automatically updated to reflect the committed changes.
MaskRay added a subscriber: MaskRay.May 9 2023, 1:27 PM
MaskRay added inline comments.
llvm/lib/CodeGen/PrologEpilogInserter.cpp
305

Note: we should not emit messages to dbg() in non-assertion builds.
This was fixed by 945f6e65be0d20b3446e7c1537c64151de618af4

llvm/test/CodeGen/ARM/warn-stack.ll
27

We should not test dbgs messages. This was fixed by b97527f14459ef89bc94d652fcf94ba91b61b34c.