Commit Graph

260 Commits

Author SHA1 Message Date
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
Chris Lattner
3584a47588 Add a new Type::getPointerTo method, which is shorthand for
llvm::PointerType::get().  Patch by Anders Johnsen!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68772 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 06:42:02 +00:00
Chris Lattner
bd6de0a2b3 disable this code for now, re-breaking PR2975, but fixing
a testcase I'm about to attach to that pr.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68592 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-08 04:36:59 +00:00
Torok Edwin
68c405d6e8 fix style.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68542 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-07 19:45:59 +00:00
Torok Edwin
eb55f3ea3c Another attempt at fixing PR2975.
Types can have references to eachother, so we can't just call destroy on them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68523 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-07 17:23:02 +00:00
Torok Edwin
5ce1b11412 revert r68457, its crashing in make check.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68459 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-06 20:57:34 +00:00
Torok Edwin
59d5f83b32 fix (part of) memory leak on shutdown. See PR2975.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68457 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-06 20:49:21 +00:00
Nick Lewycky
21cc4460ef Add support for embedded metadata to LLVM. This introduces two new types of
Constant, MDString and MDNode which can only be used by globals with a name
that starts with "llvm." or as arguments to a function with the same naming
restriction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68420 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-04 07:22:01 +00:00
Chris Lattner
ae3042316f delete a bunch of duplicated type printing logic, using the type printing
stuff in AsmWriter.cpp for Type::getDescription().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65734 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-28 23:01:57 +00:00
Sanjiv Gupta
de5b06b3e1 Reverting back 58505. Will commit it once I have the bc reader/writer/docs
ready.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58547 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-01 10:57:12 +00:00
Sanjiv Gupta
d2840fd37f For some targets pointer and int are 16-bits. Allow 16-bits as a valid index
in such cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58505 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-31 10:26:20 +00:00
Chris Lattner
3b12ab4519 Inline the fastpath of PATypeHolder::get(). This is a small speedup in
instcombine among other things.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54814 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-15 15:16:50 +00:00