summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGBlocks.h
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Fix the type of 1<<31 integer constants.Benjamin Kramer2018-09-241-1/+1
| | | | | | | Shifting into the sign bit is technically undefined behavior. No known compiler exploits it though. llvm-svn: 342909
* [CodeGen] Merge identical block descriptor global variables.Akira Hatanaka2018-08-171-0/+3
| | | | | | | | | | | | | | | | | | Currently, clang generates a new block descriptor global variable for each new block literal. This commit merges block descriptors that are identical inside and across translation units using the same approach taken in r339438. To enable merging identical block descriptors, the size and signature of the block and information about the captures are encoded into the name of the block descriptor variable. Also, the block descriptor variable is marked as linkonce_odr and unnamed_addr. rdar://problem/42640703 Differential Revision: https://reviews.llvm.org/D50783 llvm-svn: 340041
* [CodeGen] Merge equivalent block copy/helper functions.Akira Hatanaka2018-08-101-0/+5
| | | | | | | | | | | | | | | | | | | | | | | 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
* Remove trailing spaceFangrui Song2018-07-301-5/+5
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* [CodeGen][ObjC] Make copying and disposing of a non-escaping blockAkira Hatanaka2018-07-201-1/+8
| | | | | | | | | | | | | | | | | | | | | | no-ops. A non-escaping block on the stack will never be called after its lifetime ends, so it doesn't have to be copied to the heap. To prevent a non-escaping block from being copied to the heap, this patch sets field 'isa' of the block object to NSConcreteGlobalBlock and sets the BLOCK_IS_GLOBAL bit of field 'flags', which causes the runtime to treat the block as if it were a global block (calling _Block_copy on the block just returns the original block and calling _Block_release is a no-op). Also, a new flag bit 'BLOCK_IS_NOESCAPE' is added, which allows the runtime or tools to distinguish between true global blocks and non-escaping blocks. rdar://problem/39352313 Differential Revision: https://reviews.llvm.org/D49303 llvm-svn: 337580
* [CodeGen][ObjC] Block captures should inherit the type of the capturedAkira Hatanaka2016-09-161-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | field in the enclosing lambda or block. This patch fixes a bug in code-gen where it uses the type of the declared variable rather than the type of the capture of the enclosing lambda or block for the block capture. For example, in the following function, code-gen currently uses i32* for the block capture "a" because "a" is passed to foo1 as a reference, but it should use i32 since the enclosing lambda captures "a" by value. void foo1(int &a) { auto lambda = [a]{ auto block1 = ^{ i = a; }; block1(); }; lambda(); } rdar://problem/18586386 Differential Revision: https://reviews.llvm.org/D21104 llvm-svn: 281682
* [NFC] Header cleanupMehdi Amini2016-07-181-4/+0
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
* Move BlockByrefHelpers back to CodeGenModule.h to placate MSVC.John McCall2015-09-081-28/+0
| | | | llvm-svn: 246986
* Compute and preserve alignment more faithfully in IR-generation.John McCall2015-09-081-6/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce an Address type to bundle a pointer value with an alignment. Introduce APIs on CGBuilderTy to work with Address values. Change core APIs on CGF/CGM to traffic in Address where appropriate. Require alignments to be non-zero. Update a ton of code to compute and propagate alignment information. As part of this, I've promoted CGBuiltin's EmitPointerWithAlignment helper function to CGF and made use of it in a number of places in the expression emitter. The end result is that we should now be significantly more correct when performing operations on objects that are locally known to be under-aligned. Since alignment is not reliably tracked in the type system, there are inherent limits to this, but at least we are no longer confused by standard operations like derived-to-base conversions and array-to-pointer decay. I've also fixed a large number of bugs where we were applying the complete-object alignment to a pointer instead of the non-virtual alignment, although most of these were hidden by the very conservative approach we took with member alignment. Also, because IRGen now reliably asserts on zero alignments, we should no longer be subject to an absurd but frustrating recurring bug where an incomplete type would report a zero alignment and then we'd naively do a alignmentAtOffset on it and emit code using an alignment equal to the largest power-of-two factor of the offset. We should also now be emitting much more aggressive alignment attributes in the presence of over-alignment. In particular, field access now uses alignmentAtOffset instead of min. Several times in this patch, I had to change the existing code-generation pattern in order to more effectively use the Address APIs. For the most part, this seems to be a strict improvement, like doing pointer arithmetic with GEPs instead of ptrtoint. That said, I've tried very hard to not change semantics, but it is likely that I've failed in a few places, for which I apologize. ABIArgInfo now always carries the assumed alignment of indirect and indirect byval arguments. In order to cut down on what was already a dauntingly large patch, I changed the code to never set align attributes in the IR on non-byval indirect arguments. That is, we still generate code which assumes that indirect arguments have the given alignment, but we don't express this information to the backend except where it's semantically required (i.e. on byvals). This is likely a minor regression for those targets that did provide this information, but it'll be trivial to add it back in a later patch. I partially punted on applying this work to CGBuiltin. Please do not add more uses of the CreateDefaultAligned{Load,Store} APIs; they will be going away eventually. llvm-svn: 246985
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-1/+1
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* Header guard canonicalization, clang part.Benjamin Kramer2014-08-131-2/+2
| | | | | | Modifications made by clang-tidy with minor tweaks. llvm-svn: 215557
* Don't indent inside namespaces.Rafael Espindola2014-05-091-9/+9
| | | | llvm-svn: 208377
* Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko2013-01-121-2/+2
| | | | | | brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
* Rewrite #includes for llvm/Foo.h to llvm/IR/Foo.h as appropriate toChandler Carruth2013-01-021-1/+1
| | | | | | | | reflect the migration in r171366. Re-sort the #include lines to reflect the new paths. llvm-svn: 171369
* objective-c blocks: Consider padding due to alignmentFariborz Jahanian2012-12-041-0/+8
| | | | | | | after the fixed size block header when generating captured block variable info. // rdar://12773256 llvm-svn: 169285
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-8/+7
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* objective-C blocks: Provide layout map for byrefFariborz Jahanian2012-11-141-2/+6
| | | | | | variables captured in a block. // rdar://12184410 llvm-svn: 167931
* objective-C blocks: Change BLOCK_HAS_EXTENDED_LAYOUT to be 1<<31.Fariborz Jahanian2012-11-101-2/+2
| | | | | | lower 24bit is currently being used. llvm-svn: 167678
* objective-C block meta-data. This patch completes meta-dataFariborz Jahanian2012-11-011-0/+5
| | | | | | | | generation for captured block variables in arc mode. This includes inlined version of the meta-data when it can be done. It also includes severat tests. This is wip. // rdar://12184410. llvm-svn: 167241
* Remove BLOCK_BYREF_LAYOUT_BYREF flags from list ofFariborz Jahanian2012-10-261-3/+2
| | | | | | flags for __block variable meta-data. llvm-svn: 166811
* Declare type of flags to be used in a __block (byref)Fariborz Jahanian2012-10-261-0/+12
| | | | | | variable descriptor captured by a block. llvm-svn: 166746
* Changing name of enum for block literal flags to representFariborz Jahanian2012-10-251-3/+3
| | | | | | what it is meant for. llvm-svn: 166734
* Move TargetData to DataLayout.Micah Villmow2012-10-081-1/+1
| | | | llvm-svn: 165395
* Whenever explicitly activating or deactivating a cleanup, weJohn McCall2011-11-101-0/+9
| | | | | | | | | | need to provide a 'dominating IP' which is guaranteed to dominate the (de)activation point but which cannot be avoided along any execution path from the (de)activation point to the push-point of the cleanup. Using the entry block is bad mojo. llvm-svn: 144276
* Enter the cleanups for a block outside the enclosingJohn McCall2011-11-101-9/+29
| | | | | | | | | | | | full-expression. Naturally they're inactive before we enter the block literal expression. This restores the intended behavior that blocks belong to their enclosing scope. There's a useful -O0 / compile-time optimization that we're missing here with activating cleanups following straight-line code from their inactive beginnings. llvm-svn: 144268
* de-constify llvm::Type, patch by David Blaikie!Chris Lattner2011-07-181-1/+1
| | | | llvm-svn: 135370
* Remove more unnecessary #include <llvm/ADT/SmallVector.h>Francois Pichet2011-06-201-1/+0
| | | | llvm-svn: 133418
* Automatic Reference Counting.John McCall2011-06-151-1/+1
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Remove a rather egregious use of getFunctionInfo.John McCall2011-03-091-0/+4
| | | | llvm-svn: 127324
* Emit the structure layout of the block literal parameter to a blockJohn McCall2011-02-221-1/+0
| | | | | | | | | | invocation function into the debug info. Rather than faking up a class, which is tricky because of the custom layout we do, we just emit a struct directly from the layout information we've already got. Also, don't emit an unnecessarily parameter alloca for this "variable". llvm-svn: 126255
* Don't call objc_read_weak as part of emitting a block literal.John McCall2011-02-161-3/+0
| | | | | | | | Nobody ever gave me a clear reason for why we were doing this, and now it's apparently causing serious problems, so if *not* having this causes problems, we get to solve them the right way this time. llvm-svn: 125627
* Reorganize CodeGen{Function,Module} to eliminate the unfortunateJohn McCall2011-02-081-91/+128
| | | | | | | | Block{Function,Module} base class. Minor other refactorings. Fixed a few address-space bugs while I was there. llvm-svn: 125085
* A few more tweaks to the blocks AST representation: John McCall2011-02-071-60/+9
| | | | | | | | | | | | | | | | | - BlockDeclRefExprs always store VarDecls - BDREs no longer store copy expressions - BlockDecls now store a list of captured variables, information about how they're captured, and a copy expression if necessary With that in hand, change IR generation to use the captures data in blocks instead of walking the block independently. Additionally, optimize block layout by emitting fields in descending alignment order, with a heuristic for filling in words when alignment of the end of the block header is insufficient for the most aligned field. llvm-svn: 125005
* IR Gen. part of API support for __block cxxFariborz Jahanian2010-12-021-4/+7
| | | | | | | | objects imported into blocks. //rdar://8594790. Will have a test case coming (as well as one sent to llvm test suite). llvm-svn: 120713
* Some cleanup of block API code.Fariborz Jahanian2010-11-151-4/+4
| | | | llvm-svn: 119174
* Block API patch to do copy ctor of copied-in cxx objects inFariborz Jahanian2010-11-131-0/+1
| | | | | | | | copy helper function and dtor of copied cxx objects in dispose helper functions. __block variables TBD next. llvm-svn: 119011
* Adding couple of Block API, a bug fix andFariborz Jahanian2010-11-111-0/+6
| | | | | | a test change, all for blocks. wip. llvm-svn: 118745
* IRgen: Move blocks runtime interfaces to CodeGenModule.Daniel Dunbar2010-07-161-17/+1
| | | | llvm-svn: 108481
* Validated by nightly-test runs on x86 and x86-64 darwin, including afterJohn McCall2010-07-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | self-host. Hopefully these results hold up on different platforms. I tried to keep the GNU ObjC runtime happy, but it's hard for me to test. Reimplement how clang generates IR for exceptions. Instead of creating new invoke destinations which sequentially chain to the previous destination, push a more semantic representation of *why* we need the cleanup/catch/filter behavior, then collect that information into a single landing pad upon request. Also reorganizes how normal cleanups (i.e. cleanups triggered by non-exceptional control flow) are generated, since it's actually fairly closely tied in with the former. Remove the need to track which cleanup scope a block is associated with. Document a lot of previously poorly-understood (by me, at least) behavior. The new framework implements the Horrible Hack (tm), which requires every landing pad to have a catch-all so that inlining will work. Clang no longer requires the Horrible Hack just to make exceptions flow correctly within a function, however. The HH is an unfortunate requirement of LLVM's EH IR. llvm-svn: 107631
* finally get around to doing a significant cleanup to irgen:Chris Lattner2010-06-271-1/+2
| | | | | | | | have CGF create and make accessible standard int32,int64 and intptr types. This fixes a ton of 80 column violations introduced by LLVMContextification and cleans up stuff a lot. llvm-svn: 106977
* Fixed a block regression caused by trying to useFariborz Jahanian2010-06-071-3/+0
| | | | | | | | an existing ir for load of a bock variable. This cannot be done across basic blocks. Fixes radar 8064140. llvm-svn: 105549
* For C++ copied in objects, use copy constructors inFariborz Jahanian2010-06-041-0/+3
| | | | | | | | setting up block's descriptor. This is on going work to support c++ specific issues in setting up blocks various APIs. llvm-svn: 105469
* Allocate space in a block record for implicit references to the Objective CJohn McCall2010-05-211-24/+0
| | | | | | | | | | 'self' variable arising from uses of the 'super' keyword. Also reorganize some code so that BlockInfo (now CGBlockInfo) can be opaque outside of CGBlocks.cpp. Fixes rdar://problem/8010633. llvm-svn: 104312
* Support implicitly closing on 'this' in a block. Fixed PR7165.John McCall2010-05-201-8/+24
| | | | | | (the codegen works here, too, but that's annoying to test without execution) llvm-svn: 104202
* Miscellaneous codegen cleanups. Mostly, don't create new basic blocksJohn McCall2010-04-211-1/+2
| | | | | | | just to save the current insertion state! This change significantly simplifies the IR CFG in exceptions code. llvm-svn: 101996
* Minor include pruning.Benjamin Kramer2010-03-311-1/+0
| | | | llvm-svn: 100007
* add support for a 1<<29 bit in the block flags field to mark blocks using ↵Blaine Garst2010-03-051-1/+3
| | | | | | alternate struct return ABI llvm-svn: 97775
* Unconditionally support block introspection data in a new field at the endBlaine Garst2010-02-231-1/+0
| | | | | | | | | | | | | | | of the block descriptor field. This field is the ObjC style @encode signature of the implementation function, and was to this point conditionally provided in the block literal data structure. That provisional support is removed. Additionally, eliminate unused enumerations for the block literal flags field. The first shipping ABI unconditionally set (1<<29) but this bit is unused by the runtime, so the second ABI will unconditionally have (1<<30) set so that the runtime can in fact distinguish whether the additional data is present or not. llvm-svn: 96989
OpenPOWER on IntegriCloud