summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/ObjCARC
Commit message (Collapse)AuthorAgeFilesLines
...
* [objc-arc] Added descriptions for EnableARCAnnotations, ↵Michael Gottesman2013-04-172-3/+7
| | | | | | EnableCheckForCFGHazards, EnableARCOptimizations. llvm-svn: 179718
* [objc-arc] Added an option to arc-annotations for turning off CheckForCFGHazard.Michael Gottesman2013-04-171-0/+6
| | | | llvm-svn: 179717
* Fix some comment typos.Bob Wilson2013-04-091-2/+2
| | | | llvm-svn: 179132
* Removed trailing whitespace.Michael Gottesman2013-04-051-27/+27
| | | | llvm-svn: 178932
* An objc_retain can serve as a use for a different pointer.Michael Gottesman2013-04-051-2/+3
| | | | | | | This is the counterpart to commit r160637, except it performs the action in the bottomup portion of the data flow analysis. llvm-svn: 178922
* Properly model precise lifetime when given an incomplete dataflow sequence.Michael Gottesman2013-04-051-6/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The normal dataflow sequence in the ARC optimizer consists of the following states: Retain -> CanRelease -> Use -> Release The optimizer before this patch stored the uses that determine the lifetime of the retainable object pointer when it bottom up hits a retain or when top down it hits a release. This is correct for an imprecise lifetime scenario since what we are trying to do is remove retains/releases while making sure that no ``CanRelease'' (which is usually a call) deallocates the given pointer before we get to the ``Use'' (since that would cause a segfault). If we are considering the precise lifetime scenario though, this is not correct. In such a situation, we *DO* care about the previous sequence, but additionally, we wish to track the uses resulting from the following incomplete sequences: Retain -> CanRelease -> Release (TopDown) Retain <- Use <- Release (BottomUp) *NOTE* This patch looks large but the most of it consists of updating test cases. Additionally this fix exposed an additional bug. I removed the test case that expressed said bug and will recommit it with the fix in a little bit. llvm-svn: 178921
* Added two debug logging messages to VisitInstructionsTopDown to match ↵Michael Gottesman2013-04-051-0/+4
| | | | | | VisitInstructionsBottomUp. llvm-svn: 178895
* Cleaned up whitespace and made debug logging less verbose.Michael Gottesman2013-04-051-114/+95
| | | | llvm-svn: 178893
* Refactored out the helper method FindPredecessorAutoreleaseWithSafePath from ↵Michael Gottesman2013-04-031-25/+45
| | | | | | | | ObjCARCOpt::OptimizeReturns. Now ObjCARCOpt::OptimizeReturns is easy to read and reason about. llvm-svn: 178715
* Refactored out the helper function FindPredecessorRetainWithSafePath from ↵Michael Gottesman2013-04-031-18/+32
| | | | | | ObjCARCOpt::OptimizeReturns. llvm-svn: 178714
* Small cleanups.Michael Gottesman2013-04-031-14/+14
| | | | | | | | Cleaned up trailing whitespace and added extra slashes in front of a function level comment so that it follow the convention of having 3 slashes. llvm-svn: 178712
* Refactored out a part of ObjCARCOpt::OptimizeReturns into its own method ↵Michael Gottesman2013-04-031-22/+33
| | | | | | HasSafePathToPredecessorCall. llvm-svn: 178710
* Removed an old comment.Michael Gottesman2013-04-031-7/+0
| | | | llvm-svn: 178709
* Clean up arc annotations by moving the top/bottom BB annotations into ↵Michael Gottesman2013-04-031-58/+46
| | | | | | | | conditional macros that no-op in Release mode instead of #ifdef sections of the code. This is to follow the example of the DEBUG macro. llvm-svn: 178705
* Remove an optimization where we were changing an objc_autorelease into an ↵Michael Gottesman2013-04-031-16/+1
| | | | | | | | | | | | | | | | | | | | | objc_autoreleaseReturnValue. The semantics of ARC implies that a pointer passed into an objc_autorelease must live until some point (potentially down the stack) where an autorelease pool is popped. On the other hand, an objc_autoreleaseReturnValue just signifies that the object must live until the end of the given function at least. Thus objc_autorelease is stronger than objc_autoreleaseReturnValue in terms of the semantics of ARC* implying that performing the given strength reduction without any knowledge of how this relates to the autorelease pool pop that is further up the stack violates the semantics of ARC. *Even though objc_autoreleaseReturnValue if you know that no RV optimization will occur is more computationally expensive. llvm-svn: 178612
* Improved comment. No functionality change.Michael Gottesman2013-04-031-1/+2
| | | | llvm-svn: 178605
* Add clang.arc.used to ModuleHasARC so ARC always runs if said call is ↵Michael Gottesman2013-03-291-1/+2
| | | | | | | | | | present in a module. clang.arc.used is an interesting call for ARC since ObjCARCContract needs to run to remove said intrinsic to avoid a linker error (since the call does not exist). llvm-svn: 178369
* Removed trailing whitespace.Michael Gottesman2013-03-291-15/+15
| | | | llvm-svn: 178329
* Removed dead code from ObjCARCOpts relating to tracking objc_retainBlocks ↵Michael Gottesman2013-03-281-37/+6
| | | | | | through the ARC Dataflow analysis. By the time we get to the ARC dataflow analysis, any objc_retainBlock calls are not optimizable. llvm-svn: 178306
* Non optimizable objc_retainBlock calls are not forwarding.Michael Gottesman2013-03-281-3/+0
| | | | | | | | | | | | Since we handle optimizable objc_retainBlocks through strength reduction in OptimizableIndividualCalls, we know that all code after that point will only see non-optimizable objc_retainBlock calls. IsForwarding is only called by functions after that point, so it is ok to just classify objc_retainBlock as non-forwarding. <rdar://problem/13249661>. llvm-svn: 178285
* [ObjCARC] Strength reduce objc_retainBlock -> objc_retain if the ↵Michael Gottesman2013-03-281-10/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | objc_retainBlock is optimizable. If an objc_retainBlock has the copy_on_escape metadata attached to it AND if the block pointer argument only escapes down the stack, we are allowed to strength reduce the objc_retainBlock to to an objc_retain and thus optimize it. Current there is logic in the ARC data flow analysis to handle this case which is complicated and involved making distinctions in between objc_retainBlock and objc_retain in certain places and considering them the same in others. This patch simplifies said code by: 1. Performing the strength reduction in the initial ARC peephole analysis (ObjCARCOpts::OptimizeIndividualCalls). 2. Changes the ARC dataflow analysis (which runs after the peephole analysis) to consider all objc_retainBlock calls to not be optimizable (since if the call was optimizable, we would have strength reduced it already). This patch leaves in the infrastructure in the ARC dataflow analysis to handle this case, which due to 2 will just be dead code. I am doing this on purpose to separate the removal of the old code from the testing of the new code. <rdar://problem/13249661>. llvm-svn: 178284
* [ObjCARC Annotations] Added support for displaying the state of pointers at ↵Michael Gottesman2013-03-262-4/+147
| | | | | | | | | | | | | | | | | | | | | | | the bottom/top of BBs of the ARC dataflow analysis for both bottomup and topdown analyses. This will allow for verification and analysis of the merge function of the data flow analyses in the ARC optimizer. The actual implementation of this feature is by introducing calls to the functions llvm.arc.annotation.{bottomup,topdown}.{bbstart,bbend} which are only declared. Each such call takes in a pointer to a global with the same name as the pointer whose provenance is being tracked and a pointer whose name is one of our Sequence states and points to a string that contains the same name. To ensure that the optimizer does not consider these annotations in any way, I made it so that the annotations are considered to be of IC_None type. A test case is included for this commit and the previous ObjCARCAnnotation commit. llvm-svn: 177952
* [ObjCARC Annotations] Implemented ARC annotation metadata to expose the ARC ↵Michael Gottesman2013-03-261-5/+186
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | data flow analysis state in the IR via metadata. Previously the inner works of the data flow analysis in ObjCARCOpts was hard to get out of the optimizer for analysis of bugs or testing. All of the current ARC unit tests are based off of testing the effect of the data flow analysis (i.e. what statements are removed or moved, etc.). This creates weakness in the current unit testing regimem since we are not actually testing what effects various instructions have on the modeled pointer state. Additionally in order to analyze a bug in the optimizer, one would need to track by hand what the optimizer was actually doing either through use of DEBUG statements or through the usage of a debugger, both yielding large loses in developer productivity. This patch deals with these two issues by providing ARC annotation metadata that annotates instructions with the state changes that they cause in various pointers as well as provides metadata to annotate provenance sources. Specifically, we introduce the following metadata types: 1. llvm.arc.annotation.bottomup. 2. llvm.arc.annotation.topdown. 3. llvm.arc.annotation.provenancesource. llvm.arc.annotation.{bottomup,topdown}: These annotations describes a state change in a pointer when we are visiting instructions bottomup/topdown respectively. The output format for both is the same: !1 = metadata !{metadata !"(test,%x)", metadata !"S_Release", metadata !"S_Use"} The first element is a string tuple with the following format: (function,variable name) The second two elements of the metadata show the previous state of the pointer (in this case S_Release) and the new state of the pointer (S_Use). We write the metadata in such a manner to ensure that it is easy for outside tools to parse. This is important since I am currently working on a tool for taking this information and pretty printing it besides the IR and that can be used for LIT style testing via the generation of an index. llvm.arc.annotation.provenancesource: This metadata is used to annotate instructions which act as provenance sources, i.e. ones that introduce a new (from the optimizer's perspective) non-argument pointer to track. This enables cross-referencing in between provenance sources and the state changes that occur to them. This is still a work in progress. Additionally I plan on committing later today additions to the annotations that annotate at the top/bottom of basic blocks the state of the various pointers being tracked. *NOTE* The metadata support is conditionally compiled into libObjCARCOpts only when we are producing a debug build of llvm/clang and even so are disabled by default. To enable the annotation metadata, pass in -enable-objc-arc-annotations to opt. llvm-svn: 177951
* Changed isNullOrUndef => IsNullOrUndef and isNoopInstruction => ↵Michael Gottesman2013-03-253-14/+14
| | | | | | IsNoopInstruction so that all helper functions are named similarly in ObjCARC.h. llvm-svn: 177855
* Change method name ClearRefCount => ClearKnownPositiveRefCount to match the ↵Michael Gottesman2013-03-231-4/+4
| | | | | | name of the member that it is modifying. llvm-svn: 177818
* Changed the method name PtrState.IsKnownIncremented() to ↵Michael Gottesman2013-03-231-3/+3
| | | | | | | | | PtrState.HasKnownPositiveRefCount(). Now said method matches namewise every other method which refers to the member KnownPositiveRefCount of the class PtrState. llvm-svn: 177816
* Kill every call to @clang.arc.use in the ARC contract phase.John McCall2013-03-225-3/+22
| | | | llvm-svn: 177769
* Fixed a careless mistake.Michael Gottesman2013-02-231-1/+1
| | | | | | rdar://13273675. llvm-svn: 175939
* Make helpers static. Add missing include so LLVMInitializeObjCARCOpts gets C ↵Benjamin Kramer2013-02-151-0/+1
| | | | | | linkage. llvm-svn: 175264
* Changed isStoredObjCPointer => IsStoredObjCPointer. No functionality change.Michael Gottesman2013-02-121-4/+4
| | | | llvm-svn: 175017
* Moved some comments due to the recent refactoring of ObjCARC.Michael Gottesman2013-02-072-5/+4
| | | | | | | | 1. Moved a comment from ObjCARCOpts.cpp -> ObjCARCContract.cpp. 2. Removed a comment from ObjCARCOpts.cpp that was already moved to ObjCARCAliasAnalysis.h/.cpp. llvm-svn: 174581
* Removed explicit inline as per the LLVM style guide.Michael Gottesman2013-02-051-7/+7
| | | | llvm-svn: 174432
* Made certain small functions in PtrState inlined.Michael Gottesman2013-01-291-7/+7
| | | | llvm-svn: 173842
* Removed trailing comma in last element of enum declaration.Michael Gottesman2013-01-291-1/+1
| | | | llvm-svn: 173836
* Moved S_Stop back to its previous position in the sequence order.Michael Gottesman2013-01-291-1/+1
| | | | llvm-svn: 173834
* Fixed a few debug messages and some 80+ violations.Michael Gottesman2013-01-291-9/+10
| | | | llvm-svn: 173832
* Added some periods to some comments and added an overload for operator<< for ↵Michael Gottesman2013-01-291-6/+28
| | | | | | type Sequence so I can print out Sequences in debug statements. llvm-svn: 173831
* Changed DoesObjCBlockEscape => DoesRetainableObjPtrEscape so I can use it to ↵Michael Gottesman2013-01-291-14/+17
| | | | | | perform escape analysis of other retainable object pointers in other locations. llvm-svn: 173829
* Hopefully fix the Windows build failure introduced in r173769Timur Iskhodzhanov2013-01-292-0/+2
| | | | llvm-svn: 173781
* Fixed 2 more header comments...Michael Gottesman2013-01-292-2/+2
| | | | llvm-svn: 173774
* Fixed header comment.Michael Gottesman2013-01-291-8/+4
| | | | llvm-svn: 173773
* Fixed some whitespace/80+ violations. Also added a space after a namespace ↵Michael Gottesman2013-01-294-6/+6
| | | | | | declaration. llvm-svn: 173772
* Added missing dashes from header declaration comment.Michael Gottesman2013-01-291-1/+1
| | | | llvm-svn: 173770
* Juggled Debug.h from ObjCARC.h to only the including cpp files thatMichael Gottesman2013-01-294-2/+7
| | | | | | | actually have DEBUG statements. Also changed raw_ostream in said header to be a forward declaration (removing an include). llvm-svn: 173769
* Sorted includes using utils/sort_includes.Michael Gottesman2013-01-298-15/+6
| | | | llvm-svn: 173767
* Added two missing headers from ObjCARCAliasAnalysis.h.Michael Gottesman2013-01-291-0/+3
| | | | | | | | This was missed since whenever I was including ObjCARCAliasAnalysis.h, I was including ObjCARC.h before it which included these includes (resulting in no compilation breakage). llvm-svn: 173764
* Removed InstCombine/Targets as library dependencies for libObjCARCOpts since ↵Michael Gottesman2013-01-291-1/+1
| | | | | | they are unnecessary. llvm-svn: 173763
* Extracted ObjCARCContract from ObjCARCOpts into its own file.Michael Gottesman2013-01-299-1181/+1387
| | | | | | | | This also required adding 2x headers Dependency Analysis.h/Provenance Analysis.h and a .cpp file DependencyAnalysis.cpp to unentangle the dependencies inbetween ObjCARCContract and ObjCARCOpts. llvm-svn: 173760
* Removed some cruft from ObjCARCAliasAnalysis.cpp.Michael Gottesman2013-01-291-10/+0
| | | | llvm-svn: 173759
* Created ObjCARCUtil.cpp for functions which in my humble opinion are too ↵Michael Gottesman2013-01-283-126/+152
| | | | | | large to static inline and place in a header file such as ObjCARC.h. llvm-svn: 173666
OpenPOWER on IntegriCloud