1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00
Commit Graph

2235 Commits

Author SHA1 Message Date
Devang Patel
e60ebc7744 Let invoke return aggregate value.
llvm-svn: 47425
2008-02-21 02:14:01 +00:00
Devang Patel
702c4a60a6 Let function call return aggregate.
Now, we have very first multiple return value testcase!

llvm-svn: 47424
2008-02-21 01:54:02 +00:00
Devang Patel
d2142aeb44 What if functions can return aggregate values ?
One small step towards multiple return value support.

llvm-svn: 47406
2008-02-20 22:36:03 +00:00
Devang Patel
4034343b67 getresult does not support nested aggregates.
llvm-svn: 47396
2008-02-20 19:39:41 +00:00
Devang Patel
f114189912 Verifier should use Assert1 instead of assert.
llvm-svn: 47394
2008-02-20 19:32:20 +00:00
Devang Patel
de35f122f2 getresult type is the type of indexed aggregate element
llvm-svn: 47392
2008-02-20 19:26:55 +00:00
Devang Patel
6266d7147e Specify GetResultInst index as an unsigned.
llvm-svn: 47390
2008-02-20 19:10:47 +00:00
Devang Patel
019b5585e8 Use isValidOperands() to verify GetResultInst.
llvm-svn: 47387
2008-02-20 18:36:46 +00:00
Anton Korobeynikov
c41f5b6af4 Fix newly-introduced 4.3 warnings
llvm-svn: 47375
2008-02-20 12:07:57 +00:00
Anton Korobeynikov
0c5e186924 Unbreak build with gcc 4.3: provide missed includes and silence most annoying warnings.
llvm-svn: 47367
2008-02-20 11:08:44 +00:00
Dale Johannesen
7eccf11cfb Add Alignment field to ParameterAttributes and
treat more or less rationally in interface
functions, subject to change.  No functional change.

llvm-svn: 47352
2008-02-19 23:51:49 +00:00
Devang Patel
a74d2cbb6f Add GetResultInst. First step for multiple return value support.
llvm-svn: 47348
2008-02-19 22:15:16 +00:00
Dale Johannesen
ecb2b233b1 Expand ParameterAttributes to 32 bits (in preparation
for adding alignment info, not there yet).  Clean up
interfaces to reference ParameterAttributes consistently.

llvm-svn: 47342
2008-02-19 21:38:47 +00:00
Chris Lattner
85482657eb Fix some minor issues folding undef, PR2052
llvm-svn: 47314
2008-02-19 06:22:12 +00:00
Duncan Sands
a85448506d Simplify caller updating using a CallSite, as
requested by Chris.  While there, do the same
for an existing function committed by someone
called "lattner" :)

llvm-svn: 47273
2008-02-18 17:32:13 +00:00
Owen Anderson
e4e1706f95 I got the predicate backwards in my last patch. The comment is correct, the code was not.
llvm-svn: 47264
2008-02-18 09:22:21 +00:00
Owen Anderson
18a7d290cb Duncan pointed out that we can fast fail here, because the sret parameter of
a function must be the first parameter.

llvm-svn: 47254
2008-02-18 04:06:26 +00:00
Owen Anderson
48dd6a0f96 Add a predicate to Argument to check for the StructRet attribute.
llvm-svn: 47248
2008-02-17 23:22:28 +00:00
Duncan Sands
753597d1cf Some micro-optimizations.
llvm-svn: 47219
2008-02-16 20:53:06 +00:00
Chris Lattner
bab03a1b50 targets that support quotes for mangled names still need to escape newlines
when they occur in the name, just like " is escaped.

llvm-svn: 47169
2008-02-15 18:54:56 +00:00
Chris Lattner
22696c10f0 check that terminators only occur at the end of a block. This catches the
common problem of putting two terminators in the same block.  I can't write
a testcase for this because the .ll parser rejects this before the verifier
can, but this can occur when generating IR.

llvm-svn: 46900
2008-02-09 01:06:01 +00:00
Dan Gohman
b4aa0b2a15 Fix a typo in a comment.
llvm-svn: 46836
2008-02-07 02:30:40 +00:00
Devang Patel
cad20dbdb0 Add comment explaining what is lower level analysis pass.
llvm-svn: 46658
2008-02-02 01:43:30 +00:00
Gordon Henriksen
b75d9e974d Fixing a bug creating floating point constants of type other
than double through the C bindings. Thanks to Tomas Lindquist
Olsen for reporting it.

llvm-svn: 46656
2008-02-02 01:07:50 +00:00
Dan Gohman
241714222a Fix 80-col violations.
llvm-svn: 46510
2008-01-29 12:09:55 +00:00
Dan Gohman
522401f26e Add explicit keywords.
llvm-svn: 46506
2008-01-29 11:36:12 +00:00
Nick Lewycky
6b070b1b93 Handle some more combinations of extend and icmp. Fixes PR1940.
llvm-svn: 46431
2008-01-28 03:48:02 +00:00
Chris Lattner
5740a10d2c Add hasByValAttr() and hasNoAliasAttr() methods to the Argument class.
llvm-svn: 46314
2008-01-24 17:47:11 +00:00
Duncan Sands
fe83650649 It turns out that in C++ it is legal to declare functions
that return an opaque type by value, as long as you don't
call it or provide a body (you can take the address of it).
So it is wrong to insist that sret parameters not be an
opaque*.  And I guess it is really up to codegen to complain
if someone tries to call such a function.  I'm also removing
the analogous check from byval parameters, since I don't
see why we shouldn't allow them as long as no-one tries to
call the function or give it a body.

llvm-svn: 46216
2008-01-21 21:37:41 +00:00
Duncan Sands
50df31d59a Check that sret is only used on pointers to types
with a size, like byval.

llvm-svn: 46207
2008-01-21 11:28:49 +00:00
Duncan Sands
26de25066c Be consistent with other attribute methods, and
check the callee also if it is known.

