Commit Graph

271 Commits

Author SHA1 Message Date
David Greene
fc524526e4 Change errs() to dbgs().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92657 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:29:55 +00:00
John McCall
be58a432ac Put TypesEqual and TypeHasCycleThroughItself in namespace llvm so ADL from
the templates in TypesContext.h can find them.  Caught by clang++.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91735 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-19 00:51:42 +00:00
Jeffrey Yasskin
ad715f86c9 This fixes a memory leak in OpaqueType found by Google's internal heapchecker.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91611 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-17 19:55:06 +00:00
Chris Lattner
c4775e4b97 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85728 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-01 18:42:03 +00:00
Duncan Sands
83ed76869e Make getPointerTo return a const PointerType* rather than
an unqualified PointerType* because it seems more correct.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83454 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-07 07:35:19 +00:00
Duncan Sands
ac53a0b272 Introduce and use convenience methods for getting pointer types
where the element is of a basic builtin type.  For example, to get
an i8* use getInt8PtrTy.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83379 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-06 15:40:36 +00:00
Nick Lewycky
c261df9fab Remove the "metadata*" type and simplify the code it complicated. This was only
used to support GlobalVariables storing MDNodes, back when they were derived
from Constant before the introduction of NamedMDNode, but never removed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82943 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-27 23:27:42 +00:00
Dan Gohman
6afea253e0 Micro-optimize DerivedType::dropAllTypeUses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82900 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-27 15:32:21 +00:00
Nick Lewycky
513869453b Remove dead code from this function and optimize. Update its corresponding
LangRef entry too.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82890 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-27 07:55:32 +00:00
Dan Gohman
e3394d4a49 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81861 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-15 15:58:07 +00:00
Nick Lewycky
1fbb13e4fa Forbid arrays of function-type and structures with function-typed fields.
While I'm there, change code that does:
  SomeTy == Type::getFooType(Context)
into:
  SomeTy->getTypeID() == FooTyID
