summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGNonTrivialStruct.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [CodeGen] Merge equivalent block copy/helper functions.Akira Hatanaka2018-08-101-3/+21
| | | | | | | | | | | | | | | | | | | | | | | Clang generates copy and dispose helper functions for each block literal on the stack. Often these functions are equivalent for different blocks. This commit makes changes to merge equivalent copy and dispose helper functions and reduce code size. To enable merging equivalent copy/dispose functions, the captured object infomation is encoded into the helper function name. This allows IRGen to check whether an equivalent helper function has already been emitted and reuse the function instead of generating a new helper function whenever a block is defined. In addition, the helper functions are marked as linkonce_odr to enable merging helper functions that have the same name across translation units and marked as unnamed_addr to enable the linker's deduplication pass to merge functions that have different names but the same content. rdar://problem/42640608 Differential Revision: https://reviews.llvm.org/D50152 llvm-svn: 339438
* Move the visitor classes that are used to traverse non-trivial C structsAkira Hatanaka2018-04-171-118/+89
| | | | | | | | | | | | | | to a header file. This is in preparation for using the visitor classes to warn about memcpy'ing non-trivial C structs. See the discussion here: https://reviews.llvm.org/D45310 rdar://problem/36124208 llvm-svn: 330201
* [CodeGen] Fix a crash that occurs when a non-trivial C struct with aAkira Hatanaka2018-04-161-15/+25
| | | | | | | | | | | | | | volatile array field is copied. The crash occurs because method 'visitArray' passes a null FieldDecl to method 'visit' and some of the methods called downstream expect a non-null FieldDecl to be passed. This reapplies r330151 with a fix to the test case. rdar://problem/33599681 llvm-svn: 330155
* Revert "[CodeGen] Fix a crash that occurs when a non-trivial C struct with a"Akira Hatanaka2018-04-161-25/+15
| | | | | | This reverts commit r330151, which caused bots to fail. llvm-svn: 330153
* [CodeGen] Fix a crash that occurs when a non-trivial C struct with aAkira Hatanaka2018-04-161-15/+25
| | | | | | | | | | | | volatile array field is copied. The crash occurs because method 'visitArray' passes a null FieldDecl to method 'visit' and some of the methods called downstream expect a non-null FieldDecl to be passed. rdar://problem/33599681 llvm-svn: 330151
* [ObjC] Allow declaring __weak pointer fields in C structs in ARC.Akira Hatanaka2018-03-191-5/+54
| | | | | | | | | | | | | | | | | | | This patch uses the infrastructure added in r326307 for enabling non-trivial fields to be declared in C structs to allow __weak fields in C structs in ARC. This recommits r327206, which was reverted because it caused module-enabled builders to fail. I discovered that the CXXRecordDecl::CanPassInRegisters flag wasn't being set correctly in some cases after I moved it to RecordDecl. Thanks to Eric Liu for helping me investigate the bug. rdar://problem/33599681 https://reviews.llvm.org/D44095 llvm-svn: 327870
* Revert "[ObjC] Allow declaring __weak pointer fields in C structs inAkira Hatanaka2018-03-121-54/+5
| | | | | | | | | | | ARC." This reverts commit r327206 as there were test failures caused by this patch. http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180312/221427.html llvm-svn: 327294
* [ObjC] Allow declaring __weak pointer fields in C structs in ARC.Akira Hatanaka2018-03-101-5/+54
| | | | | | | | | | | | This patch uses the infrastructure added in r326307 for enabling non-trivial fields to be declared in C structs to allow __weak fields in C structs in ARC. rdar://problem/33599681 Differential Revision: https://reviews.llvm.org/D44095 llvm-svn: 327206
* [ObjC] Allow declaring __strong pointer fields in structs in Objective-CAkira Hatanaka2018-02-281-0/+855
ARC mode. Declaring __strong pointer fields in structs was not allowed in Objective-C ARC until now because that would make the struct non-trivial to default-initialize, copy/move, and destroy, which is not something C was designed to do. This patch lifts that restriction. Special functions for non-trivial C structs are synthesized that are needed to default-initialize, copy/move, and destroy the structs and manage the ownership of the objects the __strong pointer fields point to. Non-trivial structs passed to functions are destructed in the callee function. rdar://problem/33599681 Differential Revision: https://reviews.llvm.org/D41228 llvm-svn: 326307
OpenPOWER on IntegriCloud