[CodeGen] Eagerly emit lifetime.end markers for calls
authorGeorge Burgess IV <george.burgess.iv@gmail.com>
Sat, 10 Mar 2018 23:06:31 +0000 (23:06 +0000)
committerGeorge Burgess IV <george.burgess.iv@gmail.com>
Sat, 10 Mar 2018 23:06:31 +0000 (23:06 +0000)
commit4deb75d2e8578f75bfbce8328323620222377335
tree7ff8fed2259905a4d63c8637c4c417ab6f84f93a
parent4fb6f8189f5283d450c2fbab35a3878961f84965
[CodeGen] Eagerly emit lifetime.end markers for calls

In C, we'll wait until the end of the scope to clean up aggregate
temporaries used for returns from calls. This means in cases like:

{
  // Assuming that `Bar` is large enough to warrant indirect returns
  struct Bar b = {};
  b = foo(&b);
  b = foo(&b);
  b = foo(&b);
  b = foo(&b);
}

...We'll allocate space for 5 Bars on the stack (`b`, and 4
temporaries). This becomes painful in things like large switch
statements.

If cleaning up sooner is trivial, we should do it.

llvm-svn: 327229
clang/lib/CodeGen/CGExprAgg.cpp
clang/test/CodeGen/aggregate-assign-call.c [new file with mode: 0644]