Commit Graph

5420 Commits

Author SHA1 Message Date
Chris Lattner 3ce8668273 fix PR10335 by watching out for IR type compatibility in call argument lists.
llvm-svn: 134966
2011-07-12 04:53:39 +00:00
Chris Lattner bb1952cfda add some aggressive assertions that call arguments match up to callee
expectations in EmitCall.  Next patch will take this further.

llvm-svn: 134962
2011-07-12 04:46:18 +00:00
Bruno Cardoso Lopes 37b7fd0ab2 Fix a typo!
llvm-svn: 134952
2011-07-12 02:47:38 +00:00
Bruno Cardoso Lopes 75541d00e0 Do the same as r134946 for arrays. Add more testcases for avx x86_64 arg
passing.

llvm-svn: 134951
2011-07-12 01:27:38 +00:00
Bill Wendling 7475113d74 Revert r134888 (and related patches in other trees). It was causing
an assert on Darwin llvm-gcc builds.

Assertion failed: (castIsValid(op, S, Ty) && "Invalid cast!"), function Create, file /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.llvm-gcc-i386-darwin9-RA/llvm.src/lib/VMCore/Instructions.cpp, line 2067.
etc.

http://smooshlab.apple.com:8013/builders/llvm-gcc-i386-darwin9-RA/builds/2354

--- Reverse-merging r134888 into '.':
U    lib/CodeGen/CodeGenModule.cpp

llvm-svn: 134950
2011-07-12 01:16:47 +00:00
Bruno Cardoso Lopes 7a26681092 Fix one x86_64 abi issue and the test to actually look for the right thing,
which is: { <4 x float>, <4 x float> } should continue to go through memory.

llvm-svn: 134946
2011-07-12 00:30:27 +00:00
John McCall 5fcf8da33d Do full-expression cleanups in a much more sensible way that still lets
people write useful cleanup classes.

llvm-svn: 134942
2011-07-12 00:15:30 +00:00
Bruno Cardoso Lopes 21a41bb5ec Reapply r134754, which turns out to be working correctly and also
add one more testcase.

llvm-svn: 134934
2011-07-11 22:41:29 +00:00
John McCall 3b935d33a1 Emit partial destruction of structs with initializer lists.
llvm-svn: 134913
2011-07-11 19:35:02 +00:00
Jay Foad 7c57be3e2b De-constify Types in StructType::get() and TargetData::getIntPtrType().
llvm-svn: 134893
2011-07-11 09:56:20 +00:00
John McCall 178360e1cd Fix a lot of problems with the partial destruction of arrays:
- an off-by-one error in emission of irregular array limits for
   InitListExprs
 - use an EH partial-destruction cleanup within the normal
   array-destruction cleanup
 - get the branch destinations right for the empty check
Also some refactoring which unfortunately obscures these changes.

llvm-svn: 134890
2011-07-11 08:38:19 +00:00
Jay Foad 56cc1530ee De-constify Types in FunctionType::get().
llvm-svn: 134888
2011-07-11 07:56:41 +00:00
John McCall 944e502cb4 Use cached types; no functionality change.
llvm-svn: 134880
2011-07-10 20:11:30 +00:00
Chris Lattner 18ca0475d7 implement a nice new optimization: CodeGenTypes::UpdateCompletedType
is called whenever a tag type is completed.  We previously used that
as the sign to layout the codegen representation for the tag type,
which worked but meant that we laid out *every* completed type, whether
it was used or not.

Now we just lay out the type if we've already seen it somehow else.
This means that we lay out types we've used but haven't seen a body
for, but we don't lay out tons of stuff that noone cares about.

llvm-svn: 134866
2011-07-10 06:03:22 +00:00
Chris Lattner d7c59353bd enhance EmitLValueForFieldInitialization to do the proper pointer adjustment, allowing
us to revert the other half of r134860.  Now things are back to a relatively tidy state.

llvm-svn: 134865
2011-07-10 05:53:24 +00:00
Chris Lattner a2673ce134 revert part of r134860, which is empirically unnecessary after the proper fix
llvm-svn: 134864
2011-07-10 05:44:18 +00:00
Chris Lattner 117b724b59 keep track of whether being in a RS_StructPointer state
caused us to skip layout out a function accurately.  If
so, flush the type cache for both the function and struct
case to ensure that any pointers to the functions get
recomputed.  This is overconservative, but with this patch
clang can build itself again.

llvm-svn: 134863
2011-07-10 05:39:13 +00:00
Chris Lattner 13ee4f4834 change EmitLValueForField to cast the returned lvalue to the right
type, even when in the struct case.  This was one root issue that was
causing type mismatches throughout the compiler.

llvm-svn: 134862
2011-07-10 05:34:54 +00:00
Chris Lattner d1f1158203 Fix the clang bootstrap and Jay's testcase from llvm-dev by being completely
conservative when converting a functiontype to IR when in a "pointer within
a struct" context.  This has the unfortunate sideeffect of compiling all 
function pointers inside of structs into "{}*" which, though correct, is
ugly.  This has the positive side effect of being correct, and it is pretty
straight-forward to improve on this.

llvm-svn: 134861
2011-07-10 03:47:27 +00:00
Chris Lattner 1a5f8978e9 when emitting pointer load from an lvalue or storing to an lvalue,
do an explicit bitcast to whatever ConvertType produces.  This will
go with the next patch.

llvm-svn: 134860
2011-07-10 03:38:35 +00:00
Chris Lattner 35bd5be2a2 how about we initialize RecursionState.
llvm-svn: 134855
2011-07-10 01:10:18 +00:00
Chris Lattner 8806e32f16 Rename CGT::VerifyFuncTypeComplete to isFuncTypeConvertible since
it is a predicate, not an action.  Change the return type to be a bool,
not the incomplete member.  Enhace it to detect the recursive compilation
case, allowing us to compile Eli's testcase on llvmdev:

struct T {
 struct T (*p)(void);
} t;

into:

%struct.T = type { {}* }

@t = common global %struct.T zeroinitializer, align 8

llvm-svn: 134853
2011-07-10 00:18:59 +00:00
Chris Lattner 955d9c715e when an enum type is completed, only flush the type cache when
the enum has already been converted.  If not, there cannot be any types
built on top of it, so there is no need to flush the cache.

llvm-svn: 134841
2011-07-09 18:53:56 +00:00
Chris Lattner a5f58b05e8 clang side to match the LLVM IR type system rewrite patch.
llvm-svn: 134831
2011-07-09 17:41:47 +00:00
John McCall c2f0001c80 More compiler workarounds. I have to admit that I was not
expecting so much concentrated oddity on what seemed like a
trivial feature.  Thanks to François Pichet for doing the
MSVC legwork here.

llvm-svn: 134813
2011-07-09 09:09:00 +00:00
John McCall 7c4df104ce GCC 4.2 compatibility hack.
llvm-svn: 134785
2011-07-09 02:30:03 +00:00
John McCall 82fe67bb82 A number of array-related IR-gen cleanups.
- Emit default-initialization of arrays that were partially initialized
    with initializer lists with a loop, rather than emitting the default
    initializer N times;
  - support destroying VLAs of non-trivial type, although this is not
    yet exposed to users; and
  - support the partial destruction of arrays initialized with
    initializer lists when an initializer throws an exception.

llvm-svn: 134784
2011-07-09 01:37:26 +00:00
Eli Friedman 3346582bca Change -mno-mmx to be more compatible with gcc. Specifically, -mno-mmx should not imply -mno-sse.
Note that because we don't usually touch the MMX registers anyway, all -mno-mmx needs to do is tweak the x86-32 calling convention a little for vectors that look like MMX vectors, and prevent the definition of __MMX__.

clang doesn't actually stop the user from using MMX inline asm operands or MMX builtins in -mno-mmx mode; as a QOI issue, it would be nice to diagnose, but I doubt it really matters much.

<rdar://problem/9694837>

llvm-svn: 134770
2011-07-08 23:31:17 +00:00
Bruno Cardoso Lopes 129b4cc9ec Revert x86_64 ABI changes until I have time to check the items raised by Eli.
llvm-svn: 134765
2011-07-08 22:57:35 +00:00
Jakub Staszak d2cf2cbae9 Introduce __builtin_expect() intrinsic support.
llvm-svn: 134761
2011-07-08 22:45:14 +00:00
Bruno Cardoso Lopes 308d7423a9 Add support for AVX 256-bit in the x86_64 ABI (as in the 0.99.5 draft)
llvm-svn: 134754
2011-07-08 22:18:40 +00:00
Cameron Zwarich ae7bc98710 Add codegen support for the fma/fmal/fmaf builtins.
llvm-svn: 134743
2011-07-08 21:39:34 +00:00
Bill Wendling e367f387af Layout the code for trapping arithmetic so that the overflow case comes after
the normal case.

Before, for this:

$ cat t.c
int test(int x) { return x * 2; }

We would get this:

   addl  %edi, %edi
   jno   LBB0_2
## BB#1:                                ## %overflow
   ud2
LBB0_2:                                 ## %nooverflow
   movl    %edi, %eax
   popq    %rbp
   ret

Now we get this:

   addl   %edi, %edi
   jo     LBB0_2
## BB#1:                                ## %nooverflow
   movl                                 %edi, %eax
   popq                                 %rbp
   ret
LBB0_2:                                 ## %overflow
   ud2

<rdar://problem/8283919>

llvm-svn: 134642
2011-07-07 21:13:10 +00:00
Cameron Zwarich be652e6a24 r134634 causes a failure on MultiSource/Benchmarks/Olden/bh with TEST=nightly,
so roll it out.

llvm-svn: 134638
2011-07-07 21:03:28 +00:00
Nick Lewycky d755e6ac48 A redeclaration of an inline method in C99 mode should trigger emission of that
function. Fixes PR10233!

llvm-svn: 134634
2011-07-07 20:25:10 +00:00
David Chisnall 1bfe6d374d If we're using the pure non-fragile ABI, then skip some of the contortions required to support the transitional ABI.
llvm-svn: 134612
2011-07-07 12:34:51 +00:00
David Chisnall a918b88952 Set a flag to tell the runtime when we're compiling in ARC mode and use the pure-nonfragile ABI for both ARC and GC mode.
llvm-svn: 134611
2011-07-07 11:22:31 +00:00
John McCall 4db5c3c83a In ARC, reclaim all return values of retainable type, not just those
where we have an immediate need of a retained value.

As an exception, don't do this when the call is made as the immediate
operand of a __bridge retain.  This is more in the way of a workaround
than an actual guarantee, so it's acceptable to be brittle here.

rdar://problem/9504800

llvm-svn: 134605
2011-07-07 06:58:02 +00:00
Nick Lewycky 7c6c6cc425 Sort #includes.
llvm-svn: 134589
2011-07-07 03:54:51 +00:00
Fariborz Jahanian 134f4587e7 revert patch for // rdar://9227352
llvm-svn: 134536
2011-07-06 21:05:11 +00:00
John McCall 9de1978f6e Call objc_terminate() instead of abort() when a cleanup throws an
exception in Objective-C;  in Objective-C++ we still use std::terminate().
This is only available in very recent runtimes.

