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

509 Commits

Author SHA1 Message Date
Jay Foad
9bd6e1956b PR9214: Convert ConstantExpr::getWithOperands() to use ArrayRef.
llvm-svn: 129439
2011-04-13 13:46:01 +00:00
Nick Lewycky
46bb763f35 ConstantInt has some getters which return ConstantInt's or ConstantVector's of
the value splatted into every element. Extend this to getTrue and getFalse which
by providing new overloads that take Types that are either i1 or <N x i1>. Use
it in InstCombine to add vector support to some code, fixing PR8469!

llvm-svn: 127116
2011-03-06 03:36:19 +00:00
Talin
1d7928c794 Added missing va_end().
llvm-svn: 126759
2011-03-01 18:00:49 +00:00
Talin
753b7ce425 Add an END_WITH_NULL accessor for ConstantStruct.
llvm-svn: 126714
2011-02-28 23:53:27 +00:00
Chris Lattner
87de1d1bb8 hoist GlobalValue::removeDeadConstantUsers up to being a method on Constant.
llvm-svn: 125828
2011-02-18 04:41:42 +00:00
Nadav Rotem
ad2fd4eada Enhance constant folding of bitcast operations on vectors of floats.
Add getAllOnesValue of FP numbers to Constants and APFloat.
Add more tests.

llvm-svn: 125776
2011-02-17 21:22:27 +00:00
Chris Lattner
db204cbe42 convert ConstantVector::get to use ArrayRef.
llvm-svn: 125537
2011-02-15 00:14:00 +00:00
Chris Lattner
ee7f7c2494 revert my ConstantVector patch, it seems to have made the llvm-gcc
builders unhappy.

llvm-svn: 125504
2011-02-14 18:15:46 +00:00
Chris Lattner
34f32cb4c2 Switch ConstantVector::get to use ArrayRef instead of a pointer+size
idiom.  Change various clients to simplify their code.

llvm-svn: 125487
2011-02-14 07:55:32 +00:00
Chris Lattner
46815e1da6 make ConstantExpr::replaceUsesOfWithOnConstant preserve the inbounds
flag.  Noticed by Jin Gu Kang!

llvm-svn: 125366
2011-02-11 05:37:21 +00:00
Chris Lattner
9e2e84606d make the constantexpr interfaces for inbounds GEPs follow the same style
as other constantexpr flags, reducing redundancy.

llvm-svn: 125365
2011-02-11 05:34:33 +00:00
Chris Lattner
63f1d56458 switch the constantexpr, target folder, and IRBuilder interfaces
for NSW/NUW binops to follow the pattern of exact binops.  This
allows someone to use Builder.CreateAdd(x, y, "tmp", MaybeNUW);

llvm-svn: 125270
2011-02-10 07:01:55 +00:00
Chris Lattner
7a5307ec0b refactor ConstantExpr interfaces a bit around "exactness".
llvm-svn: 125190
2011-02-09 16:43:07 +00:00
Chris Lattner
b641eb91a3 fix comment change.
llvm-svn: 125047
2011-02-07 20:03:14 +00:00
Chris Lattner
2fd09e3397 implement .ll and .bc support for nsw/nuw on shl and exact on lshr/ashr.
Factor some code better.

llvm-svn: 125006
2011-02-07 16:40:21 +00:00
Chris Lattner
7b6a968f5d enhance vmcore to know that udiv's can be exact, and add a trivial
instcombine xform to exercise this.

Nothing forms exact udivs yet though.  This is progress on PR8862

llvm-svn: 124992
2011-02-06 21:44:57 +00:00
Duncan Sands
06e82c76ee Have m_One also match constant vectors for which every element is 1.
llvm-svn: 124655
2011-02-01 08:39:12 +00:00
Jay Foad
284c5bc9bd Fix indentation.
llvm-svn: 124375
2011-01-27 14:44:55 +00:00
Jay Foad
fa61721cf2 Remove casts between Value** and Constant**, which won't work if a
static_cast from Constant* to Value* has to adjust the "this" pointer.
This is groundwork for PR889.

llvm-svn: 123435
2011-01-14 08:07:43 +00:00
Benjamin Kramer
612c7225ee Apparently APFloat::getZero doesn't like PPCDoubleDoubles.
llvm-svn: 120909
2010-12-04 14:43:08 +00:00
Benjamin Kramer
77faee6ba1 Simplify code. No functionality change.
llvm-svn: 120907
2010-12-04 14:22:24 +00:00
Benjamin Kramer
9141603779 Simplify code. No change in functionality.
llvm-svn: 119908
2010-11-20 18:43:35 +00:00
Chris Lattner
ecf276b787 remove unions from LLVM IR. They are severely buggy and not
being actively maintained, improved, or extended.