to decrease the amount of useless type creation which may involve locking, etc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81846 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-15 06:28:26 +00:00
Nick Lewycky
af7263d51e Fix a pair of comment typos.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81750 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-14 02:25:34 +00:00
Torok Edwin
254bb831d8 Opaque types didn't work if llvm_is_multithreaded().
AlwaysOpaqueTy is always NULL at this point, and it causes an assertion failure.
Fix it by using the just constructed tmp instead.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80780 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-02 12:23:05 +00:00
Torok Edwin
2cd5155c0e Free the constants that have no uses in ~LLVMContext.
This fixes leaks from LLVMContext in multithreaded apps.
Since constants are only deleted if they have no uses, it is safe to not delete
a Module on shutdown, as many single-threaded tools do.
Multithreaded apps should however delete the Module before destroying the
Context to ensure that there are no leaks (assuming they use a different context
for each thread).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80590 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-31 16:14:59 +00:00
Dan Gohman
63a03cf585 Allocate the basic types inside the LLVMContextImpl instance,
rather than separately with new. Move the members above the
TypeMap members to avoid destruction order issues. This fixes
a leak of these objects, and eliminates an extra level of
indirection in Type::getInt32Ty and friends.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79997 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-25 16:00:35 +00:00
Chris Lattner
79c5d3f971 remove the std::ostream version of module and type printing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79823 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-23 04:52:46 +00:00
Chris Lattner
569f121f4e remove some DOUTs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79821 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-23 04:44:11 +00:00
Owen Anderson
7b7b102023 Privatize the last bits of static type state.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79258 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-17 17:59:35 +00:00
Owen Anderson
36a3eb0aaa Move the TypeMap lock to a member on LLVMContextImpl.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79256 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-17 17:34:27 +00:00
Owen Anderson
0e275dc538 Actually privatize a IntegerTypes, and fix a few bugs exposed by this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78955 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-13 23:27:32 +00:00
Owen Anderson
1d0be15f89 Push LLVMContexts through the IntegerType APIs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78948 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-13 21:58:54 +00:00
Owen Anderson
d7f2a6cb3f Privatize the StructType table, which unfortunately involves routing contexts through a number of APIs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78258 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 23:16:16 +00:00
Owen Anderson
ab90b28adc Privatize the FunctionType table.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78221 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 18:13:27 +00:00
Owen Anderson
84e99f3c25 Privatize the PointerType factory.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78130 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 00:15:12 +00:00
Owen Anderson
9eb5c93d34 Privatize the VectorType uniquing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78125 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-04 23:47:44 +00:00
Owen Anderson
020e9ab052 Begin the process of privatizing the type uniquing tables. No API changes yet, but there will be in the near future.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78122 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-04 23:33:01 +00:00
Torok Edwin
c23197a26f 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").


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75640 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 16:55:14 +00:00
Torok Edwin
c25e7581b9 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75379 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-11 20:10:48 +00:00
Torok Edwin
dac237e182 Implement changes from Chris's feedback.
Finish converting lib/Target.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75043 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-08 20:53:28 +00:00
Torok Edwin
ab7c09b6b6 Start converting to new error handling API.
cerr+abort -> llvm_report_error
assert(0)+abort -> LLVM_UNREACHABLE (assert(0)+llvm_unreachable-> abort() included)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75018 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-08 18:01:40 +00:00
Owen Anderson
a9d1f2c559 Have scoped mutexes take referenes instead of pointers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74931 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-07 18:33:04 +00:00
Owen Anderson
334143d304 I give up on trying to use reader/writer locks for recursive type refinement. Use a recursive mutex instead, which will (in theory) generate more contention, but is really
a much more natural fit for what's going on during recursive type refinement.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74618 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-01 17:22:27 +00:00
Owen Anderson
8e1c17aa5a Move the memory fences out of the path for single-threaded mode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73775 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 17:45:12 +00:00
Owen Anderson
ae60c0f78e Fix incorrect comment pointed out by Duncan.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73773 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 17:20:50 +00:00
Owen Anderson
6cf69cfdee Simplify using mutexes that become no-ops when not in multithreaded mode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73716 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-18 20:15:26 +00:00
Owen Anderson
0e4d606684 Use SmartMutex to simplify.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73712 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-18 18:36:34 +00:00
Owen Anderson
e3cd5ca7e7 Move Threading.[h|cpp] from Support to System.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73707 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-18 16:54:52 +00:00
Owen Anderson
1d36e4fa7c Fix the double checked locking in this file too.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73703 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-18 16:17:42 +00:00
Owen Anderson
a23d2c1262 Use double-checked locking for this lazy initialization.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73653 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 22:53:57 +00:00
Owen Anderson
4f0ac58da1 We need to guard reads of the AbstractTypeUsers list, as well as writes to it. While it would be nice to use a R/W lock here,
we can't, because it HAS to be recursive.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73617 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 17:13:54 +00:00
Owen Anderson
142fb2acdd Add locking around the accessors for AbstractTypeUsers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73586 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 00:12:30 +00:00
Owen Anderson
845e7e812c Use a reader-writer lock to guard large portions of the Type infrastructure, including abstract type refinement.
There's still some more work to be done here, such as guarding removeAbstractTypeUser() and the printers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73575 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-16 22:51:18 +00:00
Dan Gohman
6de29f8d96 Support vector casts in more places, fixing a variety of assertion
failures.

To support this, add some utility functions to Type to help support
vector/scalar-independent code. Change ConstantInt::get and
ConstantFP::get to support vector types, and add an overload to
ConstantInt::get that uses a static IntegerType type, for
convenience.

Introduce a new getConstant method for ScalarEvolution, to simplify
common use cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73431 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-15 22:12:54 +00:00
Nick Lewycky
a5f54a06b0 Create FunctionType::isValidArgumentType to go along with isValidReturnType.
Also create isValidElementType for ArrayType, PointerType, StructType and
VectorType.

Make LLParser use them. This closes up some holes like an assertion failure on:

  %x = type {label}

but largely doesn't change any semantics. The only thing we accept now which
we didn't before is vectors of opaque type such as "<4 x opaque>". The opaque
can be resolved to an int or float when linking.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73016 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-07 07:26:46 +00:00
Nick Lewycky
7a0370f66a Give embedded metadata its own type instead of relying on EmptyStructTy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72610 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 05:06:04 +00:00
Nick Lewycky
d67a1666ec Audit the type constructors. Previously it was possible to create [0 x void]
or use labels as members of structures for example. Also included a couple of
whitespace fixes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72402 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-25 21:28:11 +00:00
Dan Gohman
fea3da9e58 Update an assertion string to new-style type names.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72239 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-22 00:40:35 +00:00
Sanjiv Gupta
9341c808ae Any size of integral indices are allowed in gep for indexing into sequential types. Also adding a test case to check the indices type allowed into struct.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70134 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26 17:14:35 +00:00
Sanjiv Gupta
7787d4a34b Allow i16 type indices to gep.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69946 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-24 02:37:54 +00:00
Dan Gohman
5b7ff35503 Implement operator<<(raw_ostream &OS, const Type &T).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69596 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-20 15:55:38 +00:00