Commit Graph

6764 Commits

Author SHA1 Message Date
Chris Lattner b9801ffcb5 fix PR6760, a missing check in heap SRoA.
llvm-svn: 100936
2010-04-10 18:19:22 +00:00
Dan Gohman 607e02b33a When determining a canonical insert position, don't climb deeper
into adjacent loops. Also, ensure that the insert position is
dominated by the loop latch of any loop in the post-inc set which
has a latch.

llvm-svn: 100906
2010-04-09 22:07:05 +00:00
Chris Lattner 74e2ef68b9 suck the propagating "has dynamic libs" check into a single makefile
variable TARGET_HAS_DYNAMIC_LIBS

llvm-svn: 100896
2010-04-09 20:51:47 +00:00
Chris Lattner c86cdc7d47 add minix support, patch by Kees van Reeuwijk! PR6797
llvm-svn: 100895
2010-04-09 20:45:04 +00:00
Wesley Peck a2ca3fa781 Adding IPSCCP and Internalize passes to the C-bindings
llvm-svn: 100893
2010-04-09 20:43:20 +00:00
Dan Gohman 42ec4eb351 When looking for loop-invariant users, look through no-op instructions,
so that an unfortunately placed bitcast doesn't pin a value in a
register.

llvm-svn: 100883
2010-04-09 19:12:34 +00:00
Gabor Greif ef60190a00 performance: cache result of looking up user
llvm-svn: 100862
2010-04-09 15:18:34 +00:00
Dan Gohman 0a8175d1db Minor code simplification.
llvm-svn: 100859
2010-04-09 14:53:59 +00:00
Gabor Greif ce6dd889ec const-ize a predicate
llvm-svn: 100856
2010-04-09 10:57:00 +00:00
Dan Gohman d2df643ddb Refactor the code for computing the insertion point for an expression into
a separate function.

llvm-svn: 100845
2010-04-09 02:00:38 +00:00
Chris Lattner c6c153be45 fix a SCCP miscompilation that could happen when a
forced constant is changed to a constant, we would end
up adding the instruction to the wrong worklist, 
preventing it from being properly revisited.  This fixes
rdar://7832370

llvm-svn: 100837
2010-04-09 01:14:31 +00:00
Dan Gohman 9b5d0bb774 Avoid allocating a value of zero in a register if the initial formula
inputs happen to negate each other.

llvm-svn: 100828
2010-04-08 23:36:27 +00:00
Dan Gohman 4ce1fb1448 Add variants of ult, ule, etc. which take a uint64_t RHS, for convenience.
llvm-svn: 100824
2010-04-08 23:03:40 +00:00
Dan Gohman 4506539d84 When expanding expressions which are using post-inc mode for multiple loops,
ensure that the expansion is dominated by the increments of those loops.

llvm-svn: 100748
2010-04-08 05:57:57 +00:00
Dan Gohman eb7111b98f Say bitcast instead of bitconvert.
llvm-svn: 100720
2010-04-07 23:22:42 +00:00
Eric Christopher e8b281c3c3 Add support for stpncpy_chk.
llvm-svn: 100710
2010-04-07 23:00:07 +00:00
Chris Lattner 2104b8d36e rename llvm::llvm_report_error -> llvm::report_fatal_error
llvm-svn: 100709
2010-04-07 22:58:41 +00:00
Dan Gohman d006ab90dd Generalize IVUsers to track arbitrary expressions rather than expressions
explicitly split into stride-and-offset pairs. Also, add the
ability to track multiple post-increment loops on the same expression.

This refines the concept of "normalizing" SCEV expressions used for
to post-increment uses, and introduces a dedicated utility routine for
normalizing and denormalizing expressions.

This fixes the expansion of expressions which are post-increment users
of more than one loop at a time. More broadly, this takes LSR another
step closer to being able to reason about more than one loop at a time.

llvm-svn: 100699
2010-04-07 22:27:08 +00:00
Gabor Greif 08d85da6cc fix 80-col violations
llvm-svn: 100677
2010-04-07 18:59:26 +00:00
Gabor Greif df323a51f5 performance: get rid of repeated dereferencing of use_iterator by caching its result
llvm-svn: 100550
2010-04-06 19:32:30 +00:00
Gabor Greif 679728790b make more two predicates constant
llvm-svn: 100549
2010-04-06 19:24:18 +00:00
Gabor Greif 08355d6cda performance: get rid of repeated dereferencing of use_iterator by caching its result
llvm-svn: 100547
2010-04-06 19:14:05 +00:00
Gabor Greif a21bc0fbd5 const-ize predicate ValueIsOnlyUsedLocallyOrStoredToOneGlobal
llvm-svn: 100546
2010-04-06 18:58:22 +00:00
Gabor Greif 0439789023 use CallSite to access calls vs. invokes uniformly
and remove assumptions about operand order

llvm-svn: 100544
2010-04-06 18:45:08 +00:00
Chris Lattner adca608281 fix a really nasty bug that Evan was tracking in SCCP. When resolving
undefs in branches/switches, we have two cases: a branch on a literal
undef or a branch on a symbolic value which is undef.  If we have a
literal undef, the code was correct: forcing it to a constant is the
right thing to do.

If we have a branch on a symbolic value that is undef, we should force
the symbolic value to a constant, which then makes the successor block
live.  Forcing the condition of the branch to being a constant isn't 
safe if later paths become live and the value becomes overdefined.  This
is the case that 'forcedconstant' is designed to handle, so just use it.

This fixes rdar://7765019 but there is no good testcase for this, the
one I have is too insane to be useful in the future.

llvm-svn: 100478
2010-04-05 22:14:48 +00:00
Chris Lattner c832c1bf69 some code cleanups, use SwitchInst::findCaseValue, reduce indentation
llvm-svn: 100468
2010-04-05 21:18:32 +00:00
Evan Cheng ba930449a9 Code clean up.
llvm-svn: 100467
2010-04-05 21:16:25 +00:00
Mon P Wang c576ee9040 Reapply address space patch after fixing an issue in MemCopyOptimizer.
Added support for address spaces and added a isVolatile field to memcpy, memmove, and memset,
e.g., llvm.memcpy.i32(i8*, i8*, i32, i32) -> llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)