llvm-svn: 112356
2010-08-28 04:09:24 +00:00
Oscar Fuentes
4742c01c2a Prefix next' iterator operation with llvm::'.
Fixes potential ambiguity problems on VS 2010.

Patch by nobled!

llvm-svn: 110029
2010-08-02 06:00:15 +00:00
Benjamin Kramer
1f47ed839d Preallocate vector, avoid unnecessary vector growth.
llvm-svn: 109971
2010-08-01 11:43:26 +00:00
Chris Lattner
d2097ce7ab Fix PR7658, a problem where type refinement can trigger
constant replacement which was botching its handling of
types.  Use of getType() instead of getRawType() was causing
the type map in constant folding to be updated wrong.

llvm-svn: 108610
2010-07-17 06:13:52 +00:00
Dan Gohman
b8016872b6 Remove the API compatibility layer which converted add, sub, and mul
to fadd, fsub, and fmul, when used with a floating-point type. LLVM
has supported the new instructions since 2.6, so it's time to get
on board.

llvm-svn: 102971
2010-05-03 22:44:19 +00:00
Dan Gohman
377b9cade7 Simplify this code.
llvm-svn: 101074
2010-04-12 22:12:29 +00:00
Chris Lattner
542ebce5fa move some method definitions to files that make sense.
llvm-svn: 99927
2010-03-30 20:48:48 +00:00
Chris Lattner
f21a1afe81 add support for zero initialized unions, patch by Tim Northover!
llvm-svn: 99818
2010-03-29 17:36:02 +00:00
Gabor Greif
df5013e4d8 rename use_const_iterator to const_use_iterator for consistency's sake
llvm-svn: 99564
2010-03-25 23:06:16 +00:00
Talin
cd8428c41f replaceUsesOfWithOnConstant implementation for unions.
llvm-svn: 96616
2010-02-18 21:43:45 +00:00
Duncan Sands
1b33dd3c83 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
Duncan Sands
2acaf3609c 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
Chris Lattner
2265d6280b Add support for a union type in LLVM IR. Patch by Talin!
llvm-svn: 96011
2010-02-12 20:49:41 +00:00
Duncan Sands
364e9510fb Adding missing methods for creating Add, Mul, Neg and Sub with NUW.
llvm-svn: 95086
2010-02-02 12:53:04 +00:00
Chris Lattner
af2e10ddef eliminate a bunch of pointless LLVMContext arguments.
llvm-svn: 95001
2010-02-01 20:48:08 +00:00
Dan Gohman
d1d30c5ec2 Add a getNUWMul function.
llvm-svn: 94982
2010-02-01 16:38:14 +00:00
Dan Gohman
9026a494ae Add a generalized form of ConstantExpr::getOffsetOf which works for
array types as well as struct types, and which accepts arbitrary
Constant indicies.  

llvm-svn: 94981
2010-02-01 16:37:38 +00:00
Dan Gohman
4319402eb0 Make getAlignOf return an i64, for consistency with getSizeOf and
getOffsetOf, and remove the comment about assuming i8 is byte-aligned,
which is no longer applicable.

llvm-svn: 94738
2010-01-28 02:43:22 +00:00
Dan Gohman
1eb6920a2f Remove SCEVAllocSizeExpr and SCEVFieldOffsetExpr, and in their place
use plain SCEVUnknowns with ConstantExpr::getSizeOf and
ConstantExpr::getOffsetOf constants. This eliminates a bunch of
special-case code.

Also add code for pattern-matching these expressions, for clients that
want to recognize them.

Move ScalarEvolution's logic for expanding array and vector sizeof
expressions into an element count times the element size, to expose
the multiplication to subsequent folding, into the regular constant
folder.

llvm-svn: 94737
2010-01-28 02:15:55 +00:00
Chris Lattner
c2717878e8 fix CastInst::castIsValid to reject aggregate types, fixing PR6153:
llvm-as: t.ll:1:25: error: invalid cast opcode for cast from '[4 x i8]' to '[1 x i32]'
@x = constant [1 x i32] bitcast ([4 x i8] c"abcd" to [1 x i32])
                        ^

llvm-svn: 94595
2010-01-26 21:51:43 +00:00
Nick Lewycky
938b8b195c Fix a crasher trying to fold each element in a comparison between two vectors
if one of the vectors didn't have elements (such as undef). Fixes PR 6096.