llvm-svn: 134456
2011-07-06 01:22:26 +00:00
John McCall 24fc0decfe Change the driver's logic about Objective-C runtimes: abstract out a
structure to hold inferred information, then propagate each invididual
bit down to -cc1.  Separate the bits of "supports weak" and "has a native
ARC runtime";  make the latter a CodeGenOption.

The tool chain is still driving this decision, because it's the place that
has the required deployment target information on Darwin, but at least it's
better-factored now.

llvm-svn: 134453
2011-07-06 00:26:06 +00:00
Dan Gohman fec0ff84dc Add the ObjC ARC optimization passes manually, now that they're not
hardwired into the default pass list.

llvm-svn: 134445
2011-07-05 22:02:36 +00:00
Eli Friedman 1310c68bb0 Don't use x86_mmx where it isn't necessary.
The start of some work on getting -mno-mmx working the way we want it to.

llvm-svn: 134300
2011-07-02 00:57:27 +00:00
Eric Christopher bf15d2b311 Update for llvm commit r134291.
Fixes rdar://9714064

llvm-svn: 134292
2011-07-02 00:20:22 +00:00
Douglas Gregor fa918f69f6 Emit guard variables for any weak global that has a run-time
initializer. Previously, we only used guard variables for weak static
data members. Fixes <rdar://problem/9692249>.

llvm-svn: 134266
2011-07-01 21:54:36 +00:00
Douglas Gregor 82e1af20cb Don't zero-initialize default-initialized local variables that have
trivial default constructors. This generated-code regression was
caused by r131796, which had simplified the handling of default
initialization in Sema. Fixes <rdar://problem/9694300>.

llvm-svn: 134260
2011-07-01 21:08:19 +00:00
David Chisnall 08d6733ed7 Add support for weakly imported classes (GNU runtime).
llvm-svn: 134140
2011-06-30 10:14:37 +00:00
Evan Cheng adc7959851 createTargetMachine now takes a CPU string.
llvm-svn: 134128
2011-06-30 02:06:32 +00:00
Fariborz Jahanian 326701e2c7 objc-arc: fix a IRGen crash when checking for
accessibility of an initializer which is a compound 
statement. // rdar://9694706

llvm-svn: 134091
2011-06-29 20:00:16 +00:00
Fariborz Jahanian 25e61c58bf Use existing -fcatch-undefined-behavior option,
replacing -freset-local-blocks. // rdar://9227352

llvm-svn: 134082
2011-06-29 18:41:17 +00:00
David Chisnall 920e83b00b Add ARC support for the GNUstep runtime.
llvm-svn: 134065
2011-06-29 13:16:41 +00:00
Eli Friedman 4774b7e456 We don't pass classes with a copy-constructor or destructor byval, so the address takes up an integer register (if one is available). Make sure the x86-64 ABI implementation takes that into account properly.
The fixed implementation is compatible with the implementation both gcc and llvm-gcc use.

rdar://9686430 . (This is the issue that was reported in the thread "[LLVMdev] Segfault calling LLVM libs from a clang-compiled executable".)

llvm-svn: 134059
2011-06-29 07:04:55 +00:00
Evan Cheng eeb486dda5 SubtargetFeature.h has been moved to MC.
llvm-svn: 134050
2011-06-29 01:14:32 +00:00
Fariborz Jahanian fc510bdd94 Under a compiler flag, -freset-local-blocks,
wipe out stack blocks when they go out of scope.
// rdar://9227352

llvm-svn: 134045
2011-06-28 23:51:26 +00:00
Eric Christopher fd9a5f4f66 Split out logic for valid clobbers and valid inline asm registers.
Fixes rdar://9281377

llvm-svn: 134016
2011-06-28 18:20:53 +00:00
Fariborz Jahanian b26d578b41 Eliminate most uses of ShallowCollectObjCIvars which requires
a vector for collection. Use iterators where needed instead.
// rdar://6817577

llvm-svn: 134015
2011-06-28 18:05:25 +00:00
John McCall d68b2d0438 Fix PR10204 in a better way.
llvm-svn: 133943
2011-06-27 21:24:11 +00:00
Nico Weber 8aba2d8014 Revert parts of r133860 to fix a crash. Add a test.
llvm-svn: 133931
2011-06-27 19:46:54 +00:00
Eli Friedman 5836852e9c Cleanup cast IRGen a bit; no intended functionality change.
llvm-svn: 133864
2011-06-25 02:58:47 +00:00
John McCall b793de703e Do not apply the ARC move optimization to 'const'-qualified xvalues.
llvm-svn: 133861
2011-06-25 02:26:44 +00:00
John McCall 55e1fbc848 LValue carries a type now, so simplify the main EmitLoad/Store APIs
by removing the redundant type parameter.

llvm-svn: 133860
2011-06-25 02:11:03 +00:00
John McCall 77527a8e65 Mark the multiply which occurs as part of performing pointer
arithmetic on a VLA as 'nsw', per discussion with djg, and
implement pointer arithmetic (other than array accesses) and
pointer subtraction for VLA types.

llvm-svn: 133855
2011-06-25 01:32:37 +00:00
John McCall 1bd2556ccc Honor objc_precise_lifetime in GC mode by feeding the value
in the variable to an inline asm which gets run when the variable
goes out of scope.

llvm-svn: 133840
2011-06-24 23:21:27 +00:00
Bob Wilson 6bc2164d2a Revert "Shorten some ARM builtin names by removing unnecessary "neon" prefix."
Sorry, this was a bad idea.  Within clang these builtins are in a separate
"ARM" namespace, but the actual builtin names should clearly distinguish tha
they are target specific.

llvm-svn: 133833
2011-06-24 22:13:26 +00:00
Devang Patel 15013e78c3 Fix struct member's scope. Patch by Xi Wang.
llvm-svn: 133829
2011-06-24 22:00:59 +00:00
John McCall 23c29fea92 Change the IR-generation of VLAs so that we capture bounds,
not sizes;  so that we use well-typed allocas;  and so that we
properly recurse through the full set of variably-modified types.

llvm-svn: 133827
2011-06-24 21:55:10 +00:00
Bob Wilson 932e5b5d52 Shorten some ARM builtin names by removing unnecessary "neon" prefix.
llvm-svn: 133826
2011-06-24 21:32:46 +00:00
Fariborz Jahanian 831f0fc2e0 Support for catching objc pointer objects in c++ catch-statement
in fragile abi mode and some other cleanups. // rdar://8940528

llvm-svn: 133747
2011-06-23 19:00:08 +00:00
Fariborz Jahanian 0a3cfcc87f Alloa catching Objective-C id's being thrown with C++ throw
in Darwin's fragile abi mode.  // rdar://8940528

llvm-svn: 133639
2011-06-22 20:21:51 +00:00
Douglas Gregor ec793dde8e Try to silence GCC warning
llvm-svn: 133623
2011-06-22 16:43:25 +00:00
Douglas Gregor 1c8cd7c1a5 Implement the C++0x move optimization for Automatic Reference Counting
objects, so that we steal the retain count of a temporary __strong
pointer (zeroing out that temporary), eliding a retain/release
pair. Addresses <rdar://problem/9364932>.

llvm-svn: 133621
2011-06-22 16:32:26 +00:00
Douglas Gregor 58df509fc0 When binding a reference to an Automatic Reference Counting temporary,
retain/release the temporary object appropriately. Previously, we
would only perform the retain/release operations when the reference
would extend the lifetime of the temporary, but this does the wrong
thing across calls.

llvm-svn: 133620
2011-06-22 16:12:01 +00:00
Jay Foad 83be361b8a Replace the existing forms of ConstantArray::get() with a single form
that takes an ArrayRef.

llvm-svn: 133615
2011-06-22 09:24:39 +00:00
John McCall 6b0feb7ed6 Emit @finally blocks completely lazily instead of forcing their
existence by always threading an edge from the catchall.  Not doing
this was previously causing a crash in the very extreme case where
neither the normal cleanup nor the EH catchall was actually reachable:
we would delete the catchall entry block, which would cause us to
delete the entry block of the finally cleanup as well because the
cleanup logic would merge the blocks, which in turn triggered an assert
because later blocks in the finally would still be using values from the
entry.  Laziness turns out to be the most elegant solution to the problem.

llvm-svn: 133601
2011-06-22 02:32:12 +00:00
Daniel Dunbar d3f3d932ee IRgen: Add a -fuse-register-sized-bitfield-access option, for testing.
- Changes bit-field access policy to try to use (aligned) register sized accesses.

The idea here is that by using larger accesses we expose more coalescing
potential to the backend when we have situations like adjacent bit-fields in the
same structure (which is common), and that the backend should be smart enough to
narrow the accesses down when no coalescing is done or when it is shown not to
be profitable.

--
$ clang -m32 -O3 -S -o - t.c
_f0:                                    ## @f0
	pushl	%ebp
	movl	%esp, %ebp
	movl	8(%ebp), %eax
	movb	(%eax), %cl
	andb	$-128, %cl
	orb	$1, %cl
	movb	%cl, (%eax)
	movb	1(%eax), %cl
	andb	$-128, %cl
	orb	$1, %cl
	movb	%cl, 1(%eax)
	movb	2(%eax), %cl
	andb	$-128, %cl
	orb	$1, %cl
	movb	%cl, 2(%eax)
	movb	3(%eax), %cl
	andb	$-128, %cl
	orb	$1, %cl
	movb	%cl, 3(%eax)
	popl	%ebp
	ret

$ clang -m32 -O3 -S -o - t.c -Xclang -fuse-register-sized-bitfield-access
_f0:                                    ## @f0
	pushl	%ebp
	movl	%esp, %ebp
	movl	8(%ebp), %eax
	movl	$-2139062144, %ecx      ## imm = 0xFFFFFFFF80808080
	andl	(%eax), %ecx
	orl	$16843009, %ecx         ## imm = 0x1010101
	movl	%ecx, (%eax)
	popl	%ebp
	ret
--

llvm-svn: 133532
2011-06-21 18:54:46 +00:00
Daniel Dunbar 0de2faae4d IRgen: Add CGOptions to CGTypes.
llvm-svn: 133530
2011-06-21 18:54:39 +00:00
Douglas Gregor d410c08ebe A few tweaks to MaterializeTemporaryExpr suggested by John.
llvm-svn: 133528
2011-06-21 18:20:46 +00:00
Douglas Gregor fe31481f68 Introduce a new AST node describing reference binding to temporaries.
MaterializeTemporaryExpr captures a reference binding to a temporary
value, making explicit that the temporary value (a prvalue) needs to
be materialized into memory so that its address can be used. The
intended AST invariant here is that a reference will always bind to a
glvalue, and MaterializeTemporaryExpr will be used to convert prvalues
into glvalues for that binding to happen. For example, given

  const int& r = 1.0;