llvm-svn: 100304
2010-04-04 03:10:48 +00:00
Chris Lattner ecb536313f require that the branch being controlled by the IV
exits the loop.  With this information we can guarantee 
the iteration count of the loop is bounded by the 
compare.  I think this xforms is finally safe now.

llvm-svn: 100285
2010-04-03 07:21:39 +00:00
Chris Lattner 40060d33f6 add integer overflow check for the fp induction variable
checker.  Amusingly, we already had tests that we should
have rejects because they would be miscompiled in the
testsuite.

The remaining issue with this is that we don't check that
the branch causes us to exit the loop if it fails, so we
don't actually know if we remain in bounds.

llvm-svn: 100284
2010-04-03 07:18:48 +00:00
Chris Lattner 69913466cb add a comment and fix some consistency issues, converting
to a signed vs unsigned value depending on the sign of the
constant fp means that we can't distinguish between a 
truly negative number and a positive number so large the
32nd bit is set.  So, do don't this!

llvm-svn: 100283
2010-04-03 06:41:49 +00:00
Chris Lattner 40ea690f39 fix PR6761, a miscompilation due to the fp->int IV conversion
stuff.  More bugs remain though.

llvm-svn: 100282
2010-04-03 06:30:03 +00:00
Chris Lattner 42202868c3 just eliminate the uitofp checks. This code isn't doing
the required validity checks in the first place, and supporting
a condition large enough to require the 32'nd bit isn't worth it.

llvm-svn: 100280
2010-04-03 06:25:21 +00:00
Chris Lattner ca25b60f4e rename PH -> PN to be consistent with WeakPN and the rest
of llvm.

llvm-svn: 100276
2010-04-03 06:17:08 +00:00
Chris Lattner 774858fc38 improve comment and drop a dead check. If PH had
no uses, it would have been deleted by 
RecursivelyDeleteTriviallyDeadInstructions

llvm-svn: 100275
2010-04-03 06:16:22 +00:00
Chris Lattner 915322bc4a strength reduce a ridiculous use of APInt.
llvm-svn: 100274
2010-04-03 06:13:12 +00:00
Chris Lattner 0b941347f9 rename stuff improve comment grammar.
llvm-svn: 100273
2010-04-03 06:11:07 +00:00
Chris Lattner d77bde5f94 simplify some code and resolve a fixme.
llvm-svn: 100272
2010-04-03 06:06:59 +00:00
Chris Lattner 2ff33f91d5 There is no guarantee that the increment and the branch
are in the same block.  Insert the new increment in the
correct location.

Also, more cleanups.

llvm-svn: 100271
2010-04-03 06:05:10 +00:00
Chris Lattner c558b49f14 first half of a pass through IndVarSimplify::HandleFloatingPointIV,
this cleans up a bunch of code and also fixes several crashes and
miscompiles.  More to come unfortunately, this optimization
is quite broken.

llvm-svn: 100270
2010-04-03 05:54:59 +00:00
Chris Lattner 2e23e5284c don't internalize available_externally functions, they are
really just declarations.  This is related to PR6524

llvm-svn: 100269
2010-04-03 05:24:50 +00:00
Bob Wilson f1aa4743d9 Revert all my SSAUpdater patches. The PHI placement algorithm is not correct
(what was I thinking?) and there's also a problem with LCSSA.  I'll try again
later with fixes.

--- Reverse-merging r100263 into '.':
U    lib/Transforms/Utils/SSAUpdater.cpp
--- Reverse-merging r100177 into '.':
G    lib/Transforms/Utils/SSAUpdater.cpp
--- Reverse-merging r100148 into '.':
G    lib/Transforms/Utils/SSAUpdater.cpp
--- Reverse-merging r100147 into '.':
U    include/llvm/Transforms/Utils/SSAUpdater.h
G    lib/Transforms/Utils/SSAUpdater.cpp
--- Reverse-merging r100131 into '.':
G    include/llvm/Transforms/Utils/SSAUpdater.h
G    lib/Transforms/Utils/SSAUpdater.cpp
--- Reverse-merging r100130 into '.':
G    lib/Transforms/Utils/SSAUpdater.cpp
--- Reverse-merging r100126 into '.':
G    include/llvm/Transforms/Utils/SSAUpdater.h
G    lib/Transforms/Utils/SSAUpdater.cpp
--- Reverse-merging r100050 into '.':
D    test/Transforms/GVN/2010-03-31-RedundantPHIs.ll
--- Reverse-merging r100047 into '.':
G    include/llvm/Transforms/Utils/SSAUpdater.h
G    lib/Transforms/Utils/SSAUpdater.cpp

llvm-svn: 100264
2010-04-03 03:50:38 +00:00
Bob Wilson 25f1aefd5b Add a DEBUG_TYPE for the SSAUpdater.
llvm-svn: 100263
2010-04-03 03:28:44 +00:00
Evan Cheng ed66db3f9b Code refactoring.
llvm-svn: 100262
2010-04-03 02:23:43 +00:00
Mon P Wang 999c1b927b Revert r100191 since it breaks objc in clang
llvm-svn: 100199
2010-04-02 18:43:02 +00:00
Mon P Wang a972ab8564 Reapply address space patch after fixing an issue in MemCopyOptimizer.
Added support for address spaces and added a isVolatile field to memcpy, memmove, and memset,
e.g., llvm.memcpy.i32(i8*, i8*, i32, i32) -> llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)

llvm-svn: 100191
2010-04-02 18:04:15 +00:00
Dan Gohman f7239102fe Manually notify ScalarEvolution before making an operand replacement, since
it can't currently observe such changes automatically.

