Akira Hatanaka 2e00b98027 Distinguish __block variables that are captured by escaping blocks
from those that aren't.

This patch changes the way __block variables that aren't captured by
escaping blocks are handled:

- Since non-escaping blocks on the stack never get copied to the heap
  (see https://reviews.llvm.org/D49303), Sema shouldn't error out when
  the type of a non-escaping __block variable doesn't have an accessible
  copy constructor.

- IRGen doesn't have to use the specialized byref structure (see
  https://clang.llvm.org/docs/Block-ABI-Apple.html#id8) for a
  non-escaping __block variable anymore. Instead IRGen can emit the
  variable as a normal variable and copy the reference to the block
  literal. Byref copy/dispose helpers aren't needed either.

rdar://problem/39352313

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

llvm-svn: 341754
2018-09-08 20:03:00 +00:00
..
2018-03-20 22:02:57 +00:00
2018-07-30 19:24:48 +00:00
2018-07-30 19:24:48 +00:00
2018-07-30 19:24:48 +00:00
2018-07-30 19:24:48 +00:00
2018-07-30 19:24:48 +00:00
2018-07-30 19:24:48 +00:00
2018-07-30 19:24:48 +00:00
2018-08-09 21:08:08 +00:00
2018-08-09 21:09:38 +00:00
2018-07-30 19:24:48 +00:00
2018-07-30 19:24:48 +00:00
2018-07-30 19:24:48 +00:00
2018-07-30 19:24:48 +00:00
2018-08-09 21:08:08 +00:00
2018-03-20 22:02:57 +00:00
2018-07-30 19:24:48 +00:00
2018-07-30 19:24:48 +00:00
2018-07-11 19:51:40 +00:00
2018-07-30 19:24:48 +00:00
2018-09-06 18:26:30 +00:00
2018-07-30 19:24:48 +00:00
2018-04-06 15:14:32 +00:00

IRgen optimization opportunities.

//===---------------------------------------------------------------------===//

The common pattern of
--
short x; // or char, etc
(x == 10)
--
generates an zext/sext of x which can easily be avoided.

//===---------------------------------------------------------------------===//

Bitfields accesses can be shifted to simplify masking and sign
extension. For example, if the bitfield width is 8 and it is
appropriately aligned then is is a lot shorter to just load the char
directly.

//===---------------------------------------------------------------------===//

It may be worth avoiding creation of alloca's for formal arguments
for the common situation where the argument is never written to or has
its address taken. The idea would be to begin generating code by using
the argument directly and if its address is taken or it is stored to
then generate the alloca and patch up the existing code.

In theory, the same optimization could be a win for block local
variables as long as the declaration dominates all statements in the
block.

NOTE: The main case we care about this for is for -O0 -g compile time
performance, and in that scenario we will need to emit the alloca
anyway currently to emit proper debug info. So this is blocked by
being able to emit debug information which refers to an LLVM
temporary, not an alloca.

//===---------------------------------------------------------------------===//

We should try and avoid generating basic blocks which only contain
jumps. At -O0, this penalizes us all the way from IRgen (malloc &
instruction overhead), all the way down through code generation and
assembly time.

On 176.gcc:expr.ll, it looks like over 12% of basic blocks are just
direct branches!

//===---------------------------------------------------------------------===//