summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGObjCRuntime.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Preserve ExtParameterInfos into CGFunctionInfo.John McCall2016-03-111-15/+5
| | | | | | | | | As part of this, make the function-arrangement interfaces a little simpler and more semantic. NFC. llvm-svn: 263191
* Update for LLVM function name change.Rui Ueyama2016-01-141-3/+2
| | | | llvm-svn: 257802
* Initialize @catch variables correctly in fragile-runtime ARC.John McCall2015-10-301-18/+25
| | | | llvm-svn: 251677
* Compute and preserve alignment more faithfully in IR-generation.John McCall2015-09-081-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Devirtualize EHScopeStack::Cleanup's dtor because it's never destroyed ↵David Blaikie2015-08-181-2/+2
| | | | | | polymorphically llvm-svn: 245378
* Rely on default zero-arg value for IRBuilder::CreateCall calls to zero-arg ↵David Blaikie2015-07-141-1/+1
| | | | | | | | functions Patch by servuswiegehtz at yahoo.de llvm-svn: 242168
* Respect alignment of nested bitfieldsUlrich Weigand2015-07-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tools/clang/test/CodeGen/packed-nest-unpacked.c contains this test: struct XBitfield { unsigned b1 : 10; unsigned b2 : 12; unsigned b3 : 10; }; struct YBitfield { char x; struct XBitfield y; } __attribute((packed)); struct YBitfield gbitfield; unsigned test7() { // CHECK: @test7 // CHECK: load i32, i32* getelementptr inbounds (%struct.YBitfield, %struct.YBitfield* @gbitfield, i32 0, i32 1, i32 0), align 4 return gbitfield.y.b2; } The "align 4" is actually wrong. Accessing all of "gbitfield.y" as a single i32 is of course possible, but that still doesn't make it 4-byte aligned as it remains packed at offset 1 in the surrounding gbitfield object. This alignment was changed by commit r169489, which also introduced changes to bitfield access code in CGExpr.cpp. Code before that change used to take into account *both* the alignment of the field to be accessed within the current struct, *and* the alignment of that outer struct itself; this logic was removed by the above commit. Neglecting to consider both values can cause incorrect code to be generated (I've seen an unaligned access crash on SystemZ due to this bug). In order to always use the best known alignment value, this patch removes the CGBitFieldInfo::StorageAlignment member and replaces it with a StorageOffset member specifying the offset from the start of the surrounding struct to the bitfield's underlying storage. This offset can then be combined with the best-known alignment for a bitfield access lvalue to determine the alignment to use when accessing the bitfield's storage. Differential Revision: http://reviews.llvm.org/D11034 llvm-svn: 241916
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-2/+2
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-2/+2
| | | | | | | | | | | | 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
* API update for streamlining of IRBuilder::CreateCall to just use ↵David Blaikie2015-05-181-1/+1
| | | | | | ArrayRef/initializer_list+braced init llvm-svn: 237625
* Update for llvm api change.Rafael Espindola2014-06-041-1/+1
| | | | llvm-svn: 210204
* [C++11] Use 'nullptr'. CodeGen edition.Craig Topper2014-05-211-4/+4
| | | | llvm-svn: 209272
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-121-2/+2
| | | | | | class. llvm-svn: 203643
* [Modules] Update to reflect the move of CallSite into the IR library inChandler Carruth2014-03-041-1/+1
| | | | | | LLVM r202816. llvm-svn: 202817
* Add CodeGenABITypes.h for use in LLDB.Mark Lacey2013-10-301-0/+1
| | | | | | | | | | | | | | | | | | CodeGenABITypes is a wrapper built on top of CodeGenModule that exposes some of the functionality of CodeGenTypes (held by CodeGenModule), specifically methods that determine the LLVM types appropriate for function argument and return values. I addition to CodeGenABITypes.h, CGFunctionInfo.h is introduced, and the definitions of ABIArgInfo, RequiredArgs, and CGFunctionInfo are moved into this new header from the private headers ABIInfo.h and CGCall.h. Exposing this functionality is one part of making it possible for LLDB to determine the actual ABI locations of function arguments and return values, making it possible for it to determine this for any supported target without hard-coding ABI knowledge in the LLDB code. llvm-svn: 193717
* Standardize accesses to the TargetInfo in IR-gen.John McCall2013-04-161-1/+1
| | | | | | Patch by Stephen Lin! llvm-svn: 179638
* Use the actual ABI-determined C calling convention for runtimeJohn McCall2013-02-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | calls and declarations. LLVM has a default CC determined by the target triple. This is not always the actual default CC for the ABI we've been asked to target, and so we sometimes find ourselves annotating all user functions with an explicit calling convention. Since these calling conventions usually agree for the simple set of argument types passed to most runtime functions, using the LLVM-default CC in principle has no effect. However, the LLVM optimizer goes into histrionics if it sees this kind of formal CC mismatch, since it has no concept of CC compatibility. Therefore, if this module happens to define the "runtime" function, or got LTO'ed with such a definition, we can miscompile; so it's quite important to get this right. Defining runtime functions locally is quite common in embedded applications. llvm-svn: 176286
* Rework the bitfield access IR generation to address PR13619 andChandler Carruth2012-12-061-12/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | generally support the C++11 memory model requirements for bitfield accesses by relying more heavily on LLVM's memory model. The primary change this introduces is to move from a manually aligned and strided access pattern across the bits of the bitfield to a much simpler lump access of all bits in the bitfield followed by math to extract the bits relevant for the particular field. This simplifies the code significantly, but relies on LLVM to intelligently lowering these integers. I have tested LLVM's lowering both synthetically and in benchmarks. The lowering appears to be functional, and there are no really significant performance regressions. Different code patterns accessing bitfields will vary in how this impacts them. The only real regressions I'm seeing are a few patterns where the LLVM code generation for loads that feed directly into a mask operation don't take advantage of the x86 ability to do a smaller load and a cheap zero-extension. This doesn't regress any benchmark in the nightly test suite on my box past the noise threshold, but my box is quite noisy. I'll be watching the LNT numbers, and will look into further improvements to the LLVM lowering as needed. llvm-svn: 169489
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-5/+2
| | | | | | | | | | | | | 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
* Put something sane in the DWARF offset field for bitfield ObjC ivars.Eli Friedman2012-11-061-0/+7
| | | | | | | | | This is useful because unnamed bitfields can have effects on the offsets which are not otherwise reflected in the DWARF information. <rdar://problem/12629719> llvm-svn: 167503
* Back out 167431+167437+167487; I didn't realize how incomplete our testEli Friedman2012-11-061-10/+10
| | | | | | coverage of this code is. llvm-svn: 167495
* Propagate CharUnits into ObjC CodeGen. No intended functional change.Eli Friedman2012-11-061-10/+10
| | | | llvm-svn: 167431
* Distinguish more carefully between free functions and C++ instance methodsJohn McCall2012-07-071-5/+5
| | | | | | | | in the ABI arrangement, and leave a hook behind so that we can easily tweak CCs on platforms that use different CCs by default for C++ instance methods. llvm-svn: 159894
* Propagate lvalue alignment into bitfields. Per report on cfe-dev.Eli Friedman2012-06-271-1/+4
| | | | llvm-svn: 159295
* Documentation fix: made the name given to \param match the code.James Dennett2012-06-151-1/+1
| | | | llvm-svn: 158511
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-1/+1
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* Whether an argument is required (in contrast with being anJohn McCall2012-02-171-0/+45
| | | | | | | | | | | | | | | | | | | | | optional argument passed through the variadic ellipsis) potentially affects how we need to lower it. Propagate this information down to the various getFunctionInfo(...) overloads on CodeGenTypes. Furthermore, rename those overloads to clarify their distinct purposes, and make sure we're calling the right one in the right place. This has a nice side-effect of making it easier to construct a function type, since the 'variadic' bit is no longer separable. This shouldn't really change anything for our existing platforms, with one minor exception --- we should now call variadic ObjC methods with the ... in the "right place" (see the test case), which I guess matters for anyone running GNUStep on MIPS. Mostly it's just a substantial clean-up. llvm-svn: 150788
* simplify a bunch of code to use the well-known LLVM IR types computed by ↵Chris Lattner2012-02-071-1/+1
| | | | | | CodeGenModule. llvm-svn: 149943
* When initializing a catch variable in ARC, be sure to emit retainsJohn McCall2012-01-171-1/+18
| | | | | | | | | or whatever else is required for the initialization instead of assuming it can be done with a simple store. Fixes PR11732. llvm-svn: 148325
* Switch a few callers of MakeAddrLValue places over to ↵Eli Friedman2011-12-191-1/+1
| | | | | | MakeNaturalAlignAddrLValue. llvm-svn: 146920
* Replace all comparisons between ObjCInterfaceDecl pointers with callsDouglas Gregor2011-12-151-1/+1
| | | | | | | | to declaresSameEntity(), as a baby step toward tracking forward declarations of Objective-C classes precisely. Part of <rdar://problem/10583531>. llvm-svn: 146618
* Add block information for ObjC @catch blocks.Eric Christopher2011-10-191-1/+1
| | | | | | Fixes rdar://10282889 llvm-svn: 142467
* Constant expression evaluation refactoring:Richard Smith2011-10-101-2/+1
| | | | | | | | | | | - Remodel Expr::EvaluateAsInt to behave like the other EvaluateAs* functions, and add Expr::EvaluateKnownConstInt to capture the current fold-or-assert behaviour. - Factor out evaluation of bitfield bit widths. - Fix a few places which would evaluate an expression twice: once to determine whether it is a constant expression, then again to get the value. llvm-svn: 141561
* Refactor the load of the exception pointer and the exception selector from theirBill Wendling2011-09-151-1/+1
| | | | | | storage slot into helper functions. llvm-svn: 139826
* Extend the ASTContext constructor to delay the initialization ofDouglas Gregor2011-09-021-1/+1
| | | | | | | | builtin types (When requested). This is another step toward making ASTUnit build the ASTContext as needed when loading an AST file, rather than doing so after the fact. No actual functionality change (yet). llvm-svn: 138985
* Simplify EH control flow by observing that EH scopes form a simpleJohn McCall2011-08-111-1/+1
| | | | | | | | | | | | | | | hierarchy of delegation, and that EH selector values are meaningful function-wide (good thing, too, or inlining wouldn't work). 2,3d 1a hierarchy of delegation and that EH selector values have the same meaning everywhere in the function instead of being meaningful only in the context of a specific selector. This removes the need for routing edges through EH cleanups, since a cleanup simply always branches to its enclosing scope. llvm-svn: 137293
* The lock operand to an @synchronized statement is also John McCall2011-07-271-10/+15
| | | | | | | supposed to be a full-expression; make it so. In ARC, make sure we retain the lock for the entire protected block. llvm-svn: 136271
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-1/+1
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Add a const overload for ObjCInterfaceDecl::all_declared_ivar_begin.Jordy Rose2011-07-221-2/+1
| | | | | | | | | This was previously not-const only because it has to lazily construct a chain of ivars the first time it is called (and after the chain is invalidated). In practice, all the clients were just const_casting their const Decls; all those now-unnecessary const_casts have been removed. llvm-svn: 135741
* de-constify llvm::Type, patch by David Blaikie!Chris Lattner2011-07-181-3/+3
| | | | llvm-svn: 135370
* Convert CallInst and InvokeInst APIs to use ArrayRef.Jay Foad2011-07-151-1/+1
| | | | llvm-svn: 135265
* Generalize Cleanup::Emit's "isForEH" parameter into a setJohn McCall2011-07-121-2/+2
| | | | | | of flags. No functionality change. llvm-svn: 134997
* Eliminate most uses of ShallowCollectObjCIvars which requiresFariborz Jahanian2011-06-281-5/+5
| | | | | | | a vector for collection. Use iterators where needed instead. // rdar://6817577 llvm-svn: 134015
* Emit @finally blocks completely lazily instead of forcing theirJohn McCall2011-06-221-6/+4
| | | | | | | | | | | | | existence by always threading an edge from the catchall. Not doing this was previously causing a crash in the very extreme case where neither the normal cleanup nor the EH catchall was actually reachable: we would delete the catchall entry block, which would cause us to delete the entry block of the finally cleanup as well because the cleanup logic would merge the blocks, which in turn triggered an assert because later blocks in the finally would still be using values from the entry. Laziness turns out to be the most elegant solution to the problem. llvm-svn: 133601
* Restore correct use of GC barriers.John McCall2011-06-161-1/+1
| | | | llvm-svn: 133144
* Fix some problems where functions must be bitcast but we're expecting a ↵David Chisnall2011-05-231-3/+3
| | | | | | | | llvm::Function of the right type. PR9994. llvm-svn: 131930
* Make this code more resilient against catch variables which need cleanups.John McCall2011-05-121-3/+4
| | | | llvm-svn: 131215
* Replace some literal 8s with char width and char align. No change inKen Dyck2011-04-221-2/+2
| | | | | | functionality intended. llvm-svn: 129996
* Replace a couple of divide-by-8s with divide-by-charwidths. No change inKen Dyck2011-04-141-2/+4
| | | | | | functionality intended. llvm-svn: 129496
* Continuing work on ObjC tidyup:David Chisnall2011-03-251-0/+308
- Moved the CGObjCRuntime functions out of CGObjCMac.cpp into CGObjCRuntime.cpp - Added generic functions in CGObjCRuntime for emitting @try and @synchronize blocks, usable by any runtime that uses DWARF exceptions. - Made the GNU runtimes use these functions. It should now be possible to replace the equivalent functions in CGObjCNonFragileABIMac with simple calls to these two functions, providing the runtime functions as arguments. I'll post a diff to the list for review before making any changes to the Mac runtime stuff. llvm-svn: 128274
OpenPOWER on IntegriCloud