llvm-svn: 100186
2010-04-02 14:48:31 +00:00
Bob Wilson 3c54edf9b3 Recommit 100158 now that the buildbots are happy again.
llvm-svn: 100177
2010-04-02 05:09:46 +00:00
Dan Gohman 4bd755419f Revert the recent alignment changes. They're broken for -Os because,
in particular, they end up aligning strings at 16-byte boundaries, and
there's no way for GlobalOpt to check OptForSize.

llvm-svn: 100172
2010-04-02 03:04:37 +00:00
Bob Wilson 0389adcd73 Revert 100158 in case it is causing some of the buildbot problems.
llvm-svn: 100164
2010-04-02 01:22:49 +00:00
Dan Gohman c671347fcb Make globalopt refine global variable alignment.
llvm-svn: 100160
2010-04-02 00:14:16 +00:00
Bob Wilson 9af4e118c6 Check for terminating conditions before adding PHIs to the worklists.
This is more efficient than adding them to the worklist and then ignoring them.

llvm-svn: 100158
2010-04-02 00:10:41 +00:00
Bob Wilson 737195069a Remove trailing whitespace.
llvm-svn: 100148
2010-04-01 23:06:38 +00:00
Bob Wilson 37b73d9d3e Rewrite another SSAUpdater function to avoid recursion.
llvm-svn: 100147
2010-04-01 23:05:58 +00:00
Bob Wilson 8409feadf0 Change another SSAUpdater function to avoid recursion.
llvm-svn: 100131
2010-04-01 20:04:30 +00:00
Bob Wilson 043c0406f7 Simplify the code to check for existing PHIs, now that it is only used in
one place.  This removes the template function added in svn 94690.

llvm-svn: 100130
2010-04-01 19:53:48 +00:00
Bob Wilson 38fc88ee5d The SSAUpdater should avoid recursive traversals of the CFG, since that may
blow out the stack for really big functions.  Start by fixing an easy case.

llvm-svn: 100126
2010-04-01 18:46:59 +00:00
Gabor Greif 5d5db5342b Introduce ImmutableCallSite, useful for contexts where no mutation
is necessary. Inherits from new templated baseclass CallSiteBase<>
which is highly customizable. Base CallSite on it too, in a configuration
that allows full mutation.
Adapt some call sites in analyses to employ ImmutableCallSite.

llvm-svn: 100100
2010-04-01 08:21:08 +00:00
Nick Lewycky bfb50a0d43 Clean up this file a little, no functionality change. This is a subset of my
patch back in r94322.

llvm-svn: 100097
2010-04-01 07:34:00 +00:00
Bob Wilson ac229124f4 Rewrite part of the SSAUpdater to be more careful about inserting redundant
PHIs.  The previous algorithm was unable to reliably detect when existing
PHIs in a cycle can be reused.  I'm still working on reducing a testcase.
Radar 7711900.

llvm-svn: 100047
2010-03-31 20:51:00 +00:00
Dale Johannesen b67a6e6620 Fix a nasty dangling-pointer heisenbug that could
generate wrong code pretty much anywhere AFAICT.
A case that hits the bug reproducibly is impossible,
but the situation was like this:
Addr = ...
Store -> Addr
Addr2 = GEP , 0, 0
Store -> Addr2
Handling the first store, the code changed replaced Addr
with a sunkaddr and deleted Addr, but not its table
entry.  Code in OptimizedBlock replaced Addr2 with a
bitcast; if that happened to reuse the memory of Addr,
the old table entry was erroneously found when handling
the second store.

llvm-svn: 100044
2010-03-31 20:37:15 +00:00
Bob Wilson 6f7fd28824 Revert Mon Ping's change 99928, since it broke all the llvm-gcc buildbots.
llvm-svn: 99948
2010-03-30 22:27:04 +00:00
Mon P Wang 7460571381 Added support for address spaces and added a isVolatile field to memcpy, memmove, and memset,
e.g., llvm.memcpy.i32(i8*, i8*, i32, i32) -> llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)
A update of langref will occur in a subsequent checkin.

llvm-svn: 99928
2010-03-30 20:55:56 +00:00
Dan Gohman 39027c403c Fix a grammaro.
llvm-svn: 99917
2010-03-30 20:04:57 +00:00
Gabor Greif b469818279 fix two cases where the arguments were extracted from the wrong range out of the InvokeInst
spotted by baldrick -- thanks\!

llvm-svn: 99914
2010-03-30 19:20:53 +00:00
Jeffrey Yasskin 12fd516e51 Remove another memory leak from ABCD by using Edges by value instead of
pointer.  There was also a SmallPtrSet whose settiness wasn't being used, so I
changed it to a SmallVector.

llvm-svn: 99713
2010-03-27 09:09:17 +00:00
Jeffrey Yasskin 97e613b6da In ABCD, change the non-null Bound*s to Bound&s.
llvm-svn: 99711
2010-03-27 08:15:46 +00:00
Jeffrey Yasskin 33bc7e4cb5 Fix a memory leak in ABCD by giving ownership of Bound objects to the
MemoizedResultChart.

llvm-svn: 99710
2010-03-27 08:09:24 +00:00
Eric Christopher 81c03447fc When we promote a load of an argument make sure to take the alignment
of the previous load - it's usually important.  For example, we don't want
to blindly turn an unaligned load into an aligned one.

llvm-svn: 99699
2010-03-27 01:54:00 +00:00
Dan Gohman d42e09d91e Ignore debug intrinsics in yet more places.
llvm-svn: 99580
2010-03-26 00:33:27 +00:00
Gabor Greif 6c6b2fd2b2 rename pred_const_iterator to const_pred_iterator for consistency's sake
llvm-svn: 99567
2010-03-25 23:25:28 +00:00
Gabor Greif c78d720f02 rename use_const_iterator to const_use_iterator for consistency's sake
llvm-svn: 99564
2010-03-25 23:06:16 +00:00
Chris Lattner 0563804982 fix PR6642, GVN forwarding from memset to load of the base of the memset.
llvm-svn: 99488
2010-03-25 05:58:19 +00:00
Eric Christopher 1d38538fb6 Temporarily revert this, it's causing an issue with an internal project.
llvm-svn: 99451
2010-03-24 23:35:21 +00:00
Evan Cheng c12c2d9bb4 Move OptChkCall off LibCallOptimization into StrCpyOpt.
llvm-svn: 99418
2010-03-24 20:19:04 +00:00
Gabor Greif a2fbc0ae1b Finally land the InvokeInst operand reordering.
I have audited all getOperandNo calls now, fixing
hidden assumptions. CallSite related uglyness will
be eliminated successively.

