1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00
Commit Graph

8035 Commits

Author SHA1 Message Date
Bill Wendling
1da5257929 If the block that we're threading through is jumped to by an indirect branch,
then we don't want to set the destination in the indirect branch to the
destination. This is because the indirect branch needs its destinations to have
had their block addresses taken. This isn't so of the new critical edge that's
split during this process. If it turns out that the destination block has only
one predecessor, and that being a BB with an indirect branch, then it won't be
marked as 'used' and may be removed.
PR10072

llvm-svn: 132638
2011-06-04 09:42:04 +00:00
Devang Patel
ec747bb76b Use IRBuilder, preserve line numbers.
llvm-svn: 132578
2011-06-03 19:46:19 +00:00
Nick Lewycky
ce38535f5b Bail on unswitching a switch statement for a case with a critical edge. We name
which edge to split by pred/succ pair, which means that we can end up splitting
the wrong edge (by case value) in the switch statement entirely. Fixes PR10031!

llvm-svn: 132535
2011-06-03 06:27:15 +00:00
Devang Patel
73e16acee8 Preserve line number information while converting Invoke into a Call.
llvm-svn: 132505
2011-06-02 22:46:58 +00:00
Eli Friedman
0db9c60959 PR10067: Add missing safety check to call return transformation in MemCpyOpt::processStore. If something accesses the dest of the "copy" between the call and the copy, the performCallSlotOptzn transformation is not valid.
llvm-svn: 132485
2011-06-02 21:24:42 +00:00
Stuart Hastings
904f5d9bd7 Reapply 132348 with fixes. rdar://problem/6501862
llvm-svn: 132402
2011-06-01 16:42:47 +00:00
John McCall
18921da759 First, do no harm -- even if we can't find a selector for an enclosing
landing pad, forward llvm.eh.resume calls to it instead of turning them
invalidly into invokes.

llvm-svn: 132382
2011-06-01 02:17:11 +00:00
Stuart Hastings
47cbd200e4 Revert to pacify a buildbot. rdar://problem/6501862
llvm-svn: 132351
2011-05-31 19:56:35 +00:00
Stuart Hastings
e226ec461c Followup to 132316; accept arbitrary constants, add with a constant,
sub with a non-constant.  Fix comments, enlarge test case.
rdar://problem/6501862

llvm-svn: 132348
2011-05-31 19:29:55 +00:00
Stuart Hastings
9f37a92c33 (1 - X) * (-2) -> (x - 1) * 2, for all positive nonzero powers of 2
rdar://problem/6501862

llvm-svn: 132316
2011-05-30 20:00:33 +00:00
Nick Lewycky
58d87d5490 Don't crash owhen ComputeLoadResult can't compute the result of the load.
llvm-svn: 132290
2011-05-29 19:33:36 +00:00
Nick Lewycky
07ed4434b8 Obey the isVolatile bit on memory intrinsics when analyzing uses of a global
variable. Noticed by inspection.

Simulate memset in EvaluateFunction where the target of the memset and the
value we're setting are both the null value. Fixes PR10047!

llvm-svn: 132288
2011-05-29 18:41:56 +00:00
Nadav Rotem
77b328bd14 Fix warnings due to 132263; Thanks rdivacky.
llvm-svn: 132285
2011-05-29 08:10:47 +00:00
John McCall
233946583f Fix this to work correctly with phis; test case to follow if this successfully
fixes self-host.

llvm-svn: 132275
2011-05-29 03:01:09 +00:00
Benjamin Kramer
129192d295 ConstantFoldInstOperands doesn't like compares, hand it off to instsimplify instead.
Fixes PR10040.

llvm-svn: 132254
2011-05-28 10:16:58 +00:00
John McCall
119a0222f5 Implement and document the llvm.eh.resume intrinsic, which is
transformed by the inliner into a branch to the enclosing landing pad
(when inlined through an invoke).  If not so optimized, it is lowered
DWARF EH preparation into a call to _Unwind_Resume (or _Unwind_SjLj_Resume
as appropriate).  Its chief advantage is that it takes both the
exception value and the selector value as arguments, meaning that there
is zero effort in recovering these;  however, the frontend is required
to pass these down, which is not actually particularly difficult.

Also document the behavior of landing pads a bit better, and make it
clearer that it's okay that personality functions don't always land at
landing pads.  This is just a fact of life.  Don't write optimizations that
rely on pushing things over an unwind edge.

llvm-svn: 132253
2011-05-28 07:45:59 +00:00
Nadav Rotem
531aa71d22 Refactor getActionType and getTypeToTransformTo ; place all of the 'decision'
code in one place. Re-apply 131534 and fix the multi-step promotion of integers.

llvm-svn: 132217
2011-05-27 21:03:13 +00:00
Eli Friedman
fe707571fc Attempt to preserve debug line info in LICM; as the comment in the code says, it's hard to pick good line numbers for this transformation, but something is better than nothing.
rdar://9143729