llvm-svn: 46206
2008-01-21 11:27:55 +00:00
Chris Lattner
2595fd0ca7 improve compatibility with mingw, patch by Alain Frisch
llvm-svn: 46026
2008-01-15 22:50:50 +00:00
Bill Wendling
0ad07f292c Reformatted. It was confusing the other way. No functionality change.
llvm-svn: 46009
2008-01-15 21:16:32 +00:00
Duncan Sands
087d6020ee Simplify CallInst::hasByValArgument using a new method.
llvm-svn: 45974
2008-01-14 19:57:00 +00:00
Duncan Sands
81e35b4d47 I noticed that the trampoline straightening transformation could
drop attributes on varargs call arguments.  Also, it could generate
invalid IR if the transformed call already had the 'nest' attribute
somewhere (this can never happen for code coming from llvm-gcc,
but it's a theoretical possibility).  Fix both problems.

llvm-svn: 45973
2008-01-14 19:52:09 +00:00
Evan Cheng
12fb1dc67e Simplify code.
llvm-svn: 45950
2008-01-14 02:38:45 +00:00
Duncan Sands
86c17f2ebf Allow the byval attribute for pointers to any type with
a size, not just structs.

llvm-svn: 45938
2008-01-13 21:19:12 +00:00
Evan Cheng
a5183224b0 Add hasByValArgument() to test if a call instruction has byval argument(s).
llvm-svn: 45913
2008-01-12 18:57:32 +00:00
Duncan Sands
3b617cbe30 Be more liberal in what parameter attributes are
allowed on the vararg arguments of a call.

llvm-svn: 45909
2008-01-12 16:42:01 +00:00
Duncan Sands
e55a5806ac Do not allow attributes beyond a function's last
parameter, even if it is a varargs function.  Do
allow attributes on the varargs part of a call,
but not beyond the last argument.  Only allow
selected attributes to be on the varargs part of
a call (currently only 'byval' is allowed).  The
reasoning here is that most attributes, eg inreg,
simply make no sense here.

llvm-svn: 45887
2008-01-11 22:36:48 +00:00
Evan Cheng
63753b7be7 Allow parameter attributes on varargs function parameters.
llvm-svn: 45850
2008-01-11 02:13:09 +00:00
Duncan Sands
7955cf0cd7 Small cleanup for handling of type/parameter attribute
incompatibility.

llvm-svn: 45704
2008-01-07 17:16:06 +00:00
Duncan Sands
fd975e4b3d The transform that tries to turn calls to bitcast functions into
direct calls bails out unless caller and callee have essentially
equivalent parameter attributes.  This is illogical - the callee's
attributes should be of no relevance here.  Rework the logic, which
incidentally fixes a crash when removed arguments have attributes.

llvm-svn: 45658
2008-01-06 18:27:01 +00:00
Duncan Sands
b8489f09a2 When transforming a call to a bitcast function into
a direct call with cast parameters and cast return
value (if any), instcombine was prepared to cast any
non-void return value into any other, whether castable
or not.  Add a new predicate for testing whether casting
is valid, and check it both for the return value and
(as a cleanup) for the parameters.

llvm-svn: 45657
2008-01-06 10:12:28 +00:00
Gordon Henriksen
8e4ae9a345 Trying that again.
llvm-svn: 45529
2008-01-03 03:32:33 +00:00
Gordon Henriksen
b28803a63f Fix a compile error on Windows.
llvm-svn: 45528
2008-01-03 03:21:18 +00:00
Chris Lattner
c613164542 Remove the function attr cache for intrinsics. This does not maintain the
refcount on these correctly, and can end up referring to deleted 
attributes.  This fixes PR1881.

llvm-svn: 45525
2008-01-03 01:20:12 +00:00
Chris Lattner
e54252e6e1 Don't create a new ParamAttrsList (which copies the vector) just to
get a profile.

llvm-svn: 45524
2008-01-03 00:29:27 +00:00
Chris Lattner
e14d4d026e move some code out of line, rearrange a bit.
llvm-svn: 45519
2008-01-03 00:10:22 +00:00
Chris Lattner
9ec341b120 Split param attr implementation out from Function.cpp into its
own file.  Don't #include ParameterAttributes.h into any major
public header files: just move methods out of line as appropriate.

llvm-svn: 45517
2008-01-02 23:42:30 +00:00
Chris Lattner
25b9530d7b remove blob of #if'd out code.
llvm-svn: 45512
2008-01-02 23:10:45 +00:00
Chris Lattner
93a70c4a0e Fix a build issue on cygwin
llvm-svn: 45506
2008-01-02 22:03:27 +00:00
Gordon Henriksen
d2485b2cec Adding C bindings for SwitchInst::addCase.
Patch by Bryan O'Sullivan!

llvm-svn: 45481
2008-01-01 05:50:53 +00:00
Gordon Henriksen
8082358f86 Add some doxygen comments to llvm-c/Core.h.
llvm-svn: 45450
2007-12-30 17:46:33 +00:00
Chris Lattner
ad9a6ccb83 Remove attribution from file headers, per discussion on llvmdev.
llvm-svn: 45418
2007-12-29 20:36:04 +00:00
Chris Lattner
8193d4af33 remove attribution from lib Makefiles.
llvm-svn: 45415
2007-12-29 20:09:26 +00:00
Gordon Henriksen
86e98275ff Adding bindings for target triple and data layout.
llvm-svn: 45369
2007-12-27 20:13:47 +00:00
Gordon Henriksen
d96b3222e5 Switch the bindings to use LLVMFoldingBuilder.
llvm-svn: 45367
2007-12-27 18:25:59 +00:00
Gordon Henriksen
a9f4ed4070 Noting and enforcing that GC intrinsics are valid only within a
function with GC.

This will catch the error when the inliner inlines a function with
GC into a caller with no GC.

llvm-svn: 45350
2007-12-25 02:31:26 +00:00
Gordon Henriksen
44841db057 Adjusting verification of "llvm.gc*" intrinsic prototypes to match
LangRef.

llvm-svn: 45349
2007-12-25 02:02:10 +00:00
Duncan Sands
bc10247769 Get the verifier to check attributes on calls as well
as on functions.  Make it verify invokes and not just
ordinary calls.  As a (desired) side-effect, it is no
longer legal to have call attributes on arguments that
are being passed to the varargs part of a varargs
function (llvm-as drops them on the floor anyway).

llvm-svn: 45286
2007-12-21 19:19:01 +00:00
Gordon Henriksen
46137f1e2e Adding bindings for memory buffers and module providers. Switching
to exceptions rather than variants for error handling in Ocaml.

llvm-svn: 45226
2007-12-19 22:30:40 +00:00
Duncan Sands
56f3add5b7 When inlining through an 'nounwind' call, mark inlined
calls 'nounwind'.  It is important for correct C++
exception handling that nounwind markings do not get
lost, so this transformation is actually needed for
correctness.

llvm-svn: 45218
2007-12-19 21:13:37 +00:00
Chris Lattner
fabeb5e6c1 remove a dead annotation
llvm-svn: 45163
2007-12-18 19:04:24 +00:00
Duncan Sands
242f80be86 Rename isNoReturn to doesNotReturn, and isNoUnwind to
doesNotThrow.

llvm-svn: 45160
2007-12-18 09:59:50 +00:00
Christopher Lamb
efdf2791b2 Don't forget to print address space qualifiers when printing out the type table! Thanks to Gordon Henriksen for pointing this out.
llvm-svn: 45147
2007-12-18 03:49:35 +00:00
Evan Cheng
8b4947fe98 Remove int_x86_sse2_movl_dq. It's replaced with a string compare.
llvm-svn: 45140
2007-12-18 01:04:25 +00:00
Evan Cheng
d9df071ead Bring back int_x86_sse2_movl_dq intrinsic for backward compatibility. Make sure
it's auto-upgraded to a shufflevector instruction.

llvm-svn: 45131
2007-12-17 22:33:23 +00:00
Duncan Sands
3a0d757bd5 Make invokes of inline asm legal. Teach codegen
how to lower them (with no attempt made to be
efficient, since they should only occur for
unoptimized code).

llvm-svn: 45108
2007-12-17 18:08:19 +00:00
Gordon Henriksen
ef2c27d164 C and Ocaml bindings for address spaces, for that burgeoning market
for Ocaml-based compilers targeting embedded devices. :)