Note this patch has a long and griveous history,
for all the back-and-forths have a look at
CallSite.h's log.

llvm-svn: 99399
2010-03-24 13:21:49 +00:00
Gabor Greif be18ae6781 tighten a type and remove trailing whitespace, no functional changes
llvm-svn: 99398
2010-03-24 11:58:07 +00:00
Gabor Greif 9027ffb918 increase const goodness and remove pointless getUser() calls
llvm-svn: 99395
2010-03-24 10:29:52 +00:00
Gabor Greif 11ff53146f cache result of UI.getOperandNo() instead of calling it twice, it is cheaper this way
llvm-svn: 99394
2010-03-24 10:12:54 +00:00
Chris Lattner 00eeac4179 add some accessors to callsite/callinst/invokeinst to check
for the noinline attribute, and make the inliner refuse to
inline a call site when the call site is marked noinline even
if the callee isn't.  This fixes PR6682.

llvm-svn: 99341
2010-03-23 22:59:07 +00:00
Bill Wendling 04803e8ef6 Skip debugging intrinsics when sinking unused invariants.
llvm-svn: 99324
2010-03-23 21:15:59 +00:00
Evan Cheng d9e822345c Teach simplify libcall to transform __strcpy_chk to __memcpy_chk to enable optimizations down stream.
llvm-svn: 99282
2010-03-23 15:48:04 +00:00
Gabor Greif 161cb044f3 add assert in argpromotion, which cannot trigger
if Function::hasAddressTaken works as advertised

also included some cosmetic cleanups

llvm-svn: 99276
2010-03-23 14:40:20 +00:00
Evan Cheng 3f7842232e Fix an incorrect logic causing instcombine to miss some _chk -> non-chk transformations.
llvm-svn: 99263
2010-03-23 06:06:09 +00:00
Evan Cheng 9a7b270825 Fix 80 col violation.
llvm-svn: 99224
2010-03-22 22:44:31 +00:00
Gabor Greif e1517a084f backing out r99170 because it still fails on clang-x86_64-darwin10-fnt
llvm-svn: 99171
2010-03-22 09:11:00 +00:00
Gabor Greif 7a743e15e3 Now that hopefully all direct accesses to InvokeInst operands are fixed
we can reapply the InvokeInst operand reordering patch. (see r98957).

llvm-svn: 99170
2010-03-22 08:28:00 +00:00
Gabor Greif febf6ab718 Add a setCalledFunction member to InvokeInst (like in CallInst)
and use this (as well as getCalledValue) to access the callee,
instead of {g|s}etOperand(0).

llvm-svn: 99084
2010-03-20 21:00:25 +00:00
Dan Gohman 1a2abe5580 Clear the SCEVExpander's insertion point after making deletions,
so that the SCEVExpander doesn't retain a dangling pointer as its
insert position. The dangling pointer in this case wasn't ever used
to insert new instructions, but it was causing trouble with
SCEVExpander's code for automatically advancing its insert position
past debug intrinsics.

This fixes use-after-free errors that valgrind noticed in
test/Transforms/IndVarSimplify/2007-06-06-DeleteDanglesPtr.ll and
test/Transforms/IndVarSimplify/exit_value_tests.ll.

llvm-svn: 99036
2010-03-20 03:53:53 +00:00
Gabor Greif 6c56ed847e back out r98957, it broke http://smooshlab.apple.com:8010/builders/clang-x86_64-darwin10-fnt/builds/703 in the nightly test suite
llvm-svn: 98958
2010-03-19 13:50:02 +00:00
Gabor Greif 8335f9c0bf Recommit r80858 again (which has been backed out in r80871).
This time I did a self-hosted bootstrap on Linux x86-64,
with no problems. Let's see how darwin 64-bit self-hosting
goes. At the first sign of failure I'll back this out.

Maybe the valgrind bots give me a hint of what may be wrong
(it at all).

llvm-svn: 98957
2010-03-19 11:55:53 +00:00
Benjamin Kramer f2e4b5dd7f str[r]chr returns its pointer argument so we cannot mark it as nocapture. Thanks to Duncan for spotting my mistake.
llvm-svn: 98671
2010-03-16 20:33:15 +00:00
Benjamin Kramer 5cf5fd2ffa Mark str[r]chr readonly.
llvm-svn: 98663
2010-03-16 19:36:43 +00:00
Devang Patel 45c1505bf6 Skip debug info intrinsics.
llvm-svn: 98584
2010-03-15 22:23:03 +00:00
Devang Patel b21991c4f5 Skip debug info intrinsics.
llvm-svn: 98581
2010-03-15 21:25:29 +00:00
Devang Patel d3f41e8939 In "empty" bb, the return instruction may not be first instruction, if dbg value intrinsics are present in this bb. Use terminator to find return instructions.
llvm-svn: 98565
2010-03-15 19:05:46 +00:00
Bill Wendling 55e69d179b Skip over debug info when trying to merge two return BBs.
llvm-svn: 98491
2010-03-14 10:40:55 +00:00
Bill Wendling ee84f27536 Make returns more consistent with others.
llvm-svn: 98490
2010-03-14 10:40:28 +00:00
Benjamin Kramer a956527c92 Add a virtual destructor and give vtable a home.
llvm-svn: 98376
2010-03-12 20:41:29 +00:00
Benjamin Kramer 7b88a49f3e Factor checked library call optimization into a common helper class and use it
to unify the almost identical code in CodeGenPrepare and InstCombineCalls.