llvm-svn: 132215
2011-05-27 20:31:51 +00:00
Eli Friedman
1062ba1e1f Don't sink or hoist debug info instrinsics; it isn't useful. This also prevents LICM sinking from erasing debug intrinsics which don't dominate any exit block of the loop.
rdar://9143943 .

llvm-svn: 132201
2011-05-27 18:37:52 +00:00
John McCall
2f479c4d42 Fix the inliner to maintain the current de facto invoke semantics:
- the selector for the landing pad must provide all available information
    about the handlers, filters, and cleanups within that landing pad
  - calls to _Unwind_Resume must be converted to branches to the enclosing
    lpad so as to avoid re-entering the unwinder when the lpad claimed it
    was going to handle the exception in some way
This is quite specific to libUnwind-based unwinding.  In an effort to not
interfere too badly with other unwinders, and with existing hacks in frontends,
this only triggers on _Unwind_Resume (not _Unwind_Resume_or_Rethrow) and does
nothing with selectors if it cannot find a selector call for either lpad.

llvm-svn: 132200
2011-05-27 18:34:38 +00:00
Eli Friedman
17000790d8 Oops, wasn't intending to commit this. Partial revert of r132194.
llvm-svn: 132195
2011-05-27 18:04:04 +00:00
Eli Friedman
560532051b Fix a silly mistake (which trips over an assertion) in r132099. rdar://9515076
llvm-svn: 132194
2011-05-27 18:02:04 +00:00
Benjamin Kramer
5b491b9d0e InstCombine: Make switch folding with equality compares more aggressive by trying instsimplify on the arm where we know the compared value.
Stuff like "x == y ? y : x&y" now folds into "x&y".

