[CodeGen] Try to not call a dtor after lifetime.end
authorGeorge Burgess IV <george.burgess.iv@gmail.com>
Sat, 10 Mar 2018 01:11:17 +0000 (01:11 +0000)
committerGeorge Burgess IV <george.burgess.iv@gmail.com>
Sat, 10 Mar 2018 01:11:17 +0000 (01:11 +0000)
commit56e5a2e13e3048fc2ff39029cde406d9f4eb55f3
treee41ed5b67a9cd1437e7a421e4fe985093ccd067d
parentb9abf3d299bd8cf75a3934e4008fd9683f83ae70
[CodeGen] Try to not call a dtor after lifetime.end

If CodeGenFunction::EmitCall is:
- asked to emit a call with an indirectly returned value,
- given an invalid return value slot, and
- told the return value of the function it's calling is unused

then it'll make its own temporary, and add lifetime markers so that the
temporary's lifetime ends immediately after the call.

The early lifetime.end becomes problematic when we need to run a
destructor on the result of the function.

Instead of unconditionally saying that results of all calls are used
here (which would be correct, but would also cause us to never emit
lifetime markers for these temporaries), we just build our own temporary
to pass in when a dtor has to be run.

llvm-svn: 327192
clang/lib/CodeGen/CGExprAgg.cpp
clang/test/CodeGenObjC/arc.m