llvm-svn: 98338
2010-03-12 09:27:41 +00:00
Nate Begeman 2e41605d4f Whoops this already existed.
llvm-svn: 98297
2010-03-11 23:21:19 +00:00
Nate Begeman 5daa235c91 Add a handful of additional useful pass manager things to the C API
llvm-svn: 98296
2010-03-11 23:06:07 +00:00
Benjamin Kramer 2fc395659c stpcpy is so similar to strcpy, it doesn't deserve a complete copy of the __strcpy_chk -> strcpy code.
llvm-svn: 98284
2010-03-11 20:45:13 +00:00
Eric Christopher 607de1de53 Lower stpcpy_chk when possible.
llvm-svn: 98274
2010-03-11 19:24:34 +00:00
Eric Christopher 103e3ef893 Fix typo.
llvm-svn: 98260
2010-03-11 17:45:38 +00:00
Eric Christopher 4b7948e09e Do some final lowering in CodeGenPrepare of _chk calls similar to
that in InstCombineCalls.

More call lowering needed.

llvm-svn: 98228
2010-03-11 02:41:03 +00:00
Eric Christopher 43dc11c525 Add strncpy libcall creator. Use it when it should be used.
llvm-svn: 98219
2010-03-11 01:25:07 +00:00
Dan Gohman 2734ebd37f Add a DominatorTree argument to isLCSSA so that it doesn't have to
compute a set of reachable blocks for itself each time it is called, which
is fairly frequently.

llvm-svn: 98179
2010-03-10 19:38:49 +00:00
Dan Gohman b7e0b87441 Fix a comment.
llvm-svn: 98122
2010-03-10 02:18:48 +00:00
Jakob Stoklund Olesen b495cad7ca Try to keep the cached inliner costs around for a bit longer for big functions.
The Caller cost info would be reset everytime a callee was inlined. If the
caller has lots of calls and there is some mutual recursion going on, the
caller cost info could be calculated many times.

This patch reduces inliner runtime from 240s to 0.5s for a function with 20000
small function calls.

This is a more conservative version of r98089 that doesn't break the clang
test CodeGenCXX/temp-order.cpp. That test relies on rather extreme inlining
for constant folding.

llvm-svn: 98099
2010-03-09 23:02:17 +00:00
Jakob Stoklund Olesen 4497475905 Revert r98089, it was breaking a clang test.
llvm-svn: 98094
2010-03-09 22:43:37 +00:00
Jakob Stoklund Olesen 741dec43e4 Try to keep the cached inliner costs around for a bit longer for big functions.
The Caller cost info would be reset everytime a callee was inlined. If the
caller has lots of calls and there is some mutual recursion going on, the
caller cost info could be calculated many times.

This patch reduces inliner runtime from 240s to 0.5s for a function with 20000
small function calls.

llvm-svn: 98089
2010-03-09 22:17:11 +00:00
Jakob Stoklund Olesen d62c2f554c Add inlining threshold to log output.
llvm-svn: 98024
2010-03-09 00:59:53 +00:00
Evan Cheng 4f2fd2d2be Re-commit 97860 with fix. getMallocAllocatedType may return null.
llvm-svn: 98000
2010-03-08 22:54:36 +00:00
Devang Patel 3b548aa8e2 Avoid using DIDescriptor.isNull().
This is a first step towards eliminating checks in Descriptor constructors.

llvm-svn: 97975
2010-03-08 20:52:55 +00:00
Devang Patel bc97f6b757 Revert r97947.
llvm-svn: 97963
2010-03-08 19:20:38 +00:00
Devang Patel fe28599f6f Avoid using DIDescriptor.isNull().
This is a first step towards eliminating unncessary constructor checks in light weight DIDescriptor wrappers.

llvm-svn: 97947
2010-03-08 18:25:48 +00:00
Eric Christopher 1810d77cb4 Let the fallthrough handle whether or not we've changed anything
before we try to optimize.

llvm-svn: 97876
2010-03-06 10:59:25 +00:00
Eric Christopher a7fb58f5f5 Migrate _chk call lowering from SimplifyLibCalls to InstCombine. Stub
out the remainder of the calls that we should lower in some way and
move the tests to the new correct directory. Fix up tests that are now
optimized more than they were before by -instcombine.

llvm-svn: 97875
2010-03-06 10:50:38 +00:00
Eric Christopher d8b43d0e59 Temporarily revert:
Log:
Transform @llvm.objectsize to integer if the argument is a result of malloc of known size.

Modified:
   llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
   llvm/trunk/test/Transforms/InstCombine/objsize.ll

It appears to be causing swb and nightly test failures.

llvm-svn: 97866
2010-03-06 03:11:35 +00:00
Evan Cheng afdc7d3aab Transform @llvm.objectsize to integer if the argument is a result of malloc of known size.
llvm-svn: 97860
2010-03-06 01:01:42 +00:00
Ted Kremenek 65bb311629 Update CMake build.
llvm-svn: 97846
2010-03-05 22:34:16 +00:00
Eric Christopher 87abfc506f Move SimplifyLibCalls's LibCall builders to a separate file so they
can be used in more places.  Add an argument for the TargetData that
most of them need. Update for the getInt8PtrTy() change.  Should be
no functionality change.

llvm-svn: 97844
2010-03-05 22:25:30 +00:00
Evan Cheng d214ed0e75 Safely turn memset_chk etc. to non-chk variant if the known object size is >= memset / memcpy / memmove size.
llvm-svn: 97828
2010-03-05 20:59:47 +00:00
Evan Cheng fffdad58ac Instcombine should turn llvm.objectsize of a alloca with static size to an integer.
llvm-svn: 97827
2010-03-05 20:47:23 +00:00
Chris Lattner f6befffbb2 fix PR6512, a case where instcombine would incorrectly merge loads
from different addr spaces.

