oota-llvm.git
14 years agoWhen factoring multiply expressions across adds, factor both
Chris Lattner [Fri, 1 Jan 2010 01:13:15 +0000 (01:13 +0000)]
When factoring multiply expressions across adds, factor both
positive and negative forms of constants together.  This
allows us to compile:

int foo(int x, int y) {
    return (x-y) + (x-y) + (x-y);
}

into:

_foo:                                                       ## @foo
subl %esi, %edi
leal (%rdi,%rdi,2), %eax
ret

instead of (where the 3 and -3 were not factored):

_foo:
        imull   $-3, 8(%esp), %ecx
        imull   $3, 4(%esp), %eax
        addl    %ecx, %eax
        ret

this started out as:
    movl    12(%ebp), %ecx
    imull   $3, 8(%ebp), %eax
    subl    %ecx, %eax
    subl    %ecx, %eax
    subl    %ecx, %eax
    ret

This comes from PR5359.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92381 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agotest case we alredy get right.
Chris Lattner [Fri, 1 Jan 2010 00:50:00 +0000 (00:50 +0000)]
test case we alredy get right.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92380 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoRemove old header.
Ted Kremenek [Fri, 1 Jan 2010 00:04:49 +0000 (00:04 +0000)]
Remove old header.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92378 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoclean up some comments.
Chris Lattner [Fri, 1 Jan 2010 00:04:26 +0000 (00:04 +0000)]
clean up some comments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92377 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoswitch from std::map to DenseMap for rank data structures.
Chris Lattner [Fri, 1 Jan 2010 00:01:34 +0000 (00:01 +0000)]
switch from std::map to DenseMap for rank data structures.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92375 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoRemove derelict serialization code.
Ted Kremenek [Thu, 31 Dec 2009 23:40:17 +0000 (23:40 +0000)]
Remove derelict serialization code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92374 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoreuse negates where possible instead of always creating them from scratch.
Chris Lattner [Thu, 31 Dec 2009 20:34:32 +0000 (20:34 +0000)]
reuse negates where possible instead of always creating them from scratch.
This allows us to optimize test12 into:

