summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGNonTrivialStruct.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [NFC] Pass a reference to CodeGenFunction to methods of LValue andAkira Hatanaka2019-12-031-9/+10
| | | | | | | | | | | | | | AggValueSlot This reapplies 8a5b7c35709d9ce1f44a99f0c5b084bf2696ea17 after a null dereference bug in CGOpenMPRuntime::emitUserDefinedMapper. Original commit message: This is needed for the pointer authentication work we plan to do in the near future. https://github.com/apple/llvm-project/blob/a63a81bd9911f87a0b5dcd5bdd7ccdda7124af87/clang/docs/PointerAuthentication.rst
* Revert "[NFC] Pass a reference to CodeGenFunction to methods of LValue and"Akira Hatanaka2019-12-031-10/+9
| | | | | This reverts commit 8a5b7c35709d9ce1f44a99f0c5b084bf2696ea17. This seems to have broken UBSan because of a null dereference.
* [NFC] Pass a reference to CodeGenFunction to methods of LValue andAkira Hatanaka2019-12-031-9/+10
| | | | | | | | | AggValueSlot This is needed for the pointer authentication work we plan to do in the near future. https://github.com/apple/llvm-project/blob/a63a81bd9911f87a0b5dcd5bdd7ccdda7124af87/clang/docs/PointerAuthentication.rst
* [CodeGen] Assign locations to calls to special struct helpersVedant Kumar2019-11-181-0/+1
| | | | | | | | | | | | | | Assign artificial locations to calls to special struct-related helper functions. Such calls may not inherit a location if emitted within FinishFunction, at which point the lexical scope stack may be empty, causing CGDebugInfo to report the current DebugLoc as empty. Fixes an IR verifier complaint about a call to '__destructor_8_s0' not having a !dbg location attached. rdar://57293361
* Do a sweep of symbol internalization. NFC.Benjamin Kramer2019-08-231-1/+1
| | | | llvm-svn: 369803
* Add { } to silence compiler warning [NFC]Mikael Holmen2019-04-111-3/+3
| | | | | | | | | | | | | | | At least clang 3.6 warns on the original code: ../tools/clang/lib/CodeGen/CGNonTrivialStruct.cpp:829:34: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces] return std::array<Address, 1>({Address(nullptr, CharUnits::Zero())}); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { } ../tools/clang/lib/CodeGen/CGNonTrivialStruct.cpp:833:34: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces] return std::array<Address, 2>({Address(nullptr, CharUnits::Zero()), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 errors generated. llvm-svn: 358152
* Add IRGen APIs to fetch ctor/dtor helper functions for non-trivial structs.John McCall2019-04-101-0/+90
| | | | | | Patch by Tony Allevato! llvm-svn: 358132
* [CodeGen][ObjC] Adjust the addresses passed to calls to synthesizedAkira Hatanaka2019-03-291-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | copy/move constructor/assignment operator functions for non-trivial C structs. This commit fixes a bug where the offset of struct fields weren't being taken into account when computing the addresses passed to calls to the special functions. For example, the copy constructor for S1 (__copy_constructor_8_8_s0_s8) would pass the start addresses of the destination and source structs to the call to S0's copy constructor (_copy_constructor_8_8_s0) without adding the offset of field f1 to the addresses. typedef struct { id f0; S0 f1; } S1; void test(S1 s1) { S1 t = s1; } rdar://problem/49400610 llvm-svn: 357229
* Fix typos and formatting. NFC.Akira Hatanaka2019-03-291-58/+54
| | | | llvm-svn: 357228
* [CodeGen] Add additional mangling for struct members of non trivial structsShoaib Meenai2019-03-281-2/+3
| | | | | | | | | | | | | In https://bugs.llvm.org/show_bug.cgi?id=41206 we observe bad codegen when embedding a non-trivial C struct within a C struct. This is due to the fact that name mangling for non-trivial structs marks the two structs as identical. This diff contains a fix for this issue. Patch by Dan Zimmerman <daniel.zimmerman@me.com>. Differential Revision: https://reviews.llvm.org/D59873 llvm-svn: 357184
* [opaque pointer types] Cleanup CGBuilder's Create*GEP.James Y Knight2019-02-091-2/+1
| | | | | | | | | | | | | | The various EltSize, Offset, DataLayout, and StructLayout arguments are all computable from the Address's element type and the DataLayout which the CGBuilder already has access to. After having previously asserted that the computed values are the same as those passed in, now remove the redundant arguments from CGBuilder's Create*GEP functions. Differential Revision: https://reviews.llvm.org/D57767 llvm-svn: 353629
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [NFC] Move storage of dispatch-version to GlobalDeclErich Keane2018-11-131-1/+1
| | | | | | | | | | | | | | | | | | | As suggested by Richard Smith, and initially put up for review here: https://reviews.llvm.org/D53341, this patch removes a hack that was used to ensure that proper target-feature lists were used when emitting cpu-dispatch (and eventually, target-clones) implementations. As a part of this, the GlobalDecl object is proliferated to a bunch more locations. Originally, this was put up for review (see above) to get acceptance on the approach, though discussion with Richard in San Diego showed he approved of the approach taken here. Thus, I believe this is acceptable for Review-After-commit Differential Revision: https://reviews.llvm.org/D53341 Change-Id: I0a0bd673340d334d93feac789d653e03d9f6b1d5 llvm-svn: 346757
* Pass the function type instead of the return type to FunctionDecl::CreateJonas Devlieghere2018-11-111-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix places where the return type of a FunctionDecl was being used in place of the function type FunctionDecl::Create() takes as its T parameter the type of function that should be created, not the return type. Passing in the return type looks to have been copypasta'd around a bit, but the number of correct usages outweighs the incorrect ones so I've opted for keeping what T is the same and fixing up the call sites instead. This fixes a crash in Clang when attempting to compile the following snippet of code with -fblocks -fsanitize=function -x objective-c++ (my original repro case): void g(void(^)()); void f() { __block int a = 0; g(^(){ a++; }); } as well as the following which only requires -fsanitize=function -x c++: void f(char * buf) { __builtin_os_log_format(buf, ""); } Patch by: Ben (bobsayshilol) Differential revision: https://reviews.llvm.org/D53263 llvm-svn: 346601
* [CodeGen] Before entering the loop that copies a non-trivial array fieldAkira Hatanaka2018-10-021-0/+2
| | | | | | | | | | | | of a non-trivial C struct, copy the preceding trivial fields that haven't been copied. This commit fixes a bug where the instructions used to copy the preceding trivial fields were emitted inside the loop body. rdar://problem/44185064 llvm-svn: 343556
* [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