llvm-svn: 97813
2010-03-05 18:53:28 +00:00
Chris Lattner 067459c62b Fix PR6503. This turned into a much more interesting and nasty bug. Various
parts of the cmp|cmp and cmp&cmp folding logic wasn't prepared for vectors
(unrelated to the bug but noticed while in the code) and the code was 
*definitely* not safe to use by the (cast icmp)|(cast icmp) handling logic
that I added in r95855.  Fix all this up by changing the various routines
to more consistently use IRBuilder and not pass in the I which had the wrong 
type.

llvm-svn: 97801
2010-03-05 08:46:26 +00:00
Chris Lattner 343d2e48b2 simplify some functions and make them work with vector
compares, noticed by inspection.

llvm-svn: 97795
2010-03-05 07:47:57 +00:00
Chris Lattner c6c1523f59 fix a nice subtle reassociate bug which would only occur
in a very specific use pattern embodied in the carefully
reduced testcase.

llvm-svn: 97794
2010-03-05 07:18:54 +00:00
Eric Christopher 4899cbc77d Move GetStringLength and helper from SimplifyLibCalls to ValueTracking.
No functionality change.

llvm-svn: 97793
2010-03-05 06:58:57 +00:00
Evan Cheng 43d6ff7701 Add missing break for Intrinsic::objectsize case. It was falling through to the following Intrinsic::bswap code. I have no idea why it wasn't breaking stuff.
llvm-svn: 97774
2010-03-05 01:22:47 +00:00
Dan Gohman 29707de4fe Make SCEVExpander and LSR more aggressive about hoisting expressions out
of loops.

llvm-svn: 97642
2010-03-03 05:29:13 +00:00
Bill Wendling af13d82945 This test case:
long test(long x) { return (x & 123124) | 3; }

Currently compiles to:

_test:
        orl     $3, %edi
        movq    %rdi, %rax
        andq    $123127, %rax
        ret

This is because instruction and DAG combiners canonicalize

  (or (and x, C), D) -> (and (or, D), (C | D))

However, this is only profitable if (C & D) != 0. It gets in the way of the
3-addressification because the input bits are known to be zero.

llvm-svn: 97616
2010-03-03 00:35:56 +00:00
Dan Gohman 52f5563973 Non-affine post-inc SCEV expansions have more code which must be
emitted after the increment. Make sure the insert position
reflects this. This fixes PR6453.

llvm-svn: 97537
2010-03-02 01:59:21 +00:00
Dan Gohman 6f34abd092 Floating-point add, sub, and mul are now spelled fadd, fsub, and fmul,
respectively.

llvm-svn: 97531
2010-03-02 01:11:08 +00:00
Bob Wilson 0fd415820b Don't attempt load PRE when there is no real redundancy (i.e., the load is in
a loop and is itself the only dependency).

llvm-svn: 97526
2010-03-02 00:09:29 +00:00
Bob Wilson 892432b7ef When GVN needs to split critical edges for load PRE, check all of the
predecessors before returning.  Otherwise, if multiple predecessor edges need
splitting, we only get one of them per iteration.  This makes a small but
measurable compile time improvement with -enable-full-load-pre.

llvm-svn: 97521
2010-03-01 23:37:32 +00:00
Evan Cheng 7263cf8431 MemoryDepAnalysis is not used if redundant load processing is disabled.
llvm-svn: 97512
2010-03-01 22:23:12 +00:00
Dan Gohman 39917c7c81 Add some debug output to LoopSimplify.
llvm-svn: 97458
2010-03-01 17:55:27 +00:00
Dan Gohman 8b0a419eb1 Spelling fixes.
llvm-svn: 97453
2010-03-01 17:49:51 +00:00
Dan Gohman 0c39a35457 Prune #includes.
llvm-svn: 97448
2010-03-01 17:42:17 +00:00
Bob Wilson 1136166ee9 Revert r97245 which seems to be causing performance problems.
llvm-svn: 97366
2010-02-28 05:34:05 +00:00
Chris Lattner 2af7e3dceb fix grammaro's pointed out by daniel
llvm-svn: 97313
2010-02-27 07:50:40 +00:00
Chris Lattner d887f1da73 fix PR6414, a nondeterminism issue in IPSCCP which was because
of a subtle interation in a loop operating in densemap order.

llvm-svn: 97288
2010-02-27 00:07:42 +00:00
Chris Lattner 65d3a0a5f8 Fix rdar://7694996 a miscompile of 183.equake from my patch yesterday,
confusing the old MAT variable with the new GlobalType one.  This caused
us to promote the @disp global pointer into:

@disp.body = internal global double*** undef

instead of:

@disp.body = internal global [3 x double**] undef

llvm-svn: 97285
2010-02-26 23:42:13 +00:00
Chris Lattner da5fcdace0 remove dead code, by this point all uses of CI are gone.
llvm-svn: 97283
2010-02-26 23:35:25 +00:00
Bob Wilson ed1b0c31a7 Move the EnableFullLoadPRE flag from a separate command-line option to an
argument of createGVNPass and set it automatically for -O3.

llvm-svn: 97245
2010-02-26 19:09:47 +00:00
Bob Wilson d4655991c3 Remove unused "NoPRE" parameter in GVN and createGVNPass().
llvm-svn: 97235
2010-02-26 18:35:19 +00:00
Chris Lattner 0521c09d97 fix PR6435 another bug from the MallocInst elimination work.
llvm-svn: 97231
2010-02-26 18:23:13 +00:00
Chris Lattner 7939f795f5 rewrite OptimizeGlobalAddressOfMalloc to fix PR6422, some bugs
introduced when mallocinst was eliminated. 

llvm-svn: 97178
2010-02-25 22:33:52 +00:00
Dan Gohman a9c205cc88 Make LoopSimplify change conditional branches in loop exiting blocks
which branch on undef to branch on a boolean constant for the edge
exiting the loop. This helps ScalarEvolution compute trip counts for
loops.

Teach ScalarEvolution to recognize single-value PHIs, when safe, and
ForgetSymbolicName to forget such single-value PHI nodes as apprpriate
in ForgetSymbolicName.