llvm-svn: 45096
2007-12-17 16:08:32 +00:00
Christopher Lamb
a608afb52e Change the PointerType api for creating pointer types. The old functionality of PointerType::get() has become PointerType::getUnqual(), which returns a pointer in the generic address space. The new prototype of PointerType::get() requires both a type and an address space.
llvm-svn: 45082
2007-12-17 01:12:55 +00:00
Christopher Lamb
d3bac47ce6 Make it clear in the LangRef that allocation instructions only operated on the generic address space. Implement support in the verifier for ensuring this is true.
llvm-svn: 45080
2007-12-17 01:00:21 +00:00
Duncan Sands
bf62f62058 Make instcombine promote inline asm calls to 'nounwind'
calls.  Remove special casing of inline asm from the
inliner.  There is a potential problem: the verifier
rejects invokes of inline asm (not sure why).  If an
asm call is not marked "nounwind" in some .ll, and
instcombine is not run, but the inliner is run, then
an illegal module will be created.  This is bad but
I'm not sure what the best approach is.  I'm tempted
to remove the check in the verifier...

llvm-svn: 45073
2007-12-16 15:51:49 +00:00
Anders Carlsson
900a684ae7 All MMX shift instructions took a <2 x i32> vector as the shift amount parameter. Change this to be <1 x i64> instead, which matches the assembler instruction.
llvm-svn: 45027
2007-12-14 06:38:54 +00:00
Duncan Sands
998cd21867 Revert r44626, which turned off the use of readonly
and readnone for functions with bodies because it
broke llvm-gcc-4.2 bootstrap.  It turns out that,
because of LLVM's array_ref hack, gcc was computing
pure/const attributes wrong (now fixed by turning
off the gcc ipa-pure-const pass).

llvm-svn: 44937
2007-12-12 16:01:40 +00:00
Gordon Henriksen
3f070cf3b9 Add (very basic) bindings for ModuleProvider.
llvm-svn: 44899
2007-12-12 01:04:30 +00:00
Christopher Lamb
7368604860 Implement address space attribute for LLVM pointer types. Address spaces are
regions of memory that have a target specific relationship, as described in the 
Embedded C Technical Report. 

This also implements the 2007-12-11-AddressSpaces test, 
which demonstrates how address space attributes can be used in LLVM IR.

In addition, this patch changes the bitcode signature for stores (in a backwards 
compatible manner), such that the pointer type, rather than the pointee type, is 
encoded. This permits type information in the pointer (e.g. address space) to be 
preserved for stores.

LangRef updates are forthcoming.

llvm-svn: 44858
2007-12-11 08:59:05 +00:00
Chris Lattner
a8b1b4b5d2 Teach VMCore to constant fold shufflevectors with constant operands.
This allows us to compile:

#include <emmintrin.h>
typedef __m128i VSInt16;
typedef short vSInt16 __attribute__ ((__vector_size__ (16)));
VSInt16 t3() {
  return (VSInt16)((vSInt16)_mm_set1_epi16(6518));
}

into:

_t3:
	movaps	LCPI1_0, %xmm0
	ret

instead of:
_t3:
	movl	$6518, %eax
	movd	%eax, %xmm0
	pextrw	$0, %xmm0, %eax
	xorps	%xmm0, %xmm0
	pinsrw	$0, %eax, %xmm0
	punpcklwd	%xmm0, %xmm0
	pshufd	$0, %xmm0, %xmm0
	ret

