summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenObjC
Commit message (Collapse)AuthorAgeFilesLines
...
* Only enable AddDiscriminator pass when -fdebug-info-for-profiling is trueDehao Chen2017-02-211-3/+2
| | | | | | | | | | | | | | Summary: AddDiscriminator pass is only useful for sample pgo. This patch restricts AddDiscriminator to -fdebug-info-for-profiling so that it does not introduce unecessary debug size increases for non-sample-pgo builds. Reviewers: dblaikie, aprantl Reviewed By: dblaikie Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D30220 llvm-svn: 295764
* CodeGen: annotate ObjC ARC functions with ABI constraintsSaleem Abdulrasool2017-02-111-11/+13
| | | | | | | | | | | | | | | | 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. llvm-svn: 294872
* test: ignore some warnings in test code (NFC)Saleem Abdulrasool2017-02-111-4/+4
| | | | | | | Silence some diagnostics which clang now generates. This makes it easier to see the failures in lit output. NFC. llvm-svn: 294871
* [CodeGen][ObjC] Avoid asserting on block pointer types inAlex Lorenz2017-02-011-0/+28
| | | | | | | | isPointerZeroInitializable rdar://30111891 llvm-svn: 293787
* Handle ObjCEncodeExpr in extractStringLiteralCharacter.Akira Hatanaka2017-01-311-0/+11
| | | | | | | | | This fixes an assertion failure that occurs later in the function when an ObjCEncodeExpr is cast to StringLiteral. rdar://problem/30111207 llvm-svn: 293596
* Cleanup the handling of noinline function attributes, -fno-inline,Chandler Carruth2016-12-232-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -fno-inline-functions, -O0, and optnone. These were really, really tangled together: - We used the noinline LLVM attribute for -fno-inline - But not for -fno-inline-functions (breaking LTO) - But we did use it for -finline-hint-functions (yay, LTO is happy!) - But we didn't for -O0 (LTO is sad yet again...) - We had weird structuring of CodeGenOpts with both an inlining enumeration and a boolean. They interacted in weird ways and needlessly. - A *lot* of set smashing went on with setting these, and then got worse when we considered optnone and other inlining-effecting attributes. - A bunch of inline affecting attributes were managed in a completely different place from -fno-inline. - Even with -fno-inline we failed to put the LLVM noinline attribute onto many generated function definitions because they didn't show up as AST-level functions. - If you passed -O0 but -finline-functions we would run the normal inliner pass in LLVM despite it being in the O0 pipeline, which really doesn't make much sense. - Lastly, we used things like '-fno-inline' to manipulate the pass pipeline which forced the pass pipeline to be much more parameterizable than it really needs to be. Instead we can *just* use the optimization level to select a pipeline and control the rest via attributes. Sadly, this causes a bunch of churn in tests because we don't run the optimizer in the tests and check the contents of attribute sets. It would be awesome if attribute sets were a bit more FileCheck friendly, but oh well. I think this is a significant improvement and should remove the semantic need to change what inliner pass we run in order to comply with the requested inlining semantics by relying completely on attributes. It also cleans up tho optnone and related handling a bit. One unfortunate aspect of this is that for generating alwaysinline routines like those in OpenMP we end up removing noinline and then adding alwaysinline. I tried a bunch of other approaches, but because we recompute function attributes from scratch and don't have a declaration here I couldn't find anything substantially cleaner than this. Differential Revision: https://reviews.llvm.org/D28053 llvm-svn: 290398
* Make '-disable-llvm-optzns' an alias for '-disable-llvm-passes'.Chandler Carruth2016-12-2312-15/+15
| | | | | | | | | | | | | | | | | | | | | | | | | Much to my surprise, '-disable-llvm-optzns' which I thought was the magical flag I wanted to get at the raw LLVM IR coming out of Clang deosn't do that. It still runs some passes over the IR. I don't want that, I really want the *raw* IR coming out of Clang and I strongly suspect everyone else using it is in the same camp. There is actually a flag that does what I want that I didn't know about called '-disable-llvm-passes'. I suspect many others don't know about it either. It both does what I want and is much simpler. This removes the confusing version and makes that spelling of the flag an alias for '-disable-llvm-passes'. I've also moved everything in Clang to use the 'passes' spelling as it seems both more accurate (*all* LLVM passes are disabled, not just optimizations) and much easier to remember and spell correctly. This is part of simplifying how Clang drives LLVM to make it cleaner to wire up to the new pass manager. Differential Revision: https://reviews.llvm.org/D28047 llvm-svn: 290392
* Add a lit test for PR31374Yaxun Liu2016-12-191-0/+22
| | | | | | Differential Revision: https://reviews.llvm.org/D27909 llvm-svn: 290075
* [CodeGen][ObjC] Emit objc_unsafeClaimAutoreleasedReturnValue forAkira Hatanaka2016-12-131-0/+3
| | | | | | | | | | fragile runtime too. Follow-up to r258962. rdar://problem/29269006 llvm-svn: 289615
* [ubsan] Treat ObjC's BOOL as if its range is always {0, 1}Vedant Kumar2016-12-091-0/+13
| | | | | | | | | | | | | | On some Apple platforms, the ObjC BOOL type is defined as a signed char. When performing instrumentation for -fsanitize=bool, we'd like to treat the range of BOOL like it's always {0, 1}. While we can't change clang's IRGen for char-backed BOOL's due to ABI compatibility concerns, we can teach ubsan to catch potential abuses of this type. rdar://problem/29502773 Differential Revision: https://reviews.llvm.org/D27607 llvm-svn: 289290
* Switch CGObjCMac to use ConstantInitBuilder. Whew.John McCall2016-11-302-5/+4
| | | | | | | Not strictly NFC because I did change the order of emission of some global constants, but it shouldn't make any difference. llvm-svn: 288229
* Improve handling of __FUNCTION__ and other predefined expression for ↵Mehdi Amini2016-11-161-3/+2
| | | | | | | | | | | | | | Objective-C Blocks Instead of always displaying the mangled name, try to do better and get something closer to regular functions. Recommit r287039 (that was reverted in r287039) with a tweak to be more generic, and test fixes! Differential Revision: https://reviews.llvm.org/D26522 llvm-svn: 287085
* CodeGen: be more conservative about setting sectionSaleem Abdulrasool2016-10-251-0/+45
| | | | | | | The section names currently are MachO specific. Only set the section on the variables if the file format is MachO. llvm-svn: 285126
* CodeGen: mark protocols as common dataSaleem Abdulrasool2016-10-251-0/+20
| | | | | | | | 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
* Add support for __builtin_os_log_format[_buffer_size]Mehdi Amini2016-10-241-0/+39
| | | | | | | | | | | | | | | | | This reverts commit r285007 and reapply r284990, with a fix for the opencl test that I broke. Original commit message follows: These new builtins support a mechanism for logging OS events, using a printf-like format string to specify the layout of data in a buffer. The _buffer_size version of the builtin can be used to determine the size of the buffer to allocate to hold the data, and then __builtin_os_log_format can write data into that buffer. This implements format checking to report mismatches between the format string and the data arguments. Most of this code was written by Chris Willmore. Differential Revision: https://reviews.llvm.org/D25888 llvm-svn: 285019
* Revert "Add support for __builtin_os_log_format[_buffer_size]"Mehdi Amini2016-10-241-39/+0
| | | | | | This reverts commit r284990, two opencl test are broken llvm-svn: 285007
* Add support for __builtin_os_log_format[_buffer_size]Mehdi Amini2016-10-241-0/+39
| | | | | | | | | | | | | | These new builtins support a mechanism for logging OS events, using a printf-like format string to specify the layout of data in a buffer. The _buffer_size version of the builtin can be used to determine the size of the buffer to allocate to hold the data, and then __builtin_os_log_format can write data into that buffer. This implements format checking to report mismatches between the format string and the data arguments. Most of this code was written by Chris Willmore. Differential Revision: https://reviews.llvm.org/D25888 llvm-svn: 284990
* DebugInfo: pass alignment value only if it was forcedVictor Leschuk2016-10-205-10/+9
| | | | | | | | | | Preparation to implement DW_AT_alignment support: - We pass non-zero align value to DIBuilder only when alignment was forced - Modify tests to match this change Differential Revision: https://reviews.llvm.org/D24426 llvm-svn: 284679
* test: attempt to repair SCEI buildbotsSaleem Abdulrasool2016-10-131-0/+1
| | | | | | The tests target ARM, ensure that the ARM target is registered. llvm-svn: 284156
* CodeGen: ensure that the runtime calling convention matchesSaleem Abdulrasool2016-10-131-0/+24
| | | | | | | | Incorrect specification of the calling convention results in UB which can cause the code path to be eliminated. Simplify the existing code by using the RuntimeCall constructor in `CodeGenFunction`. llvm-svn: 284154
* Update clang test to accomendate discriminator change in ↵Dehao Chen2016-10-071-2/+3
| | | | | | | | | | | | | | https://reviews.llvm.org/D25132 Summary: https://reviews.llvm.org/D25132 added discriminator even add -g0. This leads to test fail which is addressed in thie patch. Reviewers: davidxl, dnovillo Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D25133 llvm-svn: 283564
* [ubsan] Disable bounds-check for flexible array ivarsVedant Kumar2016-10-041-0/+59
| | | | | | | | | This eliminates a class of false positives for -fsanitize=array-bounds on instrumented ObjC projects. Differential Revision: https://reviews.llvm.org/D22227 llvm-svn: 283249
* [ARC] Ignore qualifiers in copy-restore expressionsVedant Kumar2016-10-031-0/+14
| | | | | | | | | | | | | | | | When ARC is enabled, an ObjCIndirectCopyRestoreExpr models the passing of a function argument s.t: * The argument is copied into a temporary, * The temporary is passed into the function, and * After the function call completes, the temporary is move-assigned back to the original location of the argument. The argument type and the parameter type must agree "except possibly in qualification". This commit weakens an assertion in EmitCallArg() to actually reflect that. llvm-svn: 283116
* CodeGen: mark ObjC cstring literals as unnamed_addrSaleem Abdulrasool2016-09-1816-76/+76
| | | | | | | | 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
* CodeGen: mark ObjC cstring literals as constantSaleem Abdulrasool2016-09-1816-76/+76
| | | | | | | | 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
* Update clang unittests for rL281586.Wei Mi2016-09-151-1/+1
| | | | | | | The change in rL281586 is in llvm component and tests updated here are in clang component, so I have to commit them consecutively. llvm-svn: 281587
* CodeGen: try harder to make the CFString structure RWSaleem Abdulrasool2016-07-292-2/+2
| | | | | | | | The previous change was insufficient to mark the content as read-write as the structure itself was marked constant. Adjust this and add tests to ensure that the section is marked appropriately as being read-write. llvm-svn: 277200
* test: add missing triple to testSaleem Abdulrasool2016-07-171-1/+1
| | | | | | | The test was relying on the default triple which may not be correct. Explicitly provide it a triple. Should repair the windows on Linux builder. llvm-svn: 275738
* CodeGen: honour dllstorage on ObjC typesSaleem Abdulrasool2016-07-171-0/+151
| | | | | | | | 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
* Allow 'nodebug' on local variables.Paul Robinson2016-06-161-0/+26
| | | | | | | | | Parameters and non-static members of aggregates are still excluded, and probably should remain that way. Differential Revision: http://reviews.llvm.org/D19754 llvm-svn: 272859
* test: add explicit targets for some testsSaleem Abdulrasool2016-05-302-4/+8
| | | | | | | These tests currently expect MachO section names and do not provide a target. Explicitly provide one. llvm-svn: 271212
* [ObjC] Remove _Atomic from return type and parameter type ofAkira Hatanaka2016-05-261-0/+34
| | | | | | | | | | | | | | 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 llvm-svn: 270808
* [Clang] Remove unwanted --check-prefix=CHECK from unit tests. NFC.Mandeep Singh Grang2016-04-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Removed unwanted --check-prefix=CHECK from the following unit tests: test/CXX/special/class.copy/implicit-move-def.cpp test/CodeGen/cleanup-destslot-simple.c test/CodeGen/inline-asm-immediate-ubsan.c test/CodeGen/mips-interrupt-attr.c test/CodeGenCXX/cfi-stats.cpp test/CodeGenCXX/copy-constructor-elim.cpp test/CodeGenCXX/microsoft-templ-uuidof.cpp test/CodeGenCXX/vtable-linkage.cpp test/CodeGenObjC/messages-2.m test/Driver/noinline.c test/Index/remap-load.c test/Index/retain-comments-from-system-headers.c test/OpenMP/task_if_codegen.cpp test/Preprocessor/comment_save_macro.c Patch by: Mandeep Singh Grang (mgrang) Reviewers: rafael, ABataev, rengolin Projects: #clang-c Differential Revision: http://reviews.llvm.org/D19232 llvm-svn: 266843
* ObjC Class Property: don't emit class properties on old deployment targets.Manman Ren2016-04-191-2/+13
| | | | | | | | For old deployment targets, emit nil for all class property lists. rdar://25616128 llvm-svn: 266800
* Update to match LLVM changes for PR27284.Adrian Prantl2016-04-152-10/+9
| | | | | | | | | (Reverse the ownership between DICompileUnit and DISubprogram.) http://reviews.llvm.org/D19034 <rdar://problem/25256815> llvm-svn: 266445
* [ObjC] Pop all cleanups created in EmitObjCForCollectionStmt beforeAkira Hatanaka2016-04-121-0/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 266147
* [Objective-C] Introduce objc_runtime_visible attribute.Douglas Gregor2016-04-011-0/+19
| | | | | | | | | | | | | | | | | | | | 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
* Revert "Convert some ObjC msgSends to runtime calls."Pete Cooper2016-03-211-129/+0
| | | | | | | | | | | | | | 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. llvm-svn: 263984
* Convert some ObjC msgSends to runtime calls.Pete Cooper2016-03-161-0/+129
| | | | | | | | | | | | | | 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 llvm-svn: 263607
* Objective-C: Add a size field to non-fragile category metadata.Manman Ren2016-02-241-1/+1
| | | | | | | | | | | 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
* Class Property: Fix a crash with old ABI when generating metadata in classes.Manman Ren2016-02-211-0/+14
| | | | | | rdar://23891898 llvm-svn: 261466
* Remove unnecessary regex in the test cases I fixed in r260496.Akira Hatanaka2016-02-162-2/+2
| | | | llvm-svn: 260921
* [Objective-c] Stop attaching section "datacoal_nt" to global variables.Akira Hatanaka2016-02-113-7/+7
| | | | | | | | | | | | | 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
* Add an ARC autoreleased-return-value caller marker on i386.John McCall2016-02-051-0/+43
| | | | | | rdar://24531556 llvm-svn: 259932
* Fix predefine for __NSConstantString struct typeBen Langmuir2016-02-043-6/+5
| | | | | | | | | | | | | | | | | Per review feedback the name was wrong and it can be used outside Objective-C. Unfortunately, making the internal struct visible broke some ASTMatchers tests that assumed that the first record decl would be from user code, rather than a builtin type. I'm worried that this will also affect users' code. So this patch adds a typedef to wrap the internal struct and only makes the typedef visible to namelookup. This is sufficient to allow the ASTReader to merge the decls we need without making the struct itself visible. rdar://problem/24425801 llvm-svn: 259734
* Reapply r259624, it is likely not the commit causing the bot failures.Quentin Colombet2016-02-033-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Original message: Make CF constant string decl visible to name lookup to fix module errors The return type of the __builtin___*StringMakeConstantString functions is a pointer to a struct, so we need that struct to be visible to name lookup so that we will correctly merge multiple declarations of that type if they come from different modules. Incidentally, to make this visible to name lookup we need to rename the type to __NSConstantString, since the real NSConstantString is an Objective-C interface type. This shouldn't affect anyone outside the compiler since users of the constant string builtins cast the result immediately to CFStringRef. Since this struct type is otherwise implicitly created by the AST context and cannot access namelookup, we make this a predefined type and initialize it in Sema. Note: this issue of builtins that refer to types not visible to name lookup technically also affects other builtins (e.g. objc_msgSendSuper), but in all other cases the builtin is a library builtin and the issue goes away if you include the library that defines the types it uses, unlike for these constant string builtins. rdar://problem/24425801 llvm-svn: 259721
* Revert r259624 - Make CF constant string decl visible to name lookup to fix ↵Quentin Colombet2016-02-033-5/+5
| | | | | | | | | module errors. This breaks some internal bots in stage2: clang seg fault. Looking with Ben to see what is going on. llvm-svn: 259715
* Make CF constant string decl visible to name lookup to fix module errorsBen Langmuir2016-02-033-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | The return type of the __builtin___*StringMakeConstantString functions is a pointer to a struct, so we need that struct to be visible to name lookup so that we will correctly merge multiple declarations of that type if they come from different modules. Incidentally, to make this visible to name lookup we need to rename the type to __NSConstantString, since the real NSConstantString is an Objective-C interface type. This shouldn't affect anyone outside the compiler since users of the constant string builtins cast the result immediately to CFStringRef. Since this struct type is otherwise implicitly created by the AST context and cannot access namelookup, we make this a predefined type and initialize it in Sema. Note: this issue of builtins that refer to types not visible to name lookup technically also affects other builtins (e.g. objc_msgSendSuper), but in all other cases the builtin is a library builtin and the issue goes away if you include the library that defines the types it uses, unlike for these constant string builtins. rdar://problem/24425801 llvm-svn: 259624
* Class Property: generate metadata for class properties in protocols.Manman Ren2016-01-292-1/+5
| | | | | | | | | | 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
* Class Property: generate metadata for class properties in categories.Manman Ren2016-01-291-0/+24
| | | | | | | | | | | 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
OpenPOWER on IntegriCloud