This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Reuse stack space from unused function results
ClosedPublic

Authored by sdmitrouk on May 13 2015, 7:10 AM.

Details

Summary

Space on stack allocated for unused structures returned by functions was unused
even when it's lifetime didn't intersect with lifetime of any other objects that
could use the same space.

The test added also checks for named and auto objects. It seems to make sense
to have this all in one place.

Diff Detail

Repository
rL LLVM

Event Timeline

sdmitrouk updated this revision to Diff 25677.May 13 2015, 7:10 AM
sdmitrouk retitled this revision from to [CodeGen] Reuse stack space from unused function results.
sdmitrouk updated this object.
sdmitrouk edited the test plan for this revision. (Show Details)
sdmitrouk added reviewers: aadg, rnk, rsmith, rjmccall.
sdmitrouk set the repository for this revision to rL LLVM.
sdmitrouk added subscribers: Unknown Object (MLST), asl.
rnk added inline comments.May 13 2015, 11:01 AM
test/CodeGenCXX/stack-reuse.cpp
1 ↗(On Diff #25677)

The IR test doesn't need -O3, just -O1 -disable-llvm-optzns. It's better to keep the test as isolated from LLVM changes as possible.

2 ↗(On Diff #25677)

We should drop the integration test here and assume that LLVM does the right thing when the lifetime markers are right. This test will fail if the ARM backend is compiled out, but the IR test is portable. I'd rather have a test that runs everywhere instead of one that runs sometimes and breaks when LLVM changes a little.

30 ↗(On Diff #25677)

I'd throw in a check for call void @foo_small between the lifetimes.

sdmitrouk updated this revision to Diff 25727.May 13 2015, 1:05 PM

Address inline comments:

  • remove ARM asm checks;
  • add check for function calls between lifetime markers;
  • replace -O3 with -O1 -disable-llvm-optzns.
rnk accepted this revision.May 14 2015, 10:46 AM
rnk edited edge metadata.

lgtm, thanks!

This revision is now accepted and ready to land.May 14 2015, 10:46 AM
This revision was automatically updated to reflect the committed changes.