llvm-svn: 44856
2007-12-11 07:49:37 +00:00
Chris Lattner
b265924121 significantly simplify some code, no functionality change.
llvm-svn: 44850
2007-12-11 06:07:39 +00:00
Chris Lattner
3822e8ee5a refactor some code, no functionality change.
llvm-svn: 44849
2007-12-11 05:55:02 +00:00
Chris Lattner
5ca42cd342 Fix PR1850 by removing an unsafe transformation from VMCore/ConstantFold.cpp.
Reimplement the xform in Analysis/ConstantFolding.cpp where we can use
targetdata to validate that it is safe.  While I'm in there, fix some const
correctness issues and generalize the interface to the "operand folder".

llvm-svn: 44817
2007-12-10 22:53:04 +00:00
Gordon Henriksen
aadbdd1a62 Delete the CollectorNamePool if it should become empty.
llvm-svn: 44775
2007-12-10 03:35:18 +00:00
Gordon Henriksen
5d201e0bcc Adding a collector name attribute to Function in the IR. These
methods are new to Function:

  bool hasCollector() const;
  const std::string &getCollector() const;
  void setCollector(const std::string &);
  void clearCollector();

The assembly representation is as such:

  define void @f() gc "shadow-stack" { ...

The implementation uses an on-the-side table to map Functions to 
collector names, such that there is no overhead. A StringPool is 
further used to unique collector names, which are extremely
likely to be unique per process.

llvm-svn: 44769
2007-12-10 03:18:06 +00:00
Gordon Henriksen
8430f1ff9a Reverting dtor devirtualization patch.
_sabre_: it has a major problem: by the time ~Value is run, all of the "parts" of the derived classes have been destroyed
_sabre_: the vtable lives to fight another day

llvm-svn: 44760
2007-12-10 02:14:30 +00:00
Chris Lattner
11bc69b3c8 fix some warnings.
llvm-svn: 44756
2007-12-10 01:51:22 +00:00
Chris Lattner
3d939a50a5 Fix a big problem in the recent dtor refactoring work, now it passes 2007-11-19-InlineAsm.ll
llvm-svn: 44755
2007-12-10 01:48:29 +00:00
Gordon Henriksen
a18a78e6e5 Devirtualizing Value destructor (PR889). Patch by Pawel Kunio!
llvm-svn: 44747
2007-12-09 22:46:10 +00:00
Duncan Sands
928143423b Commit 44487 broke bootstrap of llvm-gcc-4.2. It is
not yet clear why, but in the meantime work around the
problem by making less use of readnone/readonly info.

llvm-svn: 44626
2007-12-05 21:03:28 +00:00
Duncan Sands
1e2e4972ff Rather than having special rules like "intrinsics cannot
throw exceptions", just mark intrinsics with the nounwind
attribute.  Likewise, mark intrinsics as readnone/readonly
and get rid of special aliasing logic (which didn't use
anything more than this anyway).

llvm-svn: 44544
2007-12-03 20:06:50 +00:00
Duncan Sands
97ddf89236 Small optimization of parameter attribute lookup.
llvm-svn: 44458
2007-11-30 18:20:58 +00:00
Duncan Sands
94d751995e Add a convenience method for modifying parameter
attributes.  While there, I noticed that not all
attribute methods returned a pointer-to-constant,
so I fixed that.

llvm-svn: 44457
2007-11-30 18:19:18 +00:00
Duncan Sands
8d9be63cd3 Check that there are not more attributes than
function parameters.

llvm-svn: 44452
2007-11-30 15:52:20 +00:00
Duncan Sands
19a1638e99 Small parameter attributes cleanup.
llvm-svn: 44433
2007-11-29 08:30:15 +00:00
Duncan Sands
1b0feb42e2 Add some convenience methods for querying attributes, and
use them.

llvm-svn: 44403
2007-11-28 17:07:01 +00:00
Duncan Sands
3602011bec Fix PR1146: parameter attributes are longer part of
the function type, instead they belong to functions
and function calls.  This is an updated and slightly
corrected version of Reid Spencer's original patch.
The only known problem is that auto-upgrading of
bitcode files doesn't seem to work properly (see
test/Bitcode/AutoUpgradeIntrinsics.ll).  Hopefully
a bitcode guru (who might that be? :) ) will fix it.

llvm-svn: 44359
2007-11-27 13:23:08 +00:00
Duncan Sands
114968a3e8 Fix PR1816. If a bitcast of a function only exists because of a
trivial difference in function attributes, allow calls to it to
be converted to direct calls.  Based on a patch by Török Edwin.
While there, move the various lists of mutually incompatible
parameters etc out of the verifier and into ParameterAttributes.h.

llvm-svn: 44315
2007-11-25 14:10:56 +00:00
Duncan Sands
d05a55f03f Rename the 'const' parameter attribute to 'readnone',
and the 'pure' parameter attribute to 'readonly'.
Names suggested by DannyB.

llvm-svn: 44273
2007-11-22 20:23:04 +00:00
Duncan Sands
f69444f091 In order for parameter attribute uniquing to make
any sense it is important that ParamAttr::None gets
treated the same as not supplying an attribute at
all.  Rather than stripping ParamAttr::None out of
the list of attributes, assert if ParamAttr::None
is seen.  Fix up the bitcode reader which liked to
insert ParamAttr::None all over the place.  Patch
based on one by Török Edwin.

llvm-svn: 44250
2007-11-20 14:09:29 +00:00
Dan Gohman
27ac53cc23 Remove meaningless qualifiers from return types, avoiding compiler warnings.
llvm-svn: 44240
2007-11-19 20:46:23 +00:00
Chris Lattner
cf741eccd6 print a call to a fastcc function as:
call x86_fastcallcc void @func( i32* %X, i64 0 )
not:
	callx86_fastcallcc  void @func( i32* %X, i64 0 )

