summaryrefslogtreecommitdiff
path: root/lib/VMCore/Constants.cpp
Commit message (Collapse)AuthorAge
* Merge r168147 from trunk:Hans Wennborg2012-11-16
| | | | | | | | | | | | | | Constant::IsThreadDependent(): Use dyn_cast<Constant> instead of cast It turns out that the operands of a Constant are not always themselves Constant. For example, one of the operands of BlockAddress is BasicBlock, which is not a Constant. This should fix the dragonegg-x86_64-linux-gcc-4.6-test build which broke in r168037. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_32@168193 91177308-0d34-0410-b5e6-96231b3b80d8
* Merge r168037 from trunk:Hans Wennborg2012-11-16
| | | | | | | | | | | | | | | | | Make GlobalOpt be conservative with TLS variables (PR14309) For global variables that get the same value stored into them everywhere, GlobalOpt will replace them with a constant. The problem is that a thread-local GlobalVariable looks like one value (the address of the TLS var), but is different between threads. This patch introduces Constant::isThreadDependent() which returns true for thread-local variables and constants which depend on them (e.g. a GEP into a thread-local array), and teaches GlobalOpt not to track such values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_32@168192 91177308-0d34-0410-b5e6-96231b3b80d8
* Back out r166591, not sure why this made it through since I cancelled the ↵Micah Villmow2012-10-24
| | | | | | command. Bleh, sorry about this! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166596 91177308-0d34-0410-b5e6-96231b3b80d8
* Delete a directory that wasn't supposed to be checked in yet.Micah Villmow2012-10-24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166591 91177308-0d34-0410-b5e6-96231b3b80d8
* Fixed few warnings; trimmed empty lines.Galina Kistanova2012-07-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160159 91177308-0d34-0410-b5e6-96231b3b80d8
* When linearizing a multiplication, return at once if we see a factor of zero,Duncan Sands2012-06-13
| | | | | | | | | | since then the entire expression must equal zero (similarly for other operations with an absorbing element). With this in place a bunch of reassociate code for handling constants is dead since it is all taken care of when linearizing. No intended functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158398 91177308-0d34-0410-b5e6-96231b3b80d8
* Now that Reassociate's LinearizeExprTree can look through arbitrary expressionDuncan Sands2012-06-12
| | | | | | | | | | | | | | | | | | topologies, it is quite possible for a leaf node to have huge multiplicity, for example: x0 = x*x, x1 = x0*x0, x2 = x1*x1, ... rapidly gives a value which is x raised to a vast power (the multiplicity, or weight, of x). This patch fixes the computation of weights by correctly computing them no matter how big they are, rather than just overflowing and getting a wrong value. It turns out that the weight for a value never needs more bits to represent than the value itself, so it is enough to represent weights as APInts of the same bitwidth and do the right overflow-avoiding dance steps when computing weights. As a side-effect it reduces the number of multiplies needed in some cases of large powers. While there, in view of external uses (eg by the vectorizer) I made LinearizeExprTree static, pushing the rank computation out into users. This is progress towards fixing PR13021. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158358 91177308-0d34-0410-b5e6-96231b3b80d8
* Reserve space in these vectors to prevent having to grow the array tooBill Wendling2012-02-07
| | | | | | | much. This gets us an addition 0.9% on 445.gobmk. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149952 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert assert(0) to llvm_unreachableCraig Topper2012-02-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149849 91177308-0d34-0410-b5e6-96231b3b80d8
* Efficient Constant Uniquing.Talin2012-02-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149848 91177308-0d34-0410-b5e6-96231b3b80d8
* reapply the patches reverted in r149470 that reenable ConstantDataArray,Chris Lattner2012-02-05
| | | | | | | | | | | but with a critical fix to the SelectionDAG code that optimizes copies from strings into immediate stores: the previous code was stopping reading string data at the first nul. Address this by adding a new argument to llvm::getConstantStringInfo, preserving the behavior before the patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149800 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert Chris' commits up to r149348 that started causing VMCoreTests unit ↵Argyrios Kyrtzidis2012-02-01
| | | | | | | | | | | | | | | | | | | test to fail. These are: r149348 r149351 r149352 r149354 r149356 r149357 r149361 r149362 r149364 r149365 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149470 91177308-0d34-0410-b5e6-96231b3b80d8
* eliminate the "string" form of ConstantArray::get, usingChris Lattner2012-01-31
| | | | | | | ConstantDataArray::getString instead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149365 91177308-0d34-0410-b5e6-96231b3b80d8
* with recent changes, ConstantArray is never a "string". Remove the associatedChris Lattner2012-01-31
| | | | | | | methods and constant fold the clients to false. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149362 91177308-0d34-0410-b5e6-96231b3b80d8
* fix a small oversight that broke the fhourstones app.Chris Lattner2012-01-31
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149357 91177308-0d34-0410-b5e6-96231b3b80d8
* Change ConstantArray::get to form a ConstantDataArray when possible,Chris Lattner2012-01-31
| | | | | | | | | | | | | | | | | kicking in the big win of ConstantDataArray. As part of this, change the implementation of GetConstantStringInfo in ValueTracking to work with ConstantDataArray (and not ConstantArray) making it dramatically, amazingly, more efficient in the process and renaming it to getConstantStringInfo. This keeps around a GetConstantStringInfo entrypoint that (grossly) forwards to getConstantStringInfo and constructs the std::string required, but existing clients should move over to getConstantStringInfo instead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149351 91177308-0d34-0410-b5e6-96231b3b80d8
* Various improvements suggested by DuncanChris Lattner2012-01-30
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149255 91177308-0d34-0410-b5e6-96231b3b80d8
* First step of flipping on ConstantDataSequential: enable ConstantDataVectorChris Lattner2012-01-30
| | | | | | | to be formed whenever ConstantVector::get is used. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149226 91177308-0d34-0410-b5e6-96231b3b80d8
* continue making the world safe for ConstantDataVector. At this point,Chris Lattner2012-01-27
| | | | | | | | | we should (theoretically optimize and codegen ConstantDataVector as well as ConstantVector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149116 91177308-0d34-0410-b5e6-96231b3b80d8
* smallvectorize and ArrayRef'ize some stuff.Chris Lattner2012-01-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149077 91177308-0d34-0410-b5e6-96231b3b80d8
* Reduce a lot of code duplication by implementing Chris Lattner2012-01-26
| | | | | | | | | | | ConstantExpr::getWithOperandReplaced and ConstantExpr::replaceUsesOfWithOnConstant in terms of ConstantExpr::getWithOperands. While we're at it, make sure that ConstantExpr::getWithOperands covers all instructions: it was missing insert/extractvalue. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149076 91177308-0d34-0410-b5e6-96231b3b80d8
* eliminate the Constant::getVectorElements method. There are better (andChris Lattner2012-01-26
| | | | | | | | more robust) ways to do what it was doing now. Also, add static methods for decoding a ShuffleVector mask. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149028 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a ConstantDataVector::getSplatValue() method, for parity withChris Lattner2012-01-26
| | | | | | | | | | | ConstantVector. Fix some outright bugs in the implementation of ConstantArray and Constant struct, which would cause us to not make one big UndefValue when asking for an array/struct with all undef elements. Enhance Constant::isAllOnesValue to work with ConstantDataVector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149021 91177308-0d34-0410-b5e6-96231b3b80d8
* some general cleanup, using new methods and tidying up old code.Chris Lattner2012-01-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149006 91177308-0d34-0410-b5e6-96231b3b80d8
* constify some methods and add a new Constant::getAggregateElementChris Lattner2012-01-25
| | | | | | | | helper method for the common operation of extracting an element out of a constant aggregate. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148931 91177308-0d34-0410-b5e6-96231b3b80d8
* reapply r148901 with a crucial fix.Chris Lattner2012-01-25
| | | | | | | | "Introduce a new ConstantVector::getSplat constructor function to simplify a really common case." git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148924 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix assert("msg"). Fix unused-variable warnings complaining about VT used onlyNick Lewycky2012-01-25
| | | | | | | in asserts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148910 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r148901 because it crashes llvm tests.Argyrios Kyrtzidis2012-01-25
| | | | | | | | Original log: Introduce a new ConstantVector::getSplat constructor function to simplify a really common case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148906 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce a new ConstantVector::getSplat constructor function to Chris Lattner2012-01-25
| | | | | | | simplify a really common case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148901 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove the Type::getNumElements() method, which is only called in 4 places,Chris Lattner2012-01-25
| | | | | | | | did something extremely surprising, and shadowed actually useful implementations that had completely different behavior. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148898 91177308-0d34-0410-b5e6-96231b3b80d8
* C++, CBE, and TLOF support for ConstantDataSequentialChris Lattner2012-01-24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148805 91177308-0d34-0410-b5e6-96231b3b80d8
* Rearrange argument order of ::get methods so that LLVMContext comes first,Chris Lattner2012-01-24
| | | | | | | | | add a ConstantDataArray::getString method that corresponds to the (to be removed) StringRef version of ConstantArray::get, but is dramatically more efficient. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148804 91177308-0d34-0410-b5e6-96231b3b80d8
* add more support for ConstantDataSequentialChris Lattner2012-01-24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148802 91177308-0d34-0410-b5e6-96231b3b80d8
* Add AsmPrinter (aka MCLowering) support for ConstantDataSequential, Chris Lattner2012-01-24
| | | | | | | | | and clean up some other misc stuff. Unlike ConstantArray, we will prefer to emit .fill directives for "String" arrays that all have the same value, since they are denser than emitting a .ascii git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148793 91177308-0d34-0410-b5e6-96231b3b80d8
* Add various "string" methods to ConstantDataSequential, which have theChris Lattner2012-01-24
| | | | | | | | | same semantics as ConstantArray's but much more efficient because they don't have to return std::string's. The ConstantArray methods will eventually be removed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148792 91177308-0d34-0410-b5e6-96231b3b80d8
* teach valuetracking about ConstantDataSequentialChris Lattner2012-01-24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148790 91177308-0d34-0410-b5e6-96231b3b80d8
* Add some accessor methods to CAZ and UndefValue that help simplify clients.Chris Lattner2012-01-24
| | | | | | | Make some CDS methods public. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148785 91177308-0d34-0410-b5e6-96231b3b80d8
* implement the ConstantDataSequential accessor methods.Chris Lattner2012-01-24
| | | | | | | No need for 'getOperand' :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148778 91177308-0d34-0410-b5e6-96231b3b80d8
* start the implementation of a new ConstantDataVector and ConstantDataArrayChris Lattner2012-01-23
| | | | | | | | classes, per PR1324. Not all of their helper functions are implemented, nothing creates them, and the rest of the compiler doesn't handle them yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148741 91177308-0d34-0410-b5e6-96231b3b80d8
* convert CAZ, UndefValue, and CPN to use DenseMap's again, this time withoutChris Lattner2012-01-23
| | | | | | | | | using OwningPtr. OwningPtr would barf when the densemap had to reallocate, which doesn't appear to happen on the regression test suite, but obviously happens in real life :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148700 91177308-0d34-0410-b5e6-96231b3b80d8
* revert r148691 and 148693Chris Lattner2012-01-23
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148698 91177308-0d34-0410-b5e6-96231b3b80d8
* switch UndefValue and ConstantPointerNull over to DenseMap's for uniquing.Chris Lattner2012-01-23
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148693 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace a use of ConstantUniqueMap for CAZ constants with a simple DenseMap.Chris Lattner2012-01-23
| | | | | | | | Now that the type system rewrite has landed, there is no need for its complexity and std::map'ness. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148691 91177308-0d34-0410-b5e6-96231b3b80d8
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-20
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148578 91177308-0d34-0410-b5e6-96231b3b80d8
* Unweaken vtables as per ↵David Blaikie2011-12-20
| | | | | | http://llvm.org/docs/CodingStandards.html#ll_virtual_anch git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146960 91177308-0d34-0410-b5e6-96231b3b80d8
* The powers that be have decided that LLVM IR should now support 16-bitDan Gohman2011-12-17
| | | | | | | | | "half precision" floating-point with a first-class type. This patch adds basic IR support (but not codegen support). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146786 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for vectors of pointers.Nadav Rotem2011-12-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145801 91177308-0d34-0410-b5e6-96231b3b80d8
* Fold ConstantVector::isAllOnesValue into Constant::isAllOnesValue and ↵Benjamin Kramer2011-11-14
| | | | | | simplify it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144555 91177308-0d34-0410-b5e6-96231b3b80d8
* Change:Richard Trieu2011-09-21
| | | | | | | | | | | | | assert(!"error message"); To: assert(0 && "error message"); which is more consistant across the code base. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140234 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement Constant::isAllOnesValue(). Fix ConstantFolding to use the new api.Nadav Rotem2011-08-24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138469 91177308-0d34-0410-b5e6-96231b3b80d8