[PATCH] D50286: avoid creating conditional cleanup blocks that contain only @llvm.lifetime.end calls

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 3 17:07:52 PDT 2018

rsmith created this revision.
rsmith added a reviewer: rjmccall.

When a non-extended temporary object is created in a conditional branch, the lifetime of that temporary ends outside the conditional (at the end of the full-expression). If we're inserting lifetime markers, this means we can end up generating

  if (some_cond) {
  // ...
  if (some_cond) {

for a full-expression containing a subexpression of the form `some_cond ? Tmp().x : 0`. This patch moves the lifetime start for such a temporary out of the conditional branch so that we don't need to generate an additional basic block to hold the lifetime end marker.

This is disabled if we want precise lifetime markers (for asan's stack-use-after-scope checks) or of the temporary has a non-trivial destructor (in which case we'd generate an extra basic block anyway to hold the destructor call).

  rC Clang



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50286.159136.patch
Type: text/x-patch
Size: 8576 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180804/2426e5dc/attachment.bin>

More information about the cfe-commits mailing list