This fixes Codegen/X86/fast-cc-merge-stack-adj.ll

llvm-svn: 44217
2007-11-18 18:32:16 +00:00
Nate Begeman
2a8ef3f29a Add support for vectors to int <-> float casts.
llvm-svn: 44204
2007-11-17 03:58:34 +00:00
Nate Begeman
a42e2c2272 Basic non-power-of-2 vector support
llvm-svn: 44181
2007-11-15 21:15:26 +00:00
Duncan Sands
5924300986 I discover array_lengthof, thanks to gabor on #llvm.
llvm-svn: 44139
2007-11-14 21:58:02 +00:00
Duncan Sands
805a8ba9cf Simplify the attribute verification code.
llvm-svn: 44116
2007-11-14 14:02:11 +00:00
Anton Korobeynikov
00f3ace7e9 Add pure/const attributes. Documentation will follow.
llvm-svn: 44109
2007-11-14 09:52:30 +00:00
Duncan Sands
fc061f4e20 Don't barf on empty basic blocks. Do not rely on assert
doing something - this needs to work for release builds
too.  I chose to just abort rather than following the
fancy logic of abortIfBroken, because (1) it is a pain
to do otherwise, and (2) nothing is going to work if the
module is this broken.

llvm-svn: 43611
2007-11-01 10:50:26 +00:00
Chris Lattner
4618bf2f11 remove verifier command line option: this should be part of the API, not
a command line optn.

llvm-svn: 43603
2007-11-01 04:43:13 +00:00
Owen Anderson
8eb7b6ed84 Now with less tabs!
llvm-svn: 43601
2007-11-01 03:54:23 +00:00
Chris Lattner
38a21a25f2 Fix InstCombine/2007-10-31-StringCrash.ll by removing an obvious
(in hindsight) infinite recursion.  Simplify the code.

llvm-svn: 43597
2007-11-01 02:30:35 +00:00
Dan Gohman
a9d080508e Fix a regression in test/CodeGen/X86/2007-04-24-VectorCrash.ll introduced
by r43510. Gracefully handle constants with vector type that aren't
ConstantVector or ConstantAggregateZero.

llvm-svn: 43579
2007-10-31 21:36:31 +00:00
Owen Anderson
89dee120a1 Add a preverifier pass to check that every basic block ends in a terminator, so that we don't segfault when verifying invalid code.
llvm-svn: 43578
2007-10-31 21:04:18 +00:00
Dan Gohman
9365affecc Add support for folding binary operators with vector zero operands.
llvm-svn: 43510
2007-10-30 19:00:49 +00:00
Chris Lattner
1659eb3c3f I am not sure this is a good idea to be an option, but rename the option for
now.  It conflicts with clang's -pedantic flag.

llvm-svn: 43431
2007-10-29 03:14:55 +00:00
Anton Korobeynikov
ab0c5f6d32 Add 'pedantic' mode to verifier rejecting syntactically valid, but 'bad' due to other reasons code
llvm-svn: 43424
2007-10-28 22:50:32 +00:00
Owen Anderson
33b9693ab8 Make DomTree and PostDomTree thin wrappers around DomTreeBase, rather than inheriting from it.
llvm-svn: 43259
2007-10-23 20:58:37 +00:00
Dan Gohman
e223bab494 The #include <iterator> isn't needed in this header.
llvm-svn: 43232
2007-10-22 20:44:10 +00:00
Chris Lattner
61de0c50b7 this doesn't need dynamic_cast.
llvm-svn: 43133
2007-10-18 16:26:24 +00:00
Chris Lattner
4656de62bf Reduce reliance on rtti info
llvm-svn: 43130
2007-10-18 16:11:18 +00:00
Chris Lattner
80a2b5e53b fix typo
llvm-svn: 43129
2007-10-18 16:10:48 +00:00
Dan Gohman
231159e8a3 Define a helper function ConstantVector::getSplatValue for testing for
and working with broadcasted constants.

llvm-svn: 43076
2007-10-17 17:51:30 +00:00
Owen Anderson
1235d1218b Move splitBlock into DomTreeBase from DomTree.
llvm-svn: 43059
2007-10-17 02:03:17 +00:00
Dale Johannesen
fdb488d4b5 Disable attempts to constant fold PPC f128.
Remove the assumption that this will happen from
various places.

llvm-svn: 43053
2007-10-16 23:38:29 +00:00
Owen Anderson
43fefb53a6 Template DominatorTreeBase by node type. This is the next major step towards
having dominator information on MBB's.

llvm-svn: 43036
2007-10-16 19:59:25 +00:00
Duncan Sands
9d622a6de1 Initial infrastructure for arbitrary precision integer
codegen support.  This should have no effect on codegen
for other types.  Debatable bits: (1) the use (abuse?)
of a set in SDNode::getValueTypeList; (2) the length of
getTypeToTransformTo, which maybe should be refactored
with a non-inline part for extended value types.

llvm-svn: 43030
2007-10-16 09:56:48 +00:00
Chris Lattner
bf2f5b472f avoid an APFloat copy.
llvm-svn: 42979
2007-10-15 05:34:10 +00:00
Dale Johannesen
4cbce377c6 Disable some compile-time optimizations on PPC
long double.

llvm-svn: 42958
2007-10-14 01:56:47 +00:00
Dale Johannesen
0ee2a2fb59 Next PPC long double bits. First cut at constants.
No compile-time support for constant operations yet,
just format transformations.  Make readers and
writers work.  Split constants into 2 doubles in
Legalize.