The initializer of "r" will be a MaterializeTemporaryExpr whose
subexpression is an implicit conversion from the double literal "1.0"
to an integer value. 

IR generation benefits most from this new node, since it was
previously guessing (badly) when to materialize temporaries for the
purposes of reference binding. There are likely more refactoring and
cleanups we could perform there, but the introduction of
MaterializeTemporaryExpr fixes PR9565, a case where IR generation
would effectively bind a const reference directly to a bitfield in a
struct. Addresses <rdar://problem/9552231>.

llvm-svn: 133521
2011-06-21 17:03:29 +00:00
NAKAMURA Takumi 5364847a84 De-Unicode-ify in comments.
llvm-svn: 133501
2011-06-21 03:19:28 +00:00
Nick Lewycky ca6b90d8af Add support for -Wa,--noexecstack when building from a non-assembly file. For
an assembly file it worked correctly, while for a .c file it would given an
error about how --noexecstack is not a supported argument to -Wa.

llvm-svn: 133489
2011-06-21 00:14:18 +00:00
Eric Christopher b4a791f7bc Canonicalize register names properly.
Fixes rdar://9425559

llvm-svn: 133486
2011-06-21 00:07:10 +00:00
Fariborz Jahanian ab578bf355 llvm-gcc treats a tentative definition with a previous
(or follow up) extern declaration with weak_import as 
an actual definition. make clang follows this behavior. 
// rdar://9538608
llvm-gcc treats an extern declaration with weak_import

llvm-svn: 133450
2011-06-20 17:50:03 +00:00
Jay Foad e03c05c35a Change how PHINodes store their operands.
Change PHINodes to store simple pointers to their incoming basic blocks,
instead of full-blown Uses.

Note that this loses an optimization in SplitCriticalEdge(), because we
can no longer walk the use list of a BasicBlock to find phi nodes. See
the comment I removed starting "However, the foreach loop is slow for
blocks with lots of predecessors".

Extend replaceAllUsesWith() on a BasicBlock to also update any phi
nodes in the block's successors. This mimics what would have happened
when PHINodes were proper Users of their incoming blocks. (Note that
this only works if OldBB->replaceAllUsesWith(NewBB) is called when
OldBB still has a terminator instruction, so it still has some
successors.)

llvm-svn: 133435
2011-06-20 14:38:01 +00:00
Francois Pichet 1b8d5ddafb Remove more unnecessary #include <llvm/ADT/SmallVector.h>
llvm-svn: 133418
2011-06-20 06:11:46 +00:00
Chris Lattner e64d7ba153 Update to match mainline ConstantStruct::get API change. Also, use
ConvertType on InitListExprs as they are being converted.  This is
needed for a forthcoming patch, and improves the IR generated anyway
(see additional type names in testcases). 

This patch also converts a bunch of std::vector's in CGObjCMac to use
C arrays.  There are a ton more that should be converted as well.

llvm-svn: 133413
2011-06-20 04:01:35 +00:00
Chris Lattner 845511fe1c update for api change.
llvm-svn: 133365
2011-06-18 22:49:11 +00:00
Benjamin Kramer 8a9cc4fe28 Remove dead variables.
llvm-svn: 133346
2011-06-18 10:34:07 +00:00
Benjamin Kramer dd19c0114d 80 cols.
llvm-svn: 133345
2011-06-18 10:34:00 +00:00
Douglas Gregor 6c9d31eb25 When emitting a compound literal of POD type, continue to emit a
separate aggregate temporary and then memcpy it over to the
destination. This fixes a regression I introduced with r133235, where
the compound literal on the RHS of an assignment makes use of the
structure on the LHS of the assignment.

I'm deeply suspicious of AggExprEmitter::VisitBinAssign()'s
optimization where it emits the RHS of an aggregate assignment
directly into the LHS lvalue without checking whether there is any
aliasing between the LHS/RHS. However, I'm not in a position to
revisit this now.

Big thanks to Eli for finding the regression!

llvm-svn: 133261
2011-06-17 16:37:20 +00:00
John McCall 5aa5259f5e Perform an acquire memory barrier on the fast path of a thread-safe
static initializer check, as required by the Itanium ABI.

llvm-svn: 133250
2011-06-17 07:33:57 +00:00
John McCall d463132f27 Objective-C fast enumeration loop variables are not retained in ARC, but
they should still be officially __strong for the purposes of errors, 
block capture, etc.  Make a new bit on variables, isARCPseudoStrong(),
and set this for 'self' and these enumeration-loop variables.  Change
the code that was looking for the old patterns to look for this bit,
and change IR generation to find this bit and treat the resulting         
variable as __unsafe_unretained for the purposes of init/destroy in
the two places it can come up.

llvm-svn: 133243
2011-06-17 06:42:21 +00:00
Douglas Gregor 9b71f0cfac Implement proper support for generating code for compound literals in
C++, which means:
  - binding the temporary as needed in Sema, so that we generate the
  appropriate call to the destructor, and
  - emitting the compound literal into the appropriate location for
  the aggregate, rather than trying to emit it as a temporary and
  memcpy() it.

Fixes PR10138 / <rdar://problem/9615901>.

llvm-svn: 133235
2011-06-17 04:59:12 +00:00
Eric Christopher e9544258ef Check the specific target to figure out if a constraint is a valid
register constraint. Note that we're not checking if the register itself
is valid for the constraint.

Fixes rdar://9382985

llvm-svn: 133226
2011-06-17 01:53:34 +00:00
Fariborz Jahanian 8feee2d169 Move computation of __private_extern__ visibilty to
getLVForNamespaceScopeDecl(). // rdar://9609649

llvm-svn: 133182
2011-06-16 20:14:50 +00:00
Fariborz Jahanian a27070db0c Set the visibility to 'hidden' when previous
declaration of global var is __private_extern__.
// rdar://9609649

llvm-svn: 133157
2011-06-16 14:49:42 +00:00
John McCall 1553b19067 Restore correct use of GC barriers.
llvm-svn: 133144
2011-06-16 04:16:24 +00:00
John McCall 101236969f Suppress a warning in -Asserts builds.
llvm-svn: 133110
2011-06-15 23:40:09 +00:00
John McCall 31168b077c Automatic Reference Counting.
Language-design credit goes to a lot of people, but I particularly want
to single out Blaine Garst and Patrick Beard for their contributions.

Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself,
in no particular order.

llvm-svn: 133103
2011-06-15 23:02:42 +00:00
Eli Friedman f7456194a3 Per Chris's suggestion, simplify code using llvm::getOrEnforceKnownAlignment.
llvm-svn: 133095
2011-06-15 22:09:18 +00:00
Eli Friedman 471a22febc Use isAnyComplexType here so we don't pass complex numbers into the aggregate handling code; found by inspection.
llvm-svn: 133070
2011-06-15 18:27:44 +00:00
Eli Friedman 7e68c88bf7 Fix a regression from r132957 involving complex integers. (Fixes failures on gcc-testsuite bot.)
llvm-svn: 133069
2011-06-15 18:26:32 +00:00
Devang Patel 7bf741ac36 Do not emit stoppoint before emitting debug info for parameters.
- llvm.dbg.declare already receives line number information from ParmDecl
- Additional extra stoppoint messes up gdb's understanding of where function body starts.

llvm-svn: 133065
2011-06-15 17:57:08 +00:00
Bruno Cardoso Lopes 3b0297a98c Update the prefetch intrinsic usage. Now the last argument tells codegen
whether it's a data or instruction cache access.

llvm-svn: 132977
2011-06-14 05:00:30 +00:00
Peter Collingbourne ee781d586e Move GlobalDecl to AST
llvm-svn: 132973
2011-06-14 04:02:39 +00:00
Eli Friedman eb7fab61bd The LLVM IR representation of byval arguments has a rather strange property: if the alignment of an argument to a call is less than the specified byval alignment for that argument, there is no way to specify the alignment of the implied copy. Therefore, we must ensure that the alignment of the argument is at least the byval alignment. To do this, we have to mess with the alignment of relevant alloca's in some cases, and insert a copy that conceptually shouldn't be necessary in some cases.
This patch tries relatively hard to avoid creating an extra copy if it can be avoided (see test3 in the included testcase), but it is not possible to avoid in some cases (like test2 in the included testcase).

rdar://9483886

llvm-svn: 132957
2011-06-14 01:37:52 +00:00
Devang Patel 297207f813 Put local variables in appropriate debug info scope.
This fixes radar 8757124.

llvm-svn: 132949
2011-06-13 23:15:32 +00:00
Richard Smith 938f40b5aa Implement support for C++11 in-class initialization of non-static data members.
llvm-svn: 132878
2011-06-11 17:19:42 +00:00
Douglas Gregor 33823727c8 Implement Objective-C Related Result Type semantics.
Related result types apply Cocoa conventions to the type of message
sends and property accesses to Objective-C methods that are known to
always return objects whose type is the same as the type of the
receiving class (or a subclass thereof), such as +alloc and
-init. This tightens up static type safety for Objective-C, so that we
now diagnose mistakes like this:

t.m:4:10: warning: incompatible pointer types initializing 'NSSet *'
with an
      expression of type 'NSArray *' [-Wincompatible-pointer-types]
  NSSet *array = [[NSArray alloc] init];
         ^       ~~~~~~~~~~~~~~~~~~~~~~
/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:72:1:
note: 
      instance method 'init' is assumed to return an instance of its
      receiver
      type ('NSArray *')
- (id)init;
^

It also means that we get decent type inference when writing code in
Objective-C++0x:

  auto array = [[NSMutableArray alloc] initWithObjects:@"one",  @"two",nil];
  //    ^ now infers NSMutableArray* rather than id

llvm-svn: 132868
2011-06-11 01:09:30 +00:00
Eli Friedman 300f55dcad PR10120: Make CodeGenModule::getVTableLinkage use NamedDecl::getLinkage to determine whether the vtable should be externally visible, instead of a rough approximation of it which messes up with templates.
While I'm here, zap the other user of isInAnonymousNamespace outside of Decl.cpp.

llvm-svn: 132861
2011-06-10 21:53:06 +00:00
Stuart Hastings 7fdc6707ac Clang support for ARM Uv/Uy/Uq inline-asm constraints.
rdar://problem/9037836

llvm-svn: 132737
2011-06-07 23:45:05 +00:00
Douglas Gregor 0aa91e0a66 When inferring the result type of a block based on a return statement
with a type-dependent expression, infer the placeholder type
'Context.DependentTy' to indicate that this is just a
placeholder. Fixes PR9982 / <rdar://problem/9486685>.