llvm-svn: 97126
2010-02-25 06:57:05 +00:00
Nick Lewycky 614fb949b9 Modernize comment.
llvm-svn: 97121
2010-02-25 06:39:10 +00:00
Nick Lewycky dc835c4361 Correct whitespace.
llvm-svn: 97120
2010-02-25 06:38:51 +00:00
Daniel Dunbar 693ea89214 Reapply r97010, the speculative revert failed.
llvm-svn: 97036
2010-02-24 08:48:04 +00:00
Daniel Dunbar 0a2031e5b6 Speculatively revert r97010, "Add an argument to PHITranslateValue to specify
the DominatorTree. ...", in hopes of restoring poor old PPC bootstrap.

llvm-svn: 97027
2010-02-24 06:55:22 +00:00
Dan Gohman 94732024eb Fix indentation.
llvm-svn: 97024
2010-02-24 06:46:09 +00:00
Bob Wilson 66e58ac742 Add an argument to PHITranslateValue to specify the DominatorTree. If this
argument is non-null, pass it along to PHITranslateSubExpr so that it can
prefer using existing values that dominate the PredBB, instead of just
blindly picking the first equivalent value that it finds on a uselist.
Also when the DominatorTree is specified, have PHITranslateValue filter
out any result that does not dominate the PredBB.  This is basically just
refactoring the check that used to be in GetAvailablePHITranslatedSubExpr
and also in GVN.

Despite my initial expectations, this change does not affect the results
of GVN for any testcases that I could find, but it should help compile time.
Before this change, if PHITranslateSubExpr picked a value that does not
dominate, PHITranslateWithInsertion would then insert a new value, which GVN
would later determine to be redundant and would replace.  By picking a good
value to begin with, we save GVN the extra work of inserting and then
replacing a new value.

llvm-svn: 97010
2010-02-24 01:39:00 +00:00
Dan Gohman cd4c03e886 Don't do (X != Y) ? X : Y -> X for floating-point values; it doesn't
handle NaN properly.

Do (X une Y) ? X : Y  -> X if one of X and Y is not zero.

llvm-svn: 96955
2010-02-23 17:17:57 +00:00
Bob Wilson 923261bbe9 Update memdep when load PRE inserts a new load, and add some debug output.
I don't have a small testcase for this.

llvm-svn: 96890
2010-02-23 05:55:00 +00:00
Evan Cheng 3688b8fa68 Instcombine constant folding can normalize gep with negative index to index with large offset. When instcombine objsize checking transformation sees these geps where the offset seemingly point out of bound, it should just return "i don't know" rather than asserting.
llvm-svn: 96825
2010-02-22 23:34:00 +00:00
Bob Wilson 1da9041913 Erase deleted instructions from GVN's ValueTable. This fixes assertion
failures from ValueTable::verifyRemoved() when using -debug.

llvm-svn: 96805
2010-02-22 21:39:41 +00:00
Dan Gohman 8c16b38262 Remove unused variables and parameters.
llvm-svn: 96780
2010-02-22 04:11:59 +00:00
Dan Gohman 4506fcb3c2 When emitting an instruction which depends on both a post-incremented
induction variable value and a loop-variant value, don't force the
insert position to be at the post-increment position, because it may
not be dominated by the loop-variant value. This fixes a
use-before-def problem noticed on PPC.

llvm-svn: 96774
2010-02-22 03:59:54 +00:00
Dan Gohman 740909be2d This cast<Instruction> is unnecessary.
llvm-svn: 96771
2010-02-22 02:07:36 +00:00
Dan Gohman 4eebb94094 Rename getSDiv to getExactSDiv to reflect its behavior in cases where
the division would have a remainder.

llvm-svn: 96693
2010-02-19 19:35:48 +00:00
Dan Gohman 85af256779 Check for overflow when scaling up an add or an addrec for
scaled reuse.

llvm-svn: 96692
2010-02-19 19:32:49 +00:00
Dale Johannesen 1d6827adef recommit 96626, evidence that it broke things appears
to be spurious

llvm-svn: 96662
2010-02-19 07:14:22 +00:00
Dale Johannesen 1f790c28d0 Revert 96626, which causes build failure on ppc Darwin.
llvm-svn: 96653
2010-02-19 01:54:37 +00:00
Dan Gohman 2446f57503 When determining the set of interesting reuse factors, consider
strides in foreign loops. This helps locate reuse opportunities
with existing induction variables in foreign loops and reduces
the need for inserting new ones. This fixes rdar://7657764.

llvm-svn: 96629
2010-02-19 00:05:23 +00:00
Dan Gohman 60b3326435 Indvars needs to explicitly notify ScalarEvolution when it is replacing
a loop exit value, so that if a loop gets deleted, ScalarEvolution
isn't stick holding on to dangling SCEVAddRecExprs for that loop. This
fixes PR6339.

llvm-svn: 96626
2010-02-18 23:26:33 +00:00
Dan Gohman c43d264cc0 Hoist this loop-invariant logic out of the loop.
llvm-svn: 96614
2010-02-18 21:34:02 +00:00
Dan Gohman 13ac3b2139 Delete some unneeded casts.
llvm-svn: 96429
2010-02-17 00:42:19 +00:00
Dan Gohman 5f10d6c52c Don't attempt to divide INT_MIN by -1; consider such cases to
have overflowed.

llvm-svn: 96428
2010-02-17 00:41:53 +00:00
Bob Wilson aff96b2132 Rename SuccessorNumber to GetSuccessorNumber.
llvm-svn: 96387
2010-02-16 21:06:42 +00:00
Dan Gohman 6deab96c81 Refactor rewriting for PHI nodes into a separate function.
llvm-svn: 96382
2010-02-16 20:25:07 +00:00
Bob Wilson 92cdb6eec5 Split critical edges as needed for load PRE.
llvm-svn: 96378
2010-02-16 19:51:59 +00:00
Bob Wilson 3de492ec35 Refactor to share code to find the position of a basic block successor in the
terminator's list of successors.