llvm-svn: 42865
2007-10-11 18:07:22 +00:00
Gordon Henriksen
84b068154b C and Objective Caml bindings for PHINode::addIncoming etc.
llvm-svn: 42760
2007-10-08 18:14:39 +00:00
Evan Cheng
1a6e294c27 Remove debugging printf to get build going on x86-64.
llvm-svn: 42757
2007-10-08 17:49:43 +00:00
Dan Gohman
7fa473514d Add explicit keywords.
llvm-svn: 42747
2007-10-08 15:08:41 +00:00
Owen Anderson
ffcd82d1ed Begin the process of allowing DomTree on MBB's. Step One: template DomTreeNode by making it a typedef of a templated DomTreeNodeBase.
llvm-svn: 42743
2007-10-08 07:44:39 +00:00
Gordon Henriksen
8d8fae73c5 C and Objective Caml bindings for getFunction and getNamedGlobal. Also enhanced
the Objective Caml 'declare_*' functions to behave more or less like
getOrInsertFunction.

llvm-svn: 42740
2007-10-08 03:45:09 +00:00
Gordon Henriksen
454d171c26 C and Objective Caml bindings for GlobalVariable::isConstant.
llvm-svn: 42736
2007-10-07 17:31:42 +00:00
Neil Booth
6e01c5df37 convertFromInteger, as originally written, expected sign-extended
input.  APInt unfortunately zero-extends signed integers, so Dale
modified the function to expect zero-extended input.  Make this
assumption explicit in the function name.

llvm-svn: 42732
2007-10-07 11:45:55 +00:00
Gordon Henriksen
99c0e2918b C and Objective Caml bindings for PATypeHolder.
llvm-svn: 42713
2007-10-07 00:13:35 +00:00
Gordon Henriksen
ee9c8932e4 Adopting a uniform naming convention for type constructors in bindings.
llvm-svn: 42698
2007-10-06 16:05:20 +00:00
Gordon Henriksen
574434313a Adopting a uniform naming convention for constant constructors in bindings.
llvm-svn: 42697
2007-10-06 15:11:06 +00:00
Gordon Henriksen
65ce7c3085 Adding C and Ocaml bindings for ConstantExpr.
llvm-svn: 42696
2007-10-06 14:29:36 +00:00
Gordon Henriksen
8d97ababb0 Wrapping Value::dump.
llvm-svn: 42668
2007-10-06 00:08:49 +00:00
Gordon Henriksen
543f859a00 Removing the silly CHelpers header by rolling wrap and unwrap into the C
bindings headers themselves, hidden behind #ifdef __cplusplus.

llvm-svn: 42666
2007-10-05 23:59:36 +00:00
Devang Patel
36b68478cb Fix bug in updating dominance frontier after loop
unswitch when frontier includes basic blocks that 
are not inside loop.

llvm-svn: 42654
2007-10-05 22:29:34 +00:00
Owen Anderson
cb51170957 Completely merge the implementation details of DomTree and PostDomTree.
Also, add a FIXME for a bug in PostDomTree calculation I noticed while writing this,

llvm-svn: 42593
2007-10-03 21:25:45 +00:00
Dan Gohman
30ba45b569 Use empty() member functions when that's what's being tested for instead
of comparing begin() and end().

llvm-svn: 42585
2007-10-03 19:26:29 +00:00
Dan Gohman
b278232a22 Fix a using namespace llvm; in a header file.
llvm-svn: 42584
2007-10-03 19:04:09 +00:00
Owen Anderson
91e23d710c Factor some code from the DomTree and PostDomTree calculate methods up into
each one's runOnFunction method.

llvm-svn: 42563
2007-10-03 03:20:17 +00:00
Dale Johannesen
2a0b2ab2fc Constant fold int-to-long-double conversions;
use APFloat for int-to-float/double; use
round-to-nearest for these (implementation-defined,
seems to match gcc).

llvm-svn: 42484
2007-09-30 18:19:03 +00:00
Owen Anderson
09ba812a80 Template-ize more of the DomTree internal implementation details. Only the calculate() methods for DomTree and PostDomTree remain to be merged/template-ized.
llvm-svn: 42476
2007-09-30 04:17:16 +00:00
Duncan Sands
5e73fe090a Check that the second parameter of init_trampoline
can be resolved to a function.  This is required
for codegen and used by instcombine.

llvm-svn: 42469
2007-09-29 16:25:54 +00:00
Gordon Henriksen
b3d98e2023 Demoting CHelpers.h to include/llvm/Support.
llvm-svn: 42465
2007-09-29 01:38:42 +00:00
Chris Lattner
14442c9a4d Make Value::getNameLen not crash on an empty name, fixing PR1712.
llvm-svn: 42444
2007-09-28 20:09:40 +00:00
Owen Anderson
a533c458f5 Have PostDomTree use the newly templated DFSPass.
llvm-svn: 42427
2007-09-28 01:23:47 +00:00
Owen Anderson
e529f66979 Convert DFSPass into a templated friend function, in preparation for making it common to DomTree and PostDomTree.
llvm-svn: 42420
2007-09-27 23:23:00 +00:00
Dale Johannesen
089d2e760f Make temporaries explicit to avoid premature
destruction of compiler-created ones.

llvm-svn: 42383
2007-09-26 23:20:33 +00:00
Gordon Henriksen
c73d5c73a6 Added C and Ocaml bindings for functions, basic blocks, and
instruction creation. No support yet for instruction introspection.

Also eliminated allocas from the Ocaml bindings for portability,
and avoided unnecessary casts.

llvm-svn: 42367
2007-09-26 20:56:12 +00:00
Dale Johannesen
53f2e47789 Remove no-longer-used variable.
llvm-svn: 42329
2007-09-25 23:32:20 +00:00
Dale Johannesen
bc41438bab Make APFloat->int conversions deterministic even in
cases with undefined behavior.

llvm-svn: 42328
2007-09-25 23:07:07 +00:00
Duncan Sands
130f4e01fa Add missing end-of-file newlines.
llvm-svn: 42294
2007-09-25 07:10:01 +00:00
Dale Johannesen
4208f4103d float->int conversion rounds toward 0. Duh.
Fixes PR1698.