llvm-svn: 132657
2011-06-05 05:04:23 +00:00
Tanya Lattner 55808c1026 Add support for builtin astype:
__builtin_astype(): Used to reinterpreted as another data type of the same size using for both scalar and vector data types.
Added test case.

llvm-svn: 132612
2011-06-04 00:47:47 +00:00
Devang Patel 1b291b22d0 Rework r132576.
Emit debug info only if there is an insertion point. The debug info should not force an insertion point. Codegen may later on decide to not emit code for some reason, see extensive comment in CodeGenFunction::EmitStmt(), and debug info should not get in the way.

llvm-svn: 132610
2011-06-04 00:38:02 +00:00
Devang Patel 887e215e64 Emit debug info only if there is an insertion point. The debug info should not force an insertion point. Codegen may later on decide to not emit code for some reason, see extensive comment in CodeGenFunction::EmitStmt(), and debug info should not get in the way.
llvm-svn: 132576
2011-06-03 19:21:47 +00:00
Devang Patel f1e2a7f0f0 Simplify.
llvm-svn: 132560
2011-06-03 17:23:47 +00:00
Devang Patel 597a730cb8 Fix typedef's context.
llvm-svn: 132557
2011-06-03 17:05:26 +00:00
Eric Christopher e97fee6c86 80-column cleanup.
llvm-svn: 132548
2011-06-03 14:52:25 +00:00
Akira Hatanaka b579fe5f15 Add stuff for o32 ABI conformance.
llvm-svn: 132443
2011-06-02 00:09:17 +00:00
Devang Patel 5c71c2154b Robustify objc method type description (subroutine type) by walking parameters directly.
llvm-svn: 132368
2011-05-31 22:21:11 +00:00
Devang Patel 7ce99c3637 List objective-c ineterfaces as public types in dwarf debug info output.
llvm-svn: 132361
2011-05-31 21:18:50 +00:00
Devang Patel 2780e4545a List c++ class type as public type in dwarf debug info output.
llvm-svn: 132357
2011-05-31 20:46:46 +00:00
David Chisnall fcb37e944f Fix another incorrect type bug.
llvm-svn: 132311
2011-05-30 12:00:26 +00:00
John McCall 9b382dde92 Convert Clang over to resuming from landing pads with llvm.eh.resume.
It's quite likely that this will explode, but I need to know how. :)

llvm-svn: 132269
2011-05-28 21:13:02 +00:00
Benjamin Kramer df1fb13a5c Eliminate temporary argument vectors.
llvm-svn: 132260
2011-05-28 14:26:31 +00:00
David Chisnall 7441d8823f Fix another type mismatch.
llvm-svn: 132259
2011-05-28 14:23:43 +00:00
David Chisnall 8a42d19b33 Fix missing cast.
llvm-svn: 132258
2011-05-28 14:09:01 +00:00
Bruno Cardoso Lopes fe73374d7a Add support for ARM ldrexd/strexd builtins
llvm-svn: 132249
2011-05-28 04:11:33 +00:00
Eli Friedman b857842c48 Add unnamed_addr to internal globals which are only used as an operand to memcpy. (Spotted by looking at IR.)
llvm-svn: 132226
2011-05-27 22:32:55 +00:00
Eli Friedman 6ffb623a52 Match llvm-gcc's string literals alignment by forcing alignment on string literals to 1. This can significantly impact the size of the string data, and as far as I know, the alignment doesn't help performance. rdar://9078969 .
llvm-svn: 132223
2011-05-27 22:13:20 +00:00
Eli Friedman 380b8dad6b Back out r132209; it's breaking nightly tests.
llvm-svn: 132219
2011-05-27 21:32:17 +00:00
John McCall 63fb333fa4 Implement a new, much improved version of the cleanup hack. We just need
to be careful to emit landing pads that are always prepared to handle a
cleanup path.  This is correct mostly because of the fix to the LLVM
inliner, r132200.

llvm-svn: 132209
2011-05-27 20:01:14 +00:00
Douglas Gregor a9d8493310 Objective-C doesn't consider the use of incomplete types as method
parameter types to be ill-formed. However, it relies on the
completeness of method parameter types when producing metadata, e.g.,
for a protocol, leading IR generating to crash in such cases.

Since there's no real way to tighten down the semantics of Objective-C
here without breaking existing code, do something safe but lame:
suppress the generation of metadata when this happens.

Fixes <rdar://problem/9123036>.

llvm-svn: 132171
2011-05-27 01:19:52 +00:00
Eli Friedman df96819daf Skip extra copy from aggregate where it isn't necessary; rdar://problem/8139919 . This shouldn't make much of a difference at -O3, but should substantially reduce the number of generated memcpy's at -O0.
Originally r130717, but was backed out due to an ObjC regression.

llvm-svn: 132102
2011-05-26 00:10:27 +00:00
David Chisnall e4e5c0f219 Remove bitcast to incorrect type.
llvm-svn: 132077
2011-05-25 20:33:17 +00:00
Rafael Espindola c1ee12c952 Update for llvm api change.
llvm-svn: 132034
2011-05-25 03:44:55 +00:00
Alexis Hunt e852b100e2 Implement a new type node, UnaryTransformType, designed to represent a
type that turns one type into another. This is used as the basis to
implement __underlying_type properly - with TypeSourceInfo and proper
behavior in the face of templates.

llvm-svn: 132017
2011-05-24 22:41:36 +00:00
David Chisnall b85775c3ba Fix bug introduced with r131930.
llvm-svn: 131935
2011-05-23 23:15:11 +00:00
David Chisnall 1254f6efe2 Don't omit retain / release / autorelease message sends in hybrid GC mode.
llvm-svn: 131932
2011-05-23 23:13:25 +00:00
David Chisnall 3fe89562e8 Fix some problems where functions must be bitcast but we're expecting a llvm::Function of the right type.
PR9994.

llvm-svn: 131930
2011-05-23 22:33:28 +00:00
Chris Lattner e76b95ae15 make the x86-32 backend specify a byval alignment, even when the
code generator will do it.  With this patch, clang compiles the example
in PR9794 to not have an alloca temporary.

llvm-svn: 131881
2011-05-22 23:35:00 +00:00
Chris Lattner 44c2b90556 Fix x86-64 byval passing to specify the alignment even when the code
generator will give it something sufficient.  This is important because
the mid-level optimizer doesn't know what alignment is required otherwise.

llvm-svn: 131879
2011-05-22 23:21:23 +00:00
David Chisnall 5c51177981 Provide the runtime with information about the GC compile options (GNU runtimes)
llvm-svn: 131877
2011-05-22 22:37:08 +00:00
Chris Lattner a8cde3c08d fix 80 col violation
llvm-svn: 131870
2011-05-22 22:09:06 +00:00
Chris Lattner ecf0ba5bde adjust to mainline api change.
llvm-svn: 131815
2011-05-21 23:50:44 +00:00
Chris Lattner 5c12367b44 switch clang off StandardPasses.h onto PassManagerBuilder.h
llvm-svn: 131808
2011-05-21 20:40:11 +00:00
Eli Friedman e08bca9eb4 Fix the clang part of PR7952: rewrite the specialization of isa<> in DeclBase,
and stop abusing the multi-level dereference isa<> used to allow.

llvm-svn: 131804
2011-05-21 19:15:39 +00:00
Douglas Gregor 6ab2fa8f78 Introduce Type::isSignedIntegerOrEnumerationType() and
Type::isUnsignedIntegerOrEnumerationType(), which are like
Type::isSignedIntegerType() and Type::isUnsignedIntegerType() but also
consider the underlying type of a C++0x scoped enumeration type.

Audited all callers to the existing functions, switching those that
need to also handle scoped enumeration types (e.g., those that deal
with constant values) over to the new functions. Fixes PR9923 /
<rdar://problem/9447851>.

llvm-svn: 131735
2011-05-20 16:38:50 +00:00
Devang Patel e7ce54074f Fix location of setter/getter synthesized for a property.
llvm-svn: 131701
2011-05-19 23:37:41 +00:00
Eli Friedman 2f1e9e618c Make __builtin_shufflevector and -ftrapv work correctly together. PR9945.
llvm-svn: 131611
2011-05-19 00:37:32 +00:00
Roman Divacky c161735bdf Add ARMTargetCodeGenInfo::initDwarfEHRegSizeTable() defining 16 32bit regs.
llvm-svn: 131558
2011-05-18 19:36:54 +00:00
Bill Wendling 28b9e8b3a8 Conditionalize the use of 4.4 or 4.2 format based on the target.
<rdar://problem/8107317>

llvm-svn: 131504
2011-05-17 23:06:23 +00:00
Fariborz Jahanian ccdfa39005 Code cleanup of my last patch.
llvm-svn: 131499
2011-05-17 22:46:11 +00:00
Fariborz Jahanian 7bd3d1c49b Patch to fix IR-gen crash generating structure ABI which implements
user specified string class via -fconstant-string-class option.
pr9914.

llvm-svn: 131496
2011-05-17 22:21:16 +00:00
Eli Friedman af9b325d23 For calls returning first-class aggregates, store by element instead of creating aggregate stores in common cases. This is more friendly to fast-isel.
llvm-svn: 131490
2011-05-17 21:08:01 +00:00
John McCall 3597b6340c Revert r131434, my commit disabling the complete-object constructor
optimization for abstract classes;  there was a misunderstanding, and
it turns out that there are no kexts which rely on this.

llvm-svn: 131489
2011-05-17 21:05:49 +00:00
Argyrios Kyrtzidis d42411fa19 Revert r131447, see if it fixes the buildbot.
llvm-svn: 131450
2011-05-17 02:17:52 +00:00
Argyrios Kyrtzidis ceee5e8133 Inside isEmptyRecord function, for CXXRecordDecl just check the isEmpty bit.
llvm-svn: 131447
2011-05-17 00:46:40 +00:00
Devang Patel f9076f3b45 Set up appropriate context for member function.
Radar 9440721

llvm-svn: 131441
2011-05-17 00:20:09 +00:00
Ted Kremenek c249c411c2 Fix crash on C++ code when compiling with -finstrument-functions.
llvm-svn: 131435
2011-05-16 23:49:20 +00:00
John McCall 2ccfe89b3e Emit complete-object constructors for abstract classes in kext mode for
reasons that honestly really, really need to be looked into.

llvm-svn: 131434
2011-05-16 23:34:46 +00:00
Anders Carlsson d6f1518cc9 Fix another regression from the "skip vtable pointer initialization"
optimization. Make sure to require a vtable when trying to get the address
of a VTT, otherwise we would never end up emitting the VTT.

llvm-svn: 131400
2011-05-16 04:08:36 +00:00
John McCall 7ec4b4342c Don't actually emit calls to the reserved global placement new and delete
operators;  their semantics are guaranteed by the language.

If someone wants to argue that freestanding compiles shouldn't recognize
this, I might be convinceable.

