summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [objcarcopts] Encapsulate PtrState.RRI.ReleaseMetadata into the methods ↵Michael Gottesman2013-06-211-2/+10
| | | | | | PtrState.GetReleaseMetadata() and PtrState.SetReleaseMetadata(). llvm-svn: 184534
* [objcarcopts] Encapsulate PtrState.RRI.IsTailCallRelease into the method ↵Michael Gottesman2013-06-211-2/+10
| | | | | | PtrState.IsTailCallRelease() and PtrState.SetTailCallRelease(). llvm-svn: 184533
* [obcjarcopts] Encapsulate PtrState.RRI.KnownSafe in the methods ↵Michael Gottesman2013-06-211-6/+15
| | | | | | | | | | | | PtrState.IsKnownSafe and PtrState.SetKnownSafe. This is apart of a series of patches to encapsulate PtrState.RRI and make PtrState.RRI a private field of PtrState. *NOTE* This is actually the second commit in the patch stream. I should have put this note on the first such commit r184528. llvm-svn: 184532
* [objcarcopts] Some more minor code cleanups/comment additions.Michael Gottesman2013-06-211-1/+5
| | | | llvm-svn: 184531
* [objcarcopts] Refactor out the RRInfo merging code from PtrState into ↵Michael Gottesman2013-06-211-17/+28
| | | | | | | | RRInfo::Merge. I also added some comments and performed minor code cleanups. llvm-svn: 184528
* [objc-arc] Ensure that the cfg path count does not overflow when we multiply ↵Michael Gottesman2013-06-071-10/+38
| | | | | | | | TopDownPathCount/BottomUpPathCount. rdar://12480535 llvm-svn: 183489
* [objc-arc] KnownSafe does not imply that it is safe to perform code motion ↵Michael Gottesman2013-05-241-8/+40
| | | | | | | | across CFG edges since even if it is safe to remove RR pairs, we may still be able to move a retain/release into a loop. rdar://13949644 llvm-svn: 182670
* [objc-arc] Make sure that multiple owners is propogated correctly through ↵Michael Gottesman2013-05-241-17/+16
| | | | | | | | the pass via the usage of a global data structure. rdar://13750319 llvm-svn: 182669
* [objc-arc] Fixed number of prefixing slashes in some comments in a function ↵Michael Gottesman2013-05-231-6/+6
| | | | | | from 3 to 2 to match the rest of ObjCARCOpts. llvm-svn: 182557
* [objc-arc] Fixed a spelling error and made the statistic descriptions be ↵Michael Gottesman2013-05-151-5/+5
| | | | | | consistent about their usage of periods. llvm-svn: 181901
* Removed trailing whitespace.Michael Gottesman2013-05-141-4/+4
| | | | llvm-svn: 181760
* [objc-arc-opts] Added debug statements when we set and unset whether a ↵Michael Gottesman2013-05-141-0/+2
| | | | | | pointer is known positive. llvm-svn: 181745
* [objc-arc-opts] In the presense of an alloca unconditionally remove RR pairs ↵Michael Gottesman2013-05-131-5/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | if and only if we are both KnownSafeBU/KnownSafeTD rather than just either or. In the presense of a block being initialized, the frontend will emit the objc_retain on the original pointer and the release on the pointer loaded from the alloca. The optimizer will through the provenance analysis realize that the two are related (albiet different), but since we only require KnownSafe in one direction, will match the inner retain on the original pointer with the guard release on the original pointer. This is fixed by ensuring that in the presense of allocas we only unconditionally remove pointers if both our retain and our release are KnownSafe (i.e. we are KnownSafe in both directions) since we must deal with the possibility that the frontend will emit what (to the optimizer) appears to be unbalanced retain/releases. An example of the miscompile is: %A = alloca retain(%x) retain(%x) <--- Inner Retain store %x, %A %y = load %A ... DO STUFF ... release(%y) call void @use(%x) release(%x) <--- Guarding Release getting optimized to: %A = alloca retain(%x) store %x, %A %y = load %A ... DO STUFF ... release(%y) call void @use(%x) rdar://13750319 llvm-svn: 181743
* Move a couple more statistics inside '#ifndef NDEBUG'.Matt Beaumont-Gay2013-05-131-1/+1
| | | | | | Suppresses an unused-variable warning in -Asserts builds. llvm-svn: 181733
* [objc-arc-opts] Add comment to BBState making it clear that ↵Michael Gottesman2013-05-131-0/+6
| | | | | | get{TopDown,BottomUp}PtrState will create a new PtrState object if it does not find a PtrState for Arg. llvm-svn: 181726
* [objc-arc] Move the before optimization statistics gathering phase out of ↵Michael Gottesman2013-05-131-8/+7
| | | | | | | | | | | OptimizeIndividualCalls. This makes the statistics gathering completely independent of the actual optimization occuring, preventing any sort of bleeding over from occuring. Additionally, it simplifies a switch statement in the non-statistic gathering case. llvm-svn: 181719
* Add ArrayRef constructor from None, and do the cleanups that this ↵Dmitri Gribenko2013-05-051-2/+1
| | | | | | | | constructor enables Patch by Robert Wilhelm. llvm-svn: 181138
* Add in some conditional compilation in order to silence an unused variable ↵Michael Gottesman2013-04-291-0/+2
| | | | | | warning. llvm-svn: 180700
* [objc-arc] Apply the RV optimization to retains next to calls in ↵Michael Gottesman2013-04-291-52/+0
| | | | | | | | | | | | | | | ObjCARCContract instead of ObjCARCOpts. Turning retains into retainRV calls disrupts the data flow analysis in ObjCARCOpts. Thus we move it as late as we can by moving it into ObjCARCContract. We leave in the conversion from retainRV -> retain in ObjCARCOpt since it enables the dataflow analysis. rdar://10813093 llvm-svn: 180698
* Added statistics to count the number of retains/releases before/after ↵Michael Gottesman2013-04-291-0/+47
| | | | | | optimization. llvm-svn: 180697
* Removed trailing whitespace.Michael Gottesman2013-04-291-1/+1
| | | | llvm-svn: 180696
* Fix for r180693. = /.Michael Gottesman2013-04-291-1/+2
| | | | llvm-svn: 180694
* [objc-arc-annotations] Moved the disabling of call movement to ↵Michael Gottesman2013-04-291-6/+5
| | | | | | ConnectTDBUTraversals so that I can prevent Changed = true from being set. This prevents an infinite loop. llvm-svn: 180693
* Revert "[objc-arc] Added ImpreciseAutoreleaseSet to track autorelease calls ↵Michael Gottesman2013-04-261-38/+0
| | | | | | | | | | | | | | that were once autoreleaseRV instructions." This reverts commit r180222. I think this might tie in with a different problem which will require a different approach potentially. I am reverting this in the case I need to go down that second path. My apologies for the noise. = /. llvm-svn: 180590
* [objc-arc] Added ImpreciseAutoreleaseSet to track autorelease calls that ↵Michael Gottesman2013-04-241-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | were once autoreleaseRV instructions. Due to the semantics of ARC, we must be extremely conservative with autorelease calls inserted by the frontend since ARC gaurantees that said object will be in the autorelease pool after that point, an optimization invariant that the optimizer must respect. On the other hand, we are allowed significantly more flexibility with autoreleaseRV instructions. Often times though this flexibility is disrupted by early transformations which transform objc_autoreleaseRV => objc_autorelease if said instruction is no longer being used as part of an RV pair (generally due to inlining). Since we can not tell the difference in between an autorelease put into place by the frontend and one created through said ``strength reduction'' we can not perform these optimizations. The addition of this set gets around said issues by allowing us to differentiate in between said two cases. rdar://problem/13697741. llvm-svn: 180222
* Fixed comment typo.Michael Gottesman2013-04-241-1/+1
| | | | llvm-svn: 180221
* When we strength reduce an objc_retainBlock call to objc_retain, increment ↵Michael Gottesman2013-04-211-1/+6
| | | | | | NumPeeps and make sure that Changed is set to true. llvm-svn: 179968
* Fixed comment typo.Michael Gottesman2013-04-211-1/+1
| | | | llvm-svn: 179967
* [objc-arc] Fixed typo in debug message.Michael Gottesman2013-04-211-1/+1
| | | | llvm-svn: 179966
* [objc-arc] Fixed comment typo.Michael Gottesman2013-04-211-1/+1
| | | | llvm-svn: 179965
* [objc-arc] Refactored OptimizeReturns so that it uses continue instead of a ↵Michael Gottesman2013-04-211-25/+30
| | | | | | large multi-level nested if statement. llvm-svn: 179964
* [objc-arc] Added debug statement saying when we are resetting a sequence's ↵Michael Gottesman2013-04-201-0/+1
| | | | | | | | | | progress. This will make it clearer when we are actually resetting a sequence's progress vs just changing state. This is an important distinction because the former case clears any pointers that we are tracking while the later does not. llvm-svn: 179963
* [objc-arc] Do not mismatch up retains inside a for loop with releases ↵Michael Gottesman2013-04-181-96/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | outside said for loop in the presense of differing provenance caused by escaping blocks. This occurs due to an alloca representing a separate ownership from the original pointer. Thus consider the following pseudo-IR: objc_retain(%a) for (...) { objc_retain(%a) %block <- %a F(%block) objc_release(%block) } objc_release(%a) From the perspective of the optimizer, the %block is a separate provenance from the original %a. Thus the optimizer pairs up the inner retain for %a and the outer release from %a, resulting in segfaults. This is fixed by noting that the signature of a mismatch of retain/releases inside the for loop is a Use/CanRelease top down with an None bottom up (since bottom up the Retain-CanRelease-Use-Release sequence is completed by the inner objc_retain, but top down due to the differing provenance from the objc_release said sequence is not completed). In said case in CheckForCFGHazards, we now clear the state of %a implying that no pairing will occur. Additionally a test case is included. rdar://12969722 llvm-svn: 179747
* Removed trailing whitespace.Michael Gottesman2013-04-181-3/+3
| | | | llvm-svn: 179746
* [objc-arc] Added annotation option to only emit annotations for a specific ↵Michael Gottesman2013-04-171-0/+24
| | | | | | ssa identifier. llvm-svn: 179729
* Fixed typo.Michael Gottesman2013-04-171-4/+4
| | | | llvm-svn: 179721
* [objc-arc] Added descriptions for EnableARCAnnotations, ↵Michael Gottesman2013-04-171-3/+6
| | | | | | 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
OpenPOWER on IntegriCloud