Fix an issue in the constant folder where fcmp (<2 x %ty>, <2 x %ty>) would
have <2 x i1> type if constant folding was successful and i1 type if it wasn't.
This exposed a related issue in the bitcode reader.

llvm-svn: 94069
2010-01-21 07:03:21 +00:00
Benjamin Kramer
0ba7479f2c Move remaining stuff to the isInteger predicate.
llvm-svn: 92771
2010-01-05 21:05:54 +00:00
Benjamin Kramer
c233521d45 Convert a ton of simple integer type equality tests to the new predicate.
llvm-svn: 92760
2010-01-05 20:07:06 +00:00
David Greene
8637fd7d59 Change errs() to dbgs().
llvm-svn: 92650
2010-01-05 01:29:19 +00:00
Chris Lattner
7246a69d2b differences between two blockaddress's don't cause a
global variable initializer to require relocations.

llvm-svn: 92450
2010-01-03 18:09:40 +00:00
Chris Lattner
f3520d2c35 remove some misleading comments.
llvm-svn: 92311
2009-12-30 20:25:09 +00:00
Chris Lattner
2c82be93e6 add a layer of accessors around the Value::SubClassData member, and use
a convention (shadowing the setter with private forwarding function) to
prevent subclasses from accidentally using it.

This exposed some bogosity in ConstantExprs, which was propaging the
opcode of the constant expr into the NUW/NSW/Exact field in the
getWithOperands/getWithOperandReplaced methods.

llvm-svn: 92239
2009-12-29 02:14:09 +00:00
Dan Gohman
3ceb7c0c47 Add utility routines for NSW multiply.
llvm-svn: 91664
2009-12-18 03:10:26 +00:00
Dan Gohman
6bb50740f4 Add utility routines for creating integer negation operators with NSW set.
Integer negation only overflows with INT_MIN, but that's an important case.

llvm-svn: 91662
2009-12-18 02:58:50 +00:00
Chris Lattner
acc9c4f542 whitespace cleanup
llvm-svn: 90834
2009-12-08 05:31:46 +00:00
Daniel Dunbar
4daaf9d3f4 Pass StringRef by value.
llvm-svn: 86251
2009-11-06 10:58:06 +00:00
Chris Lattner
ad2926bbb4 remove a bunch of locking from LLVMContextImpl. Since only one thread
can be banging on a context at a time, this isn't needed.  Owen, please
review.

llvm-svn: 85728
2009-11-01 18:42:03 +00:00
Chris Lattner
55a53e4e79 the verifier shouldn't modify the IR.
llvm-svn: 85722
2009-11-01 18:11:50 +00:00
Chris Lattner
6e87bdadb9 Fix BlockAddress::replaceUsesOfWithOnConstant to correctly
maintain the block use count in SubclassData.

llvm-svn: 85701
2009-11-01 03:03:03 +00:00
Chris Lattner
2bbe57b2b8 Revert 85678/85680. The decision is to stay with the current form of
indirectbr, thus we don't need "blockaddr(@func, null)".  Eliminate it
for simplicity.

llvm-svn: 85699
2009-11-01 01:27:45 +00:00
Chris Lattner
cbab35746f Make blockaddress(@func, null) be valid, and make 'deleting a basic
block with a blockaddress still referring to it' replace the invalid 
blockaddress with a new blockaddress(@func, null) instead of a 
inttoptr(1).

This changes the bitcode encoding format, and still needs codegen 
support (this should produce a non-zero value, referring to the entry
block of the function would also be quite reasonable).

llvm-svn: 85678
2009-10-31 20:08:37 +00:00
Chris Lattner
74ed905748 make hasAddressTaken() constant time by storing a refcount in BB's subclass data.
llvm-svn: 85625
2009-10-30 22:33:29 +00:00
Chris Lattner
f605b2e8f9 Previously, all operands to Constant were themselves constant.
In the new world order, BlockAddress can have a BasicBlock operand.
This doesn't permute much, because if you have a ConstantExpr (or
anything more specific than Constant) we still know the operand has
to be a Constant.

llvm-svn: 85375
2009-10-28 05:14:34 +00:00
Chris Lattner
c22b8deb03 'static const void *X = &&y' can only be put in the
readonly section if a reference to the containing function
is valid in the readonly section.

