Go to file
Reid Kleckner 092d065265 Don't assume cleanup emission preserves dominance in expr evaluation
Summary:
Because of the existence branches out of GNU statement expressions, it
is possible that emitting cleanups for a full expression may cause the
new insertion point to not be dominated by the result of the inner
expression. Consider this example:

  struct Foo { Foo(); ~Foo(); int x; };
  int g(Foo, int);
  int f(bool cond) {
    int n = g(Foo(), ({ if (cond) return 0; 42; }));
    return n;
  }

Before this change, result of the call to 'g' did not dominate its use
in the store to 'n'. The early return exit from the statement expression
branches to a shared cleanup block, which ends in a switch between the
fallthrough destination (the assignment to 'n') or the function exit
block.

This change solves the problem by spilling and reloading expression
evaluation results when any of the active cleanups have branches.

I audited the other call sites of enterFullExpression, and they don't
appear to keep and Values live across the site of the cleanup, except in
ARC code. I wasn't able to create a test case for ARC that exhibits this
problem, though.

Reviewers: rjmccall, rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D30590

llvm-svn: 297084
2017-03-06 22:18:34 +00:00
clang Don't assume cleanup emission preserves dominance in expr evaluation 2017-03-06 22:18:34 +00:00
clang-tools-extra Do not display highlights for clang-include-fixer-at-point 2017-03-06 14:49:26 +00:00
compiler-rt [XRay] [compiler-rt] Stub out architectures we don't do arg1 logging on. 2017-03-06 08:26:21 +00:00
debuginfo-tests New round of fixes for "Always compile debuginfo-tests for the host triple" 2014-10-18 23:47:59 +00:00
libclc math: Implement sinh function 2017-02-25 02:46:53 +00:00
libcxx Add list of filesystem NB comments to TODO.TXT so they can be tracked separately 2017-03-06 21:23:36 +00:00
libcxxabi Fully Reformat fallback_malloc.cpp 2017-03-04 03:23:15 +00:00
libunwind Drop the dependency on dl_unwind_find_exidx(). 2017-03-05 19:11:24 +00:00
lld Detemplate EhInputSection. NFC. 2017-03-06 21:17:18 +00:00
lldb Update log_options unit test 2017-03-06 19:10:19 +00:00
llgo [llgo] Remove support for LLVM attributes 2016-12-06 19:22:04 +00:00
llvm [Outliner] Fixed Asan bot failure in r296418 2017-03-06 21:31:18 +00:00
openmp OpenMP version 5.0 added 2017-03-06 22:07:40 +00:00
parallel-libs [Axccel] Remove -Wno-missing-braces in build 2016-12-19 21:34:07 +00:00
polly Adapt to llvm change r296992 to unbreak the bots 2017-03-06 01:12:16 +00:00