llvm-svn: 42273
2007-09-24 21:06:09 +00:00
Owen Anderson
a0a11ee8b9 Merge significant portions of the DomTree and PostDomTree implementations.
The two remaining unmerged parts are DFSPass, and the Calculate().

llvm-svn: 42255
2007-09-24 02:29:29 +00:00
Dale Johannesen
f7e8b1262b Just use APFloat for const / const. Fixes
-1. / -0.

llvm-svn: 42254
2007-09-24 00:32:45 +00:00
Owen Anderson
677db80624 Move DFSPass back down into DominatorTree. I need to figure out what the difference is between it
and the PostDomTree version first.

llvm-svn: 42250
2007-09-23 22:16:38 +00:00
Owen Anderson
e04633f0ff Fix header.
llvm-svn: 42249
2007-09-23 21:32:55 +00:00
Owen Anderson
de1937fcee Factor the dominator tree calculation details out into DominatorCalculation.h. This
change is not useful in and of itself, but it lays the groundwork for combining
the dominator and postdominator implementations.

Also, factor a few methods that are common to DominatorTree and PostDominatorTree
into DominatorTreeBase.  Again, this will make merging the two calculation methods
simpler in the future.

llvm-svn: 42248
2007-09-23 21:31:44 +00:00
Dale Johannesen
dd802b7960 Fix dumb regression in constant folding (Regression/C/casts)
llvm-svn: 42165
2007-09-20 16:50:21 +00:00
Chris Lattner
d1abd00b04 reject things like "declare internal @foo"
llvm-svn: 42140
2007-09-19 17:14:45 +00:00
Dale Johannesen
f9e06fa29b Fix some long double issues.
llvm-svn: 42133
2007-09-19 14:22:58 +00:00
Duncan Sands
dd6fc40100 Partial fix for PR1678: correct some parts of constant
fold that were missed in the fix for PR1646.  Probably
this null/not-null logic should be factorized somewhere.

llvm-svn: 42131
2007-09-19 10:16:17 +00:00
Gordon Henriksen
9deea8ed1a Tests of the ocaml (and thus C) bindings for constants.
llvm-svn: 42101
2007-09-18 18:07:51 +00:00
Gordon Henriksen
765525cc71 Incorporating review feedback for GC verifier patch.
llvm-svn: 42087
2007-09-18 10:14:30 +00:00
Gordon Henriksen
3dc9d9f145 C bindings for libLLVMCore.a and libLLVMBitWriter.a.
- The naming prefix is LLVM.
- All types are represented using opaque references.
- Functions are not named LLVM{Type}{Method}; the names became
  unreadable goop. Instead, they are named LLVM{ImperativeSentence}.
- Where an attribute only appears once in the class hierarchy (e.g.,
  linkage only applies to values; parameter types only apply to
  function types), the class is omitted from identifiers for
  brevity. Tastes like methods.
- Strings are C strings or string/length tuples on a case-by-case
  basis.
- APIs which give the caller ownership of an object are not mapped
  (removeFromParent, certain constructor overloads). This keeps
  keep memory management as simple as possible.

For each library with bindings:

  llvm-c/<LIB>.h       - Declares the bindings.
  lib/<LIB>/<LIB>.cpp  - Implements the bindings.

So just link with the library of your choice and use the C header
instead of the C++ one.

llvm-svn: 42077
2007-09-18 03:18:57 +00:00
Bill Wendling
d269356b02 Add support for appending a suffix to the end of a mangled name.
llvm-svn: 42071
2007-09-17 22:39:32 +00:00
Gordon Henriksen
fa3a5915b1 Fix for PR1633: Verifier doesn't fully verify GC intrinsics
LLVM now enforces the following prototypes for the write barriers:

<ty>* @llvm.gcread(<ty2>*, <ty>**)
void @llvm.gcwrite(<ty>*, <ty2>*, <ty>**)

And for @llvm.gcroot, the first stack slot is verified to be an alloca or a 
bitcast of an alloca.

Fixes test/CodeGen/Generic/GC/lower_gcroot.ll, which violated these.

llvm-svn: 42051
2007-09-17 20:30:04 +00:00
Chris Lattner
cc315726f7 Merge DenseMapKeyInfo & DenseMapValueInfo into DenseMapInfo
Add a new DenseMapInfo::isEqual method to allow clients to redefine
the equality predicate used when probing the hash table.

llvm-svn: 42042
2007-09-17 18:34:04 +00:00
Dale Johannesen
575bd6070a Remove the assumption that FP's are either float or
double from some of the many places in the optimizers
it appears, and do something reasonable with x86
long double.
Make APInt::dump() public, remove newline, use it to
dump ConstantSDNode's.
Allow APFloats in FoldingSet.
Expand X86 backend handling of long doubles (conversions
to/from int, mostly).

llvm-svn: 41967
2007-09-14 22:26:36 +00:00
Dale Johannesen
4784ee3431 Revise previous patch per review comments.
Next round of x87 long double stuff.
Getting close now, basically works.

llvm-svn: 41875
2007-09-12 03:30:33 +00:00
Dale Johannesen
7bc3969cea Add APInt interfaces to APFloat (allows directly
access to bits).  Use them in place of float and
double interfaces where appropriate.
First bits of x86 long double constants handling 
(untested, probably does not work).

llvm-svn: 41858
2007-09-11 18:32:33 +00:00
Duncan Sands
4106f87b42 Two ParamAttrsVectors which differ by a permutation
of their elements do not yield the same ParamAttrsList,
though they should.  On the other hand, everyone seems
to pass such vectors with elements ordered by increasing
index, so rather than sorting the elements simply assert
that the elements are ordered in this way.

llvm-svn: 41845
2007-09-11 14:40:04 +00:00
Chris Lattner
f08a077fa9 Fix a buggy constant folding transformation when handling aliases.
llvm-svn: 41818
2007-09-10 23:42:42 +00:00
Owen Anderson
4b71e55287 Add lengthof and endof templates that hide a lot of sizeof computations.
Patch by Sterling Stein!