llvm-svn: 131395
2011-05-16 01:05:12 +00:00
Anders Carlsson 49c0bd2a25 Re-enable the fix for PR9181 now that all the edge cases are handled.
llvm-svn: 131385
2011-05-15 17:36:21 +00:00
John McCall 036f2f6b35 The array-size operand to a new-expression is not necessarily a size_t.
It can be larger, it can be smaller, it can be signed, whatever.  Handle
all the crazy cases with grace and spirit.

llvm-svn: 131378
2011-05-15 07:14:44 +00:00
John McCall 745ae2853c Make CGF.getContext() inlinable, because it's trivial, and optimize
hasAggregateLLVMType.

llvm-svn: 131375
2011-05-15 02:34:36 +00:00
John McCall 85dd2c5039 More killing of std::vector.
llvm-svn: 131374
2011-05-15 02:19:42 +00:00
John McCall 9dc0db2192 Use arrays and SmallVectors instead of std::vectors when building function
types.  Also, cache a translation of 'void' in CGM and provide a ptrdiff_t
alias.  No functionality change.

llvm-svn: 131373
2011-05-15 01:53:33 +00:00
Anders Carlsson b55c8c127e Disable the optimization until the bug noticed by Sean Hunt has been fixed.
llvm-svn: 131372
2011-05-15 01:50:14 +00:00
Anders Carlsson 9bd7d16440 When emitting the destructor for a class with a vtable, if we can determine
that the destructor body is trivial and that all member variables also have either
trivial destructors or trivial destructor bodies, we don't need to initialize the
vtable pointers since no virtual member functions will be called on the destructor.

Fixes PR9181.

llvm-svn: 131368
2011-05-14 23:26:09 +00:00
John McCall 5880fb8edf Only perform the null-initialization of an aggregate result of a message
send if the receiver is null.  Normally it's not worthwhile to check this,
but avoiding the null-initialization is nice, and this also avoids nasty
problems where the null-initialization is visible within the call because
we use an aliased result buffer.  rdar://problem/9402992

llvm-svn: 131366
2011-05-14 21:12:11 +00:00
John McCall 9e8bb000d8 Objective-C vtables are not taking the world by storm; call them
out as "v-table" message sends and stop calling normal messages "legacy"
message sends.

Also, fix some comments to reveal the true state of affairs.

llvm-svn: 131335
2011-05-14 03:10:52 +00:00
John McCall 234eac88ae Reorganize this method to avoid multiple calls for computing CGFunctionInfo
and to decrease the amount of effort in appending strings.

llvm-svn: 131323
2011-05-13 23:16:18 +00:00
Joerg Sonnenberger be7850dd8a Simplify
llvm-svn: 131321
2011-05-13 22:58:37 +00:00
Joerg Sonnenberger caf8ffd8e3 Bug 8765: Honor assembler labels for builtins. Ensure that the label is
mangled to avoid doing it twice for platforms that use prefixes like
Darwin.

llvm-svn: 131311
2011-05-13 21:12:10 +00:00
Bill Wendling bb455154a1 Remove the 'unaligned load' builtins now that they're no longer used in the *mmintrin.h files.
llvm-svn: 131300
2011-05-13 18:52:28 +00:00
Fariborz Jahanian a52b1f72ef Produce UTF-8 strings with -fconstant-string-class
-fno-constant-cfstrings. Patch by Jonathan Schleifer.

llvm-svn: 131298
2011-05-13 18:13:10 +00:00
Douglas Gregor 61226d3fcf When determining whether we can make a declaration into a global
constant, also consider whether it's a class type that has any mutable
fields. If so, it can't be a global constant.

llvm-svn: 131276
2011-05-13 01:05:07 +00:00
Devang Patel e91b54cc56 Doug convinced me that DW_AT_APPLE_objc_complete_type is more appropriate name.
s/DW_AT_APPLE_objc_class_extension/DW_AT_APPLE_objc_complete_type/g

llvm-svn: 131245
2011-05-12 21:29:57 +00:00
Devang Patel 70d77d144b Do not add AT_APPLE_objc_class_extension attribute if @implementation is not seen.
llvm-svn: 131242
2011-05-12 21:14:54 +00:00
Devang Patel 36882c8f24 Use DW_AT_APPLE_objc_class_extension attribute to identify interfaces that represent class extension.
Radar 9423077.

llvm-svn: 131239
2011-05-12 19:07:41 +00:00
Bill Wendling e106c34817 LLVM doesn't always optimize away the four loads from this:
(__m128){ p[0], p[1], p[2], p[3] }

which produces really bad code. This could be done in instcombine, but it's
probably better to do it in the front-end instead.
<rdar://problem/9424836>

llvm-svn: 131237
2011-05-12 19:02:15 +00:00
John McCall 3f6e745292 Make this code more resilient against catch variables which need cleanups.
llvm-svn: 131215
2011-05-12 01:00:15 +00:00
Alexis Hunt f479f1b7e4 Rename "hasTrivialConstructor" to "hasTrivialDefaultConstructor" and
modify the semantics slightly to accomodate default constructors (I
hope).

llvm-svn: 131087
2011-05-09 18:22:59 +00:00
Anders Carlsson c36783e8b9 Move code to emit the callee of an CXXOperatorCallExpr out into a separate function in CGClass.cpp
llvm-svn: 131075
2011-05-08 20:32:23 +00:00
Anders Carlsson cc53197903 Don't emit complete constructors for abstract classes. Also, don't emit
complete destructors for abstract classes unless the destructor is virtual
and thus needs to be in the vtable.

llvm-svn: 131068
2011-05-08 17:25:05 +00:00
Douglas Gregor 2d1c055eba In C++, allow us to emit a global as 'constant' even if it has class
type, so long as it is known to have a constant initializer and the
class type is a POD class. Fixes <rdar://problem/9306265>.