llvm-svn: 96377
2010-02-16 19:49:17 +00:00
Dan Gohman 0849ed5e26 Fix whitespace.
llvm-svn: 96372
2010-02-16 19:42:34 +00:00
Duncan Sands 19d0b47b1f There are two ways of checking for a given type, for example isa<PointerType>(T)
and T->isPointerTy().  Convert most instances of the first form to the second form.
Requested by Chris.

llvm-svn: 96344
2010-02-16 11:11:14 +00:00
Dan Gohman 521efe68ab Split the main for-each-use loop again, this time for GenerateTruncates,
as it also peeks at which registers are being used by other uses. This
makes LSR less sensitive to use-list order.

llvm-svn: 96308
2010-02-16 01:42:53 +00:00
Chris Lattner 6fbfe5897c fix PR6305 by handling BlockAddress in a helper function
called by jump threading.

llvm-svn: 96263
2010-02-15 20:47:49 +00:00
Duncan Sands 9dff9bec31 Uniformize the names of type predicates: rather than having isFloatTy and
isInteger, we now have isFloatTy and isIntegerTy.  Requested by Chris!

llvm-svn: 96223
2010-02-15 16:12:20 +00:00
Dan Gohman e4e51a63da Fix whitespace.
llvm-svn: 96179
2010-02-14 18:51:39 +00:00
Dan Gohman e7f74bb16c Fix a comment.
llvm-svn: 96178
2010-02-14 18:51:20 +00:00
Dan Gohman bb7d52213c When complicated expressions are broken down into subexpressions
with multiplication by constants distributed through, occasionally
those subexpressions can include both x and -x. For now, if this
condition is discovered within LSR, just prune such cases away,
as they won't be profitable. This fixes a "zero allocated in a
base register" assertion failure.

llvm-svn: 96177
2010-02-14 18:50:49 +00:00
Dan Gohman 2d0f96d49a Actually, this code doesn't have to be quite so conservative in
the no-TLI case. But it should still default to declining the
transformation.

llvm-svn: 96152
2010-02-14 03:21:49 +00:00
Dan Gohman cb76a806f0 Don't attempt aggressive post-inc uses if TargetLowering is not available,
because profitability can't be sufficiently approximated.

llvm-svn: 96148
2010-02-14 02:45:21 +00:00
John McCall 0daaf13b97 Make LSR not crash if invoked without target lowering info, e.g. if invoked
from opt.

llvm-svn: 96135
2010-02-13 23:40:16 +00:00
Eric Christopher 843a4cc43c Fix a problem where we had bitcasted operands that gave us
odd offsets since the bitcasted pointer size and the offset pointer
size are going to be different types for the GEP vs base object.

llvm-svn: 96134
2010-02-13 23:38:01 +00:00
Chris Lattner b8639bc2d1 remove dead code.
llvm-svn: 96109
2010-02-13 19:07:06 +00:00
Chris Lattner 42c66b7270 Split some code out to a helper function (FindReusablePredBB)
and add a doxygen comment.

Cache the phi entry to avoid doing tons of 
PHINode::getBasicBlockIndex calls in the common case.

On my insane testcase from re2c, this speeds up CGP from
617.4s to 7.9s (78x).

llvm-svn: 96083
2010-02-13 05:35:08 +00:00
Chris Lattner 5e7f705934 Speed up codegen prepare from 3.58s to 0.488s.
llvm-svn: 96081
2010-02-13 05:01:14 +00:00
Chris Lattner 72c4dce884 PHINode::getBasicBlockIndex is O(n) in the number of inputs
to a PHI, avoid it in the common case where the BB occurs
in the same index for multiple phis.  This speeds up CGP on
an insane testcase from 8.35 to 3.58s.

llvm-svn: 96080
2010-02-13 04:24:19 +00:00
Chris Lattner b0ebb65ab0 iterate over preds using PHI information when available instead of
using pred_begin/end.  It is much faster.

llvm-svn: 96079
2010-02-13 04:15:26 +00:00
Chris Lattner 96b8826542 speed up CGP a bit by scanning predecessors through phi operands
instead of with pred_begin/end.

llvm-svn: 96078
2010-02-13 04:04:42 +00:00
Dan Gohman 5b18f039eb Fix a pruning heuristic which implicitly assumed that SmallPtrSet is
deterministically sorted.

llvm-svn: 96071
2010-02-13 02:06:02 +00:00
Jakob Stoklund Olesen 492b8b42cd Enable the inlinehint attribute in the Inliner.
Functions explicitly marked inline will get an inlining threshold slightly
more aggressive than the default for -O3. This means than -O3 builds are
mostly unaffected while -Os builds will be a bit bigger and faster.

The difference depends entirely on how many 'inline's are sprinkled on the
source.

In the CINT2006 suite, only these tests are significantly affected under -Os:

               Size   Time
471.omnetpp   +1.63% -1.85%
473.astar     +4.01% -6.02%
483.xalancbmk +4.60%  0.00%

Note that 483.xalancbmk runs too quickly to give useful timing results.

llvm-svn: 96066
2010-02-13 01:51:53 +00:00
Dan Gohman 2b75de97c0 Reapply 95979, a compile-time speedup, now that the bug it exposed is fixed.
llvm-svn: 96005
2010-02-12 19:35:25 +00:00
Dan Gohman 363f847ec6 Fix this code to avoid dereferencing an end() iterator in
offset distributions it doesn't expect.

llvm-svn: 96002
2010-02-12 19:20:37 +00:00
Chris Lattner 75879be9d8 1. modernize the constantmerge pass, using densemap/smallvector.
2. don't bother trying to merge globals in non-default sections,
   doing so is quite dubious at best anyway.
3. fix a bug reported by Arnaud de Grandmaison where we'd try to
   merge two globals in different address spaces.

llvm-svn: 95995
2010-02-12 18:17:23 +00:00