llvm-svn: 41758
2007-09-07 04:06:50 +00:00
Dale Johannesen
86f367a6b7 Next round of APFloat changes.
Use APFloat in UpgradeParser and AsmParser.
Change all references to ConstantFP to use the
APFloat interface rather than double.  Remove
the ConstantFP double interfaces.
Use APFloat functions for constant folding arithmetic
and comparisons.
(There are still way too many places APFloat is
just a wrapper around host float/double, but we're
getting there.)

llvm-svn: 41747
2007-09-06 18:13:44 +00:00
David Greene
8cda5af2e7 Update GEP constructors to use an iterator interface to fix
GLIBCXX_DEBUG issues.

llvm-svn: 41697
2007-09-04 15:46:09 +00:00
Dale Johannesen
e91a908971 Change LegalFPImmediates to use APFloat.
Add APFloat interfaces to ConstantFP, SelectionDAG.
Fix integer bit in double->APFloat conversion.
Convert LegalizeDAG to use APFloat interface in
ConstantFPSDNode uses.

llvm-svn: 41587
2007-08-30 00:23:21 +00:00
David Greene
5b85021be8 Update InvokeInst to work like CallInst
llvm-svn: 41506
2007-08-27 19:04:21 +00:00
Dale Johannesen
9ec1e28e79 Poison APFloat::operator==. Replace existing uses with bitwiseIsEqual.
This means backing out the preceding change to Constants.cpp, alas.

llvm-svn: 41378
2007-08-24 22:09:56 +00:00
Chris Lattner
af91aa2f5e sink clone() down the class hierarchy from CmpInst into ICmpInst/FCmpInst.
This eliminates a conditional on that path, and ensures ICmpInst/FCmpInst
both have an out-of-line virtual method to home the class.

llvm-svn: 41371
2007-08-24 20:48:18 +00:00
Dale Johannesen
0aaabb858b Revised per review feedback from previous patch.
llvm-svn: 41353
2007-08-24 05:08:11 +00:00
Dale Johannesen
a3ab055b9d Change internal representation of ConstantFP to use APFloat.
Interface to rest of the compiler unchanged, as yet.

llvm-svn: 41348
2007-08-24 00:56:33 +00:00
Chris Lattner
8e296cc9d9 Fix potentially N^2 behavior handling arrays with many of the
same value which get RAUW'd.  This speeds up reading the .bc
file in PR1616 from 852s to 0.19s on my G5 with a debug build.

llvm-svn: 41209
2007-08-21 00:55:23 +00:00
Chris Lattner
07ac73b539 simplify code, improve a comment.
llvm-svn: 41205
2007-08-21 00:21:07 +00:00
Dan Gohman
908f4e65ed Add Type::isIntOrIntVector, like Type::isFPOrFPVector.
llvm-svn: 41190
2007-08-20 19:25:59 +00:00
Dan Gohman
5da3149de5 When Intrinsic::getName is constructing names for overloaded intrinsics,
use the ValueType name instead of the llvm type name, to match what the
verifier expects. For integers these are the same, but for floating-point
values the intrinsics use f32/f64 instead of float/double.

llvm-svn: 41189
2007-08-20 19:23:34 +00:00
Chris Lattner
a92fddf2cc simplify code and print visibility for declarations.
llvm-svn: 41173
2007-08-19 22:15:26 +00:00
Chris Lattner
d5f075ed16 Compute the argument list as lazily as possible. This ensures that clients
that don't use it don't have to pay the memory cost for the arguments.  This
allows us to avoid creating Argument nodes for many prototypes and for clients
who lazily deserialize code from a bytecode file.

llvm-svn: 41166
2007-08-18 06:14:52 +00:00
Chris Lattner
6e6a77d83b use a nicer accessor.
llvm-svn: 41165
2007-08-18 06:13:19 +00:00
Dan Gohman
644db457f0 Fix the verification for overloaded intrinsic types. Check that they are
what they're supposed to be before using them.

llvm-svn: 41130
2007-08-16 22:06:45 +00:00
Dan Gohman
b499ea1cf6 Add MVT::fAny for overloading intrinsics on floating-point types.
llvm-svn: 41128
2007-08-16 21:57:19 +00:00
Devang Patel
833a8ea187 Assert sooner. Fix wordings.
llvm-svn: 41075
2007-08-14 16:53:52 +00:00
Devang Patel
993388b1ee Add methods to erase basic block entry.
llvm-svn: 41052
2007-08-13 22:10:29 +00:00
Chris Lattner
8674db5fbf Constant fold: getelementptr (i8* inttoptr (i64 1 to i8*), i32 -1)
Into: inttoptr (i64 0 to i8*)  -> null

This occurs in the example in PR1602.  With this fixed, we now compile
the example in PR1602 into fully "devirtualized" code:

define void @_Z1g1S(%struct.S* noalias  %s) {
entry:        %tmp131415 = getelementptr %struct.S* %s, i32 0, i32 0          ; <i32 (...)***> [#uses=1]        %tmp16 = load i32 (...)*** %tmp131415, align 4          ; <i32 (...)**> [#uses=1]
        %tmp26277 = load i32 (...)** %tmp16             ; <i32 (...)*> [#uses=1]
        %tmp2829 = bitcast i32 (...)* %tmp26277 to void (%struct.S*)*           ; <void (%struct.S*)*> [#uses=1]
        tail call void %tmp2829( %struct.S* %s )
        ret void
}

This still has the vtable dispatch (as required) but does not have any pointer
to method cruft left.

llvm-svn: 41046
2007-08-13 17:09:08 +00:00
Devang Patel
fa7277dd34 Do not overuse std::string. Pass around char * directly.
llvm-svn: 41001
2007-08-10 18:29:32 +00:00