llvm-svn: 85370
2009-10-28 04:12:16 +00:00
Chris Lattner
28895dac5b IR support for the new BlockAddress constant kind. This is
untested and there is no way to use it, next up: doing battle
with asmparser.

llvm-svn: 85349
2009-10-28 00:01:44 +00:00
Owen Anderson
fb4db70d0f Banish ConstantsLock. It's serving no purpose other than slowing things down
at the moment.

llvm-svn: 84529
2009-10-19 20:11:52 +00:00
Chris Lattner
a3cf123e86 strength reduce a ton of type equality tests to check the typeid (Through
the new predicates I added) instead of going through a context and doing a
pointer comparison.  Besides being cheaper, this allows a smart compiler
to turn the if sequence into a switch.

llvm-svn: 83297
2009-10-05 05:54:46 +00:00
Nick Lewycky
5bf0eb2dd5 Requires element types in a constant initializer to match the element types of
of the constant. This reverts r6544 and r7428.

llvm-svn: 83270
2009-10-03 19:30:43 +00:00
Jeffrey Yasskin
2d4f3f6704 Assert that ConstantArrays are created with correctly-typed elements.
llvm-svn: 83168
2009-09-30 21:08:08 +00:00
Duncan Sands
ec5d64fdd5 For the NSWSub support in the builder to actually be useable,
there need to be corresponding changes to the constant folders,
done in this patch.

llvm-svn: 82862
2009-09-26 15:35:35 +00:00
Dan Gohman
d585364b0b Rename ConstantFP's getInf to getInfinity.
llvm-svn: 82823
2009-09-25 23:40:21 +00:00
Dan Gohman
01b2c857ed Add a ConstantFP::getInf utility function for creating infinity ConstantFPs.
llvm-svn: 82818
2009-09-25 23:00:48 +00:00
Dan Gohman
18a3644dde When a constant's type is refined, update the constant in place
instead of cloning and RAUWing it.

 - Make AbstractTypeUser a friend of Value so that it can offer
   its subclasses a way to update a Value's type in place. This
   is better than a universally visible setType method on Value,
   and it's sufficient for the immediate need.

 - Eliminate the constant "convert" functions. This eliminates a
   lot of logic duplication, and fixes a complicated bug where a
   constant can't actually be cloned during the type refinement
   process because some of the types that its folder needs are
   half-destroyed, being in the middle of refinement themselves.

 - Move the getValType functions from being static overloaded
   functions in Constants.cpp to be members of class template
   specializations in ConstantsContext.h. This means that the
   code ends up getting instantiated twice, however it also
   makes it possible to eliminate all "convert" functions, so
   it's not a big net code size increase. And if desired, the
   duplicate instantiations could be eliminated with some
   reorganization.

llvm-svn: 81861
2009-09-15 15:58:07 +00:00
Dan Gohman
aa66e3d968 Teach lib/VMCore/ConstantFold.cpp how to set the inbounds keyword and
how to fold notionally-out-of-bounds array getelementptr indices instead
of just doing these in lib/Analysis/ConstantFolding.cpp, because it can
be done in a fairly general way without TargetData, and because not all
constants are visited by lib/Analysis/ConstantFolding.cpp. This enables
more constant folding.

Also, set the "inbounds" flag when the getelementptr indices are
one-past-the-end.

llvm-svn: 81483
2009-09-11 00:04:14 +00:00
Dan Gohman
58a0550024 Factor out the code for checking that all indices in a getelementptr are
within the notional bounds of the static type of the getelementptr (which
is not the same as "inbounds") from GlobalOpt into a utility routine,
and use it in ConstantFold.cpp to check whether there are any mis-behaved
indices.

llvm-svn: 81478
2009-09-10 23:37:55 +00:00
Dan Gohman
1147a7ba87 Reappy r80998, now that the GlobalOpt bug that it exposed on MiniSAT is fixed.
llvm-svn: 81172
2009-09-07 23:54:19 +00:00
Daniel Dunbar
452643b58c Revert "Include optional subclass flags, such as inbounds, nsw, etc., ...", this
breaks MiniSAT on x86_64.

llvm-svn: 81098
2009-09-06 00:11:24 +00:00
Dan Gohman
8b386a0b63 Include optional subclass flags, such as inbounds, nsw, etc., in the
Constant uniquing tables. This allows distinct ConstantExpr objects
with the same operation and different flags.

Even though a ConstantExpr "a + b" is either always overflowing or
never overflowing (due to being a ConstantExpr), it's still necessary
to be able to represent it both with and without overflow flags at
the same time within the IR, because the safety of the flag may
depend on the context of the use. If the constant really does overflow,
it wouldn't ever be safe to use with the flag set, however the use
may be in code that is never actually executed.

