Dan Gohman
71475f803c
Detect overflow in the path count computation. rdar://12277446.
...
llvm-svn: 163739
2012-09-12 20:45:17 +00:00
Dan Gohman
e90f78d5cd
Make provenance checking conservative in cases when
...
pointers-to-strong-pointers may be in play. These can lead to retains and
releases happening in unstructured ways, foiling the optimizer. This fixes
rdar://12150909.
llvm-svn: 163180
2012-09-04 23:16:20 +00:00
Dan Gohman
6cf00a0abc
Don't use for loops for code that is only intended to execute once. No
...
intended functionality change. Thanks to Ahmed Charles for spotting it.
llvm-svn: 162686
2012-08-27 18:31:36 +00:00
Dan Gohman
b9b982cd41
An objc_retain can serve as a may-use for a different pointer.
...
rdar://11931823.
llvm-svn: 160637
2012-07-23 19:27:31 +00:00
Sylvestre Ledru
bf8acb65ac
Fix a typo (the the => the)
...
llvm-svn: 160621
2012-07-23 08:51:15 +00:00
Dan Gohman
2287ddbef7
Fix the objc_autoreleasedReturnValue optimization code to locate
...
the call correctly even in the case where it is an invoke. This
fixes rdar://11714057.
llvm-svn: 159157
2012-06-25 19:47:37 +00:00
Benjamin Kramer
bb30e1face
Fix typos found by http://github.com/lyda/misspell-check
...
llvm-svn: 157885
2012-06-02 10:20:22 +00:00
Chris Lattner
b787e2914f
Reimplement the intrinsic verifier to use the same table as Intrinsic::getDefinition,
...
making it stronger and more sane.
Delete the code from tblgen that produced the old code.
Besides being a path forward in intrinsic sanity, this also eliminates a bunch of
machine generated code that was compiled into Function.o
llvm-svn: 157545
2012-05-27 19:37:05 +00:00
Dan Gohman
992a69b57c
Mark an unreachable region of code with llvm_unreachable.
...
llvm-svn: 157197
2012-05-21 17:41:28 +00:00
Dan Gohman
a487e2b57e
Fix replacing all the users of objc weak runtime routines
...
when deleting them. rdar://11434915.
llvm-svn: 157080
2012-05-18 22:17:29 +00:00
Dan Gohman
9e72870dd1
Fix the objc_storeStrong recognizer to stop before walking off the
...
end of a basic block if there's no store.
llvm-svn: 156520
2012-05-09 23:08:33 +00:00
Craig Topper
749c95a942
Remove unused variable to get rid of warning.
...
llvm-svn: 156466
2012-05-09 07:08:58 +00:00
Dan Gohman
0f60d6f9b0
Miscellaneous accumulated cleanups.
...
llvm-svn: 156445
2012-05-08 23:39:44 +00:00
Dan Gohman
b47d02f929
Fix objc_storeStrong pattern matching to catch a potential use of the
...
old value after the store but before it is released.
This fixes rdar:/11116986.
llvm-svn: 156442
2012-05-08 23:34:08 +00:00
Dan Gohman
1bc0d2e1bc
Miscellaneous accumulated cleanups.
...
llvm-svn: 155725
2012-04-27 18:56:31 +00:00
Dan Gohman
64171a0b3b
Simplify the known retain count tracking; use a boolean state instead
...
of a precise count. Also, move RRInfo's Partial field into PtrState,
now that it won't increase the size.
llvm-svn: 155513
2012-04-25 00:50:46 +00:00
Dan Gohman
3a24d34041
Build custom predecessor and successor lists for each basic block.
...
These lists exclude invoke unwind edges and loop backedges which
are being ignored. This makes it easier to ignore them
consistently.
llvm-svn: 155500
2012-04-24 22:53:18 +00:00
Dan Gohman
f4472e9a1f
Avoid a bug in the path count computation, preventing an infinite
...
loop repeatedlt making the same change. This is for rdar://11256239.
llvm-svn: 155160
2012-04-19 21:50:46 +00:00
Dan Gohman
a99c119e05
Don't crash on code where the user put __attribute__((constructor)) on
...
a function with arguments. This fixes rdar://11265785.
llvm-svn: 155073
2012-04-18 22:24:33 +00:00
Dan Gohman
0387e6b701
Add some comments, and fix a few places that missed setting Changed.
...
llvm-svn: 154687
2012-04-13 18:57:48 +00:00
Dan Gohman
d5743c7fd0
Consider ObjC runtime calls objc_storeWeak and others which make a copy of
...
their argument as "escape" points for objc_retainBlock optimization.
This fixes rdar://11229925.
llvm-svn: 154682
2012-04-13 18:28:58 +00:00
Dan Gohman
81ac0c921f
Use the new Use-aware dominates method to apply the objc runtime
...
library return value optimization for phi uses. Even when the
phi itself is not dominated, the specific use may be dominated.
llvm-svn: 154647
2012-04-13 01:08:28 +00:00
Dan Gohman
6a5b02f8ee
Don't move objc_autorelease calls past autorelease pool boundaries when
...
optimizing autorelease calls on phi nodes with null operands.
This fixes rdar://11207070.
llvm-svn: 154642
2012-04-13 00:59:57 +00:00
Dan Gohman
a5e2200b2a
Fix accidentally inverted logic from r152803, and make the
...
testcase slightly less trivial. This fixes rdar://11171718.
llvm-svn: 154118
2012-04-05 20:27:21 +00:00
Francois Pichet
6a1f32c9cf
Fix the MSVC build.
...
llvm-svn: 153366
2012-03-24 01:36:37 +00:00
Dan Gohman
ef28237798
Don't convert objc_retainAutoreleasedReturnValue to objc_retain if it
...
is retaining the return value of an invoke that it immediately follows.
llvm-svn: 153344
2012-03-23 18:09:00 +00:00
Dan Gohman
0c02608af1
It's not possible to insert code immediately after an invoke in the
...
same basic block, and it's not safe to insert code in the successor
blocks if the edges are critical edges. Splitting those edges is
possible, but undesirable, especially on the unwind side. Instead,
make the bottom-up code motion to consider invokes to be part of
their successor blocks, rather than part of their parent blocks, so
that it doesn't push code past them and onto the edges. This fixes
PR12307.
llvm-svn: 153343
2012-03-23 17:47:54 +00:00
Dan Gohman
df222b2e87
Refactor the code for visiting instructions out into helper functions.
...
llvm-svn: 153267
2012-03-22 18:24:56 +00:00
Rafael Espindola
ac42573389
Short term fix for pr12270 before we change dominates to handle unreachable
...
code.
While here, reduce indentation.
llvm-svn: 152803
2012-03-15 15:52:59 +00:00
Dan Gohman
a30e1f4576
When an invoke is marked with metadata indicating its unwind edge
...
should be ignored by ARC optimization, don't insert new ARC runtime
calls in the unwind destination.
llvm-svn: 152748
2012-03-14 23:05:06 +00:00
Dan Gohman
784659a39f
When identifying exit nodes for the reverse-CFG reverse-post-order
...
traversal, consider nodes for which the only successors are backedges
which the traversal is ignoring to be exit nodes. This fixes a problem
where the bottom-up traversal was failing to visit split blocks along
split loop backedges. This fixes rdar://10989035.
llvm-svn: 152421
2012-03-09 18:50:52 +00:00
Dan Gohman
e0e8af6739
Fix an iterator invalidation problem. operator[] on a DenseMap
...
can insert a new element, invalidating iterators. Use find
instead, and handle the case where the key is not found explicitly.
llvm-svn: 151871
2012-03-02 01:26:46 +00:00
Dan Gohman
acbf555d2f
Misc micro-optimizations.
...
llvm-svn: 151869
2012-03-02 01:13:53 +00:00
Dan Gohman
71b80f9e8c
Calls and invokes with the new clang.arc.no_objc_arc_exceptions
...
metadata may still unwind, but only in ways that the ARC
optimizer doesn't need to consider. This permits more
aggressive optimization.
llvm-svn: 150829
2012-02-17 18:59:53 +00:00
Dan Gohman
20fd978e4b
Just like in regular escape analysis, loads and stores through
...
(but not of) a block pointer do not cause the block pointer to
escape. This fixes rdar://10803830.
llvm-svn: 150424
2012-02-13 22:57:02 +00:00
David Blaikie
06ecc99a56
More dead code removal (using -Wunreachable-code)
...
llvm-svn: 148578
2012-01-20 21:51:11 +00:00
Dan Gohman
9bb84ffb6c
Set the "tail" flag on pattern-matched objc_storeStrong calls.
...
rdar://10531041.
llvm-svn: 148490
2012-01-19 19:14:36 +00:00
Dan Gohman
7e17e84f9c
Add a depth limit to avoid runaway recursion.
...
llvm-svn: 148419
2012-01-18 21:24:45 +00:00
Dan Gohman
48f4e5752e
Use llvm.global_ctors to locate global constructors instead
...
of recognizing them by name.
llvm-svn: 148416
2012-01-18 21:19:38 +00:00
Dan Gohman
9b37a5592c
Add a new ObjC ARC optimization pass to eliminate unneeded
...
autorelease push+pop pairs.
llvm-svn: 148330
2012-01-17 20:52:24 +00:00
David Blaikie
2526691971
Remove unreachable code. (replace with llvm_unreachable to help GCC where necessary)
...
llvm-svn: 148284
2012-01-17 04:43:56 +00:00
Dan Gohman
4539e2a975
Fix an unused variable warning that Chad noticed.
...
llvm-svn: 148164
2012-01-14 00:47:44 +00:00
Dan Gohman
922244c634
Implement proper ObjC ARC objc_retainBlock "escape" analysis, so that
...
the optimizer doesn't eliminate objc_retainBlock calls which are needed
for their side effect of copying blocks onto the heap.
This implements rdar://10361249.
llvm-svn: 148076
2012-01-13 00:39:07 +00:00
Dan Gohman
17bd9795e9
Fix a copy+pasto. No testcase, because the symptoms of dereferencing
...
an invalid iterator aren't reproducible. rdar://10614085.
llvm-svn: 147098
2011-12-21 21:43:50 +00:00
Dan Gohman
e9572aa680
It turns out that clang does use pointer-to-function types to
...
point to ARC-managed pointers sometimes. This fixes rdar://10551239.
llvm-svn: 146577
2011-12-14 19:10:53 +00:00
Dan Gohman
40acf5d720
When computing reverse-CFG reverse-post-order, skip backedges, as
...
detected in the forward-CFG DFS. This prevents the reverse-CFG from
visiting blocks inside loops after blocks that dominate them in the
case where loops have multiple exits.
No testcase, because this fixes a bug which in practice only shows
up in a full optimizer run, due to the use-list order.
This fixes rdar://10422791 and others.
llvm-svn: 146408
2011-12-12 19:42:25 +00:00
Dan Gohman
73c245acaa
Add a TODO comment.
...
llvm-svn: 146389
2011-12-12 18:30:26 +00:00
Dan Gohman
9144e6bb3e
Fix a copy+pasto in a comment.
...
llvm-svn: 146385
2011-12-12 18:20:00 +00:00
Dan Gohman
ee8b344c67
Use getArgOperand instead of getOperand on a call.
...
llvm-svn: 146384
2011-12-12 18:19:12 +00:00
Dan Gohman
61f78d27b0
Inline SetSeqToRelease into its only caller, since it's more clear that way.
...
llvm-svn: 146383
2011-12-12 18:16:56 +00:00