Chris Lattner
784e8d9177
add getPointerAddressSpace() to GEP instruction, use the method
...
in a few scalar xforms to simplify things.
llvm-svn: 80506
2009-08-30 20:06:40 +00:00
Chris Lattner
dc6b5be632
eliminate InsertCastBefore, use the builder instead.
...
llvm-svn: 80505
2009-08-30 20:01:10 +00:00
Chris Lattner
2a3af9b743
eliminate InsertBitCastBefore, just use the builder instead.
...
llvm-svn: 80504
2009-08-30 19:47:22 +00:00
Chris Lattner
bbfe14087f
convert a bunch more calls to InsertNewInstBefore to use
...
the new Instcombine builder.
llvm-svn: 80501
2009-08-30 18:50:58 +00:00
Chris Lattner
444e6e0118
fix typo
...
llvm-svn: 80500
2009-08-30 17:53:59 +00:00
Chris Lattner
dd71643cf1
give instcombine a custom IRBuilder that adds new instructions to the
...
workslist and is set to insert new instructions before the current one.
Convert a bunch of stuff that used to call InsertNewInstBefore over to
use it, greatly simplifying code and making it more natural.
There is still a lot more to go, but this is a good start.
llvm-svn: 80492
2009-08-30 07:44:24 +00:00
Chris Lattner
d53d314bd6
add a new InstCombineWorklist::AddValue method that works even
...
if the operand is not an instruction.
Simplify most uses of AddOperandsToWorkList to use AddValue and
inline it into the one remaining callsite.
llvm-svn: 80488
2009-08-30 06:27:41 +00:00
Chris Lattner
7dfc9cc68f
move AddUsersToWorkList to the worklist processing class, make the
...
argument stronger typed.
llvm-svn: 80487
2009-08-30 06:22:51 +00:00
Chris Lattner
13202514e1
rename AddUsesToWorkList -> AddOperandsToWorkList. The
...
former looks too much like AddUsersToWorkList and keeps
confusing me.
Remove AddSoonDeadInstToWorklist and change its two callers
to do the same thing in a simpler way.
llvm-svn: 80486
2009-08-30 06:20:05 +00:00
Chris Lattner
1f8e8caacb
inline the trivial AddToWorkList/RemoveFromWorkList methods
...
into their callers. simplify ReplaceInstUsesWith. Make
EraseInstFromFunction only add operands to the worklist if
there aren't too many of them (this was a scalability win
for crazy programs that was only infrequently enforced).
Switch more code to using EraseInstFromFunction instead of
duplicating it inline. Change some fcmp/icmp optimizations
to modify fcmp/icmp in place instead of creating a new one
and deleting the old one just to change the predicate.
llvm-svn: 80483
2009-08-30 06:13:40 +00:00
Chris Lattner
97d6443c26
fix a bug I introduced in r80478 found by the build bot.
...
llvm-svn: 80482
2009-08-30 05:56:44 +00:00
Chris Lattner
ca6875bf57
refactor instcombine's worklist processing stuff out to its own class.
...
llvm-svn: 80481
2009-08-30 05:55:36 +00:00
Chris Lattner
741fcee014
more cleanups: remove some redundant code, and simplify some
...
other places.
llvm-svn: 80478
2009-08-30 05:30:55 +00:00
Chris Lattner
aecf0100db
eliminate the temporary SrcGEPOperands smallvector.
...
llvm-svn: 80477
2009-08-30 05:08:50 +00:00
Chris Lattner
2051889d14
simplify/detangle some control flow.
...
llvm-svn: 80476
2009-08-30 05:00:50 +00:00
Chris Lattner
e5c5ff8f49
simplify and cleanup some code, remove some code that just
...
does constant folding of gep's: this is already handled in
a more general way.
No functionality change.
llvm-svn: 80475
2009-08-30 04:49:01 +00:00
Dan Gohman
cc35ffe3df
Remove an unnecessary Context argument.
...
llvm-svn: 80454
2009-08-29 23:39:38 +00:00
Benjamin Kramer
34020d0ab5
Inline empty destructor.
...
llvm-svn: 80431
2009-08-29 13:38:21 +00:00
Bill Wendling
095b3c55e8
Fix warning about non-virtual destructor.
...
llvm-svn: 80429
2009-08-29 12:31:38 +00:00
Devang Patel
fbaeda732e
Reapply 79977.
...
Use MDNodes to encode debug info in llvm IR.
llvm-svn: 80406
2009-08-28 23:24:31 +00:00
Andreas Neustifter
c11b0d7108
Preparation for Optimal Edge Profiling:
...
This implements the maximum spanning tree algorithm on CFGs according to
weights given by the ProfileEstimator. This is then used to implement Optimal
Edge Profiling.
llvm-svn: 80358
2009-08-28 11:28:24 +00:00
Chris Lattner
4dbe7896a5
finish a half formed thought :)
...
llvm-svn: 80334
2009-08-28 04:48:54 +00:00
Chris Lattner
f37893e7a1
Fix PR3913, patch by Jakub Staszak!
...
llvm-svn: 80327
2009-08-28 00:43:14 +00:00
Chris Lattner
7785b6000e
Implement a new optimization in the inliner: if inlining multiple
...
calls into a function and if the calls bring in arrays, try to merge
them together to reduce stack size. For example, in the testcase
we'd previously end up with 4 allocas, now we end up with 2 allocas.
As described in the comments, this is not really the ideal solution
to this problem, but it is surprisingly effective. For example, on
176.gcc, we end up eliminating 67 arrays at "gccas" time and another
24 at "llvm-ld" time.
One piece of concern that I didn't look into: at -O0 -g with
forced inlining this will almost certainly result in worse debug
info. I think this is acceptable though given that this is a case
of "debugging optimized code", and we don't want debug info to
prevent the optimizer from doing things anyway.
llvm-svn: 80215
2009-08-27 06:29:33 +00:00
Chris Lattner
61d49fed23
unbreak the build, yay for symlinks + makefiles. :(
...
llvm-svn: 80205
2009-08-27 04:43:05 +00:00
Chris Lattner
358f90e5b1
reduce header #include'age
...
llvm-svn: 80204
2009-08-27 04:32:07 +00:00
Chris Lattner
becb2e9534
enhance InlineFunction to be able to optionally return
...
a the list of static allocas that it inlined.
llvm-svn: 80203
2009-08-27 04:20:52 +00:00
Chris Lattner
7fbde3dedf
smallvectorize the list of returns built by CloneAndPruneFunctionInto.
...
llvm-svn: 80202
2009-08-27 04:02:30 +00:00
Chris Lattner
8b277ab324
remove CloneTrace, which appears to be dead since 2004.
...
llvm-svn: 80201
2009-08-27 03:56:43 +00:00
Chris Lattner
71e787d93b
reduce inlining factor some stuff out to a static helper function,
...
and other code cleanups. No functionality change.
llvm-svn: 80199
2009-08-27 03:51:50 +00:00
Owen Anderson
2ed352c8b6
Make this into a static method.
...
llvm-svn: 80170
2009-08-26 22:55:11 +00:00
Devang Patel
10c075a316
Revert 79977. It causes llvm-gcc bootstrap failures on some platforms.
...
llvm-svn: 80073
2009-08-26 05:01:18 +00:00
Dan Gohman
1c96cf0732
Remove unused variables.
...
llvm-svn: 80058
2009-08-26 00:13:22 +00:00
Dan Gohman
4d20610e6e
Eliminate the unused Context argument on one of the ICmpInst and FCmpInst
...
constructors.
llvm-svn: 80049
2009-08-25 23:17:54 +00:00
Dan Gohman
cce6c79d6d
Rename Instruction::isIdenticalTo to Instruction::isIdenticalToWhenDefined,
...
and introduce a new Instruction::isIdenticalTo which tests for full
identity, including the SubclassOptionalData flags. Also, fix the
Instruction::clone implementations to preserve the SubclassOptionalData
flags. Finally, teach several optimizations how to handle
SubclassOptionalData correctly, given these changes.
This fixes the counterintuitive behavior of isIdenticalTo not comparing
the full value, and clone not returning an identical clone, as well as
some subtle bugs that could be caused by these.
Thanks to Nick Lewycky for reporting this, and for an initial patch!
llvm-svn: 80038
2009-08-25 22:11:20 +00:00
Dan Gohman
e298d55930
Special-case static allocas in IndVarSimplify's loop invariant
...
sinking code, since they are special. If the loop preheader happens
to be the entry block of a function, don't sink static allocas
out of it. This fixes PR4775.
llvm-svn: 80010
2009-08-25 17:42:10 +00:00
Owen Anderson
2f84faae31
Comment-ify.
...
llvm-svn: 80009
2009-08-25 17:42:07 +00:00
Owen Anderson
fe7348b43e
Switch to SmallVector.
...
llvm-svn: 80007
2009-08-25 17:35:37 +00:00
Owen Anderson
66ea4dea86
Pull out this predicate loop into a helper function.
...
llvm-svn: 80006
2009-08-25 17:26:32 +00:00
Devang Patel
7d42bfab6c
Update DebugInfo interface to use metadata, instead of special named llvm.dbg.... global variables, to encode debugging information in llvm IR. This is mostly a mechanical change that tests metadata support very well.
...
This change speeds up llvm-gcc by more then 6% at "-O0 -g" (measured by compiling InstructionCombining.cpp!)
llvm-svn: 79977
2009-08-25 05:24:07 +00:00
Dale Johannesen
77c3fb475f
Allow multiple occurrences of -inline-threshold on
...
the command line. This gives llvm-gcc developers
a way to control inlining (documented as "not intended
for end users").
llvm-svn: 79966
2009-08-25 01:13:58 +00:00
Owen Anderson
af732792b7
Handle a corner case when extracing code regions where one of the immediate successor
...
of an extracted block contains a PHI using a value defined in the extracted region.
With this patch, the partial inliner now passes MultiSource/Applications.
llvm-svn: 79963
2009-08-25 00:54:39 +00:00
Owen Anderson
7113af190c
When extracting SEME regions of code, the extractor needs to update the dominator tree for split return blocks.
...
llvm-svn: 79957
2009-08-24 23:32:14 +00:00
Chris Lattner
39262eb119
prune the #includes in raw_ostream.h by moving a
...
member out of line. ftostr is not particularly speedy,
so that method is presumably not perf sensitive.
llvm-svn: 79885
2009-08-24 03:52:50 +00:00
Benjamin Kramer
e5458c19a2
Kill off more cerr/cout uses and prune includes a bit.
...
llvm-svn: 79852
2009-08-23 11:37:21 +00:00
Daniel Dunbar
40ba5f6f58
Fix -Asserts warnings.
...
llvm-svn: 79849
2009-08-23 10:29:55 +00:00
Chris Lattner
f536c93134
convert LoopInfo.h and GraphWriter.h to use raw_ostream
...
llvm-svn: 79836
2009-08-23 07:19:13 +00:00
Chris Lattner
bd73307361
eliminate uses of cerr()
...
llvm-svn: 79834
2009-08-23 07:05:07 +00:00
Chris Lattner
89d3d59e83
remove a few DOUTs here and there.
...
llvm-svn: 79832
2009-08-23 06:35:02 +00:00
Chris Lattner
1c0452caeb
Change Pass::print to take a raw ostream instead of std::ostream,
...
update all code that this affects.
llvm-svn: 79830
2009-08-23 06:03:38 +00:00
Chris Lattner
ea2bfd7a9f
eliminate the std::ostream form of WriteAsOperand and update clients.
...
This also updates dominator related stuff.
llvm-svn: 79825
2009-08-23 05:17:37 +00:00
Chris Lattner
8500c36f86
remove the std::ostream version of module and type printing.
...
llvm-svn: 79823
2009-08-23 04:52:46 +00:00
Chris Lattner
01dae858b6
eliminate the "Value" printing methods that print to a std::ostream.
...
This required converting a bunch of stuff off DOUT and other cleanups.
llvm-svn: 79819
2009-08-23 04:37:46 +00:00
Dan Gohman
6ec8176e22
Rename hasNoUnsignedOverflow and hasNoSignedOverflow to hasNoUnsignedWrap
...
and hasNoSignedWrap, for consistency with the nuw and nsw properties.
llvm-svn: 79539
2009-08-20 17:11:38 +00:00
Dan Gohman
5b725f1a48
Fix a few places to check if TargetData is available before using it.
...
llvm-svn: 79493
2009-08-19 23:38:22 +00:00
Dan Gohman
e982de2e30
Make SROA and PredicateSimplifier cope if TargetData is not
...
available. This is very conservative for now.
llvm-svn: 79442
2009-08-19 18:22:18 +00:00
Dan Gohman
ba656de4a4
Use hasDefinitiveInitializer() instead of testing the same thing
...
by hand, and fix a few places that were using hasInitializer() that
appear to depend on the initializer value.
llvm-svn: 79441
2009-08-19 18:20:44 +00:00
Nick Lewycky
47bc7e0bd0
Fix up PHI nodes correctly in the presence of unreachable BBs, part two. Also
...
delete a newed pointer, and improve readability a little bit.
llvm-svn: 79411
2009-08-19 07:16:57 +00:00
Nick Lewycky
ed3dcdbdb8
Be more careful when modifying PHI nodes. Patch by Andre Tavares.
...
llvm-svn: 79407
2009-08-19 06:24:33 +00:00
Dan Gohman
807652ac3a
Fix SimplifyLibcalls and ValueTracking to check mayBeOverridden
...
before performing optimizations based on constant string values.
llvm-svn: 79384
2009-08-19 00:11:12 +00:00
Dan Gohman
0b1af29372
Fix a bug that caused globalopt to miscompile tramp3d: don't miss
...
unruly indices for arrays that are members of structs.
llvm-svn: 79337
2009-08-18 14:58:19 +00:00
Dan Gohman
b4a24b3b8b
Make TargetData optional in MemCpyOptimizer.
...
llvm-svn: 79306
2009-08-18 01:17:52 +00:00
Dan Gohman
3137ac23bc
Make TargetData optional in SimplifyLibCalls.
...
llvm-svn: 79298
2009-08-18 00:48:13 +00:00
Anton Korobeynikov
c9d9a008b5
The attached patches attempt to fix cross builds. For example, if you
...
try to use i686-darwin to build for arm-eabi, you'll quickly run into
several false assumptions that the target OS must be the same as the
host OS. These patches split $(OS) into $(HOST_OS) and $(TARGET_OS) to
help builds like "make check" and the test-suite able to cross
compile. Along the way a target of *-unknown-eabi is defined as
"Freestanding" so that TARGET_OS checks have something to work with.
Patch by Sandeep Patel!
llvm-svn: 79296
2009-08-18 00:40:33 +00:00
Dan Gohman
e78d27bcf9
Update comments to new-style syntax.
...
llvm-svn: 79263
2009-08-17 18:45:31 +00:00
Nick Lewycky
afaae7957e
Don't crash on critical edge. Patch by Andre Tavares.
...
llvm-svn: 79252
2009-08-17 17:00:57 +00:00
Dan Gohman
e8847ebe10
Fix debug output to include a newline after printing a Value, now
...
that Value's operator<< doesn't include one.
llvm-svn: 79240
2009-08-17 15:25:05 +00:00
Duncan Sands
d0eda03882
Don't access the first element of a potentially empty
...
vector (&Formals[0]). With this change llvm-gcc builds
with expensive checking enabled for C, C++ and Fortran.
While there, change a std::vector into a SmallVector.
This is partly gratuitous, but mostly because not all
STL vector implementations define the data method (and
it should be faster).
llvm-svn: 79237
2009-08-17 14:33:27 +00:00
Nick Lewycky
e791519ea3
Don't crash trying to promote VLAs.
...
llvm-svn: 79226
2009-08-17 05:37:31 +00:00
Eli Friedman
ca19f19760
Fix for PR3016: detect the tricky case, where there are
...
unfoldable references to a PHI node in the block being folded, and disable
the transformation in that case. The correct transformation of such PHI
nodes depends on whether BB dominates Succ, and dominance is expensive
to compute here. (Alternatively, it's possible to check whether any
uses are live, but that's also essentially a dominance calculation.
Another alternative is to use reg2mem, but it probably isn't a good idea to
use that in simplifycfg.)
Also, remove some incorrect code from CanPropagatePredecessorsForPHIs
which is made unnecessary with this patch: it didn't consider the case
where a PHI node in BB has multiple uses.
llvm-svn: 79174
2009-08-16 04:23:49 +00:00
Benjamin Kramer
5c54156e82
Don't try to get the context from an erased Instruction.
...
llvm-svn: 79134
2009-08-15 21:07:49 +00:00
Nick Lewycky
de61ef6c5e
SSI construction should just go ahead and ignore instructions in unreachable
...
blocks.
llvm-svn: 79132
2009-08-15 20:12:18 +00:00
Dan Gohman
b3aa090ddf
Make TargetData optional in GlobalOpt and ArgumentPromotion.
...
llvm-svn: 78967
2009-08-14 00:11:03 +00:00
Owen Anderson
dc11fe967d
Actually privatize a IntegerTypes, and fix a few bugs exposed by this.
...
llvm-svn: 78955
2009-08-13 23:27:32 +00:00
Owen Anderson
9df206d02d
Push LLVMContexts through the IntegerType APIs.
...
llvm-svn: 78948
2009-08-13 21:58:54 +00:00
Mon P Wang
d56e4482fc
When InstCombine simplifies a load -> extract element to gep -> load, place
...
the new load by the old load instead of by the extract element because
a store could have occurred between the load and extract element.
llvm-svn: 78891
2009-08-13 05:12:13 +00:00
Andreas Bolka
a2220fbb8d
Simplify conditional.
...
llvm-svn: 78889
2009-08-13 03:05:20 +00:00
Andreas Bolka
68a2326175
Simplify and reduce indentation using early exits.
...
No intended functionality change.
llvm-svn: 78888
2009-08-13 03:00:57 +00:00
Andreas Bolka
c4476bdb2e
DEBUGify some DOUTs.
...
llvm-svn: 78887
2009-08-13 02:45:03 +00:00
Andreas Bolka
00d6ad063a
Prune trailing whitespace.
...
llvm-svn: 78886
2009-08-13 02:40:50 +00:00
Dan Gohman
00ee3a9a1a
Transform -X/C to X/-C, implementing a README.txt entry.
...
llvm-svn: 78812
2009-08-12 16:37:02 +00:00
Dan Gohman
d5b6e35080
Optimize (x/C)*C to x if the division is exact.
...
llvm-svn: 78811
2009-08-12 16:33:09 +00:00
Dan Gohman
9ea1b2644b
Update instcombine's debug output to account for Value*'s operator<<
...
not appending its own newline.
llvm-svn: 78810
2009-08-12 16:28:31 +00:00
Dan Gohman
9a6b2f19e5
Remove a bunch more now-unnecessary Context arguments.
...
llvm-svn: 78809
2009-08-12 16:23:25 +00:00
Dan Gohman
ccb751285b
Eliminate a bunch of now unnecessary explicit Context variables.
...
llvm-svn: 78808
2009-08-12 16:04:34 +00:00
Owen Anderson
dbf9a912fb
Add contexts to some of the MVT APIs. No functionality change yet, just the infrastructure work needed to get the contexts to where they need to be first.
...
llvm-svn: 78759
2009-08-12 00:36:31 +00:00
Dan Gohman
8d69df5773
Optimize exact sdiv by a constant power of 2 to ashr.
...
llvm-svn: 78714
2009-08-11 20:47:47 +00:00
Dan Gohman
e3fa540e7a
Remove unnecessary casts.
...
llvm-svn: 78664
2009-08-11 15:15:10 +00:00
Devang Patel
4609ecd4bd
Remove dead metadata.
...
llvm-svn: 78651
2009-08-11 06:31:57 +00:00
Owen Anderson
b4bce99769
Rename MVT to EVT, in preparation for splitting SimpleValueType out into its own struct type.
...
llvm-svn: 78610
2009-08-10 22:56:29 +00:00
Daniel Dunbar
87825212a4
More ProfileInfo improvements.
...
- Part of optimal static profiling patch sequence by Andreas Neustifter.
- Store edge, block, and function information separately for each functions
(instead of in one giant map).
- Return frequencies as double instead of int, and use a sentinel value for
missing information.
llvm-svn: 78477
2009-08-08 17:43:09 +00:00
Devang Patel
625352f701
Fix dom frontier update. This fixes PR4667.
...
Patch by Jakub Staszak.
llvm-svn: 78388
2009-08-07 17:16:44 +00:00
Dan Gohman
1c41d60c4a
Fix a bunch of namespace pollution.
...
llvm-svn: 78363
2009-08-07 01:32:21 +00:00
Devang Patel
ee39ff2666
Use DebugInfoFinder.
...
llvm-svn: 78333
2009-08-06 20:53:06 +00:00
Owen Anderson
3d0e1b855d
Privatize the StructType table, which unfortunately involves routing contexts through a number of APIs.
...
llvm-svn: 78258
2009-08-05 23:16:16 +00:00
Dan Gohman
bee2eedb5f
Check for !isa<Constant> instead of isa<Instruction>. This
...
matches what the comment says, and it avoids spurious BitCast
instructions for Argument values.
llvm-svn: 78121
2009-08-04 23:23:56 +00:00
Dan Gohman
39f93f6443
Add a new Constant::getIntegerValue helper function, and convert a
...
few places in InstCombine to use it, to fix problems handling pointer
types. This fixes the recent llvm-gcc bootstrap error.
llvm-svn: 78005
2009-08-03 22:07:33 +00:00
Eli Friedman
af54b9b643
Make SimplifyDemandedUseBits generate vector constants where
...
appropriate. Patch per report on llvmdev. No testcase because the
original report didn't come with a testcase, and I can't come up with a case
that actually fails.
llvm-svn: 77986
2009-08-03 19:15:42 +00:00
Owen Anderson
1dc40e205b
Move a few more APIs back to 2.5 forms. The only remaining ones left to change back are
...
metadata related, which I'm waiting on to avoid conflicting with Devang.
llvm-svn: 77721
2009-07-31 20:28:14 +00:00
Dan Gohman
0831bdef1d
Fix GVN's debug output, now that operator<< on Value* doesn't print
...
a trailing newline.
llvm-svn: 77719
2009-07-31 20:24:18 +00:00
Bill Wendling
6920c80ab6
- Convert the rest of the DOUTs to DEBUG+errs().
...
- One formatting change.
No intended functionality change.
llvm-svn: 77717
2009-07-31 19:52:24 +00:00
Eli Friedman
7bb0485237
PR4662: Fix a crash introduced by the recent LLVMContext changes.
...
llvm-svn: 77716
2009-07-31 19:36:47 +00:00
Owen Anderson
d0e6352c97
Move getTrue() and getFalse() to 2.5-like APIs.
...
llvm-svn: 77685
2009-07-31 17:39:07 +00:00
Owen Anderson
93ccaf5c60
Move more code back to 2.5 APIs.
...
llvm-svn: 77635
2009-07-30 23:03:37 +00:00
Daniel Dunbar
81f704c26a
Twines: Don't allow implicit conversion from integers, this is too tricky.
...
llvm-svn: 77605
2009-07-30 17:37:43 +00:00
Daniel Dunbar
4d07efb3c4
Switch obvious clients to Twine instead of utostr (when they were already using
...
a Twine, e.g., for names).
- I am a little ambivalent about this; we don't want the string conversion of
utostr, but using overload '+' mixed with string and integer arguments is
sketchy. On the other hand, this particular usage is something of an idiom.
llvm-svn: 77579
2009-07-30 04:20:37 +00:00
Douglas Gregor
8c9b60cabc
Eliminate a few unused-variable warnings
...
llvm-svn: 77519
2009-07-29 22:41:10 +00:00
Owen Anderson
881d928f9b
Move types back to the 2.5 API.
...
llvm-svn: 77516
2009-07-29 22:17:13 +00:00
Daniel Dunbar
89cb72a6bc
Fix PR4645 which was fallout from the fix for PR4641.
...
- Call RAUW to delete all instructions (this is a patch from Nick Lewycky).
llvm-svn: 77512
2009-07-29 22:00:43 +00:00
Benjamin Kramer
da986c3fc9
Remove now unused Context variables.
...
llvm-svn: 77495
2009-07-29 19:14:17 +00:00
Owen Anderson
0ce2151b36
Move ConstantExpr to 2.5 API.
...
llvm-svn: 77494
2009-07-29 18:55:55 +00:00
Nick Lewycky
e0524c1795
Bulk erasing instructions without RAUWing them is unsafe. Instead, break them
...
into a new BB that has no predecessors.
llvm-svn: 77433
2009-07-29 05:17:50 +00:00
Devang Patel
cb23671431
Rename MDNode.h header. It defines MDnode and other metadata classes.
...
New name is Metadata.h.
llvm-svn: 77370
2009-07-28 21:49:47 +00:00
Owen Anderson
390e9778d4
Return ConstantVector to 2.5 API.
...
llvm-svn: 77366
2009-07-28 21:19:26 +00:00
Owen Anderson
aa8c94b051
Change ConstantArray to 2.5 API.
...
llvm-svn: 77347
2009-07-28 18:32:17 +00:00
Dan Gohman
0d0dd7b732
Teach instcombine to respect and preserve inbounds. Add inbounds
...
to a few tests where it is required for the expected transformation.
llvm-svn: 77290
2009-07-28 01:40:03 +00:00
Mike Stump
8902846c69
Fix a small little typo.
...
llvm-svn: 77289
2009-07-28 01:35:34 +00:00
Dan Gohman
11eb2ee32c
Replace dyn_castGetElementPtr with dyn_cast<GEPOperator>.
...
llvm-svn: 77286
2009-07-28 00:37:50 +00:00
Dan Gohman
361e911b89
Grab the LLVMContext and parent Module of SI ahead of the
...
point where SI can get deleted. This fixes a use of free'd memory.
This fixes Externals/Povray.
llvm-svn: 77285
2009-07-28 00:37:06 +00:00
Mike Stump
6cc3ea28df
Fix a release-asserts warning. Debug functions should be marked used,
...
if there are no other uses. If people don't need this routine
anymore, if should be deleted.
llvm-svn: 77274
2009-07-27 23:33:34 +00:00
Mike Stump
be4029ff76
Avoid build warnings.
...
llvm-svn: 77271
2009-07-27 23:14:11 +00:00
Owen Anderson
d729f993b8
Move ConstantStruct back to 2.5 API.
...
llvm-svn: 77266
2009-07-27 22:29:26 +00:00
Owen Anderson
256c2c250e
Move ConstantFP construction back to the 2.5-ish API.
...
llvm-svn: 77247
2009-07-27 20:59:43 +00:00
Devang Patel
dfa0528df7
Do not seed mstadata into the value map.
...
llvm-svn: 77208
2009-07-27 17:17:04 +00:00
Daniel Dunbar
4a36d5dcfd
Remove Value::getName{Start,End}, the last of the old Name APIs.
...
llvm-svn: 77152
2009-07-26 09:48:23 +00:00
Daniel Dunbar
64abfd0337
Remove Value::getNameLen
...
llvm-svn: 77148
2009-07-26 08:34:35 +00:00
Daniel Dunbar
75a66c519b
Eliminate some uses of DOUT, cerr, and getNameStart().
...
llvm-svn: 77145
2009-07-26 07:49:05 +00:00
Daniel Dunbar
038a7f0d35
Remove Value::{isName, getNameRef}.
...
Also, change MDString to use a StringRef.
llvm-svn: 77098
2009-07-25 23:55:21 +00:00
Daniel Dunbar
251177c96e
Initial update to VMCore to use Twines for string arguments.
...
- The only meat here is in Value.{h,cpp} the rest is essential 'const
std::string &' -> 'const Twine &'.
llvm-svn: 77048
2009-07-25 04:41:11 +00:00
Eric Christopher
b5f8390b6c
Fix 80-col violations.
...
llvm-svn: 77045
2009-07-25 02:45:27 +00:00
Eric Christopher
df9c86fc26
Move ExtractElementInst to ::Create instead of new. Update all uses.
...
llvm-svn: 77044
2009-07-25 02:28:41 +00:00
Dan Gohman
9a7deba67e
Convert a few more things to use raw_ostream.
...
llvm-svn: 77039
2009-07-25 01:43:01 +00:00
Dan Gohman
fdf1a11a27
Convert a few more uses of llvm/Support/Streams.h to raw_ostream.
...
llvm-svn: 77033
2009-07-25 01:13:51 +00:00
Dan Gohman
acc5d6eaae
Make AliasAnalysis and related classes use
...
getAnalysisIfAvailable<TargetData>().
llvm-svn: 77028
2009-07-25 00:48:42 +00:00
Daniel Dunbar
8496064116
More migration to raw_ostream, the water has dried up around the iostream hole.
...
- Some clients which used DOUT have moved to DEBUG. We are deprecating the
"magic" DOUT behavior which avoided calling printing functions when the
statement was disabled. In addition to being unnecessary magic, it had the
downside of leaving code in -Asserts builds, and of hiding potentially
unnecessary computations.
llvm-svn: 77019
2009-07-25 00:23:56 +00:00
Owen Anderson
cc33e89571
Revert the ConstantInt constructors back to their 2.5 forms where possible, thanks to contexts-on-types. More to come.
...
llvm-svn: 77011
2009-07-24 23:12:02 +00:00
Dan Gohman
b895f668cc
AliasAnalysis wants sizes in address-units, not bits.
...
llvm-svn: 77009
2009-07-24 23:01:30 +00:00
Dan Gohman
58619d5ad2
Fix this condition I accidentally inverted.
...
llvm-svn: 76988
2009-07-24 18:31:07 +00:00
Dan Gohman
f1a01b8cc0
Convert several more passes to use getAnalysisIfAvailable<TargetData>()
...
instead of getAnalysis<TargetData>().
llvm-svn: 76982
2009-07-24 18:13:53 +00:00
Daniel Dunbar
339c88008f
Move more to raw_ostream, provide support for writing MachineBasicBlock,
...
LiveInterval, etc to raw_ostream.
llvm-svn: 76965
2009-07-24 10:36:58 +00:00
Daniel Dunbar
e3fea713f1
Switch to getNameStr().
...
llvm-svn: 76962
2009-07-24 08:24:36 +00:00
Daniel Dunbar
b5adc13728
Convert StringMap to using StringRef for its APIs.
...
- Yay for '-'s and simplifications!
- I kept StringMap::GetOrCreateValue for compatibility purposes, this can
eventually go away. Likewise the StringMapEntry Create functions still follow
the old style.
- NIFC.
llvm-svn: 76888
2009-07-23 18:17:34 +00:00
Chris Lattner
2ed4453d0e
refactor a blob of code out to a new 'FoldOrOfFCmps' function and
...
simplify it.
llvm-svn: 76866
2009-07-23 05:46:22 +00:00
Chris Lattner
c687344f0c
Make some existing optimizations that would only trigger on scalars
...
also apply to vectors. This allows us to compile this:
#include <emmintrin.h>
__m128i a(__m128 a, __m128 b) { return a==a & b==b; }
__m128i b(__m128 a, __m128 b) { return a!=a | b!=b; }
to:
_a:
cmpordps %xmm1, %xmm0
ret
_b:
cmpunordps %xmm1, %xmm0
ret
with clang instead of to a ton of horrible code.
llvm-svn: 76863
2009-07-23 05:32:17 +00:00
Chris Lattner
af6fdef894
refactor a bunch of code out into a helper function,
...
no functionality change.
llvm-svn: 76859
2009-07-23 05:14:02 +00:00
Daniel Dunbar
51818313fe
Remove unnecessary store to temporary std::string.
...
llvm-svn: 76782
2009-07-22 20:46:46 +00:00
Eli Friedman
ca2e01b721
Don't give a massive inlining cost bonus to available_externally
...
functions with a single use; eliminating the single use may eliminate
the function from the current module, but usually doesn't eliminate
it from the final program.
llvm-svn: 76730
2009-07-22 08:12:59 +00:00
Owen Anderson
cc287b28c9
Get rid of the Pass+Context magic.
...
llvm-svn: 76702
2009-07-22 00:24:57 +00:00
Dan Gohman
b45091f0f9
Convert instcombine from using using getAnalysis<TargetData> to
...
getAnalysisIfAvailable<TargetData>.
llvm-svn: 76676
2009-07-21 23:21:54 +00:00
Owen Anderson
7f61f8dc30
Rename getConstantInt{True|False} to get{True|False} at Chris' behest.
...
llvm-svn: 76598
2009-07-21 18:03:38 +00:00
Ted Kremenek
60d0ab4838
Update CMake files.
...
llvm-svn: 76595
2009-07-21 17:43:20 +00:00
Owen Anderson
b64eef73cf
Move a bit more state over to the LLVMContext.
...
llvm-svn: 76533
2009-07-21 02:47:59 +00:00
Chris Lattner
31022c9412
use ExpandInlineAsm on TargetLowering instead of TargetAsmInfo.
...
llvm-svn: 76442
2009-07-20 17:52:52 +00:00
Dan Gohman
00b05492f1
Revert the addition of hasNoPointerOverflow to GEPOperator.
...
Getelementptrs that are defined to wrap are virtually useless to
optimization, and getelementptrs that are undefined on any kind
of overflow are too restrictive -- it's difficult to ensure that
all intermediate addresses are within bounds. I'm going to take
a different approach.
Remove a few optimizations that depended on this flag.
llvm-svn: 76437
2009-07-20 17:43:30 +00:00
Chris Lattner
eac40b1473
implement a new magic global "llvm.compiler.used" which is like llvm.used, but
...
doesn't cause ".no_dead_strip" to be emitted on darwin.
llvm-svn: 76399
2009-07-20 06:14:25 +00:00
Bill Wendling
1a10a060cb
Add plumbing for the `linker_private' linkage type. This type is meant for
...
"private" symbols which the assember shouldn't strip, but which the linker may
remove after evaluation. This is mostly useful for Objective-C metadata.
This is plumbing, so we don't have a use of it yet. More to come, etc.
llvm-svn: 76385
2009-07-20 01:03:30 +00:00
Eli Friedman
e507c1afaa
Canonicalize bitcasts between types like <1 x i64> and i64 to
...
insertelement/extractelement.
I'm not entirely sure this is precisely what we want to do: should we
prefer bitcast(insertelement) or insertelement(bitcast)? Similarly. should we
prefer extractelement(bitcast) or bitcast(extractelement)?
llvm-svn: 76345
2009-07-18 23:06:53 +00:00
Eli Friedman
debc43cb11
Back out 76300; apparently the preference is to canonicalize the other
...
way (bitcast -> insert/extractelement).
llvm-svn: 76325
2009-07-18 19:04:16 +00:00
Chris Lattner
ffd009f039
add a fixme
...
llvm-svn: 76324
2009-07-18 18:49:04 +00:00
Eli Friedman
65a5fe312a
Add combine: X sdiv (1 << Y) -> X udiv (1 << Y) when X doesn't have the
...
sign bit set.
llvm-svn: 76304
2009-07-18 09:53:21 +00:00
Eli Friedman
cb34ee3ac3
Remove no-op check.
...
llvm-svn: 76302
2009-07-18 09:21:25 +00:00
Eli Friedman
b7b1eca368
Remove dead check.
...
llvm-svn: 76301
2009-07-18 09:12:15 +00:00
Eli Friedman
f1878fcda1
Canonicalize insert/extractelement from single-element vectors into
...
bitcasts.
It would also be possible to canonicalize the other way; does anyone
have a preference?
llvm-svn: 76300
2009-07-18 09:07:47 +00:00
Eli Friedman
7b1597133d
Fix simplifylibcalls memset recognition to work on 64-bit platforms
...
where int is 32 bits.
llvm-svn: 76293
2009-07-18 08:34:51 +00:00
Nick Lewycky
ec10fcbd04
Replace intersectWith with maximalIntersectWith. The latter guarantees that
...
all values belonging to the intersection will belong to the resulting range.
The former was inconsistent about that point (either way is fine, just pick
one.) This is part of PR4545.
llvm-svn: 76289
2009-07-18 06:34:42 +00:00
Eli Friedman
b5b88b60b3
Fix the inline cost calculation to take into account instructions
...
which cannot be folded even if they have constant operands. Significantly
helps if_spppsubr.c attached to PR4573.
llvm-svn: 76285
2009-07-18 05:26:06 +00:00
Eli Friedman
c0d63a2fec
Add line breaks to make the debug output a bit more readable.
...
llvm-svn: 76284
2009-07-18 05:12:58 +00:00
Dan Gohman
e45061eefe
Convert more code to use Operator instead of explicitly handling both
...
ConstantExpr and Instruction. This involves duplicating some code
between GetElementPtrInst and GEPOperator, but it's not a lot.
llvm-svn: 76265
2009-07-17 23:55:56 +00:00
Dan Gohman
93cbd452ed
Make BasicAliasAnalysis and Value::getUnderlyingObject use
...
GEPOperator's hasNoPointer0verflow(), and make a few places in instcombine
that create GEPs that may overflow clear the NoOverflow value. Among
other things, this partially addresses PR2831.
llvm-svn: 76252
2009-07-17 22:25:10 +00:00
Dan Gohman
bda1bacf36
Fix some typos in a comment.
...
llvm-svn: 76249
2009-07-17 22:16:21 +00:00
Dan Gohman
25a722cc45
Add a new Operator class, for handling Instructions and ConstantExprs
...
in a convenient manner, factoring out some common code from
InstructionCombining and ValueTracking. Move the contents of
BinaryOperators.h into Operator.h and use Operator to generalize them
to support ConstantExprs as well as Instructions.
llvm-svn: 76232
2009-07-17 20:47:02 +00:00
Daniel Dunbar
8ce5e03431
Initialize another Context, in the hopes of unbreaking CBE.
...
llvm-svn: 76184
2009-07-17 16:20:23 +00:00
Eli Friedman
b56b3ca224
Replace isTrapping with a new, similar method called
...
isSafeToSpeculativelyExecute. The new method is a bit closer to what
the callers actually care about in that it rejects more things callers
don't want. It also adds more precise handling for integer
division, and unifies code for analyzing the legality of a speculative
load.
llvm-svn: 76150
2009-07-17 04:28:42 +00:00
Owen Anderson
21d2d69727
Move the ConstantInt uniquing table into LLVMContextImpl. This exposed a number of issues in
...
our current context-passing stuff, which is also fixed here
llvm-svn: 76089
2009-07-16 18:04:31 +00:00
Owen Anderson
4483fbda5e
Revert yesterday's change by removing the LLVMContext parameter to AllocaInst and MallocInst.
...
llvm-svn: 75863
2009-07-15 23:53:25 +00:00
Eli Friedman
6aa39dcd93
Switch invars away from using isTrapping when it really shouldn't be
...
using it.
llvm-svn: 75852
2009-07-15 22:48:29 +00:00
Eli Friedman
048d13f9bb
Don't restrict the set of instructions where we try to constant-fold the
...
operands; it's possible to end up with a constant-foldable operand to
most instructions, even those which can't trap.
llvm-svn: 75845
2009-07-15 22:13:34 +00:00
Dan Gohman
6cc9cb6dc4
Fix indentation.
...
llvm-svn: 75723
2009-07-15 01:26:32 +00:00
Dan Gohman
81885d5b80
Make makeLoopInvariant report whether it made any changes or not,
...
and use this to simplify more code.
llvm-svn: 75722
2009-07-15 01:25:43 +00:00
Owen Anderson
8c85061ee6
Move EVER MORE stuff over to LLVMContext.
...
llvm-svn: 75703
2009-07-14 23:09:55 +00:00
Dale Johannesen
35fc3243a8
Revert 75571; I'm convinced this isn't the right thing to do.
...
llvm-svn: 75642
2009-07-14 17:48:25 +00:00
Torok Edwin
f955a6ef49
llvm_unreachable->llvm_unreachable(0), LLVM_UNREACHABLE->llvm_unreachable.
...
This adds location info for all llvm_unreachable calls (which is a macro now) in
!NDEBUG builds.
In NDEBUG builds location info and the message is off (it only prints
"UREACHABLE executed").
llvm-svn: 75640
2009-07-14 16:55:14 +00:00
Dan Gohman
084661b1b5
Require IVUsers after LCSSA, since LCSSA does not preserve IVUsers.
...
This results in the pass manager running IVUsers only once for
indvars, instead of twice.
llvm-svn: 75633
2009-07-14 14:26:23 +00:00
Eli Friedman
63028801b8
Fix trivial todo in instcombine.
...
llvm-svn: 75586
2009-07-14 02:01:53 +00:00
Dan Gohman
493855541b
Update LoopSimplify and LoopUnswitch to use the new makeLoopInvariant
...
function.
llvm-svn: 75584
2009-07-14 01:37:59 +00:00
Dan Gohman
b9f3a3c96b
Fix indvars to not assume that a loop with a single unique exit
...
block has a single unique exiting block.
llvm-svn: 75579
2009-07-14 01:09:02 +00:00
Dale Johannesen
de1ed58935
Don't delete asm's just because their inputs are undefined;
...
xor R, R is a common and valid idiom for zeroing a register, for example.
llvm-svn: 75571
2009-07-14 00:45:38 +00:00
Eli Friedman
a6c7a3d44e
PR4548: optimize zext+udiv+trunc to udiv.
...
llvm-svn: 75539
2009-07-13 22:46:01 +00:00
Eli Friedman
6b51ac6728
Canonicalize boolean +/- a constant to a select.
...
(I think it's reasonably clear that we want to have a canonical form for
constructs like this; if anyone thinks that a select is not the best
canonical form, please tell me.)
llvm-svn: 75531
2009-07-13 22:27:52 +00:00
Owen Anderson
3501454313
These don't really need contexts either.
...
llvm-svn: 75528
2009-07-13 22:18:28 +00:00
Dan Gohman
f6caa6f1e3
Make Loop and MachineLoop be subclasses of LoopBase, rather than typedefs,
...
using the Curiously Recurring Template Pattern with LoopBase.
This will help further refactoring, and future functionality for
Loop. Also, Headers can now foward-declare Loop, instead of pulling
in LoopInfo.h or doing tricks.
llvm-svn: 75519
2009-07-13 21:51:15 +00:00
Eli Friedman
b2a8c4ffc9
Misc simplifications to InstCombiner::commonIntCastTransforms. Most of
...
the changes are allowed by not calling this function for bitcasts.
The Instruction::AShr case is dead because
SimplifyDemandedInstructionBits handles that case.
llvm-svn: 75514
2009-07-13 21:45:57 +00:00
Eli Friedman
baf7e04afa
Fix comment.
...
llvm-svn: 75499
2009-07-13 20:58:59 +00:00
Owen Anderson
1e5155161a
Move more functionality over to LLVMContext.
...
llvm-svn: 75497
2009-07-13 20:58:05 +00:00
Eli Friedman
832f33550c
Don't bother to call commonIntCastTransforms for bitcasts; int->int
...
bitcasts will always be eliminated anyway.
llvm-svn: 75495
2009-07-13 20:53:00 +00:00
Owen Anderson
393d8b0a0c
Begin the painful process of tearing apart the rat'ss nest that is Constants.cpp and ConstantFold.cpp.
...
This involves temporarily hard wiring some parts to use the global context. This isn't ideal, but it's
the only way I could figure out to make this process vaguely incremental.
llvm-svn: 75445
2009-07-13 04:09:18 +00:00
Eli Friedman
8c0118042a
Remove check which is duplicated in
...
InstCombiner::visitSelectInstWithICmp.
llvm-svn: 75409
2009-07-12 02:00:05 +00:00
Chris Lattner
edf6f031d8
silence a vc++ warning.
...
llvm-svn: 75393
2009-07-11 22:31:59 +00:00
Torok Edwin
ae8a3ff177
assert(0) -> LLVM_UNREACHABLE.
...
Make llvm_unreachable take an optional string, thus moving the cerr<< out of
line.
LLVM_UNREACHABLE is now a simple wrapper that makes the message go away for
NDEBUG builds.
llvm-svn: 75379
2009-07-11 20:10:48 +00:00
Torok Edwin
9b41a5faf2
Convert more assert(0)+abort() -> LLVM_UNREACHABLE,
...
and abort()/exit() -> llvm_report_error().
llvm-svn: 75363
2009-07-11 13:10:19 +00:00