[CodeGen] Emit lifetime.ends in both EH and non-EH blocks
authorGeorge Burgess IV <george.burgess.iv@gmail.com>
Thu, 8 Mar 2018 05:32:30 +0000 (05:32 +0000)
committerGeorge Burgess IV <george.burgess.iv@gmail.com>
Thu, 8 Mar 2018 05:32:30 +0000 (05:32 +0000)
commit003be7cbf4a4c95f1cc005ec96cbd1fbf9724391
tree2c0dba5dd7031262d635d6c14c495254ba0eb931
parente465a84f85aae78fb5cce8f8630190fe81727959
[CodeGen] Emit lifetime.ends in both EH and non-EH blocks

Before this, we'd only emit lifetime.ends for these temps in
non-exceptional paths. This potentially made our stack larger than it
needed to be for any code that follows an EH cleanup. e.g. in

```
struct Foo { char cs[32]; };

void escape(void *);

struct Bar { ~Bar() { char cs[64]; escape(cs); } };

Foo getFoo();

void baz() {
  Bar b;
  getFoo();
}
```

baz() would require 96 bytes of stack, since the temporary from getFoo()
only had a lifetime.end on the non-exceptional path.

This also makes us keep hold of the Value* returned by
EmitLifetimeStart, so we don't have to remake it later.

llvm-svn: 326988
clang/lib/CodeGen/CGCall.cpp
clang/test/CodeGenCXX/stack-reuse-exceptions.cpp [new file with mode: 0644]