llvm-svn: 132185
2011-05-27 13:00:16 +00:00
Eli Friedman
d619bcd565 One more debug line number miss in instcombine (although the code in question isn't actually in instcombine).
llvm-svn: 132170
2011-05-27 01:00:36 +00:00
Eli Friedman
6937c422a0 Final step of instcombine debuginfo; switch a couple more places over to InsertNewInstWith, and use setDebugLoc for the cases which can't be easily handled by the automated mechanisms.
llvm-svn: 132167
2011-05-27 00:19:40 +00:00
Chandler Carruth
6a41ac0d30 Fix warning about || and && without explicit grouping.
This looks like it flagged an actual bug. Devang, please review. I added
the parentheses that change behavior, but make the behavior more closely
match commit log's intent.

llvm-svn: 132165
2011-05-26 23:37:58 +00:00
Devang Patel
5e3f883ddf Do not insert anything after terminator.
llvm-svn: 132164
2011-05-26 23:16:48 +00:00
Chad Rosier
b87c4a6945 Renamed llvm.x86.sse42.crc32 intrinsics; crc64 doesn't exist.
crc32.[8|16|32] have been renamed to .crc32.32.[8|16|32] and
crc64.[8|16|32] have been renamed to .crc32.64.[8|64].

llvm-svn: 132163
2011-05-26 23:13:19 +00:00
Devang Patel
c67e8c5d45 Do not move DBG_VALUE in middle of PHI nodes.
llvm-svn: 132161
2011-05-26 22:43:14 +00:00
Devang Patel
52e803e053 If llvm.dbg.value and the value instruction it refers to are far apart then iSel may not be able to find corresponding Node for llvm.dbg.value during DAG construction. Make iSel's life easier by removing this distance between llvm.dbg.value and its value instruction.
llvm-svn: 132151
2011-05-26 21:51:06 +00:00
Andrew Trick
0577c5768b indvars: incremental fixes for -disable-iv-rewrite and testcases.
Use a proper worklist for use-def traversal without holding onto an
iterator. Now that we process all IV uses, we need complete logic for
resusing existing derived IV defs. See HoistStep.

llvm-svn: 132103
2011-05-26 00:46:11 +00:00
Eli Friedman
5cd755549b PR9998: ashr exact %x, 31 is not equivalent to sdiv exact %x, -2147483648.
llvm-svn: 132097
2011-05-25 23:26:20 +00:00
Evan Cheng
335fcad6bc Simplify r132022 based on Cameron's feedback.
llvm-svn: 132071
2011-05-25 18:17:13 +00:00
Andrew Trick
0aa40b2f8f indvars: fixed IV cloning in -disable-iv-rewrite mode with associated
cleanup and overdue test cases.

llvm-svn: 132038
2011-05-25 04:42:22 +00:00
Evan Cheng
d359a7cab3 Forgot dyn_cast check.
llvm-svn: 132025
2011-05-24 23:47:50 +00:00
Evan Cheng
9466b36c02 Fix LoopUnswitch bug. RewriteLoopBodyWithConditionConstant can delete a dead
case of a switch instruction. Back off this optimization when this would
eliminate all of the predecessors to the latch.

Sorry, I am unable to reduce a reasonably sized test case.

rdar://9486843

llvm-svn: 132022
2011-05-24 23:12:57 +00:00
Eli Friedman
5ae1b40f55 Make instcombine O(N) instead of O(N^2) in code where the same simplifiable constant is used many times.
Part of rdar://9471075.

llvm-svn: 131979
2011-05-24 18:52:07 +00:00
Cameron Zwarich
e425894eaf Clean up the lazy initialization of DIBuilder a bit.
llvm-svn: 131956
2011-05-24 06:00:08 +00:00
Cameron Zwarich
462b5db500 Make LoadAndStorePromoter preserve debug info and create llvm.dbg.values when
promoting allocas to SSA variables. Fixes <rdar://problem/9479036>.

llvm-svn: 131953
2011-05-24 03:10:43 +00:00
Dan Gohman
e6a4a2aa6f When checking for signed multiplication overflow, watch out for INT_MIN and -1.
This fixes PR9845.

llvm-svn: 131919
2011-05-23 21:07:39 +00:00
Chris Lattner
bee56202ba rearrange two transforms, since one subsumes the other. Make the shift-exactness
xform recurse.

llvm-svn: 131888
2011-05-23 00:32:19 +00:00
Chris Lattner
ec35f49b3e Transform any logical shift of a power of two into an exact/NUW shift when
in a known-non-zero context.

llvm-svn: 131887
2011-05-23 00:21:50 +00:00
Chris Lattner
498f516575 use the valuetracking isPowerOfTwo function, which is more powerful than checking
for a constant directly.  Thanks to Duncan for pointing this out.

llvm-svn: 131885
2011-05-23 00:09:55 +00:00
Chris Lattner
c277b19e97 Teach valuetracking that byval arguments with a specified alignment are
aligned.

Teach memcpyopt to not give up all hope when confonted with an underaligned
memcpy feeding an overaligned byval.  If the *source* of the memcpy can be
determined to be adequeately aligned, or if it can be forced to be, we can
eliminate the memcpy.

This addresses PR9794.  We now compile the example into:

define i32 @f(%struct.p* nocapture byval align 8 %q) nounwind ssp {
entry:
  %call = call i32 @g(%struct.p* byval align 8 %q) nounwind
  ret i32 %call
}

in both x86-64 and x86-32 mode.  We still don't get a tailcall though,
because tailcalls apparently can't handle byval.

llvm-svn: 131884
2011-05-23 00:03:39 +00:00
Chris Lattner
84f101ea45 add some random notes.
llvm-svn: 131862
2011-05-22 18:26:48 +00:00
Chris Lattner
8ed794f599 Carve out a place in instcombine to put transformations which work knowing that their
result is non-zero.  Implement an example optimization (PR9814), which allows us to
transform:
  A / ((1 << B) >>u 2)
into:
  A >>u (B-2)

which we compile into:

_divu3:                                 ## @divu3
	leal	-2(%rsi), %ecx
	shrl	%cl, %edi
	movl	%edi, %eax
	ret

instead of:

_divu3:                                 ## @divu3
	movb	%sil, %cl
	movl	$1, %esi
	shll	%cl, %esi
	shrl	$2, %esi
	movl	%edi, %eax
	xorl	%edx, %edx
	divl	%esi, %eax
	ret

llvm-svn: 131860
2011-05-22 18:18:41 +00:00
Chris Lattner
44516c3ba3 Fix PR9815: I was trying to get out of "generating code and then
failing to form a memset, then having to delete it" but my approximation
isn't safe for self recurrent loops.  Instead of doign a hack, just
do it the right way.

llvm-svn: 131858
2011-05-22 17:39:56 +00:00
Frits van Bommel
df58ece78a Add a parameter to ConstantFoldTerminator() that callers can use to ask it to also clean up the condition of any conditional terminator it folds to be unconditional, if that turns the condition into dead code. This just means it calls RecursivelyDeleteTriviallyDeadInstructions() in strategic spots. It defaults to the old behavior.
I also changed -simplifycfg, -jump-threading and -codegenprepare to use this to produce slightly better code without any extra cleanup passes (AFAICT this was the only place in -simplifycfg where now-dead conditions of replaced terminators weren't being cleaned up). The only other user of this function is -sccp, but I didn't read that thoroughly enough to figure out whether it might be holding pointers to instructions that could be deleted by this.

llvm-svn: 131855
2011-05-22 16:24:18 +00:00
Chris Lattner
98ce5cd957 fix PR9856, an incorrectly conservative assertion: a global can be
"stored once" even if its address is compared.

llvm-svn: 131849
2011-05-22 07:15:13 +00:00
Chris Lattner
6cce3b63ab fix PR9841 by having GVN not process dead loads. This was
causing it to get into infinite loops when it would widen a 
load (which can necessarily leave around dead loads).

llvm-svn: 131847
2011-05-22 07:03:34 +00:00