llvm-svn: 131060
2011-05-07 22:06:45 +00:00
Douglas Gregor 9ca5465500 Revert r130717, which caused a regression (<rdar://problem/9402621>).
llvm-svn: 131057
2011-05-07 20:12:26 +00:00
Cameron Esfahani bceca20ab9 Fix false positive warning about uninitialized variable.
llvm-svn: 131019
2011-05-06 21:28:42 +00:00
Alexis Hunt 4a8ea1092a Modify some deleted function methods to better reflect reality:
- New isDefined() function checks for deletedness
 - isThisDeclarationADefinition checks for deletedness
 - New doesThisDeclarationHaveABody() does what
   isThisDeclarationADefinition() used to do
 - The IsDeleted bit is not propagated across redeclarations
 - isDeleted() now checks the canoncial declaration
 - New isDeletedAsWritten() does what it says on the tin.
 - isUserProvided() now correct (thanks Richard!)

This fixes the bug that we weren't catching

void foo() = delete;
void foo() {}

as being a redefinition.

llvm-svn: 131013
2011-05-06 20:44:56 +00:00
Eli Friedman 409943efcb Don't emit nsw flags for vector operations; there's basically no benefit, and a lot of downside (like PR9850, which is about clang's xmmintrin.h making an unexpected transformation on an expression involving _mm_add_epi32).
llvm-svn: 131000
2011-05-06 18:04:18 +00:00
Eli Friedman 49a94b1c7c Add an implementation of thunks for varargs methods. The implementation is a bit messy, but it is correct as long as the method in question doesn't use indirect gotos. A couple of possible alternative implementations are outlined in FIXME's in this patch. rdar://problem/8077308 .
llvm-svn: 130993
2011-05-06 17:27:27 +00:00
Axel Naumann bd26a58538 Reset the emitted initializers.
This enables incremental codegen, where the initializer array can be removed from the module, such that only new initializers will be emitted and run.

llvm-svn: 130986
2011-05-06 15:24:04 +00:00
Fariborz Jahanian 30aa4aa4ae type of last arg of objc_assign_ivar is ptrdiff_t.
// rdar://9362887

llvm-svn: 130956
2011-05-05 22:00:38 +00:00
Richard Smith 3f1b5d077b Implement support for C++0x alias templates.
llvm-svn: 130953
2011-05-05 21:57:07 +00:00
Devang Patel 979aba5d09 Do not drop uint128 on the floor.
llvm-svn: 130929
2011-05-05 17:06:30 +00:00
Nick Lewycky 85c011ddc4 Preserve the full name of the file, so that '-c -o foo.pic.o' produces
foo.pic.gcno instead of foo.gcno.

llvm-svn: 130899
2011-05-05 00:08:20 +00:00
Bill Wendling f7d4598b74 Pack ivar offsets together.
Ivar offsets for synthesized ivars are wrong, which could end up with a large
number of dirty pages because of ivar fixups at runtime. When we pack all of the
synthesized ivars into the same section, it limits the number of dirty pages
created. Place them in the "__DATA,__objc_ivar" section.
<rdar://problem/9374905>

llvm-svn: 130870
2011-05-04 21:37:25 +00:00
Nick Lewycky 480cb9918d Record where the GCOV data files should be placed.
llvm-svn: 130866
2011-05-04 20:46:58 +00:00
Bill Wendling 6869b6abf8 Simplification noticed by Chris.
llvm-svn: 130864
2011-05-04 20:28:12 +00:00
Bill Wendling 5f9150b5b1 Convert the non-temporal store builtins to LLVM-native IR.
llvm-svn: 130830
2011-05-04 02:40:38 +00:00
Alexis Hunt 9d47faf686 Ensure that destructors are properly inovked when an exception leaves
the body of a delegating constructor call.

This means that the delegating constructor implementation should be
complete and correct, though there are some rough edges (diagnostic
quality with the cycle detection and using a deleted destructor).

llvm-svn: 130803
2011-05-03 23:05:34 +00:00
Fariborz Jahanian fc0fe6eb52 Finish off rules for z-length bitfields in ms_struct
structs. // rdar://8823265

llvm-svn: 130783
2011-05-03 20:21:04 +00:00
Alexis Hunt 271c36811d Fix delegating constructors stylistic issues.
Material bugfixes to come this afternoon.

llvm-svn: 130782
2011-05-03 20:19:28 +00:00
Devang Patel 04ab75c9ab Function with internal linkage name do not have mangled name.
llvm-svn: 130736
2011-05-02 22:49:30 +00:00
Devang Patel b7ff0da623 Do not try to get mangled name of block helpers. Apply a stopgap measure to fix SingleSource/UnitTests/block-copied-in-cxxobj compile time crash.
llvm-svn: 130734
2011-05-02 22:37:48 +00:00
Devang Patel 2a7c219466 Emit debug info for __destroy_helper_block_ and __copy_helper_block.
llvm-svn: 130719
2011-05-02 20:37:08 +00:00
Eli Friedman 30458b51e3 Skip extra copy from aggregate where it isn't necessary; rdar://problem/8139919 . This shouldn't make much of a difference at -O3, but should substantially reduce the number of generated memcpy's at -O0.
llvm-svn: 130717
2011-05-02 20:24:29 +00:00
Eli Friedman f4258eb484 Switch CallArgList from an std::pair to a new CallArg struct (which will eventually gain more members). Working towards modifying call emission to avoid unnecessary copies.
llvm-svn: 130700
2011-05-02 18:05:27 +00:00
Eli Friedman 43dca6a8d2 Simplify code a bit by using CallArgList::add. No intended functionality change.
llvm-svn: 130699
2011-05-02 17:57:46 +00:00
Fariborz Jahanian eb39741c0b More rule enforcement of zero bitfields for ms_struct.
llvm-svn: 130696
2011-05-02 17:20:56 +00:00
Nick Lewycky fc49f72b58 Remove unused variable spotted by GCC.
Devang, can we remove this call entirely? If I try that, "make check" passes
but the call has a side-effect of ensuring that the block's context exists in
the debug info. getContextDescriptor() is used in a void context for that side-
effect elsewhere in this file. Please take a look!

llvm-svn: 130679
2011-05-02 01:41:48 +00:00
Nick Lewycky 1c60a0bc98 Remove dead variable, flagged by gcc's -Wunused-but-set-variable.
llvm-svn: 130674
2011-05-02 00:46:56 +00:00
Nick Lewycky b4175cad29 Remove dead variable flagged by gcc's -Wunused-but-set-variable. No
functionality change.

llvm-svn: 130673
2011-05-02 00:41:17 +00:00
Nick Lewycky 18a1ee7f51 Remove a dead variable flagged by gcc's -Wunused-but-set-variable. No
functionality change.

llvm-svn: 130672
2011-05-02 00:40:24 +00:00
Alexis Hunt 61bc173784 Fully implement delegating constructors!
As far as I know, this implementation is complete but might be missing a
few optimizations. Exceptions and virtual bases are handled correctly.

Because I'm an optimist, the web page has appropriately been updated. If
I'm wrong, feel free to downgrade its support categories.

llvm-svn: 130642
2011-05-01 07:04:31 +00:00
Rafael Espindola e264187cf2 Implement -fno-dwarf2-cfi-asm.
llvm-svn: 130616
2011-04-30 18:35:43 +00:00
Devang Patel a3e3fded0a Tie constructor defintion with its declaration using AT_specification.
llvm-svn: 130561
2011-04-29 23:42:32 +00:00
Bob Wilson 9a5f84facb Add -Oz option and use it to set the inline threshold to 25.
Radar 9333566.  Patch by Chad Rosier!

llvm-svn: 130554
2011-04-29 22:49:50 +00:00
Fariborz Jahanian 52a8cca56f removes a meaningless comment.
llvm-svn: 130550
2011-04-29 22:11:28 +00:00
Fariborz Jahanian 99514b9168 block variables on lhs need be ir-gen'ed after the
rhs when its 'forwarding' pointer may be modified 
in rhs evaluation as result of call to Block_copy.
// rdar://9309454

llvm-svn: 130545
2011-04-29 21:53:21 +00:00
David Chisnall 10d2ded910 Don't crash if the AST doesn't have a sensible ObjC id type.
llvm-svn: 130500
2011-04-29 14:10:35 +00:00
Fariborz Jahanian 6d003c3041 Fixes debug info generation problem for ms_struct structs.
// rdar://8823265

llvm-svn: 130458
2011-04-28 23:43:23 +00:00
Argyrios Kyrtzidis 03535265ef Cut down unnecessary zero'ing when value-initializing arrays of C++ objects.
-C++ objects with user-declared constructor don't need zero'ing.
-We can zero-initialize arrays of C++ objects in "bulk" now, in which case don't zero-initialize each object again.

llvm-svn: 130453
2011-04-28 22:57:55 +00:00
Fariborz Jahanian 8409bce4ac ms_struct patch for initialization and field access irgen.
// rdar://8823265 - wip.

llvm-svn: 130451
2011-04-28 22:49:46 +00:00
Stuart Hastings 9f02fd9d8d Raise ARM byval minimum size from 32 to 64, addressing a performance
regression in mason.  rdar://problem/7662569

llvm-svn: 130444
2011-04-28 21:35:59 +00:00
Argyrios Kyrtzidis 9d3c504078 Get the base element type even in multidimensional arrays.
llvm-svn: 130427
2011-04-28 20:07:15 +00:00
Stuart Hastings dd77c8efa2 Replace unitary array with scalar. rdar://problem/7662569
llvm-svn: 130423
2011-04-28 19:24:47 +00:00
Argyrios Kyrtzidis e07425a5e7 When value-initializing the elements of an array not not included in the initializer make sure
that a non-trivial C++ constructor gets called.

Fixes rdar://9347552 & http://llvm.org/PR9801

llvm-svn: 130421
2011-04-28 18:53:58 +00:00
Stuart Hastings 4b21495e42 Replace SmallVector with an array, as suggested by Frits van Bommel. rdar://problem/7662569
llvm-svn: 130417
2011-04-28 18:16:06 +00:00
John McCall a85af56e66 When block-capturing a variable with a non-trivial destructor,
make sure to mark the destructor.  This normally isn't required,
because the destructor should have been marked as part of the
declaration of the local, but it's necessary when the variable
is a parameter because it's the call sites that are responsible
for those destructors.

llvm-svn: 130372
2011-04-28 02:15:35 +00:00
John Wiegley 1c0675e155 Parsing/AST support for Structured Exception Handling
Patch authored by Sohail Somani.

Provide parsing and AST support for Windows structured exception handling.

llvm-svn: 130366
2011-04-28 01:08:34 +00:00
John Wiegley 6242b6a688 Implementation of Embarcadero array type traits
Patch authored by John Wiegley.

These are array type traits used for parsing code that employs certain
features of the Embarcadero C++ compiler: __array_rank(T) and
__array_extent(T, Dim).

llvm-svn: 130351
2011-04-28 00:16:57 +00:00
Stuart Hastings f2752a3938 Re-enable byval for ARM in clang. rdar://problem/7662569
llvm-svn: 130312
2011-04-27 17:24:02 +00:00
Fariborz Jahanian 595ec5d43c Some refactoring of my ms_struct patch.
// rdar://8823265 related.

llvm-svn: 130311
2011-04-27 17:14:21 +00:00
Anders Carlsson c5d3ba1aad When compiling with -fno-threadsafe-statics, guard variables for globals with internal linkage don't have to be i64, i8 works just fine!
llvm-svn: 130286
2011-04-27 04:37:08 +00:00
Fariborz Jahanian bcb23a180b With ms_struct attribut, Zero-length bitfields following
non-bitfield members are ignore. // rdar://8823265 wip

llvm-svn: 130257
2011-04-26 23:52:16 +00:00
Devang Patel e67eca43d6 We need pointer size in bits here.
llvm-svn: 130244
2011-04-26 21:16:49 +00:00
John McCall 0009fcc39e Make yet another placeholder type, this one marking that an expression is a bound
member function, i.e. something of the form 'x.f' where 'f' is a non-static
member function.  Diagnose this in the general case.  Some of the new diagnostics
are probably worse than the old ones, but we now get this right much more
universally, and there's certainly room for improvement in the diagnostics.

llvm-svn: 130239
2011-04-26 20:42:42 +00:00
Daniel Dunbar a59b0a6e3c IRgen/Darwin: Fix refacto introduced in Triple changes.
llvm-svn: 130233
2011-04-26 19:43:00 +00:00
Eric Christopher 6f095d613a Temporarily revert r130176, it appears to have broken a few tests.
llvm-svn: 130179
2011-04-26 01:02:04 +00:00
Devang Patel 420c8de92e Emit intrinsic at current insert point, not at the end of current block.
llvm-svn: 130177
2011-04-25 23:52:27 +00:00
Stuart Hastings 83da03c2ab Turn on byval parameters in Clang for ARM APCS. rdar://problem/7662569
llvm-svn: 130176
2011-04-25 23:48:12 +00:00
Devang Patel 4f325d1f0f Simplify. There is no need to have a method to just call another method.
llvm-svn: 130175
2011-04-25 23:43:36 +00:00
Fariborz Jahanian 24ac1599fc Generalize case for built-in expressions having
side-effect to generate their ir. Not just for
__builtin_expect. // rdar://9330105

llvm-svn: 130172
2011-04-25 23:10:07 +00:00
Fariborz Jahanian 5a866c0bf2 Ir-gen the side-effect(s) when __builtin_expect is
constant-folded. // rdar://9330105

llvm-svn: 130163
2011-04-25 22:30:02 +00:00
John Wiegley f9f6584e95 t/clang/expr-traits
Patch authored by David Abrahams.

These two expression traits (__is_lvalue_expr, __is_rvalue_expr) are used for
parsing code that employs certain features of the Embarcadero C++ compiler.

llvm-svn: 130122
2011-04-25 06:54:41 +00:00
Ken Dyck bb2c24008f Convert size and alignment variables to CharUnits in EmitAggregateCopy(). No
change in functionality intended.

llvm-svn: 130113
2011-04-24 17:37:26 +00:00
Ken Dyck 239a3357af Convert type size and alignment to CharUnits in CheckAggExprForMemSetUse().
No change in functionality intended.

llvm-svn: 130112
2011-04-24 17:25:32 +00:00
Ken Dyck df94cb7dbe Convert the return type of GetNumNonZeroBytesInInit() to CharUnits. No
change in functionality intended.

llvm-svn: 130111
2011-04-24 17:17:56 +00:00
Ken Dyck 3b4bd9a164 Eliminate some literal 8s by converting size variables in EmitGCMove() and
EmitFinalDestCopy() to CharUnits. No change in functionality intended.

llvm-svn: 130110
2011-04-24 17:08:00 +00:00
Ken Dyck a8094505e2 Replace calls to ASTContext::getTypeInfo() with calls to
ASTContext::getTypeSize() when only the size part is used. No change in
functionality intended.

llvm-svn: 130109
2011-04-24 17:02:38 +00:00
Ken Dyck 272b6fa0f0 Simplify AppendTailPadding() by converting its parameter to CharUnits. No
change in functionality intended.

llvm-svn: 130108
2011-04-24 16:53:44 +00:00
Ken Dyck 7a0b19f978 Eliminate literal 8s from LayoutUnionField by converting NumBytesToAppend to
CharUnits. No change in functionality intended.

llvm-svn: 130107
2011-04-24 16:47:33 +00:00
Ken Dyck 345a6de9b4 Eliminate literal 8s from LayoutBitField(), converting variables to
CharUnits or replacing the 8s with char align. No change in functionality
intended.

llvm-svn: 130106
2011-04-24 16:40:29 +00:00
Ken Dyck 27337a8800 Convert AccessInfo::AccessAlignment to CharUnits. No change in functionality
intended.

llvm-svn: 130087
2011-04-24 10:13:17 +00:00
Jay Foad dbf81d8ddf PR9214: Convert the DIBuilder API to use ArrayRef.
llvm-svn: 130086
2011-04-24 10:11:03 +00:00
Ken Dyck f76759c6fa Convert CGBitFieldInfo::FieldByteOffset to CharUnits. No change in
functionality intended.

llvm-svn: 130085
2011-04-24 10:04:59 +00:00
Jay Foad 1a180156b6 Remove unused STL header includes.
llvm-svn: 130068
2011-04-23 19:53:52 +00:00
Devang Patel a6cb0642b2 Tie debug information for method declaration with debug information for method definition.
llvm-svn: 130037
2011-04-23 00:08:01 +00:00
Francois Pichet 1c229c0472 Add -fdelayed-template-parsing option. Using this option all templated function definitions are parsed at the end of the translation unit only if it is required by an actual instantiation. As such all the symbols of the TU are available during name lookup.
Using this flag is necessary for compatibility with Microsoft template code.
This also provides some parsing speed improvement.

llvm-svn: 130022
2011-04-22 22:18:13 +00:00
Fariborz Jahanian c057794adb Fixes an instance method meta-data generation bug in
ObjC NeXt runtime where method pointer registered in
metadata belongs to an unrelated method. Ast part of this fix,
I turned at @end missing warning (for class
implementations) into an error as we can never
be sure that meta-data being generated is correct.
// rdar://9072317

llvm-svn: 130019
2011-04-22 22:02:28 +00:00
Ken Dyck 0fed10e704 Replace a couple of literal 8s with ASTContext::getCharWidth(). No change in
functionality intended.

llvm-svn: 130002
2011-04-22 17:59:22 +00:00
Ken Dyck c5c416f7db Eliminate some literal 8s from EmitNullInitialization() by converting
variables to CharUnits. No change in functionality intended.

llvm-svn: 130001
2011-04-22 17:51:05 +00:00
Ken Dyck bbe3862d95 Eliminate some literal 8s from EmitDeclare by converting to CharUnits. No
change in functionality intended.

llvm-svn: 129999
2011-04-22 17:41:34 +00:00
Ken Dyck 8159c1f2df Use CharUnits to eliminate some literal 8s in
EmitTypeForVarWithBlocksAttr(). No change in functionality intended.

llvm-svn: 129998
2011-04-22 17:34:18 +00:00
Ken Dyck abae3beec5 Replace some literal 8s with char width and char align. No change in
functionality intended.

llvm-svn: 129996
2011-04-22 17:23:43 +00:00
Justin Holewinski bd4a3c03ff PTX: Add default PTX calling conventions
llvm-svn: 129987
2011-04-22 11:10:38 +00:00
Nick Lewycky 207bce31e1 Wire up the -ftest-coverage and -fprofile-arcs flags to .gcno file emission (at
compile time) and .gcda emission (at runtime). --coverage enables both.

This does not yet add the profile_rt library to the link step if -fprofile-arcs
is enabled when linking.

llvm-svn: 129956
2011-04-21 23:44:07 +00:00
Jay Foad ea324f154b PR9214: Convert Metadata API to use ArrayRef.
llvm-svn: 129929
2011-04-21 19:59:12 +00:00
John McCall e0fda7377e The 0.98 revision of the x86-64 ABI clarified a lot of things, some
of which break strict compatibility with previous compilers.  Implement
one of them and then immediately opt out on Darwin.

llvm-svn: 129899
2011-04-21 01:20:55 +00:00
Argyrios Kyrtzidis b2ed28ea4b For
double data[20000000] = {0};

we would blow out the memory by creating 20M Exprs to fill out the initializer.

To fix this, if the initializer list initializes an array with more elements than
there are initializers in the list, have InitListExpr store a single 'ArrayFiller' expression
that specifies an expression to be used for value initialization of the rest of the elements.

Fixes rdar://9275920.

llvm-svn: 129896
2011-04-21 00:27:41 +00:00
Anders Carlsson f03f3ec9dd Don't add type names for enums; they're never used in LLVM IR.
llvm-svn: 129894
2011-04-20 23:51:43 +00:00
Chris Lattner 54fd1a1ad3 fix a crash on code that uses the result value of __builtin___memcpy_chk.
llvm-svn: 129892
2011-04-20 23:14:50 +00:00
Daniel Dunbar 914bc4106c IRgen/ARM: Fix a think-o in conversion-to-null for member function pointers, we
were computing the conversion as (ptr != 0 && non-virtual), when it should be
(ptr != 0 || is-virtual).
 - Test to follow in LLVM test-suite.

llvm-svn: 129830
2011-04-19 23:10:47 +00:00
Chris Lattner 2531eb421f some cleanups to use IRBuilder methods instead of llvm:: foo methods.
llvm-svn: 129829
2011-04-19 22:55:03 +00:00
Daniel Dunbar 14ad22f09d ADT/Triple: Switch to using .isOSDarwin() predicate.
llvm-svn: 129823
2011-04-19 21:43:27 +00:00
Chris Lattner 46f1614d56 use the newly introduced IRBuilder getInt() method to reduce some
redundancy pointed out by John.

llvm-svn: 129808
2011-04-19 20:53:45 +00:00
Devang Patel 43cfa5dce1 Fix typo in comment.
llvm-svn: 129703
2011-04-18 17:30:25 +00:00
Anders Carlsson 566ae67ef8 Get rid of std::vector usage when getting function types in CGException.cpp
llvm-svn: 129698
2011-04-18 14:24:10 +00:00
Anders Carlsson 940f02d248 Clean up code generation of typeid expressions and add C++ standard references.
llvm-svn: 129682
2011-04-18 00:57:03 +00:00
Chris Lattner 97bbee2fb4 Fix a miscompilation I introduced in r129652, thanks for Eli for tracking
it down.  we effectively were compile the testcase into:

void test14(int x) {
  switch (x) {
    case 11: break;
    case 42: test14(97);  // fallthrough
    default: test14(42); break;

which is not the same thing at all.  This fixes a miscompilation of 
MallocBench/gs seen on the clang-x86_64-linux-fnt buildbot.

llvm-svn: 129679
2011-04-17 23:21:26 +00:00
Anders Carlsson fcaaa697ec When laying out bases in, always try the "base subobject" LLVM type. If it
turns out that a field or base needs to be laid out in the tail padding of
the base, CGRecordLayoutBuilder::ResizeLastBaseFieldIfNecessary will convert
it to an array of i8.

I've audited the new test results to make sure that they are still valid. I've
also verified that we pass a self-host with this change.

This (finally) fixes PR5589!

llvm-svn: 129673
2011-04-17 21:56:13 +00:00
Anders Carlsson 56c4d80a4e Add addBaseSubobjectTypeName which isn't used yet.
llvm-svn: 129671
2011-04-17 21:40:34 +00:00
Anders Carlsson c58f8cb7fc Move code to add a type name to a TagDecl type out into a helper function. No functionality change.
llvm-svn: 129669
2011-04-17 21:36:59 +00:00
Anders Carlsson b6d31e7dcc Use a SmallVector for field types in CGRecordLayoutBuilder now that llvm::StructType::get takes an ArrayRef.
llvm-svn: 129667
2011-04-17 21:32:41 +00:00
Eli Friedman 2e2ff8894d Hack to turn the valgrind buildbot green, until Devang can address it
properly.

llvm-svn: 129657
2011-04-17 06:40:15 +00:00
Chris Lattner bc204c8043 implement rdar://9289524 - case followed immediately by break results in empty IR block,
a -O0 code quality issue.

llvm-svn: 129652
2011-04-17 00:54:30 +00:00
Chris Lattner 30107ed600 fold memcpy/set/move_chk to llvm.memcpy/set/move when the sizes
are trivial.  This exposes opportunities earlier, and allows fastisel
to do good things with these at -O0.

This addresses rdar://9289468 - clang doesn't fold memset_chk at -O0

llvm-svn: 129651
2011-04-17 00:40:24 +00:00
Chris Lattner 56784f9de6 fix rdar://9289603 - clang should fold trivial ?: for enums as well as integer constants into select at -O0
by making the isCheapEnoughToEvaluateUnconditionally predicate handle anything that folds to a constant.  In particular, we now fold enums.

llvm-svn: 129649
2011-04-16 23:15:35 +00:00
Devang Patel 7294d74627 Emit proper selector name in debug info.
llvm-svn: 129626
2011-04-16 00:37:51 +00:00
Devang Patel 9d6c857862 Emit debug info for Objective-C properties.
llvm-svn: 129625
2011-04-16 00:12:55 +00:00
Michael J. Spencer 6826eb816a Add 3DNow! Intrinsics.
llvm-svn: 129570
2011-04-15 15:07:13 +00:00
Richard Smith dda56e4b4a Support for C++11 (non-template) alias declarations.
llvm-svn: 129567
2011-04-15 14:24:37 +00:00
Chris Lattner 57540c5be0 fix a bunch of comment typos found by codespell. Patch by
Luis Felipe Strano Moraes!

llvm-svn: 129559
2011-04-15 05:22:18 +00:00
Peter Collingbourne 9114759641 C1X: implement generic selections
As an extension, generic selection support has been added for all
supported languages.  The syntax is the same as for C1X.

llvm-svn: 129554
2011-04-15 00:35:48 +00:00
Richard Smith 02e85f3bc5 Add support for C++0x's range-based for loops, as specified by the C++11 draft standard (N3291).
llvm-svn: 129541
2011-04-14 22:09:26 +00:00
Anton Korobeynikov 231e875b5c Implement ARM pcs attribute. Basically it's another way of calling convention selection (AAPCS or
AAPCS+VFP), similar to fastcall / stdcall / whatevercall seen on x86.

In particular, all library functions should always be AAPCS regardless of floating point ABI used.

llvm-svn: 129534
2011-04-14 20:06:49 +00:00
Ken Dyck 3563aa6520 Replace a couple of divide-by-8s with divide-by-charwidths. No change in
functionality intended.

llvm-svn: 129496
2011-04-14 01:00:39 +00:00
Ken Dyck c5ca87675e Replace a couple of divisions-by-'8' with divisions-by-charwidth. No change
in functionality intended.

llvm-svn: 129491
2011-04-14 00:43:09 +00:00
Bill Wendling a865185ad6 Removing the unaligned load tests from builtins-x86.c since they're generated by a regular 'load' now.
llvm-svn: 129464
2011-04-13 20:17:22 +00:00
Bill Wendling 88ae43772a It looks like the FreeBSD buildbot needs this for the builtins-x86.c test.
llvm-svn: 129433
2011-04-13 10:02:54 +00:00
Bill Wendling b9c9e34cb3 Just use a native "load" instead of translating the builtin later. Clang can
take it!

I wasn't able to get __builtin_ia32_loaddqu to transform into an unaligned
load...I'll have to look into it further.

llvm-svn: 129427
2011-04-13 05:58:17 +00:00
Anders Carlsson bbe277c4a9 Use EmitCallOrInvoke in EmitBadTypeidCall and EmitBadCastCall.
llvm-svn: 129424
2011-04-13 02:35:36 +00:00
Bill Wendling 3137d3cb49 Convert the unaligned load builtins to the first-class versions.
llvm-svn: 129420
2011-04-13 00:36:37 +00:00
Daniel Dunbar 9c8cd4c097 IRgen/Obj-C: Emit CFStrings and NSStrings with the alignment of the char type,
there is no reason to align them higher.
 - This roughly matches llvm-gcc's r126913.
 - It is an open question whether or not we should do this for cstring's in
   general (code size vs optimization potential), for now we just match llvm-gcc
   until someone wants to run some experiments.

llvm-svn: 129410
2011-04-12 23:30:52 +00:00
John McCall 58989b7125 We can't emit an aggregate cast as its sub-expression in general just
because the result is ignored.  The particular example here is with
property l-values, but there could be all sorts of lovely casts that this
isn't safe for.  Sink the check into the one case that seems to actually
be capable of honoring this.

llvm-svn: 129397
2011-04-12 22:02:02 +00:00
John McCall a97f329869 Template static data members can have weak_odr linkage, not just
weak linkage.  Also, fix a problem where global weak variables
with non-trivial initializers were getting guard variables, or at
least were checking for them and then crashing.

llvm-svn: 129342
2011-04-12 01:46:54 +00:00
John McCall 32f44bd0fc Ignore indirect field declarations. Fixes PR9570.
llvm-svn: 129337
2011-04-12 01:01:22 +00:00
John McCall 2979fe01da After some discussion with Doug, we decided that it made a lot more sense
for __unknown_anytype resolution to destructively modify the AST.  So that's
what it does now, which significantly simplifies some of the implementation.
Normal member calls work pretty cleanly now, and I added support for
propagating unknown-ness through &.

llvm-svn: 129331
2011-04-12 00:42:48 +00:00
Anders Carlsson 0c63350b0b If there's an invoke destination, we should use invoke instead of call when calling the __cxa_bad_typeid function. Fixes PR7400.
llvm-svn: 129273
2011-04-11 14:13:40 +00:00
John McCall 2d2e870745 More __unknown_anytype work.
llvm-svn: 129269
2011-04-11 07:02:50 +00:00
Anders Carlsson 8a01a751c9 Remove CK_DynamicToNull.
llvm-svn: 129265
2011-04-11 02:03:26 +00:00
Anders Carlsson c1c9971cab When we know that a dynamic_cast always returns null, we can make
CodeGenFunction::EmitDynamicCast always return null or throw a bad_cast 
exception.

llvm-svn: 129264
2011-04-11 01:45:29 +00:00
Anders Carlsson 882d790f72 Clean up CodeGenFunction::EmitDynamicCast. No functionality change.
llvm-svn: 129262
2011-04-11 00:46:40 +00:00
Anders Carlsson 98981b10c8 Replace a couple of Builder.CreateICmpEQ with Builder.CreateIsNull. No functionality change.
llvm-svn: 129261
2011-04-11 00:30:07 +00:00
Anders Carlsson c602006638 As a first step towards fixing PR9641, add a CK_DynamicToNull cast kind which
represents a dynamic cast where we know that the result is always null.

For example:

struct A {
  virtual ~A();
};
struct B final : A { };
struct C { };

bool f(B* b) {
  return dynamic_cast<C*>(b);
}

llvm-svn: 129256
2011-04-10 20:33:22 +00:00
Anders Carlsson c53d9e8350 Strip off parens and no-op casts when deciding if an expr can be devirtualized. Fixes the second half of PR9660.
llvm-svn: 129253
2011-04-10 18:20:53 +00:00
Anders Carlsson e5ec21c977 Change CollectPrimaryBases to collect the bases in the right order. Fixes one half of PR9660.
llvm-svn: 129252
2011-04-10 18:00:32 +00:00
Anders Carlsson 68aad14dd3 Make -fdump-vtable-layouts also dump vtable indices for all virtual member functions in the class.
llvm-svn: 129250
2011-04-10 17:42:45 +00:00
Eli Friedman 493c34a86c PR9580: Handle vectors correctly in ScalarExprEmitter::EmitRem.
While I'm here, FileCheck-ize the ext-vector test, so we actually check
what it is generating.

llvm-svn: 129241
2011-04-10 04:44:11 +00:00
Eli Friedman db42a3e876 Make sure we or together the overflow flags of the multiply and add, so the
check is triggered appropriately.  Reported on cfe-dev.

llvm-svn: 129231
2011-04-09 19:54:33 +00:00
Eli Friedman c5b20b5283 PR8369: make __attribute((regparm(0))) work correctly. Original patch by
pageexec@freemail.hu, tweaks by me.

llvm-svn: 129206
2011-04-09 08:18:08 +00:00
Chris Lattner e4ec5abf1b fix indentation
llvm-svn: 129202
2011-04-09 07:11:53 +00:00
Chris Lattner 9cb59fa834 add a __sync_swap builtin to fill out the rest of the __sync builtins.
Patch by Dave Zarzycki!

llvm-svn: 129189
2011-04-09 03:57:26 +00:00
Ken Dyck df01628e08 Convert the PointerWidthInBytes variable in EmitMemberPointer() to CharUnits
to eliminate a divide-by-8. No change in functionality intended.

llvm-svn: 129180
2011-04-09 01:30:02 +00:00
Ken Dyck 499e93d7ee Eliminate a divide-by-8 in BuildVMIClassTypeInfo() by using CharUnits for
the base offset. No change in functionality intended.

llvm-svn: 129179
2011-04-09 01:09:56 +00:00
Nick Lewycky d85ae78c48 Apply explicit braces to avoid ambiguous 'else' [-Wparentheses]
llvm-svn: 129176
2011-04-09 00:25:15 +00:00
Devang Patel 0b37e79891 Do not use zero as an upper bound for unbounded array because upper bound zero also indicates one element array.
llvm-svn: 129157
2011-04-08 21:56:52 +00:00
Ken Dyck bb4e977218 [Reapply r128776, modified so that it does not break debug info.]
Change the return type of CodeGenVTables::getVirtualBaseOffsetOffset() to
CharUnits. No change in functionality intended.

llvm-svn: 129072
2011-04-07 12:37:09 +00:00
John McCall 319963434c Basic, untested implementation for an "unknown any" type requested by LLDB.
The idea is that you can create a VarDecl with an unknown type, or a
FunctionDecl with an unknown return type, and it will still be valid to
access that object as long as you explicitly cast it at every use.  I'm
still going back and forth about how I want to test this effectively, but
I wanted to go ahead and provide a skeletal implementation for the LLDB
folks' benefit and because it also improves some diagnostic goodness for
placeholder expressions.

llvm-svn: 129065
2011-04-07 08:22:57 +00:00
Ken Dyck 3a09bc5ab0 [Reapply r128773. This is not the source of the issues Devang was seeing
with debug info.]

Use CharUnits for the offsets in the VirtualBaseClassOffsetOffsetsMapTy. No
change in functionality intended.

llvm-svn: 129048
2011-04-07 01:22:42 +00:00
Ken Dyck 25c82240e9 [Reapply r128771. It wasn't the source of the issues Devang saw with debug
info.]

Use CharUnits for the offset type in the ClassNamesAndOffsets map in
dumpLayout(). No change in functionality intended.

llvm-svn: 129046
2011-04-07 00:59:42 +00:00
Ken Dyck 42a9d29c2c Reapply r128770. It's not the cause of the issues Devang saw with debug info.
Use CharUnits for the offsets in the VBaseOffsetOffsetsMapTy types. No
change in functionality intended.

llvm-svn: 129043
2011-04-07 00:55:01 +00:00
Fariborz Jahanian 5de5313abe Refine rules for atomic property api to
pass a previously failing clang test.
// rdar://8808439

llvm-svn: 129004
2011-04-06 16:05:26 +00:00
Peter Collingbourne eafa4e4b5b If this is an intrinsic function, set the function's attributes to the intrinsic's attributes.
llvm-svn: 129000
2011-04-06 12:29:04 +00:00
Devang Patel 78019ec14d Simplify.
llvm-svn: 128957
2011-04-05 23:26:36 +00:00
Fariborz Jahanian 10a95ca876 Fixes a regression caused by my last patch.
As a result, I had to remove a c++ version of a clang
test which requires more scrutiny on my part.

llvm-svn: 128950
2011-04-05 23:01:27 +00:00
Devang Patel b87c428055 Emit debug info for function template parameters.
llvm-svn: 128948
2011-04-05 22:54:11 +00:00
Fariborz Jahanian 0f4c711895 Generate atomic api for atomic properties (x86 and x86_64
targets) when load/store results in multiple instructions.
// rdar://8808439

llvm-svn: 128937
2011-04-05 21:41:23 +00:00
Devang Patel e1dd424380 Remove unintentional check-in.
llvm-svn: 128928
2011-04-05 21:05:56 +00:00
Devang Patel 095421b4a8 Fix typo.
llvm-svn: 128921
2011-04-05 20:28:21 +00:00
Devang Patel 98d26c91da Use TemplateParameterList to extract template parameter name.
llvm-svn: 128915
2011-04-05 20:15:06 +00:00
Andrew Trick 15e36e8edd Added *hidden* flags -print-options and -print-all-options so
developers can see if their driver changed any cl::Option's. The
current implementation isn't perfect but handles most kinds of
options. This is nice to have when decomposing the stages of
compilation and moving between different drivers. It's also a good
sanity check when comparing results produced by different command line
invocations that are expected to produce the comparable results.

Note: This is not an attempt to prolong the life of cl::Option. On the
contrary, it's a placeholder for a feature that must exist when
cl::Option is replaced by a more appropriate framework. A new
framework needs: a central option registry, dynamic name lookup,
non-global containers of option values (e.g. per-module,
per-function), *and* the ability to print options values and their defaults at
any point during compilation.

llvm-svn: 128911
2011-04-05 18:56:55 +00:00
Andrew Trick b2a84726f6 whitespace
llvm-svn: 128908
2011-04-05 18:49:32 +00:00
Devang Patel 7522abd3ce Refactor.
llvm-svn: 128893
2011-04-05 17:30:54 +00:00
David Chisnall ec343e8544 Fix copy-and-paste bug that I introduced while tidying up the code.
Does anyone want to buy me a new brain?

llvm-svn: 128890
2011-04-05 17:15:18 +00:00
Sandeep Patel 45df3dd3fe Set AAPCS-VFP calling convention accordingly and hard float ABI command handling.
llvm-svn: 128866
2011-04-05 00:23:47 +00:00
Devang Patel 44927690c3 Eliminate conservative check that is covered by isIncompleteType() check.
llvm-svn: 128857
2011-04-04 23:23:39 +00:00
Devang Patel a540f1462c Incomplete type does not have any size.
llvm-svn: 128855
2011-04-04 23:18:38 +00:00