Граф коммитов

5413 Коммитов

Автор SHA1 Сообщение Дата
Eli Friedman ec24b0ed9c Fix r137086 to actually work properly in general. PR10650.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137574 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-14 04:50:34 +00:00
Francois Pichet af0f4d0b2e Implement function template specialization at class scope extension in Microsoft mode. A new AST node is introduced: ClassScopeFunctionSpecialization. This node holds a FunctionDecl that is not yet specialized; then during the class template instantiation the ClassScopeFunctionSpecialization will spawn the actual function specialization.
Example:
template <class T>
class A {
public:
  template <class U> void f(U p) {  }
  template <> void f(int p) {  } // <== class scope specialization
};

This extension is necessary to parse MSVC standard C++ headers, MFC and ATL code.
BTW, with this feature in, clang can parse (-fsyntax-only) all the MSVC 2010 standard header files without any error.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137573 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-14 03:52:19 +00:00
Bob Wilson 83bbba1fc9 Move handling of vget_lane/vset_lane before the code that checks the type.
Unlike most of the other Neon intrinsics, these are not overloaded and do not
have the extra argument that specifies the vector type.  This has not been
fatal because the lane number operand is supposed to be an ICE and so that
value has harmlessly been used as the type identifier.  Radar 9901281.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137550 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-13 05:03:46 +00:00
Chris Lattner c1c20114a4 switch clang to use the new-new way of creating llvm::StructType's.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137472 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 17:43:31 +00:00
Akira Hatanaka 7b0a0383ef Alignment of a va_arg must be at least as large as the ABI's minimum alignment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137420 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 02:30:14 +00:00
Akira Hatanaka 3827e42982 Add definition of a static member of a class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137411 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 01:43:14 +00:00
Douglas Gregor 01a4cf1177 Encapsulate the Objective-C id/Class/SEL "redefinition" types in
ASTContext with accessors/mutators. The only functional change is that
the AST writer won't bother writing the id/Class/SEL redefinition type
if it hasn't been explicitly set; previously, it ended up being
written as a synonym for the built-in id/Class/SEL.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137349 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-11 20:58:55 +00:00
John McCall 777d6e56ad Simplify EH control flow by observing that EH scopes form a simple
hierarchy of delegation, and that EH selector values are meaningful
function-wide (good thing, too, or inlining wouldn't work).
2,3d
1a
hierarchy of delegation and that EH selector values have the same
meaning everywhere in the function instead of being meaningful only
in the context of a specific selector.

This removes the need for routing edges through EH cleanups,
since a cleanup simply always branches to its enclosing scope.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137293 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-11 02:22:43 +00:00
John McCall e7d002041d Formatting.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137200 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 04:11:11 +00:00
Eli Friedman 03f486168f Revert bad change. (It may look equivalent, but it isn't.)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137132 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-09 18:16:09 +00:00
Eli Friedman c55db3b76d Cleanup; no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137126 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-09 17:38:12 +00:00
Douglas Gregor 0815b579b3 Move the creation of the record type for the state of Objective-C fast
enumerations from the ASTContext into CodeGen, so that we don't need
to serialize it to AST files. This appears to be the last of the
low-hanging fruit for SpecialTypes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137124 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-09 17:23:49 +00:00
Douglas Gregor 45c4ea75b2 Move the construction of the RecordDecl representing the runtime
layout of a constant NSString from the ASTContext over to CodeGen,
since this is solely CodeGen's responsibility. Eliminates one of the
unnecessary "special" types that we serialize.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137121 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-09 15:54:21 +00:00
Douglas Gregor 3f86ce1dc6 Hand materialization of temporary expressions when emitting a scalar
expression. Fxies PR10592.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137086 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-09 00:37:14 +00:00
David Chisnall 4bd5d09e3a Fix typo so we don't use the wrong function for ending ObjC++ catch blocks (GNU runtimes)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137052 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-08 17:26:06 +00:00
John McCall f66a3ea859 Avoid fallthrough-branching to an inactive cleanup even if it's
otherwise required.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137029 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-07 07:05:57 +00:00
John McCall 82cd2e5c15 Be sure to destroy the normal entry block of a cleanup that we
aren't actually going to make a normal cleanup for.  Sometimes
we optimistically create branches to such blocks for fixups,
and then we resolve the fixup to somewhere within the cleanup's
scope, and then the cleanup is actually not reachable for some
reason.  The process of resolving the fixup leaves us with
switches whose default edge leads to the cleanup;  we can
replace that with unreachable, then (in many cases) turn
the switch into an unconditional branch.

Fixes PR10467.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137011 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-06 06:53:52 +00:00
John McCall 4b302d3237 The continue label in an ARC for-in loop should not involve
releasing the collection.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136949 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-05 00:14:38 +00:00
John McCall a5e19c6b25 Emit wide string literals with the appropriate alignment.
Patch by Craig Topper and Sundeep!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136856 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-04 01:03:22 +00:00
John McCall bddfd87863 Use the general conditional-cleanup framework instead of rolling our
own, incorrectly, for releasing objects at the end of a full-expression.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136823 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-03 22:24:24 +00:00
Bob Wilson 194f06a476 Handle "homogeneous aggregates" as required by the ARM AAPCS-VFP ABI.
A homogeneous aggregate is an aggregate data structure where after flattening
any nesting there are 1 to 4 elements of the same base type that is either a
float, double, or Neon vector.  All Neon vectors of the same size, either 64
or 128 bits, are treated as equivalent for this purpose.  When using the
AAPCS-VFP ABI, check for homogeneous aggregates and pass them as arguments by
expanding them into a sequence of their base types.  This requires extending
the existing support for expanded arguments to handle not only structs, but
also constant arrays and complex types.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136767 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-03 05:58:22 +00:00
John McCall 40f9c302f2 When rewriting a call to a K&R function to lead to a well-prototyped
function, be sure to drop parameter attributes when dropping their
associated arguments.  Patch by Aaron Landwehr!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136753 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-03 00:43:55 +00:00
Rafael Espindola e164c18052 Implements alignment for long long and double types in va_arg on ARM AAPCS.
Patch by Jim (Ningjie) Chen.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136734 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-02 22:33:37 +00:00
Rafael Espindola cf565c5737 Update for LLVM change in PassManagerBuilder.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136728 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-02 21:51:02 +00:00
Eli Friedman aebab72698 PR10566: Make sure codegen for deleting an pointer to an incomplete type actually works.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136703 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-02 18:05:30 +00:00
Bob Wilson 53fc1a6151 Revert "Re-enable byval for ARM in clang. rdar://problem/7662569"
This reverts commit 67d097e123.
We found a miscompile with ARM byval, which is still being investigated.
In the meantime, this works around the problem by disabling ARM byval.

Conflicts:
	lib/CodeGen/TargetInfo.cpp

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136662 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-01 23:39:04 +00:00
Akira Hatanaka c35e69d758 Implement MipsABIInfo::EmitVAArg. This fix enables clang to complete compilation
without bailing out when va_arg is an aggregate expression. However, 
alignment checking needs to be added in isSafeToEliminateVarargsCast in
InstCombineCalls.cpp in order to produce correct mips code (see link below).

http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-July/042047.html





git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136647 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-01 20:48:01 +00:00
Akira Hatanaka 511949bf7e Pass records with non-trivial destructors or constructors indirectly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136630 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-01 18:09:58 +00:00
David Chisnall 3fc81d3231 Fix linkage type for tentative definition of ivar offset variables (GNUstep runtime)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136628 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-01 17:36:53 +00:00
Jay Foad da549e8995 Remove some unnecessary single element array temporaries.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136461 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-29 13:56:53 +00:00
Peter Collingbourne 93f1322684 Fix assertion failure in CodeGen where the input operand to an asm
instruction is tied to an output operand which is a pointer, and
the input operand is narrower than the output operand.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136438 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-29 00:24:50 +00:00
John McCall fb7208119a Fix a couple of problems with initialization and assignment to
__block variables where the act of initialization/assignment
itself causes the __block variable to be copied to the heap
because the variable is of block type and is being assigned
a block literal which captures the variable.

rdar://problem/9814099



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136337 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 07:23:35 +00:00
John McCall 07524039dc The lock operand to an @synchronized statement is also
supposed to be a full-expression;  make it so.  In ARC, make sure
we retain the lock for the entire protected block. 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136271 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 21:50:02 +00:00
Peter Collingbourne e926523105 CodeGen: rename CodeGenModule::Runtime to ObjCRuntime
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136254 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 20:29:46 +00:00
Eli Friedman 91873b72bf Make CodeGen for array delete involving incomplete class work without crashing. Should fix regression on g++.dg/init/delete1.C.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136241 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 18:54:57 +00:00
Douglas Gregor 5cee119558 Add support for C++0x unicode string and character literals, from Craig Topper!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136210 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 05:40:30 +00:00
John McCall 990567cb60 Clean up the analysis of the collection operand to ObjC
for-in statements;  specifically, make sure to close over any
temporaries or cleanups it might require.  In ARC, this has
implications for the lifetime of the collection, so emit it
with a retain and release it upon exit from the loop.

rdar://problem/9817306



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136204 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 01:07:15 +00:00
Douglas Gregor 3e23d68e2e Disable the optimization that skips emission of complete, non-virtual
destructors of abstract classes. It's undefined behavior to actually
call the destructor (e.g., via delete), but the presence of code that
calls this destructor doesn't make the program
ill-formed. Fixes <rdar://problem/9819242>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136180 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 23:18:30 +00:00
Chandler Carruth 642116259e Rename getInstantiationLineNumber to getExpansionLineNumber in both
SourceManager and FullSourceLoc.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135969 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-25 21:09:52 +00:00
Chandler Carruth 402785357a Mechanically rename SourceManager::getInstantiationLoc and
FullSourceLoc::getInstantiationLoc to ...::getExpansionLoc. This is part
of the API and documentation update from 'instantiation' as the term for
macros to 'expansion'.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135914 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-25 16:49:02 +00:00
Frits van Bommel 1cbac8ac44 Shorten some expressions by using ArrayRef::slice().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135910 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-25 15:13:01 +00:00
Chris Lattner 9f5bff086c fix PR10415, tidying up IR representation of module level inline asm
to avoid extraneous \n's.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135862 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-23 20:04:25 +00:00
Chris Lattner 2d3ba4f5a9 Move ArrayRef to LLVM.h and eliminate now-redundant qualifiers, patch by Jon Mulder!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135855 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-23 17:14:25 +00:00
Chris Lattner 5f9e272e63 remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports
them into the clang namespace.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135852 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-23 10:55:15 +00:00
Chris Lattner d47d3b0cfe clean up forward declarations of raw_ostream to use the new LLVM.h
patch by Jon Mulder!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135851 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-23 10:35:09 +00:00
John McCall dc7c5ad7a1 Document the existing objc_precise_lifetime attribute.
Introduce and document a new objc_returns_inner_pointer
attribute, and consume it by performing a retain+autorelease
on message receivers when they're not immediately loaded from
an object with precise lifetime.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135764 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 08:53:00 +00:00
Jay Foad 0f6ac7cf7b Convert IRBuilder::CreateGEP and IRBuilder::CreateInBoundsGEP to use
ArrayRef.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135761 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 08:16:57 +00:00
Chris Lattner 01c5d1ddc8 fix PR10384: C++ allows external arrays of incomplete type as well.
Many thanks to Eli for reducing this great testcase.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135752 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 06:27:26 +00:00
John McCall ba3dd902d1 In ARC, non-atomic getters do not need to retain and autorelease
their loaded values, although it still worth doing this for __weak
properties to get the autoreleased-return-value optimization.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135747 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 05:23:13 +00:00
Jordy Rose db8264e4c5 Add a const overload for ObjCInterfaceDecl::all_declared_ivar_begin.
This was previously not-const only because it has to lazily construct a chain
of ivars the first time it is called (and after the chain is invalidated).
In practice, all the clients were just const_casting their const Decls;
all those now-unnecessary const_casts have been removed.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135741 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 02:08:32 +00:00
Jay Foad a5c04344fa Convert ConstantExpr::getGetElementPtr and
ConstantExpr::getInBoundsGetElementPtr to use ArrayRef.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135673 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-21 14:31:17 +00:00
Benjamin Kramer 77577ce8f0 Unbreak build after API change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135585 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-20 14:43:06 +00:00
Chris Lattner 8cc488fefb add raw_ostream and Twine to LLVM.h, eliminating a ton of llvm:: qualifications.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135577 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-20 07:06:53 +00:00
Chris Lattner 686775deca now that we have a centralized place to do so, add some using declarations for
some common llvm types: stringref and smallvector.  This cleans up the codebase
quite a bit.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135576 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-20 06:58:45 +00:00
Chris Lattner b13eab95e1 fix rdar://9780211 - Clang crashes with an assertion failure building WKView.mm from WebKit
This is something of a hack, the problem is as follows:

1. we instantiate both copied of RetainPtr with the two different argument types
   (an id and protocol-qualified id).
2. We refer to the ctor of one of the instantiations when introducing global "x",
   this causes us to emit an llvm::Function for a prototype whose "this" has type
   "RetainPtr<id<bork> >*".
3. We refer to the ctor of the other instantiation when introducing global "y",
   however, because it *mangles to the same name as the other ctor* we just use
   a bitcasted version of the llvm::Function we previously emitted.
4. We emit deferred declarations, causing us to emit the body of the ctor, however
   the body we emit is for RetainPtr<id>, which expects its 'this' to have an IR
   type of "RetainPtr<id>*".

Because of the mangling collision, we don't have this case, and explode.

This is really some sort of weird AST invariant violation or something, but hey
a bitcast makes the pain go away.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135572 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-20 06:29:00 +00:00
Chris Lattner 181eeee36b fix a case where we're using ConvertType for a memory object.
It doesn't matter in practice, but it is good to be tidy.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135571 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-20 06:23:59 +00:00
Chris Lattner cb8095f766 as eli points out, we're not doing memory stuff here. While ConvertType
and ConvertTypeForMem are the same for pointers, it is best to just
use ConvertType.  Thanks Eli!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135567 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-20 04:59:57 +00:00
Chris Lattner 410b12e553 fix PR10395 - array decay can produce an interesting type when
decaying an array of incomplete type (which has type [0 x i8]*) to a
normal pointer (which has incompletetype*).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135565 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-20 04:31:01 +00:00
Evan Cheng 2860e30d83 Match createTargetMachine API change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135469 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-19 06:37:41 +00:00
Devang Patel cb2a07e337 Simplify.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135456 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-19 00:52:18 +00:00
Devang Patel 478b94b945 Check column number also.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135437 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-18 22:18:04 +00:00
Frits van Bommel e9c0265d6e Migrate LLVM and Clang to use the new makeArrayRef(...) functions where previously explicit non-default constructors were used.
Mostly mechanical with some manual reformatting.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135390 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-18 12:00:32 +00:00
Nick Lewycky dce67a70a8 In C99, emit an inline function when encountering an extern redeclaration.
Fixes PR10233!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135377 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-18 05:26:13 +00:00
Chris Lattner 2acc6e3fed de-constify llvm::Type, patch by David Blaikie!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135370 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-18 04:24:23 +00:00
Joerg Sonnenberger e9b5d77b7b Fix typo
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135285 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 18:23:44 +00:00
Jay Foad 4c7d9f1507 Convert CallInst and InvokeInst APIs to use ArrayRef.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135265 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 08:37:34 +00:00
John McCall 379010addb Fix the definition of AsTypeExpr. I'm still not sure this
is right --- shouldn't there be a TypeLoc in here somewhere? ---
but at least it doesn't have a redundant QualType and a broken
children() method.

Noticed this while doing things in serialization.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135257 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 06:56:33 +00:00
Chris Lattner d26c071427 protect some calls to ConvertType when a function info is under construction
to prevent recursive compilation problems.  This fixes a failure of CodeGen/decl.c
on x86-32 targets that don't fill in the coerce-to type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135256 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 06:41:05 +00:00
Chris Lattner 71305cc81b Enhance the IR type lowering code to be much smarter about recursively lowering
types.  Fore xample, we used to lower:

struct bar { int a; };
struct foo {
 void (*FP)(struct bar);
} G;

to:

%struct.foo = type { {}* }

since the function pointer would cause recursive translation of bar and
we didn't know if that would get us into trouble.  We are now smart enough
to know that it is fine, so we get this type instead:

%struct.foo = type { void (i32)* }

Codegen still needs to be prepared for uncooperative types at any place,
which is why I let the maximally uncooperative code sit around for awhile to
help shake out the bugs.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135244 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 05:16:14 +00:00
John McCall 91a5755ad7 Create a new expression node, SubstNonTypeTemplateParmExpr,
to represent a fully-substituted non-type template parameter.
This should improve source fidelity, as well as being generically
useful for diagnostics and such.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135243 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 05:09:51 +00:00
Benjamin Kramer 8dd55a3c3b Change intrinsic getter to take an ArrayRef, now that the underlying function in LLVM does.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135155 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-14 17:45:50 +00:00
Bruno Cardoso Lopes b8981df0ed Reapply r134946 with fixes. Tested on Benjamin testcase and other test-suite failures.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135091 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 21:58:55 +00:00
Devang Patel d15608e986 Emit debug info for extended vectors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135083 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 21:23:30 +00:00
John McCall 799d34e950 Don't crash if defining -dealloc in a category.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135054 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 18:26:47 +00:00
John McCall fbf780a9d1 Okay, that rule about zero-length arrays applies to destroying
them, too.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135038 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 08:09:46 +00:00
John McCall dd376cae98 Arrays are permitted to be zero-length in some situations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135036 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 07:37:11 +00:00
John McCall c3c0766277 Convert the standard default-construction loops to use phis and
partial destruction.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135033 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 06:10:41 +00:00
Chris Lattner 2045b2dd6a per john's advice, speculatively lower uses of forward-declared enums to
i32.  They almost always end up this way in the end anyway, and if we get
lucky, this avoids generating some bitcasts.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135032 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 05:31:19 +00:00
Chris Lattner 6af13f3a35 PR10337 reminds me that calls return values, lets handle them just
like arguments.  Thanks PR10337! :)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135030 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 03:59:32 +00:00
John McCall 8f62992730 Aggressive dead code elimination.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135029 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 03:03:51 +00:00
John McCall a91f6661c4 Generalize the routine for destroying an object with static
storage duration, then explicitly exempt ownership-qualified
types from it.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135028 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 03:01:35 +00:00
John McCall 7cfd76cb5c Switch delete[] IR-generation over to the destroy framework,
which implicitly makes it EH-safe as well.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135025 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 01:41:37 +00:00
Douglas Gregor a8b20f70d5 When compiling ::delete for a class with a virtual destructor, call
the complete destructor and then invoke the global delete
operator. Previously, we would invoke the deleting destructor, which
calls the wrong delete operator. Fixes PR10341.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135021 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 00:54:47 +00:00
Bruno Cardoso Lopes 548e478b8b Revert r134946
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135004 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 22:30:58 +00:00
John McCall ad346f4f67 Generalize Cleanup::Emit's "isForEH" parameter into a set
of flags.  No functionality change.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134997 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 20:27:29 +00:00
Benjamin Kramer 0d516767a3 Add more compiler workarounds. Should fix the build with old GCCs and MSVC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134995 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 18:37:23 +00:00
John McCall 5bcd95efc3 Ugh, use this compiler workaround again.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134989 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 16:53:04 +00:00
John McCall 9928c4805a Switch field destruction over to use the new destroyer-based API
and kill a lot of redundant code.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134988 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 16:41:08 +00:00
Jay Foad df983a8bcb Second attempt at de-constifying LLVM Types in FunctionType::get(),
StructType::get() and TargetData::getIntPtrType().

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134982 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 14:06:48 +00:00
Chandler Carruth a98742c32c Work around a problem with a static helper's formulation in release
builds introduced in r134972:

lib/CodeGen/CGExpr.cpp:1294:7: error: no matching function for call to 'EmitBitCastOfLValueToProperType'
lib/CodeGen/CGExpr.cpp:1278:1: note: candidate function not viable: no known conversion from 'CGBuilderTy' (aka 'IRBuilder<false>') to 'llvm::IRBuilder<> &' for 1st argument

This fixes the issue by passing CodeGenFunction on down, and using its
builder directly rather than passing just the builder down.

This may not be the best / cleanest fix, Chris please review. It at
least fixes builds.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134977 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 08:58:26 +00:00
Chris Lattner 3a2b657088 Fix a problem Eli ran into where we now reject incomplete arrays of
uncompleted struct types.  We now do what llvm-gcc does and compile
them into [i8 x 0].  If the type is later completed, we make sure that
it is appropriately cast.

We compile the terrible example to something like this now:

%struct.A = type { i32, i32, i32 }

@g = external global [0 x i8]

define void @_Z1fv() nounwind {
entry:
  call void @_Z3fooP1A(%struct.A* bitcast ([0 x i8]* @g to %struct.A*))
  ret void
}

declare void @_Z3fooP1A(%struct.A*)

define %struct.A* @_Z2f2v() nounwind {
entry:
  ret %struct.A* getelementptr inbounds ([0 x %struct.A]* bitcast ([0 x i8]* @g to [0 x %struct.A]*), i32 0, i64 1)
}





git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134972 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 06:52:18 +00:00
Chris Lattner 811bf3669f insert a bitcast in the 'expand' case of argument passing when needed. This
fixes the -m32 build of oggenc.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134971 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 06:29:11 +00:00
Chris Lattner cd87d1e4d1 fix an unintended behavior change in the type system rewrite, which caused us to compile
stuff like this:

typedef struct {
 int x, y, z; 
} foo_t;

foo_t g;

into:
%"struct.<anonymous>" = type { i32, i32, i32 }
we now get:
%struct.foo_t = type { i32, i32, i32 }

This doesn't change the behavior of the compiler, but makes the IR much easier to read.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134969 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 05:53:08 +00:00
Chris Lattner 21ca1fdb25 fix PR10335 by watching out for IR type compatibility in call argument lists.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134966 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 04:53:39 +00:00
Chris Lattner 7085544985 add some aggressive assertions that call arguments match up to callee
expectations in EmitCall.  Next patch will take this further.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134962 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 04:46:18 +00:00
Bruno Cardoso Lopes 75d28b58d9 Fix a typo!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134952 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 02:47:38 +00:00
Bruno Cardoso Lopes 089d8927ab Do the same as r134946 for arrays. Add more testcases for avx x86_64 arg
passing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134951 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 01:27:38 +00:00
Bill Wendling e455f1c32b 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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134950 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 01:16:47 +00:00
Bruno Cardoso Lopes ccafadb68f 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134946 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 00:30:27 +00:00
John McCall c4a1a8450a Do full-expression cleanups in a much more sensible way that still lets
people write useful cleanup classes.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134942 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 00:15:30 +00:00
Bruno Cardoso Lopes 4943c15df5 Reapply r134754, which turns out to be working correctly and also
add one more testcase.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134934 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-11 22:41:29 +00:00
John McCall 2b30dcfb76 Emit partial destruction of structs with initializer lists.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134913 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-11 19:35:02 +00:00
Jay Foad ef6de3da85 De-constify Types in StructType::get() and TargetData::getIntPtrType().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134893 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-11 09:56:20 +00:00
John McCall 2673c68aa5 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134890 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-11 08:38:19 +00:00
Jay Foad 00d40eae54 De-constify Types in FunctionType::get().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134888 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-11 07:56:41 +00:00
John McCall 61c1601e2a Use cached types; no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134880 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-10 20:11:30 +00:00
Chris Lattner 3ade975047 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134866 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-10 06:03:22 +00:00
Chris Lattner 1b5ba858e4 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134865 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-10 05:53:24 +00:00
Chris Lattner aa01d26e6b revert part of r134860, which is empirically unnecessary after the proper fix
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134864 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-10 05:44:18 +00:00
Chris Lattner 57eb23f34e 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134863 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-10 05:39:13 +00:00
Chris Lattner 74339dfbfe 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.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134862 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-10 05:34:54 +00:00
Chris Lattner f0a8679b6e 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134861 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-10 03:47:27 +00:00
Chris Lattner 12569fb55d 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134860 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-10 03:38:35 +00:00
Chris Lattner be5f332c4d how about we initialize RecursionState.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134855 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-10 01:10:18 +00:00
Chris Lattner f742eb0196 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




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134853 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-10 00:18:59 +00:00
Chris Lattner 8dd5cdfc46 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134841 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-09 18:53:56 +00:00
Chris Lattner 9cbe4f0ba0 clang side to match the LLVM IR type system rewrite patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134831 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-09 17:41:47 +00:00
John McCall 0850e8d1b0 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134813 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-09 09:09:00 +00:00
John McCall 7566aa2e47 GCC 4.2 compatibility hack.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134785 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-09 02:30:03 +00:00
John McCall bdc4d80956 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.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134784 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-09 01:37:26 +00:00
Eli Friedman c3e0fb406f 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>



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134770 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-08 23:31:17 +00:00
Bruno Cardoso Lopes 528a8c7b4c Revert x86_64 ABI changes until I have time to check the items raised by Eli.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134765 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-08 22:57:35 +00:00
Jakub Staszak 558229f267 Introduce __builtin_expect() intrinsic support.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134761 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-08 22:45:14 +00:00
Bruno Cardoso Lopes df41b4c10a Add support for AVX 256-bit in the x86_64 ABI (as in the 0.99.5 draft)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134754 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-08 22:18:40 +00:00
Cameron Zwarich 094240ab18 Add codegen support for the fma/fmal/fmaf builtins.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134743 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-08 21:39:34 +00:00
Bill Wendling 14ef3191a7 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>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134642 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-07 21:13:10 +00:00
Cameron Zwarich dbd3c85825 r134634 causes a failure on MultiSource/Benchmarks/Olden/bh with TEST=nightly,
so roll it out.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134638 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-07 21:03:28 +00:00
Nick Lewycky 2357aeec0d A redeclaration of an inline method in C99 mode should trigger emission of that
function. Fixes PR10233!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134634 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-07 20:25:10 +00:00
David Chisnall 63ff703393 If we're using the pure non-fragile ABI, then skip some of the contortions required to support the transitional ABI.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134612 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-07 12:34:51 +00:00
David Chisnall f074885425 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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134611 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-07 11:22:31 +00:00
John McCall 7e5e5f4cc3 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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134605 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-07 06:58:02 +00:00
Nick Lewycky e4330726b8 Sort #includes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134589 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-07 03:54:51 +00:00
Fariborz Jahanian 9d5ac7c9ca revert patch for // rdar://9227352
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134536 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-06 21:05:11 +00:00
John McCall 256a76e0b0 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134456 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-06 01:22:26 +00:00
John McCall 9f084a3166 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134453 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-06 00:26:06 +00:00
Dan Gohman b18b8ad630 Add the ObjC ARC optimization passes manually, now that they're not
hardwired into the default pass list.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134445 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-05 22:02:36 +00:00
Eli Friedman 14508ff0bf 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134300 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-02 00:57:27 +00:00
Eric Christopher aa7333c860 Update for llvm commit r134291.
Fixes rdar://9714064


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134292 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-02 00:20:22 +00:00
Douglas Gregor e67d1512f2 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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134266 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 21:54:36 +00:00
Douglas Gregor bcc3e660a1 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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134260 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 21:08:19 +00:00
David Chisnall d3fc7296ae Add support for weakly imported classes (GNU runtime).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134140 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-30 10:14:37 +00:00
Evan Cheng 368691e5ac createTargetMachine now takes a CPU string.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134128 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-30 02:06:32 +00:00
Fariborz Jahanian 8fefc8e245 objc-arc: fix a IRGen crash when checking for
accessibility of an initializer which is a compound 
statement. // rdar://9694706


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134091 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-29 20:00:16 +00:00
Fariborz Jahanian 5d9b6bf9de Use existing -fcatch-undefined-behavior option,
replacing -freset-local-blocks. // rdar://9227352


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134082 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-29 18:41:17 +00:00
David Chisnall c7aed3b9fb Add ARC support for the GNUstep runtime.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134065 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-29 13:16:41 +00:00
Eli Friedman ded137fcab 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".)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134059 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-29 07:04:55 +00:00
Evan Cheng 693769cafc SubtargetFeature.h has been moved to MC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134050 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-29 01:14:32 +00:00
Fariborz Jahanian 1077e420b8 Under a compiler flag, -freset-local-blocks,
wipe out stack blocks when they go out of scope.
// rdar://9227352


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134045 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-28 23:51:26 +00:00
Eric Christopher de31fd7eee Split out logic for valid clobbers and valid inline asm registers.
Fixes rdar://9281377


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134016 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-28 18:20:53 +00:00
Fariborz Jahanian bf9eb88792 Eliminate most uses of ShallowCollectObjCIvars which requires
a vector for collection. Use iterators where needed instead.
// rdar://6817577


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134015 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-28 18:05:25 +00:00
John McCall e6d134b244 Fix PR10204 in a better way.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133943 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-27 21:24:11 +00:00
Nico Weber 9d11e6f475 Revert parts of r133860 to fix a crash. Add a test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133931 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-27 19:46:54 +00:00
Eli Friedman 6594942e98 Cleanup cast IRGen a bit; no intended functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133864 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-25 02:58:47 +00:00
John McCall df7b091c58 Do not apply the ARC move optimization to 'const'-qualified xvalues.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133861 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-25 02:26:44 +00:00
John McCall 545d996ec5 LValue carries a type now, so simplify the main EmitLoad/Store APIs
by removing the redundant type parameter.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133860 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-25 02:11:03 +00:00
John McCall 913dab2525 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133855 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-25 01:32:37 +00:00
John McCall 0c24c808e4 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.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133840 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-24 23:21:27 +00:00
Bob Wilson 537c346116 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133833 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-24 22:13:26 +00:00
Devang Patel 1d323e0482 Fix struct member's scope. Patch by Xi Wang.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133829 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-24 22:00:59 +00:00
John McCall bc8d40d85f 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133827 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-24 21:55:10 +00:00
Bob Wilson 89f19e4373 Shorten some ARM builtin names by removing unnecessary "neon" prefix.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133826 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-24 21:32:46 +00:00
Fariborz Jahanian cf5abc7ba0 Support for catching objc pointer objects in c++ catch-statement
in fragile abi mode and some other cleanups. // rdar://8940528



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133747 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-23 19:00:08 +00:00
Fariborz Jahanian 9d96bce991 Alloa catching Objective-C id's being thrown with C++ throw
in Darwin's fragile abi mode.  // rdar://8940528


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133639 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 20:21:51 +00:00
Douglas Gregor 34aace8933 Try to silence GCC warning
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133623 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 16:43:25 +00:00
Douglas Gregor d1bd98a2c2 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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133621 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 16:32:26 +00:00
Douglas Gregor d7b2316776 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133620 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 16:12:01 +00:00
Jay Foad 97357602a2 Replace the existing forms of ConstantArray::get() with a single form
that takes an ArrayRef.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133615 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 09:24:39 +00:00
John McCall d768e9d29a 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133601 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 02:32:12 +00:00
Daniel Dunbar e26bdb91b7 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
--

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133532 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 18:54:46 +00:00
Daniel Dunbar 08d4792bb5 IRgen: Add CGOptions to CGTypes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133530 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 18:54:39 +00:00
Douglas Gregor 0b5810882b A few tweaks to MaterializeTemporaryExpr suggested by John.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133528 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 18:20:46 +00:00
Douglas Gregor 03e8003051 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>.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133521 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 17:03:29 +00:00
NAKAMURA Takumi 4857947d18 De-Unicode-ify in comments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133501 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 03:19:28 +00:00
Nick Lewycky c3b9014c72 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133489 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 00:14:18 +00:00
Eric Christopher 43fec879a5 Canonicalize register names properly.
Fixes rdar://9425559


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133486 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 00:07:10 +00:00
Fariborz Jahanian ab27d6ea7b 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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133450 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-20 17:50:03 +00:00
Jay Foad d36d036c81 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.)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133435 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-20 14:38:01 +00:00
Francois Pichet 6af9662662 Remove more unnecessary #include <llvm/ADT/SmallVector.h>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133418 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-20 06:11:46 +00:00
Chris Lattner c5cbb909e8 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133413 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-20 04:01:35 +00:00
Chris Lattner 7650d95a1a update for api change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133365 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-18 22:49:11 +00:00
Benjamin Kramer 19bd77c649 Remove dead variables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133346 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-18 10:34:07 +00:00
Benjamin Kramer d510fd2dde 80 cols.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133345 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-18 10:34:00 +00:00
Douglas Gregor 673e98b481 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!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133261 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 16:37:20 +00:00
John McCall 0502a22498 Perform an acquire memory barrier on the fast path of a thread-safe
static initializer check, as required by the Itanium ABI.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133250 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 07:33:57 +00:00
John McCall 7acddacc92 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133243 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 06:42:21 +00:00
Douglas Gregor 751ec9be96 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>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133235 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 04:59:12 +00:00
Eric Christopher e3e07a5b34 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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133226 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 01:53:34 +00:00
Fariborz Jahanian c7c9058f49 Move computation of __private_extern__ visibilty to
getLVForNamespaceScopeDecl(). // rdar://9609649


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133182 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 20:14:50 +00:00
Fariborz Jahanian 119f19b46b Set the visibility to 'hidden' when previous
declaration of global var is __private_extern__.
// rdar://9609649


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133157 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 14:49:42 +00:00
John McCall a07398ed98 Restore correct use of GC barriers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133144 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 04:16:24 +00:00
John McCall 175d6596a5 Suppress a warning in -Asserts builds.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133110 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 23:40:09 +00:00
John McCall f85e193739 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133103 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 23:02:42 +00:00
Eli Friedman 97cb5a4a21 Per Chris's suggestion, simplify code using llvm::getOrEnforceKnownAlignment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133095 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 22:09:18 +00:00
Eli Friedman 431e4b35fb Use isAnyComplexType here so we don't pass complex numbers into the aggregate handling code; found by inspection.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133070 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 18:27:44 +00:00
Eli Friedman 70cbd2a2a0 Fix a regression from r132957 involving complex integers. (Fixes failures on gcc-testsuite bot.)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133069 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 18:26:32 +00:00
Devang Patel 98703d32ff 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133065 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 17:57:08 +00:00
Bruno Cardoso Lopes 2eccb67279 Update the prefetch intrinsic usage. Now the last argument tells codegen
whether it's a data or instruction cache access.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132977 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-14 05:00:30 +00:00
Peter Collingbourne fd05ca03ab Move GlobalDecl to AST
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132973 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-14 04:02:39 +00:00
Eli Friedman ea5e4da116 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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132957 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-14 01:37:52 +00:00
Devang Patel 9d99f2db9b Put local variables in appropriate debug info scope.
This fixes radar 8757124.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132949 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-13 23:15:32 +00:00
Richard Smith 7a614d8380 Implement support for C++11 in-class initialization of non-static data members.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132878 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-11 17:19:42 +00:00
Douglas Gregor 926df6cfab 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




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132868 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-11 01:09:30 +00:00
Eli Friedman cb5d2d0647 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132861 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-10 21:53:06 +00:00
Stuart Hastings 002333f8b2 Clang support for ARM Uv/Uy/Uq inline-asm constraints.
rdar://problem/9037836


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132737 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-07 23:45:05 +00:00
Douglas Gregor 6a576ab708 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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132657 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-05 05:04:23 +00:00
Tanya Lattner 61eee0ca33 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132612 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-04 00:47:47 +00:00
Devang Patel 9198126067 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.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132610 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-04 00:38:02 +00:00
Devang Patel c594abdb78 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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132576 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-03 19:21:47 +00:00
Devang Patel c490312704 Simplify.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132560 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-03 17:23:47 +00:00
Devang Patel 2fd5a0f3ea Fix typedef's context.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132557 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-03 17:05:26 +00:00
Eric Christopher a18f539628 80-column cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132548 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-03 14:52:25 +00:00
Akira Hatanaka 619e8875d2 Add stuff for o32 ABI conformance.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132443 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-02 00:09:17 +00:00
Devang Patel d127bcbaab Robustify objc method type description (subroutine type) by walking parameters directly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132368 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 22:21:11 +00:00
Devang Patel c478f21820 List objective-c ineterfaces as public types in dwarf debug info output.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132361 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 21:18:50 +00:00
Devang Patel 1c29652fbc List c++ class type as public type in dwarf debug info output.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132357 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 20:46:46 +00:00
David Chisnall 31fc0c1a16 Fix another incorrect type bug.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132311 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-30 12:00:26 +00:00
John McCall 93c332a8ba 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. :)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132269 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-28 21:13:02 +00:00
Benjamin Kramer 95d318c4c1 Eliminate temporary argument vectors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132260 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-28 14:26:31 +00:00
David Chisnall 68e5e1331d Fix another type mismatch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132259 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-28 14:23:43 +00:00
David Chisnall 0bbe0cfd37 Fix missing cast.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132258 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-28 14:09:01 +00:00
Bruno Cardoso Lopes 26c1b8df8d Add support for ARM ldrexd/strexd builtins
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132249 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-28 04:11:33 +00:00
Eli Friedman 460980d3b9 Add unnamed_addr to internal globals which are only used as an operand to memcpy. (Spotted by looking at IR.)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132226 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 22:32:55 +00:00
Eli Friedman b0dd6702ab 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 .
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132223 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 22:13:20 +00:00
Eli Friedman addd80d1c8 Back out r132209; it's breaking nightly tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132219 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 21:32:17 +00:00
John McCall 0903421e36 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132209 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 20:01:14 +00:00
Douglas Gregor f968d83747 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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132171 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 01:19:52 +00:00
Eli Friedman 55d484802f 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132102 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-26 00:10:27 +00:00
David Chisnall b44eda31a2 Remove bitcast to incorrect type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132077 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-25 20:33:17 +00:00
Rafael Espindola abca5a1b3e Update for llvm api change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132034 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-25 03:44:55 +00:00
Sean Hunt ca63c20034 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132017 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-24 22:41:36 +00:00
David Chisnall 5f0bcc4c3f Fix bug introduced with r131930.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131935 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-23 23:15:11 +00:00
David Chisnall e6a11a62d1 Don't omit retain / release / autorelease message sends in hybrid GC mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131932 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-23 23:13:25 +00:00
David Chisnall 789ecdebd0 Fix some problems where functions must be bitcast but we're expecting a llvm::Function of the right type.
PR9994.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131930 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-23 22:33:28 +00:00
Chris Lattner de92d739ba 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131881 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-22 23:35:00 +00:00
Chris Lattner 855d227967 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131879 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-22 23:21:23 +00:00
David Chisnall a2120039ed Provide the runtime with information about the GC compile options (GNU runtimes)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131877 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-22 22:37:08 +00:00
Chris Lattner b644425e4c fix 80 col violation
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131870 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-22 22:09:06 +00:00
Chris Lattner 9ca02e521b adjust to mainline api change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131815 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-21 23:50:44 +00:00
Chris Lattner 33c09d5cb3 switch clang off StandardPasses.h onto PassManagerBuilder.h
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131808 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-21 20:40:11 +00:00
Eli Friedman 4d509341bd Fix the clang part of PR7952: rewrite the specialization of isa<> in DeclBase,
and stop abusing the multi-level dereference isa<> used to allow.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131804 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-21 19:15:39 +00:00
Douglas Gregor 575a1c9dc8 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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131735 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-20 16:38:50 +00:00
Devang Patel 8d3f8979e4 Fix location of setter/getter synthesized for a property.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131701 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-19 23:37:41 +00:00
Eli Friedman 0eb47fc018 Make __builtin_shufflevector and -ftrapv work correctly together. PR9945.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131611 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-19 00:37:32 +00:00
Roman Divacky 09345d1c2a Add ARMTargetCodeGenInfo::initDwarfEHRegSizeTable() defining 16 32bit regs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131558 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-18 19:36:54 +00:00
Bill Wendling 3621b31cd9 Conditionalize the use of 4.4 or 4.2 format based on the target.
<rdar://problem/8107317>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131504 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-17 23:06:23 +00:00
Fariborz Jahanian 25dba5d294 Code cleanup of my last patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131499 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-17 22:46:11 +00:00
Fariborz Jahanian 6f40e2244b Patch to fix IR-gen crash generating structure ABI which implements
user specified string class via -fconstant-string-class option.
pr9914.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131496 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-17 22:21:16 +00:00
Eli Friedman badea57d1d For calls returning first-class aggregates, store by element instead of creating aggregate stores in common cases. This is more friendly to fast-isel.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131490 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-17 21:08:01 +00:00
John McCall 492bafc66b 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131489 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-17 21:05:49 +00:00
Argyrios Kyrtzidis c5f18f3e8c Revert r131447, see if it fixes the buildbot.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131450 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-17 02:17:52 +00:00