summaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/CGObjC.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [CodeGen] Do not construct complete LValue base info in trivial casesIvan A. Kosarev2017-10-101-3/+3
| | | | | | | | | | | | | | Besides obvious code simplification, avoiding explicit creation of LValueBaseInfo objects makes it easier to make TBAA information to be part of such objects. This is part of D38126 reworked to be a separate patch to simplify review. Differential Revision: https://reviews.llvm.org/D38695 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315289 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGen: correct arguments for NSFastEnumerationSaleem Abdulrasool2017-09-081-16/+14
| | | | | | | | | | | | | | | When performing a NSFastEnumeration, the compiler synthesizes a call to `countByEnumeratingWithState:objects:count:` where the `count` parameter is of type `NSUInteger` and the return type is a `NSUInteger`. We would previously always use a `UnsignedLongTy` for the `NSUInteger` type. On 32-bit targets, `long` is 32-bits which is the same as `unsigned int`. Most 64-bit targets are LP64, where `long` is 64-bits. However, on LLP64 targets, such as Windows, `long` is 32-bits. Introduce new `getNSUIntegerType` and `getNSIntegerType` helpers to allow us to determine the correct type for the `NSUInteger` type. Wire those through into the generation of the message dispatch to the selector. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@312835 91177308-0d34-0410-b5e6-96231b3b80d8
* [DebugInfo] Add kind of ImplicitParamDecl for emission of FlagObjectPointer.Alexey Bataev2017-06-091-12/+16
| | | | | | | | | | | | | | | | | Summary: If the first parameter of the function is the ImplicitParamDecl, codegen automatically marks it as an implicit argument with `this` or `self` pointer. Added internal kind of the ImplicitParamDecl to separate 'this', 'self', 'vtt' and other implicit parameters from other kind of parameters. Reviewers: rjmccall, aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33735 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305075 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Propagate LValueBaseInfo instead of AlignmentSourceKrzysztof Parzyszek2017-05-181-3/+3
| | | | | | | | | | | | | | The functions creating LValues propagated information about alignment source. Extend the propagated data to also include information about possible unrestricted aliasing. A new class LValueBaseInfo will contain both AlignmentSource and MayAlias info. This patch should not introduce any functional changes. Differential Revision: https://reviews.llvm.org/D33284 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303358 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen][ObjC] Don't retain captured Objective-C pointers at blockAkira Hatanaka2017-04-281-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | creation that are const-qualified. When a block captures an ObjC object pointer, clang retains the pointer to prevent prematurely destroying the object the pointer points to before the block is called or copied. When the captured object pointer is const-qualified, we can avoid emitting the retain/release pair since the pointer variable cannot be modified in the scope in which the block literal is introduced. For example: void test(const id x) { callee(^{ (void)x; }); } This patch implements that optimization. rdar://problem/28894510 Differential Revision: https://reviews.llvm.org/D32601 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301667 91177308-0d34-0410-b5e6-96231b3b80d8
* Prefer addAttr(Attribute::AttrKind) over the AttributeList overloadReid Kleckner2017-04-191-6/+2
| | | | | | | | This should simplify the call sites, which typically want to tweak one attribute at a time. It should also avoid creating ephemeral AttributeLists that live forever. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300718 91177308-0d34-0410-b5e6-96231b3b80d8
* [ObjC] Mark loads from __NSArray0 and __NSDictionary0 as invariant.load.Akira Hatanaka2017-04-171-4/+6
| | | | | | | | Also, simplify code by calling MakeNaturalAlignAddrLValue. This is a follow-up to r300396. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300454 91177308-0d34-0410-b5e6-96231b3b80d8
* [ObjC] Use empty Objective-C collection literal constants whenAkira Hatanaka2017-04-151-2/+14
| | | | | | | | | | | | | available. Original patch by Douglas Gregor with minor modifications. This recommits r300389, which broke bots because there have been API changes since the original patch was written. rdar://problem/20689633 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300396 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "[ObjC] Use empty Objective-C collection literal constants when"Akira Hatanaka2017-04-151-14/+2
| | | | | | | This reverts commit r300389. There were mistakes in the changes I made to CodeGen. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300391 91177308-0d34-0410-b5e6-96231b3b80d8
* [ObjC] Use empty Objective-C collection literal constants whenAkira Hatanaka2017-04-151-2/+14
| | | | | | | | | | available. Original patch by Douglas Gregor with minor modifications. rdar://problem/20689633 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300389 91177308-0d34-0410-b5e6-96231b3b80d8
* [ObjC] Fix lifetime markers of loop variable in EmitObjCForCollectionStmt ↵Kuba Mracek2017-04-141-2/+2
| | | | | | | | | | | | [take 2] CodeGenFunction::EmitObjCForCollectionStmt currently emits lifetime markers for the loop variable in an inconsistent way: lifetime.start is emitted before the loop is entered, but lifetime.end is emitted inside the loop. AddressSanitizer uses these markers to track out-of-scope accesses to local variables, and we get false positives in Obj-C foreach loops (in the 2nd iteration of the loop). This patch keeps the loop variable alive for the whole loop by extending ForScope and registering the cleanup function inside EmitAutoVarAlloca. Differential Revision: https://reviews.llvm.org/D32029 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300340 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r300287.Kuba Mracek2017-04-141-2/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300290 91177308-0d34-0410-b5e6-96231b3b80d8
* [ObjC] Fix lifetime markers of loop variable in EmitObjCForCollectionStmtKuba Mracek2017-04-141-5/+2
| | | | | | | | | | CodeGenFunction::EmitObjCForCollectionStmt currently emits lifetime markers for the loop variable in an inconsistent way: lifetime.start is emitted before the loop is entered, but lifetime.end is emitted inside the loop. AddressSanitizer uses these markers to track out-of-scope accesses to local variables, and we get false positives in Obj-C foreach loops (in the 2nd iteration of the loop). The markers of the loop variable need to be either both inside the loop (so that we poison and unpoison the variable in each iteration), or both outside. This patch implements the "both inside" approach. Differential Revision: https://reviews.llvm.org/D32029 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300287 91177308-0d34-0410-b5e6-96231b3b80d8
* Encapsulate FPOptions and use it consistentlyAdam Nemet2017-03-271-2/+2
| | | | | | | | | | | | | | | | | | Sema holds the current FPOptions which is adjusted by 'pragma STDC FP_CONTRACT'. This then gets propagated into expression nodes as they are built. This encapsulates FPOptions so that this propagation happens opaquely rather than directly with the fp_contractable on/off bit. This allows controlled transitioning of fp_contractable to a ternary value (off, on, fast). It will also allow adding more fast-math flags later. This is toward moving fp-contraction=fast from an LLVM TargetOption to a FastMathFlag in order to fix PR25721. Differential Revision: https://reviews.llvm.org/D31166 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@298877 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Emit a CoreFoundation link guard when @available is usedAlex Lorenz2017-03-231-0/+33
| | | | | | | | | | | | | | | | | After r297760, __isOSVersionAtLeast in compiler-rt loads the CoreFoundation symbols at runtime. This means that `@available` will always fail when used in a binary without a linked CoreFoundation. This commit forces Clang to emit a reference to a CoreFoundation symbol when `@available` is used to ensure that linking will fail when CoreFoundation isn't linked with the build product. rdar://31039592 Differential Revision: https://reviews.llvm.org/D30977 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@298588 91177308-0d34-0410-b5e6-96231b3b80d8
* Update Clang for LLVM rename AttributeSet -> AttributeListReid Kleckner2017-03-211-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@298394 91177308-0d34-0410-b5e6-96231b3b80d8
* [ubsan] Extend the nonnull arg check to ObjCVedant Kumar2017-03-061-1/+1
| | | | | | | | | | UBSan's nonnull argument check applies when a parameter has the "nonnull" attribute. The check currently works for FunctionDecls, but not for ObjCMethodDecls. This patch extends the check to work for ObjC. Differential Revision: https://reviews.llvm.org/D30599 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296996 91177308-0d34-0410-b5e6-96231b3b80d8
* [ObjC][CodeGen] CodeGen support for @available.Erik Pilkington2017-02-231-0/+16
| | | | | | | | | | | | CodeGens uses of @available into calls to the compiler-rt function __isOSVersionAtLeast. This commit is part of a feature that I proposed here: http://lists.llvm.org/pipermail/cfe-dev/2016-July/049851.html Differential revision: https://reviews.llvm.org/D27827 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296015 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix copy and paste mistake in header comment, NFC.Erik Pilkington2017-02-211-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@295763 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGen: annotate ObjC ARC functions with ABI constraintsSaleem Abdulrasool2017-02-111-0/+23
| | | | | | | | | | | | | | | | Certain ARC runtime functions have an ABI contract of being forwarding. Annotate the functions with the appropriate `returned` attribute on the arguments. This hoists some of the runtime ABI contract information into the frontend rather than the backend transformations. The test adjustments are to mark the returned function parameter as such. The minor change to the IR output is due to the fact that the returned reference of the object causes it to extend the lifetime of the object by returning an autoreleased return value. The result is that the explicit objc_autorelease call is no longer formed, as autorelease elision is now possible on the return. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294872 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGen: rename variables to adhere to naming conventionSaleem Abdulrasool2017-02-111-9/+10
| | | | | | Adjust style before making more intrusive changes. NFC. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294854 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGen: fix runtime function dll storageSaleem Abdulrasool2016-12-151-1/+2
| | | | | | | | | | | | | | | | | Properly attribute DLL storage to runtime functions. When generating the runtime function, scan for an existing declaration which may provide an explicit declaration (local storage) or a DLL import or export storage from the user. Honour that if available. Otherwise, if building with a local visibility of the public or standard namespaces (-flto-visibility-public-std), give the symbols local storage (it indicates a /MT[d] link, so static runtime). Otherwise, assume that the link is dynamic, and give the runtime function dllimport storage. This allows for implementations to get the correct storage as long as they are properly declared, the user to override the import storage, and in case no explicit storage is given, use of the import storage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289776 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactor call emission to package the function pointer together withJohn McCall2016-10-261-18/+25
| | | | | | | | | | | abstract information about the callee. NFC. The goal here is to make it easier to recognize indirect calls and trigger additional logic in certain cases. That logic will come in a later patch; in the meantime, I felt that this was a significant improvement to the code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285258 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen][ObjC] Do not call objc_storeStrong when initializing aAkira Hatanaka2016-10-181-1/+2
| | | | | | | | | | | | | | | | | | | constexpr variable. When compiling a constexpr NSString initialized with an objective-c string literal, CodeGen emits objc_storeStrong on an uninitialized alloca, which causes a crash. This patch folds the code in EmitScalarInit into EmitStoreThroughLValue and fixes the crash by calling objc_retain on the string instead of using objc_storeStrong. rdar://problem/28562009 Differential Revision: https://reviews.llvm.org/D25547 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284516 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove CXXConstructExpr::getFoundDecl(); it turned out to not be useful.Richard Smith2016-06-101-1/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272357 91177308-0d34-0410-b5e6-96231b3b80d8
* [ObjC] Remove _Atomic from return type and parameter type ofAkira Hatanaka2016-05-261-5/+12
| | | | | | | | | | | | | | | objective-c properties. This fixes an assert in CodeGen that fires when the getter and setter functions for an objective-c property of type _Atomic(_Bool) are synthesized. rdar://problem/26322972 Differential Revision: http://reviews.llvm.org/D20407 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@270808 91177308-0d34-0410-b5e6-96231b3b80d8
* Preserve the FoundDecl when performing overload resolution for constructors.Richard Smith2016-05-111-0/+1
| | | | | | | | | | This is in preparation for C++ P0136R1, which switches the model for inheriting constructors over from synthesizing a constructor to finding base class constructors (via using shadow decls) when looking for derived class constructors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@269231 91177308-0d34-0410-b5e6-96231b3b80d8
* [ObjC] Pop all cleanups created in EmitObjCForCollectionStmt beforeAkira Hatanaka2016-04-121-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | exiting the for-in loop. This commit fixes a bug where EmitObjCForCollectionStmt didn't pop cleanups for captures. For example, in the following for-in loop, a block which captures self is passed to foo1: for (id x in [self foo1:^{ use(self); }]) { use(x); break; } Previously, the code in EmitObjCForCollectionStmt wouldn't pop the cleanup for the captured self before exiting the loop, which caused code-gen to generate an IR in which objc_release was called twice on the captured self. This commit fixes the bug by entering a RunCleanupsScope before the loop condition is evaluated and forcing its cleanup before exiting the loop. rdar://problem/16865751 Differential Revision: http://reviews.llvm.org/D18618 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@266147 91177308-0d34-0410-b5e6-96231b3b80d8
* NFC: make AtomicOrdering an enum classJF Bastien2016-04-061-2/+2
| | | | | | | | | | | | Summary: See LLVM change D18775 for details, this change depends on it. Reviewers: jyknight, reames Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18776 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@265569 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Convert some ObjC msgSends to runtime calls."Pete Cooper2016-03-211-96/+15
| | | | | | | | | | | | | | This reverts commit r263607. This change caused more objc_retain/objc_release calls in the IR but those are then incorrectly optimized by the ARC optimizer. Work is going to have to be done to ensure the ARC optimizer doesn't optimize user written RR, but that should land before this change. This change will also need to be updated to take account for any changes required to ensure that user written calls to RR are distinct from those inserted by ARC. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263984 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert some ObjC msgSends to runtime calls.Pete Cooper2016-03-161-15/+96
| | | | | | | | | | | | | | It is faster to directly call the ObjC runtime for methods such as retain/release instead of sending a message to those functions. This patch adds support for converting messages to retain/release/alloc/autorelease to their equivalent runtime calls. Tests included for the positive case of applying this transformation, negative tests that we ensure we only convert "alloc" to objc_alloc, not "alloc2", and also a driver test to ensure we enable this only for supported runtime versions. Reviewed by John McCall. Differential Revision: http://reviews.llvm.org/D14737 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263607 91177308-0d34-0410-b5e6-96231b3b80d8
* Preserve ExtParameterInfos into CGFunctionInfo.John McCall2016-03-111-30/+16
| | | | | | | | | As part of this, make the function-arrangement interfaces a little simpler and more semantic. NFC. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263191 91177308-0d34-0410-b5e6-96231b3b80d8
* Emit calls to objc_unsafeClaimAutoreleasedReturnValue whenJohn McCall2016-01-271-160/+435
| | | | | | | | | | | | | | | | | reclaiming a call result in order to ignore it or assign it to an __unsafe_unretained variable. This avoids adding an unwanted retain/release pair when the return value is not actually returned autoreleased (e.g. when it is returned from a nonatomic getter or a typical collection accessor). This runtime function is only available on the latest Apple OS releases; the backwards-compatibility story is that you don't get the optimization unless your deployment target is recent enough. Sorry. rdar://20530049 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258962 91177308-0d34-0410-b5e6-96231b3b80d8
* [PGO] Instrument only base constructors and destructors.Serge Pavlov2015-12-061-1/+1
| | | | | | | | | | | | | | | | | Constructors and destructors may be represented by several functions in IR. Only base structors correspond to source code, others are small pieces of code and eventually call the base variant. In this case instrumentation of non-base structors has little sense, this fix remove it. Now profile data of a declaration corresponds to exactly one function in IR, it agrees with the current logic of the profile data loading. This change fixes PR24996. Differential Revision: http://reviews.llvm.org/D15158 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@254876 91177308-0d34-0410-b5e6-96231b3b80d8
* Preserve exceptions information during calls code generation.Samuel Antao2015-11-231-5/+5
| | | | | | | | | | | | | This patch changes the generation of CGFunctionInfo to contain the FunctionProtoType if it is available. This enables the code generation for call instructions to look into this type for exception information and therefore generate better quality IR - it will not create invoke instructions for functions that are know not to throw. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253926 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Attach function attributes to Objective-C and OpenMPAkira Hatanaka2015-10-281-1/+5
| | | | | | | | | | | | | | | functions. This commit fixes a bug in CGOpenMPRuntime.cpp and CGObjC.cpp where some of the function attributes are not attached to newly created functions. rdar://problem/20828324 Differential Revision: http://reviews.llvm.org/D13928 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251476 91177308-0d34-0410-b5e6-96231b3b80d8
* Define weak and __weak to mean ARC-style weak references, even in MRC.John McCall2015-10-221-1/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, __weak was silently accepted and ignored in MRC mode. That makes this a potentially source-breaking change that we have to roll out cautiously. Accordingly, for the time being, actual support for __weak references in MRC is experimental, and the compiler will reject attempts to actually form such references. The intent is to eventually enable the feature by default in all non-GC modes. (It is, of course, incompatible with ObjC GC's interpretation of __weak.) If you like, you can enable this feature with -Xclang -fobjc-weak but like any -Xclang option, this option may be removed at any point, e.g. if/when it is eventually enabled by default. This patch also enables the use of the ARC __unsafe_unretained qualifier in MRC. Unlike __weak, this is being enabled immediately. Since variables are essentially __unsafe_unretained by default in MRC, the only practical uses are (1) communication and (2) changing the default behavior of by-value block capture. As an implementation matter, this means that the ObjC ownership qualifiers may appear in any ObjC language mode, and so this patch removes a number of checks for getLangOpts().ObjCAutoRefCount that were guarding the processing of these qualifiers. I don't expect this to be a significant drain on performance; it may even be faster to just check for these qualifiers directly on a type (since it's probably in a register anyway) than to do N dependent loads to grab the LangOptions. rdar://9674298 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251041 91177308-0d34-0410-b5e6-96231b3b80d8
* Unify the ObjC entrypoint caches.John McCall2015-10-211-20/+28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250918 91177308-0d34-0410-b5e6-96231b3b80d8
* Roll-back r250822.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250827 91177308-0d34-0410-b5e6-96231b3b80d8
* Apply modernize-use-default to clang.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | | | Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250822 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Remove dead code. NFC.Benjamin Kramer2015-10-151-31/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250418 91177308-0d34-0410-b5e6-96231b3b80d8
* ARC: Fix the precise-lifetime suppression of returns_inner_pointerJohn McCall2015-09-091-0/+13
| | | | | | | | receiver extension for message sends via property syntax. rdar://22172983 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247209 91177308-0d34-0410-b5e6-96231b3b80d8
* Compute and preserve alignment more faithfully in IR-generation.John McCall2015-09-081-107/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246985 91177308-0d34-0410-b5e6-96231b3b80d8
* Devirtualize EHScopeStack::Cleanup's dtor because it's never destroyed ↵David Blaikie2015-08-181-5/+5
| | | | | | polymorphically git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245378 91177308-0d34-0410-b5e6-96231b3b80d8
* Pass an iterator range to EmitCallArgsDavid Blaikie2015-07-211-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242824 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242168 91177308-0d34-0410-b5e6-96231b3b80d8
* Substitute type arguments into uses of Objective-C interface members.Douglas Gregor2015-07-071-18/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When messaging a method that was defined in an Objective-C class (or category or extension thereof) that has type parameters, substitute the type arguments for those type parameters. Similarly, substitute into property accesses, instance variables, and other references. This includes general infrastructure for substituting the type arguments associated with an ObjCObject(Pointer)Type into a type referenced within a particular context, handling all of the substitutions required to deal with (e.g.) inheritance involving parameterized classes. In cases where no type arguments are available (e.g., because we're messaging via some unspecialized type, id, etc.), we substitute in the type bounds for the type parameters instead. Example: @interface NSSet<T : id<NSCopying>> : NSObject <NSCopying> - (T)firstObject; @end void f(NSSet<NSString *> *stringSet, NSSet *anySet) { [stringSet firstObject]; // produces NSString* [anySet firstObject]; // produces id<NSCopying> (the bound) } When substituting for the type parameters given an unspecialized context (i.e., no specific type arguments were given), substituting the type bounds unconditionally produces type signatures that are too strong compared to the pre-generics signatures. Instead, use the following rule: - In covariant positions, such as method return types, replace type parameters with “id” or “Class” (the latter only when the type parameter bound is “Class” or qualified class, e.g, “Class<NSCopying>”) - In other positions (e.g., parameter types), replace type parameters with their type bounds. - When a specialized Objective-C object or object pointer type contains a type parameter in its type arguments (e.g., NSArray<T>*, but not NSArray<NSString *> *), replace the entire object/object pointer type with its unspecialized version (e.g., NSArray *). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241543 91177308-0d34-0410-b5e6-96231b3b80d8
* [ObjC] Add NSValue support for objc_boxed_expressionsAlex Denisov2015-06-261-2/+32
| | | | | | | | | | | | | | | Patch extends ObjCBoxedExpr to accept records (structs and unions): typedef struct __attribute__((objc_boxable)) _Color { int r, g, b; } Color; Color color; NSValue *boxedColor = @(color); // [NSValue valueWithBytes:&color objCType:@encode(Color)]; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240761 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-5/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240353 91177308-0d34-0410-b5e6-96231b3b80d8
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-5/+5
| | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240270 91177308-0d34-0410-b5e6-96231b3b80d8