HomePhabricator

Merging r353495: --------------------------------------------------------------…

Authored by hansw on Feb 12 2019, 12:35 AM.

Description

Merging r353495: ------------------------------------------------------------------------ r353495 | jfb | 2019-02-08 02:29:17 +0100 (Fri, 08 Feb 2019) | 32 lines

Variable auto-init: fix __block initialization

Summary:
Automatic initialization [1] of __block variables was trampling over the block's
headers after they'd been initialized, which caused self-init usage to crash,
such as here:

typedef struct XYZ { void (^block)(); } *xyz_t;
__attribute__((noinline))
xyz_t create(void (^block)()) {
  xyz_t myself = malloc(sizeof(struct XYZ));
  myself->block = block;
  return myself;
}
int main() {
  __block xyz_t captured = create(^(){ (void)captured; });
}

This type of code shouldn't be broken by variable auto-init, even if it's
sketchy.

[1] With -ftrivial-auto-var-init=pattern

rdar://problem/47798396

Reviewers: rjmccall, pcc, kcc

Subscribers: jkorous, dexonsmith, cfe-commits

Tags: #clang

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

llvm-svn: 353807

Details

Committed
hanswFeb 12 2019, 12:35 AM
Differential Revision
D57797: Variable auto-init: fix __block initialization
Parents
rG62ead032aaa8: Minor update to lld/ReleaseNotes.
Branches
Unknown
Tags
Unknown