This also makes it possible to merge all the flags tests into a single test.

llvm-svn: 80998
2009-09-04 12:08:11 +00:00
Dan Gohman
b9b2864a49 Revert 80959. It isn't sufficient to solve the full problem. And it
introduced regressions in the Ocaml bindings tests.

llvm-svn: 80969
2009-09-03 23:34:49 +00:00
Dan Gohman
e5ec3c1a26 Remove the API for creating ConstantExprs with the nsw, nuw, inbounds,
and exact flags. Because ConstantExprs are uniqued, creating an
expression with this flag causes all expressions with the same operands
to have the same flag, which may not be safe. Add, sub, mul, and sdiv
ConstantExprs are usually folded anyway, so the main interesting flag
here is inbounds, and the constant folder already knows how to set the
inbounds flag automatically in most cases, so there isn't an urgent need
for the API support.

This can be reconsidered in the future, but for now just removing these
API bits eliminates a source of potential trouble with little downside.

llvm-svn: 80959
2009-09-03 22:17:40 +00:00
Devang Patel
27616c3c80 Now Bitcode reader bug is fixed. Reapply 80839.
Use CallbackVH, instead of WeakVH, to hold MDNode elements.
Use FoldingSetNode to unique MDNodes in a context.
Use CallbackVH hooks to update context's MDNodeSet appropriately.

llvm-svn: 80868
2009-09-03 01:39:20 +00:00
Devang Patel
317ab82083 Revert 80839 for now. It causes test failures.
llvm-svn: 80841
2009-09-02 21:49:26 +00:00
Devang Patel
c4be6559c4 Use CallbackVH, instead of WeakVH, to hold MDNode elements.
Use FoldingSetNode to unique MDNodes in a context.
Use CallbackVH hooks to update context's MDNodeSet appropriately.

llvm-svn: 80839
2009-09-02 21:22:09 +00:00
Chris Lattner
2d541e612d switch a couple things off std::ostream
llvm-svn: 79816
2009-08-23 04:02:03 +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
Erick Tryzelaar
d7980d95e8 Add helper functions to ConstantInt and ConstantFP to accept strings.
llvm-svn: 79212
2009-08-16 23:36:33 +00:00
Dan Gohman
a7f21f1767 Add a getOffsetOf, for building a target-independent expression for
offsetof, similar to getSizeOf for sizeof.

llvm-svn: 79208
2009-08-16 21:26:11 +00:00
Owen Anderson
9df206d02d Push LLVMContexts through the IntegerType APIs.
llvm-svn: 78948
2009-08-13 21:58:54 +00:00
Dan Gohman
b0c54f532c Add convenience functions for creating nsw add operators.
llvm-svn: 78707
2009-08-11 20:20:39 +00:00
Dan Gohman
76887b6f2b Don't set the isexact flag if an sdiv operator has been folded into
something else.

llvm-svn: 78702
2009-08-11 19:56:00 +00:00
Daniel Dunbar
490f80eb1c Simplify ConstantExpr::getInBoundsGetElementPtr and fix a possible crash, if
constant folding eliminated the GEP instruction.
 - clang was hitting this on its test suite (for x86_64, at least).

llvm-svn: 78698
2009-08-11 18:28:09 +00:00
Dan Gohman
aed57ee5b0 Add convenience functions for creating inbounds GEPs.
llvm-svn: 78695
2009-08-11 17:57:01 +00:00
Dan Gohman
82b3823bb7 Add convenience functions for creating exact sdiv operators, and
use them in CreatePtrDiff.

llvm-svn: 78682
2009-08-11 17:05:24 +00:00
Owen Anderson
4cd02c843b Change the MDNode uniquing to a ValueMap, at Devang's request.
llvm-svn: 78577
2009-08-10 18:16:08 +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
Owen Anderson
762987e14b Privatize the last bit of Constant-creation state.
llvm-svn: 78097
2009-08-04 20:25:11 +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
Owen Anderson
5370346117 Privatize all but one of the remaining constant tables.
llvm-svn: 77748
2009-07-31 22:45:43 +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
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
Owen Anderson
881d928f9b Move types back to the 2.5 API.
llvm-svn: 77516
2009-07-29 22:17:13 +00:00
Owen Anderson
0ce2151b36 Move ConstantExpr to 2.5 API.
llvm-svn: 77494
2009-07-29 18:55:55 +00:00