summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Constants.cpp
Commit message (Collapse)AuthorAgeFilesLines
* There are two ways of checking for a given type, for example isa<PointerType>(T)Duncan Sands2010-02-161-10/+10
| | | | | | | and T->isPointerTy(). Convert most instances of the first form to the second form. Requested by Chris. llvm-svn: 96344
* Uniformize the names of type predicates: rather than having isFloatTy andDuncan Sands2010-02-151-40/+40
| | | | | | isInteger, we now have isFloatTy and isIntegerTy. Requested by Chris! llvm-svn: 96223
* Add support for a union type in LLVM IR. Patch by Talin!Chris Lattner2010-02-121-0/+33
| | | | llvm-svn: 96011
* Adding missing methods for creating Add, Mul, Neg and Sub with NUW.Duncan Sands2010-02-021-2/+18
| | | | llvm-svn: 95086
* eliminate a bunch of pointless LLVMContext arguments.Chris Lattner2010-02-011-27/+15
| | | | llvm-svn: 95001
* Add a getNUWMul function.Dan Gohman2010-02-011-0/+5
| | | | llvm-svn: 94982
* Add a generalized form of ConstantExpr::getOffsetOf which works forDan Gohman2010-02-011-4/+9
| | | | | | | array types as well as struct types, and which accepts arbitrary Constant indicies. llvm-svn: 94981
* Make getAlignOf return an i64, for consistency with getSizeOf andDan Gohman2010-01-281-2/+2
| | | | | | | getOffsetOf, and remove the comment about assuming i8 is byte-aligned, which is no longer applicable. llvm-svn: 94738
* Remove SCEVAllocSizeExpr and SCEVFieldOffsetExpr, and in their placeDan Gohman2010-01-281-2/+2
| | | | | | | | | | | | | | | | 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
* fix CastInst::castIsValid to reject aggregate types, fixing PR6153:Chris Lattner2010-01-261-30/+18
| | | | | | | | 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
* Fix a crasher trying to fold each element in a comparison between two vectorsNick Lewycky2010-01-211-7/+13
| | | | | | | | | | 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
* Move remaining stuff to the isInteger predicate.Benjamin Kramer2010-01-051-2/+2
| | | | llvm-svn: 92771
* Convert a ton of simple integer type equality tests to the new predicate.Benjamin Kramer2010-01-051-2/+2
| | | | llvm-svn: 92760
* Change errs() to dbgs().David Greene2010-01-051-1/+1
| | | | llvm-svn: 92650
* differences between two blockaddress's don't cause a Chris Lattner2010-01-031-0/+18
| | | | | | global variable initializer to require relocations. llvm-svn: 92450
* remove some misleading comments.Chris Lattner2009-12-301-39/+6
| | | | llvm-svn: 92311
* add a layer of accessors around the Value::SubClassData member, and use Chris Lattner2009-12-291-4/+4
| | | | | | | | | | | 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
* Add utility routines for NSW multiply.Dan Gohman2009-12-181-0/+5
| | | | llvm-svn: 91664
* Add utility routines for creating integer negation operators with NSW set.Dan Gohman2009-12-181-0/+6
| | | | | | Integer negation only overflows with INT_MIN, but that's an important case. llvm-svn: 91662
* whitespace cleanupChris Lattner2009-12-081-1/+1
| | | | llvm-svn: 90834
* Pass StringRef by value.Daniel Dunbar2009-11-061-3/+3
| | | | llvm-svn: 86251
* remove a bunch of locking from LLVMContextImpl. Since only one threadChris Lattner2009-11-011-3/+0
| | | | | | | can be banging on a context at a time, this isn't needed. Owen, please review. llvm-svn: 85728
* the verifier shouldn't modify the IR.Chris Lattner2009-11-011-0/+15
| | | | llvm-svn: 85722
* Fix BlockAddress::replaceUsesOfWithOnConstant to correctly Chris Lattner2009-11-011-5/+8
| | | | | | maintain the block use count in SubclassData. llvm-svn: 85701
* Revert 85678/85680. The decision is to stay with the current form of Chris Lattner2009-11-011-3/+2
| | | | | | | indirectbr, thus we don't need "blockaddr(@func, null)". Eliminate it for simplicity. llvm-svn: 85699
* Make blockaddress(@func, null) be valid, and make 'deleting a basic Chris Lattner2009-10-311-2/+3
| | | | | | | | | | | | 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
* make hasAddressTaken() constant time by storing a refcount in BB's subclass ↵Chris Lattner2009-10-301-5/+7
| | | | | | data. llvm-svn: 85625
* Previously, all operands to Constant were themselves constant.Chris Lattner2009-10-281-3/+4
| | | | | | | | | 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
* 'static const void *X = &&y' can only be put in the Chris Lattner2009-10-281-0/+3
| | | | | | | readonly section if a reference to the containing function is valid in the readonly section. llvm-svn: 85370
* IR support for the new BlockAddress constant kind. This isChris Lattner2009-10-281-6/+73
| | | | | | | untested and there is no way to use it, next up: doing battle with asmparser. llvm-svn: 85349
* Banish ConstantsLock. It's serving no purpose other than slowing things downOwen Anderson2009-10-191-41/+16
| | | | | | at the moment. llvm-svn: 84529
* strength reduce a ton of type equality tests to check the typeid (ThroughChris Lattner2009-10-051-5/+5
| | | | | | | | 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
* Requires element types in a constant initializer to match the element types ofNick Lewycky2009-10-031-11/+3
| | | | | | of the constant. This reverts r6544 and r7428. llvm-svn: 83270
* Assert that ConstantArrays are created with correctly-typed elements.Jeffrey Yasskin2009-09-301-1/+4
| | | | llvm-svn: 83168
* For the NSWSub support in the builder to actually be useable,Duncan Sands2009-09-261-0/+5
| | | | | | | there need to be corresponding changes to the constant folders, done in this patch. llvm-svn: 82862
* Rename ConstantFP's getInf to getInfinity.Dan Gohman2009-09-251-1/+1
| | | | llvm-svn: 82823
* Add a ConstantFP::getInf utility function for creating infinity ConstantFPs.Dan Gohman2009-09-251-0/+6
| | | | llvm-svn: 82818
* When a constant's type is refined, update the constant in placeDan Gohman2009-09-151-50/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Teach lib/VMCore/ConstantFold.cpp how to set the inbounds keyword andDan Gohman2009-09-111-2/+4
| | | | | | | | | | | | | 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
* Factor out the code for checking that all indices in a getelementptr areDan Gohman2009-09-101-0/+26
| | | | | | | | | 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
* Reappy r80998, now that the GlobalOpt bug that it exposed on MiniSAT is fixed.Dan Gohman2009-09-071-29/+60
| | | | llvm-svn: 81172
* Revert "Include optional subclass flags, such as inbounds, nsw, etc., ...", thisDaniel Dunbar2009-09-061-60/+29
| | | | | | breaks MiniSAT on x86_64. llvm-svn: 81098
* Include optional subclass flags, such as inbounds, nsw, etc., in theDan Gohman2009-09-041-29/+60
| | | | | | | | | | | | | | | | | 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
* Revert 80959. It isn't sufficient to solve the full problem. And itDan Gohman2009-09-031-0/+35
| | | | | | introduced regressions in the Ocaml bindings tests. llvm-svn: 80969
* Remove the API for creating ConstantExprs with the nsw, nuw, inbounds,Dan Gohman2009-09-031-35/+0
| | | | | | | | | | | | | | | 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
* Now Bitcode reader bug is fixed. Reapply 80839.Devang Patel2009-09-031-2/+2
| | | | | | | | 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
* Revert 80839 for now. It causes test failures.Devang Patel2009-09-021-2/+2
| | | | llvm-svn: 80841
* Use CallbackVH, instead of WeakVH, to hold MDNode elements. Devang Patel2009-09-021-2/+2
| | | | | | | Use FoldingSetNode to unique MDNodes in a context. Use CallbackVH hooks to update context's MDNodeSet appropriately. llvm-svn: 80839
* switch a couple things off std::ostreamChris Lattner2009-08-231-5/+7
| | | | llvm-svn: 79816
* Rename hasNoUnsignedOverflow and hasNoSignedOverflow to hasNoUnsignedWrapDan Gohman2009-08-201-1/+1
| | | | | | and hasNoSignedWrap, for consistency with the nuw and nsw properties. llvm-svn: 79539
OpenPOWER on IntegriCloud