aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGObjCMac.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-10-25CodeGen: mark protocols as common dataSaleem Abdulrasool1-12/+30
This allows for the coalescing of the protocol declarations. When the protocols are declared in headers, multiple definitions of the protocol would be emitted. Marking them as common data indicates that any one can be selected. llvm-svn: 285073
2016-10-24CodeGen: remove incorrect temporary TwineSaleem Abdulrasool1-2/+2
Twines should not be stack allocated. This somehow managed to get past me. llvm-svn: 285028
2016-10-24CodeGen: centralise label construction for method listsSaleem Abdulrasool1-59/+107
Move all the label construction for the various method list emission into EmitMethodList. Rather than have all the names be constructed in pieces in all of the callers of EmitMethodList, have this occur in one site. This also makes the calls much easier to understand as we simplify identify the type of the method list being emitted and the interface name for which it is being emitted. NFC. llvm-svn: 285023
2016-10-21Switch SmallSetVector to use DenseSet when it overflows its inline space.Justin Lebar1-3/+4
Summary: SetVector already used DenseSet, but SmallSetVector used std::set. This leads to surprising performance differences. Moreover, it means that the set of key types accepted by SetVector and SmallSetVector are quite different! In order to make this change, we had to convert some callsites that used SmallSetVector<std::string, N> to use SmallSetVector<CachedHashString, N> instead. Reviewers: timshen Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D25648 llvm-svn: 284887
2016-09-20CodeGen: further merge cstring literal constructionSaleem Abdulrasool1-13/+19
Use the new CreateCStringLiteral in an additional site. Now all the C string literals are created in one function. Furthermore, mark the additional literal as an `unnamed_addr constant`. llvm-svn: 281997
2016-09-18CodeGen: mark ObjC cstring literals as unnamed_addrSaleem Abdulrasool1-1/+3
These are all emitted into a section with a cstring_literal attribute. The attribute permits the linker to coalesce the string contents. The address of the strings are not important. llvm-svn: 281855
2016-09-18CodeGen: mark ObjC cstring literals as constantSaleem Abdulrasool1-1/+2
These strings are constants, mark them as such. This doesn't matter too much in practice on MachO since the constants are placed into a special section and not referred to directly. llvm-svn: 281854
2016-09-16CodeGen: refactor the ObjC cstring literal creationSaleem Abdulrasool1-44/+57
This refactors the cstring literal creation as mentioned in the couple of FIXMEs littered in the various invocations to CreateMetadataVar. This centralises the definition of the literals, and will enable changing the literal creation to a single site. NFC. llvm-svn: 281798
2016-09-16CodeGen: use pointer rather than reference in range loopSaleem Abdulrasool1-2/+2
Address post-commit comments from Justin Bogner. Explicitly indicate that the dereferenced iterator provides a pointer rather than a reference. NFC. llvm-svn: 281730
2016-09-12CodeGen: use some range-based for loopsSaleem Abdulrasool1-14/+10
Use range-based for loops to simplify the logic. Add an explicit check for MachO as the inline asm uses MachO specific directives. llvm-svn: 281261
2016-07-17CodeGen: honour dllstorage on ObjC typesSaleem Abdulrasool1-34/+114
Add support for ObjC types to respect the DLLImport/DLLExport storage annotations. This only effects COFF output. This would allow usage with clang/C2, but not with clang/LLVM due to hard coded section names. llvm-svn: 275737
2016-07-17CodeGen: whitespace cleanup, StringRef usage in ObjC EH type constructionSaleem Abdulrasool1-37/+28
Clean up some formatting issues and use a bit more StringRef based operations instead of SmallStrings. NFC. llvm-svn: 275735
2016-07-16CodeGen: use StringRefs more in ObjC class generation, NFCSaleem Abdulrasool1-27/+22
Rather than building up a number of SmallString-s in order to construct a std::string, use more StringRefs and construct the string once before use. This avoids unnecessary string constructions. NFC. llvm-svn: 275697
2016-07-16CodeGen: simplify using a local variable, NFCSaleem Abdulrasool1-36/+36
Add a couple of local variables for the class interface and the super class interface. This allows for the repeated access of the information to be cached and makes the code simpler to understand. NFC. llvm-svn: 275696
2016-07-13CodeGen: minor cleanup, NFCSaleem Abdulrasool1-23/+9
Initialise more members in initializer lists. Invert the condition that had grown to be pretty confusing. The `_objc_empty_vtable` is only used on macOS <10.9. This simplifies the code. NFC. llvm-svn: 275241
2016-07-02Use arrays or initializer lists to feed ArrayRefs instead of SmallVector ↵Benjamin Kramer1-12/+10
where possible. No functionality change intended llvm-svn: 274432
2016-06-24Use more ArrayRefsDavid Majnemer1-2/+2
No functional change is intended, just a small refactoring. llvm-svn: 273647
2016-05-16CodeGen: convert some const char * to StringRefSaleem Abdulrasool1-33/+21
Convert some use of const char * to StringRef. NFC. llvm-svn: 269630
2016-04-19ObjC Class Property: don't emit class properties on old deployment targets.Manman Ren1-0/+9
For old deployment targets, emit nil for all class property lists. rdar://25616128 llvm-svn: 266800
2016-04-08revert SVN r265702, r265640Saleem Abdulrasool1-1/+1
Revert the two changes to thread CodeGenOptions into the TargetInfo allocation and to fix the layering violation by moving CodeGenOptions into Basic. Code Generation is arguably not particularly "basic". This addresses Richard's post-commit review comments. This change purely does the mechanical revert and will be followed up with an alternate approach to thread the desired information into TargetInfo. llvm-svn: 265806
2016-04-07Basic: move CodeGenOptions from FrontendSaleem Abdulrasool1-1/+1
This is a mechanical move of CodeGenOptions from libFrontend to libBasic. This fixes the layering violation introduced earlier by threading CodeGenOptions into TargetInfo. It should also fix the modules based self-hosting builds. NFC. llvm-svn: 265702
2016-04-01[Objective-C] Introduce objc_runtime_visible attribute.Douglas Gregor1-0/+49
The objc_runtime_visible attribute deals with an odd corner case where a particular Objective-C class is known to the Objective-C runtime (and, therefore, accessible by name) but its symbol has been hidden for some reason. For such classes, teach CodeGen to use objc_lookUpClass to retrieve the Class object, rather than referencing the class symbol directly. Classes annotated with objc_runtime_visible have two major limitations that fall out from places where Objective-C metadata needs to refer to the class (or metaclass) symbol directly: * One cannot implement a subclass of an objc_runtime_visible class. * One cannot implement a category on an objc_runtime_visible class. Implements rdar://problem/25494092. llvm-svn: 265201
2016-03-11Preserve ExtParameterInfos into CGFunctionInfo.John McCall1-19/+12
As part of this, make the function-arrangement interfaces a little simpler and more semantic. NFC. llvm-svn: 263191
2016-02-24Objective-C: Add a size field to non-fragile category metadata.Manman Ren1-1/+7
This is mainly for extensibility. Note that fragile category metadata, metadata for classes and protocols all have a size field. Initial patch was provided by Greg Parker. rdar://problem/24804226 llvm-svn: 261756
2016-02-21Class Property: Fix a crash with old ABI when generating metadata in classes.Manman Ren1-2/+4
rdar://23891898 llvm-svn: 261466
2016-02-13Reduce the number of implicit StringRef->std::string conversions by ↵Benjamin Kramer1-3/+3
threading StringRef through more APIs. No functionality change intended. llvm-svn: 260815
2016-02-11[Objective-c] Stop attaching section "datacoal_nt" to global variables.Akira Hatanaka1-6/+1
The current macho linker just copies symbols in section datacoal_nt to section data, so it doesn't really matter whether or not section "datacoal_nt" is attached to the global variable. This is a follow-up to r250370, which made changes in llvm to stop putting functions and data in the *coal* sections. rdar://problem/24528611 llvm-svn: 260496
2016-02-10Fix some Clang-tidy readability-redundant-control-flow warnings; other minor ↵Eugene Zelenko1-12/+8
fixes. Differential revision: http://reviews.llvm.org/D17060 llvm-svn: 260414
2016-01-29Class Property: generate metadata for class properties in protocols.Manman Ren1-5/+16
The list of class properties is saved in Old ABI: protocol->ext->class_properties (protocol->ext->size will be updated) New ABI: protocol->class_properties (protocol->size will be updated) rdar://23891898 llvm-svn: 259268
2016-01-29Class Property: generate metadata for class properties in categories.Manman Ren1-4/+21
The list of class properties is saved in Old ABI: category->class_properties (category->size will be updated as well) New ABI: category->class_properties (a flag in objc_image_info to indicate whether or not the list of class properties is present) rdar://23891898 llvm-svn: 259267
2016-01-29Class Property: generate metadata for class properties in classes.Manman Ren1-28/+57
The list of class properties is saved in Old ABI: cls->isa->ext->properties New ABI: cls->isa->ro->properties rdar://23891898 llvm-svn: 259229
2016-01-29Use a consistent spelling for vtables.Eric Christopher1-1/+1
llvm-svn: 259137
2016-01-26Use instance_properties instead of properties. NFC.Manman Ren1-3/+3
All current properties are instance properties. This is the second patch in a series of patches to support class properties in addition to instance properties in objective-c. rdar://23891898 llvm-svn: 258824
2016-01-25Update comments to match the implementation.Manman Ren1-0/+1
llvm-svn: 258735
2016-01-14Update for LLVM function name change.Rui Ueyama1-1/+1
llvm-svn: 257802
2016-01-03Use std::is_sorted instead of a manual loop. NFCCraig Topper1-5/+1
llvm-svn: 256717
2015-12-21Reapply "[CodeGen] Fix assignments of inline layouts into the byref structure"Vedant Kumar1-0/+2
When using blocks, a byref structure is created to represent the closure. The "byref.layout" field of this structure is an i8*. However, some 'inline' layouts are represented as i64's, not i8*'s. Prior to r246985 we cast the i64 'inline' layout to an i8* before assigning it into the byref structure. This patch brings the cast back and adds a regression test. The original version of this patch was too invasive. This version only adds the cast to BuildByrefLayout. Differential Revision: http://reviews.llvm.org/D15674 rdar://23713871 llvm-svn: 256190
2015-12-21Revert "[CodeGen] Fix assignments of inline layouts into the byref structure"Vedant Kumar1-2/+1
This reverts commit r256185. It breaks CodeGenObjC/fragile-arc.m. llvm-svn: 256186
2015-12-21[CodeGen] Fix assignments of inline layouts into the byref structureVedant Kumar1-1/+2
When using blocks, a byref structure is created to represent the closure. The "byref.layout" field of this structure is an i8*. However, some 'inline' layouts are represented as i64's, not i8*'s. Prior to r246985 we cast the i64 'inline' layout to an i8* before assigning it into the byref structure. This patch brings the cast back and adds a regression test. rdar://23713871 llvm-svn: 256185
2015-12-03Fix Objective-C metadata for properties from class extensions after r251874Nico Weber1-7/+18
After, properties from class extensions no longer show up in ObjCInterfaceDecl::properties(). Make ObjCCommonMac::EmitPropertyList() explicitly look for properties in class extensions before looking at direct properties. Also add a test that passes both with clang before r251874 and after this patch (but fails with r251874 and without this patch). llvm-svn: 254622
2015-11-23Preserve exceptions information during calls code generation.Samuel Antao1-1/+1
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. llvm-svn: 253926
2015-11-19Fix the emission of ARC-style ivar layouts in the fragile runtimeJohn McCall1-5/+4
to start at the offset of the first ivar instead of the rounded-up end of the superclass. The latter could include a large amount of tail padding because of a highly-aligned ivar, and subclass ivars can be laid out within that. llvm-svn: 253533
2015-11-18Update for llvm change.Rafael Espindola1-1/+1
llvm-svn: 253440
2015-10-30Watch and TV OS: wire up basic ABI choicesTim Northover1-2/+4
This sets the mostly expected Darwin default ABI options for these two platforms. Active changes from these defaults for watchOS are in a later patch. llvm-svn: 251708
2015-10-30Initialize @catch variables correctly in fragile-runtime ARC.John McCall1-2/+2
llvm-svn: 251677
2015-10-29Fix the emission of ARC ivar layouts in the non-fragile Mac runtime.John McCall1-6/+11
My previous change in this area accidentally broke the rule when InstanceBegin was not a multiple of the word size. llvm-svn: 251666
2015-10-22Define weak and __weak to mean ARC-style weak references, even in MRC.John McCall1-18/+105
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 llvm-svn: 251041
2015-10-21Enable ARC on the fragile runtime.John McCall1-2/+7
This is almost entirely a matter of just flipping a switch. 99% of the runtime support is available all the way back to when it was implemented in the non-fragile runtime, i.e. in Lion. However, fragile runtimes do not recognize ARC-style ivar layout strings, which means that accessing __strong or __weak ivars reflectively (e.g. via object_setIvar) will end up accessing the ivar as if it were __unsafe_unretained. Therefore, when using reflective technologies like KVC, be sure that your paths always refer to a property. rdar://23209307 llvm-svn: 250955
2015-10-21Fix and stylize the emission of GC/ARC ivar and GC block layout strings.John McCall1-397/+405
Specifically, handle under-aligned object references (by explicitly ignoring them, because this just isn't representable in the format; yes, this means that GC silently ignores such references), descend into anonymous structs and unions, stop classifying fields of pointer-to-strong/weak type as strong/weak in ARC mode, and emit skips to cover the entirety of block layouts in GC mode. As a cleanup, extract this code into a helper class, avoid a number of unnecessary copies and layout queries, generate skips implicitly instead of explicitly tracking them, and clarify the bitmap-creation logic. llvm-svn: 250919
2015-10-15[CodeGen] Remove dead code. NFC.Benjamin Kramer1-3/+0
llvm-svn: 250418