define i32 @test12(i32 %X) {
  %factor = mul i32 %X, -3                        ; <i32> [#uses=1]
  %Z = add i32 %factor, 6                         ; <i32> [#uses=1]
  ret i32 %Z
}

instead of:

define i32 @test12(i32 %X) {
  %Y = sub i32 6, %X                              ; <i32> [#uses=1]
  %C = sub i32 %Y, %X                             ; <i32> [#uses=1]
  %Z = sub i32 %C, %X                             ; <i32> [#uses=1]
  ret i32 %Z
}

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92373 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agowe don't need a smallptrset to detect duplicates, the values are
Chris Lattner [Thu, 31 Dec 2009 19:49:01 +0000 (19:49 +0000)]
we don't need a smallptrset to detect duplicates, the values are
sorted, so we can just do a linear scan.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92372 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agomake reassociate more careful about not leaving around dead mul's
Chris Lattner [Thu, 31 Dec 2009 19:34:45 +0000 (19:34 +0000)]
make reassociate more careful about not leaving around dead mul's

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92370 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoremove debug
Chris Lattner [Thu, 31 Dec 2009 19:25:19 +0000 (19:25 +0000)]
remove debug

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92369 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoteach reassociate to factor x+x+x -> x*3. While I'm at it,
Chris Lattner [Thu, 31 Dec 2009 19:24:52 +0000 (19:24 +0000)]
teach reassociate to factor x+x+x -> x*3.  While I'm at it,
fix RemoveDeadBinaryOp to actually do something.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92368 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agochange reassociate to use SmallVector for its key datastructures
Chris Lattner [Thu, 31 Dec 2009 18:40:32 +0000 (18:40 +0000)]
change reassociate to use SmallVector for its key datastructures
instead of std::vector.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92366 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agochange an if to an assert, fix comment.
Chris Lattner [Thu, 31 Dec 2009 18:18:46 +0000 (18:18 +0000)]
change an if to an assert, fix comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92364 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agomove the rest of the add optimization code out to OptimizeAdd,
Chris Lattner [Thu, 31 Dec 2009 18:17:13 +0000 (18:17 +0000)]
move the rest of the add optimization code out to OptimizeAdd,
improve some comments, simplify a bit of code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92363 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agofactor statistic updating better.
Chris Lattner [Thu, 31 Dec 2009 17:51:05 +0000 (17:51 +0000)]
factor statistic updating better.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92362 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoSilence compiler warning.
Benjamin Kramer [Thu, 31 Dec 2009 16:27:13 +0000 (16:27 +0000)]
Silence compiler warning.

warning: comparison between signed and unsigned integer expressions

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92359 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agosimple fix for an incorrect factoring which causes a
Chris Lattner [Thu, 31 Dec 2009 08:33:49 +0000 (08:33 +0000)]
simple fix for an incorrect factoring which causes a
miscompilation, PR5458.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92354 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agomerge some more tests in.
Chris Lattner [Thu, 31 Dec 2009 08:32:22 +0000 (08:32 +0000)]
merge some more tests in.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92353 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agofilecheckize
Chris Lattner [Thu, 31 Dec 2009 08:29:56 +0000 (08:29 +0000)]
filecheckize

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92352 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agofix refactoro
Chris Lattner [Thu, 31 Dec 2009 08:23:09 +0000 (08:23 +0000)]
fix refactoro

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92349 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agofactor code out into helper functions.
Chris Lattner [Thu, 31 Dec 2009 07:59:34 +0000 (07:59 +0000)]
factor code out into helper functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92347 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoswitch some std::vector's to smallvector. Reduce nesting.
Chris Lattner [Thu, 31 Dec 2009 07:48:51 +0000 (07:48 +0000)]
switch some std::vector's to smallvector.  Reduce nesting.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92346 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agouse more modern datastructures.
Chris Lattner [Thu, 31 Dec 2009 07:33:14 +0000 (07:33 +0000)]
use more modern datastructures.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92344 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoclean up -debug output.
Chris Lattner [Thu, 31 Dec 2009 07:17:37 +0000 (07:17 +0000)]
clean up -debug output.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92343 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoDocument the edit-distance algorithm used in StringRef, switch it over
Douglas Gregor [Thu, 31 Dec 2009 04:24:34 +0000 (04:24 +0000)]
Document the edit-distance algorithm used in StringRef, switch it over
to SmallVector, and add a unit test.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92340 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agothis #include is ok.
Chris Lattner [Thu, 31 Dec 2009 03:02:42 +0000 (03:02 +0000)]
this #include is ok.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92338 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agofix Analysis/DebugInfo.h to not include Metadata.h. Do this
Chris Lattner [Thu, 31 Dec 2009 03:02:08 +0000 (03:02 +0000)]
fix Analysis/DebugInfo.h to not include Metadata.h.  Do this
by moving one method out of line and eliminating redundant checks
from other methods.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92337 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoadd some basic named MD tests.
Chris Lattner [Thu, 31 Dec 2009 03:00:49 +0000 (03:00 +0000)]
add some basic named MD tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92336 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agouse early exits to reduce indentation.
Chris Lattner [Thu, 31 Dec 2009 02:33:14 +0000 (02:33 +0000)]
use early exits to reduce indentation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92335 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoeliminate another copy of the mdnode printing logic, simplify the
Chris Lattner [Thu, 31 Dec 2009 02:31:59 +0000 (02:31 +0000)]
eliminate another copy of the mdnode printing logic, simplify the
one that remains.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92334 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agorandom tidying for MDNode printing.
Chris Lattner [Thu, 31 Dec 2009 02:27:30 +0000 (02:27 +0000)]
random tidying for MDNode printing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92333 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoeliminate a bunch of useless forwarding functions with one caller.
Chris Lattner [Thu, 31 Dec 2009 02:23:35 +0000 (02:23 +0000)]
eliminate a bunch of useless forwarding functions with one caller.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92332 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agomake mdnMap type safe, rename accessors for consistency with the rest of llvm.
Chris Lattner [Thu, 31 Dec 2009 02:20:11 +0000 (02:20 +0000)]
make mdnMap type safe, rename accessors for consistency with the rest of llvm.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92331 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agometadata can't be a global var initializer.
Chris Lattner [Thu, 31 Dec 2009 02:15:45 +0000 (02:15 +0000)]
metadata can't be a global var initializer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92330 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agosimplify mdnode printing logic. Now N->dump() only
Chris Lattner [Thu, 31 Dec 2009 02:13:35 +0000 (02:13 +0000)]
simplify mdnode printing logic.  Now N->dump() only
dumps one node instead of all of them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92329 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agodon't unittest mdnode printing, we have disassembler tests for this.
Chris Lattner [Thu, 31 Dec 2009 02:12:13 +0000 (02:12 +0000)]
don't unittest mdnode printing, we have disassembler tests for this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92328 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agounify two copies of the NamedMDNode printing code.
Chris Lattner [Thu, 31 Dec 2009 01:54:05 +0000 (01:54 +0000)]
unify two copies of the NamedMDNode printing code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92327 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agofix printing of function-local metadata to print all the operands of the
Chris Lattner [Thu, 31 Dec 2009 01:44:44 +0000 (01:44 +0000)]
fix printing of function-local metadata to print all the operands of the
mdnode, not just operand 0 over and over.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92326 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agosimplify printing of mdstring and Argument.
Chris Lattner [Thu, 31 Dec 2009 01:41:14 +0000 (01:41 +0000)]
simplify printing of mdstring and Argument.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92325 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agosimplify asmprinting of NamedMDNode
Chris Lattner [Thu, 31 Dec 2009 01:36:50 +0000 (01:36 +0000)]
simplify asmprinting of NamedMDNode

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92324 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoRemove #include of metadata.h from intrinsicinst.h. The only
Chris Lattner [Thu, 31 Dec 2009 01:32:41 +0000 (01:32 +0000)]
Remove #include of metadata.h from intrinsicinst.h.  The only
method that needs it (DbgValueInst::getValue) has been moved out
of line.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92323 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agorename "elements" of metadata to "operands". "Elements" are
Chris Lattner [Thu, 31 Dec 2009 01:22:29 +0000 (01:22 +0000)]
rename "elements" of metadata to "operands".  "Elements" are
things that occur in types.  "operands" are things that occur
in values.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92322 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoOptimize MDNode to coallocate the operand list immediately
Chris Lattner [Thu, 31 Dec 2009 01:05:46 +0000 (01:05 +0000)]
Optimize MDNode to coallocate the operand list immediately
after the MDNode in memory.  This eliminates the operands
pointer and saves a new[] per node.

Note that the code in DIDerivedType::replaceAllUsesWith is wrong
and quite scary.  A MDNode should not be RAUW'd with something
else: this changes all uses of the mdnode, which may not be debug
info related!  Debug info should use something non-mdnode for
declarations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92321 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agotidy
Chris Lattner [Thu, 31 Dec 2009 00:51:46 +0000 (00:51 +0000)]
tidy

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92320 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agodo not bother reuniquing mdnodes whose operands drop to null. Doing
Chris Lattner [Wed, 30 Dec 2009 21:42:11 +0000 (21:42 +0000)]
do not bother reuniquing mdnodes whose operands drop to null.  Doing
so can be a huge performance issue when tearing down modules and mdnodes
are not guaranteed to be unique anyway.  This speeds up:
$ time ~/llvm/Release/bin/clang gcc.c -w -S -g

from 72 to 35s, where gcc.c is from:
http://people.csail.mit.edu/smcc/projects/single-file-programs/

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92315 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoremove some misleading comments.
Chris Lattner [Wed, 30 Dec 2009 20:25:09 +0000 (20:25 +0000)]
remove some misleading comments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92311 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoImplement edit distance for StringRef
Douglas Gregor [Wed, 30 Dec 2009 17:23:44 +0000 (17:23 +0000)]
Implement edit distance for StringRef

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92309 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoremove some fixme's
Chris Lattner [Wed, 30 Dec 2009 06:00:36 +0000 (06:00 +0000)]
remove some fixme's

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92304 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agofix two bogus tests that the asmparser now rejects.
Chris Lattner [Wed, 30 Dec 2009 05:54:51 +0000 (05:54 +0000)]
fix two bogus tests that the asmparser now rejects.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92303 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agonow that instruction metadata is only parsed in one place, eliminate the
Chris Lattner [Wed, 30 Dec 2009 05:48:36 +0000 (05:48 +0000)]
now that instruction metadata is only parsed in one place, eliminate the
parser-global MDsOnInst vector and make ParseInstructionMetadata return
its result by-ref through an argument like the entire rest of the parser.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92302 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoreimplement ParseOptionalInfo as ParseOptionalCommaAlign, correctly
Chris Lattner [Wed, 30 Dec 2009 05:44:30 +0000 (05:44 +0000)]
reimplement ParseOptionalInfo as ParseOptionalCommaAlign, correctly
handle the comma case for metadata.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92301 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agorename ParseOptionalCustomMetadata -> ParseInstructionMetadata,
Chris Lattner [Wed, 30 Dec 2009 05:31:19 +0000 (05:31 +0000)]
rename ParseOptionalCustomMetadata -> ParseInstructionMetadata,
and make it non-optional.  This fixes the bug where we'd accept
and ignore a spurious comma after some instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92300 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoconvert 4 more instructions over.
Chris Lattner [Wed, 30 Dec 2009 05:27:33 +0000 (05:27 +0000)]
convert 4 more instructions over.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92299 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoadd facilities to start factoring instruction metadata parsing
Chris Lattner [Wed, 30 Dec 2009 05:23:43 +0000 (05:23 +0000)]
add facilities to start factoring instruction metadata parsing
out of each opcode's handler.  Change ret over so far.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92298 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoreimplement insertvalue/extractvalue metadata handling to not blindly
Chris Lattner [Wed, 30 Dec 2009 05:14:00 +0000 (05:14 +0000)]
reimplement insertvalue/extractvalue metadata handling to not blindly
accept invalid input.  Actually add a testcase.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92297 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoremove two bogus calls that accepted metadata in the middle of insert/extract value
Chris Lattner [Wed, 30 Dec 2009 05:04:46 +0000 (05:04 +0000)]
remove two bogus calls that accepted metadata in the middle of insert/extract value
*constant exprs*.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92296 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agorename NamedOrCustomMD -> MetadataVar to follow conventions of all the rest of the...
Chris Lattner [Wed, 30 Dec 2009 05:02:06 +0000 (05:02 +0000)]
rename NamedOrCustomMD -> MetadataVar to follow conventions of all the rest of the code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92295 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agorename lltok::Metadata -> lltok::exclaim. We name tokens
Chris Lattner [Wed, 30 Dec 2009 04:56:59 +0000 (04:56 +0000)]
rename lltok::Metadata -> lltok::exclaim.  We name tokens
after their syntactic form, not their semantic form.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92294 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agorename MetadataCache -> NumberedMetadata to follow the convention
Chris Lattner [Wed, 30 Dec 2009 04:51:58 +0000 (04:51 +0000)]
rename MetadataCache -> NumberedMetadata to follow the convention
used by other things.  Convert it to a vector since it is a dense
numbering.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92293 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agorewrite ParseMDNodeVector to follow the normal patter used in the .ll parser.
Chris Lattner [Wed, 30 Dec 2009 04:42:57 +0000 (04:42 +0000)]
rewrite ParseMDNodeVector to follow the normal patter used in the .ll parser.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92292 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agorename ParseMDNode -> ParseMDNodeID, since it parses !42, not !{... } as you'd expect.
Chris Lattner [Wed, 30 Dec 2009 04:15:23 +0000 (04:15 +0000)]
rename ParseMDNode -> ParseMDNodeID, since it parses !42, not !{... } as you'd expect.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92291 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agofix parsing of mdstring values.
Chris Lattner [Wed, 30 Dec 2009 04:13:37 +0000 (04:13 +0000)]
fix parsing of mdstring values.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92290 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoremove the code added in r90497. It has several major issues and no tests.
Chris Lattner [Wed, 30 Dec 2009 02:20:07 +0000 (02:20 +0000)]
remove the code added in r90497.  It has several major issues and no tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92288 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agosplit t_Metadata into t_MDNode and t_MDString, eliminating some unsafe casting.
Chris Lattner [Wed, 30 Dec 2009 02:11:14 +0000 (02:11 +0000)]
split t_Metadata into t_MDNode and t_MDString, eliminating some unsafe casting.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92287 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agofactor code even more.
Chris Lattner [Tue, 29 Dec 2009 22:40:21 +0000 (22:40 +0000)]
factor code even more.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92280 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agosimplify some code and unbreak the build by not consuming an
Chris Lattner [Tue, 29 Dec 2009 22:35:39 +0000 (22:35 +0000)]
simplify some code and unbreak the build by not consuming an
extra token.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92279 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoremove a really wrong parenthesis.
Benjamin Kramer [Tue, 29 Dec 2009 22:17:06 +0000 (22:17 +0000)]
remove a really wrong parenthesis.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92277 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoclean up some really strange code.
Chris Lattner [Tue, 29 Dec 2009 22:01:50 +0000 (22:01 +0000)]
clean up some really strange code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92275 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agochange ParseMDString and ParseMDNode to take arguments of the right type.
Chris Lattner [Tue, 29 Dec 2009 21:53:55 +0000 (21:53 +0000)]
change ParseMDString and ParseMDNode to take arguments of the right type.
This exposed a raft of other problems, which I'll deal with in subsequent
patches.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92273 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoswitch to TrackingVH instead of WeakVH, since these can never
Chris Lattner [Tue, 29 Dec 2009 21:43:58 +0000 (21:43 +0000)]
switch to TrackingVH instead of WeakVH, since these can never
be RAUW'd and go to null.  This also gets us some sorely lacking
type safety.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92272 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoEach instruction is allowed to have *multiple* different
Chris Lattner [Tue, 29 Dec 2009 21:25:40 +0000 (21:25 +0000)]
Each instruction is allowed to have *multiple* different
metadata objects on them.  Though the entire compiler supports this,
the asmparser didn't.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92270 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoDo not crash when .ll printing metadata that smells like debug info, but isn't.
Chris Lattner [Tue, 29 Dec 2009 21:17:33 +0000 (21:17 +0000)]
Do not crash when .ll printing metadata that smells like debug info, but isn't.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92268 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agofix indentation, fit in 80 cols.
Chris Lattner [Tue, 29 Dec 2009 21:09:57 +0000 (21:09 +0000)]
fix indentation, fit in 80 cols.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92267 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoReplace a few more SmallVectors with arrays.
Benjamin Kramer [Tue, 29 Dec 2009 16:57:26 +0000 (16:57 +0000)]
Replace a few more SmallVectors with arrays.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92265 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoUse an array instead of a SmallVector.
Benjamin Kramer [Tue, 29 Dec 2009 11:04:52 +0000 (11:04 +0000)]
Use an array instead of a SmallVector.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92264 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoremove a bunch of unneeded functions.
Chris Lattner [Tue, 29 Dec 2009 09:32:19 +0000 (09:32 +0000)]
remove a bunch of unneeded functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92263 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agomajor cleanups, much of this file was incorrectly indented.
Chris Lattner [Tue, 29 Dec 2009 09:22:47 +0000 (09:22 +0000)]
major cleanups, much of this file was incorrectly indented.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92262 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoone pass of cleanup over DebugInfo.h. Much more is still needed.
Chris Lattner [Tue, 29 Dec 2009 09:15:46 +0000 (09:15 +0000)]
one pass of cleanup over DebugInfo.h.  Much more is still needed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92261 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoprune #includes.
Chris Lattner [Tue, 29 Dec 2009 09:12:29 +0000 (09:12 +0000)]
prune #includes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92260 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoFinal step in the metadata API restructuring: move the
Chris Lattner [Tue, 29 Dec 2009 09:01:33 +0000 (09:01 +0000)]
Final step in the metadata API restructuring: move the
getMDKindID/getMDKindNames methods to LLVMContext (and add
convenience methods to Module), eliminating MetadataContext.
Move the state that it maintains out to LLVMContext.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92259 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agojust cleanup.
Chris Lattner [Tue, 29 Dec 2009 08:06:56 +0000 (08:06 +0000)]
just cleanup.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92258 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoremove useless argument.
Chris Lattner [Tue, 29 Dec 2009 08:03:58 +0000 (08:03 +0000)]
remove useless argument.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92256 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoprivatize another interface.
Chris Lattner [Tue, 29 Dec 2009 07:56:15 +0000 (07:56 +0000)]
privatize another interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92255 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agothe only call to this function (from clang) has been removed, zap it.
Chris Lattner [Tue, 29 Dec 2009 07:50:09 +0000 (07:50 +0000)]
the only call to this function (from clang) has been removed, zap it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92254 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoremove some unneeded Metadata interfaces.
Chris Lattner [Tue, 29 Dec 2009 07:44:16 +0000 (07:44 +0000)]
remove some unneeded Metadata interfaces.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92252 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agofix .cpp file to not wrap the entire file in namespace blocks.
Chris Lattner [Tue, 29 Dec 2009 07:28:33 +0000 (07:28 +0000)]
fix .cpp file to not wrap the entire file in namespace blocks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92250 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agotidy up debug info comments, use ->isVoidTy() where reasonable.
Chris Lattner [Tue, 29 Dec 2009 07:25:48 +0000 (07:25 +0000)]
tidy up debug info comments, use ->isVoidTy() where reasonable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92249 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agosink twine.h down out of Value.h. It is annoying that you need
Chris Lattner [Tue, 29 Dec 2009 07:12:03 +0000 (07:12 +0000)]
sink twine.h down out of Value.h.  It is annoying that you need
to #include Twine.h just to give a twine a default value.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92247 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoExtern declaration for unordered.f32 libcall was not being emitted. Fixed that.
Sanjiv Gupta [Tue, 29 Dec 2009 03:24:34 +0000 (03:24 +0000)]
Extern declaration for unordered.f32 libcall was not being emitted. Fixed that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92242 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoWhen doing v1->RAUW(v2), don't do anything to metadata. We don't know
Chris Lattner [Tue, 29 Dec 2009 02:53:52 +0000 (02:53 +0000)]
When doing v1->RAUW(v2), don't do anything to metadata.  We don't know
why one was replaced with the other.  Even in the specific case of
debug information, it doesn't make sense to transfer the location over,
this will just result in jumbled loc info.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92241 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agosink the Instruction::HasMetadata bit into SubclassData.
Chris Lattner [Tue, 29 Dec 2009 02:46:09 +0000 (02:46 +0000)]
sink the Instruction::HasMetadata bit into SubclassData.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92240 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoadd a layer of accessors around the Value::SubClassData member, and use
Chris Lattner [Tue, 29 Dec 2009 02:14:09 +0000 (02:14 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92239 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoThis is a major cleanup of the instruction metadata interfaces that
Chris Lattner [Mon, 28 Dec 2009 23:41:32 +0000 (23:41 +0000)]
This is a major cleanup of the instruction metadata interfaces that
I asked Devang to do back on Sep 27.  Instead of going through the
MetadataContext class with methods like getMD() and getMDs(), just
ask the instruction directly for its metadata with getMetadata()
and getAllMetadata().

This includes a variety of other fixes and improvements: previously
all Value*'s were bloated because the HasMetadata bit was thrown into
value, adding a 9th bit to a byte.  Now this is properly sunk down to
the Instruction class (the only place where it makes sense) and it
will be folded away somewhere soon.

This also fixes some confusion in getMDs and its clients about
whether the returned list is indexed by the MDID or densely packed.
This is now returned sorted and densely packed and the comments make
this clear.

This introduces a number of fixme's which I'll follow up on.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92235 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agorearrange some code.
Chris Lattner [Mon, 28 Dec 2009 21:56:07 +0000 (21:56 +0000)]
rearrange some code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92234 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoadd IRBuilder.cpp to cmake
Chris Lattner [Mon, 28 Dec 2009 21:52:41 +0000 (21:52 +0000)]
add IRBuilder.cpp to cmake

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92233 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoremove #include that comes in from ConstantFolder.h
Chris Lattner [Mon, 28 Dec 2009 21:52:06 +0000 (21:52 +0000)]
remove #include that comes in from ConstantFolder.h

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92232 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agoremove #include of Function.h from IRBuilder
Chris Lattner [Mon, 28 Dec 2009 21:50:56 +0000 (21:50 +0000)]
remove #include of Function.h from IRBuilder

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92231 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agomove debug info stuff out of line, allowing two #includes
Chris Lattner [Mon, 28 Dec 2009 21:45:40 +0000 (21:45 +0000)]
move debug info stuff out of line, allowing two #includes
to go away from IRBuilder.h

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92230 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agosplit code that doesn't need to be templated out of IRBuilder into a new
Chris Lattner [Mon, 28 Dec 2009 21:28:46 +0000 (21:28 +0000)]
split code that doesn't need to be templated out of IRBuilder into a new
non-templated IRBuilderBase class.  Move that large CreateGlobalString
out of line, eliminating the need to #include GlobalVariable.h in IRBuilder.h

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92227 91177308-0d34-0410-b5e6-96231b3b80d8

14 years agorename ivar to be more descriptive.
Chris Lattner [Mon, 28 Dec 2009 21:12:29 +0000 (21:12 +0000)]
rename ivar to be more descriptive.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92226 91177308-0d34-0410-b5e6-96231b3b80d8