Commit Graph

5727 Commits

Author SHA1 Message Date
Chad Rosier e2c4506979 Prevent llvm.lifetime intrinsics from being emitted at -O0.
rdar://10921594

llvm-svn: 151430
2012-02-25 02:56:13 +00:00
Eli Friedman 2495ab08fc Work-in-progress for lambda conversion-to-block operator. Still need to implement the retain+autorelease outside of ARC, and there's a bug that causes the generated code to crash in ARC (which I think is unrelated to my code, although I'm not completely sure).
llvm-svn: 151428
2012-02-25 02:48:22 +00:00
Douglas Gregor 4a71b12a4e Trying to increase my Ohloh ranking with trivial tweaks
llvm-svn: 151414
2012-02-25 00:16:17 +00:00
Douglas Gregor 78e72f08ec Simplify check per Eli's comment
llvm-svn: 151412
2012-02-25 00:06:47 +00:00
Eli Friedman cb3785e450 Fix a stupid mistake in r151133. Reported to me by Joerg Sonnenberger.
llvm-svn: 151407
2012-02-24 23:53:49 +00:00
Douglas Gregor 4f283c8b20 For the purposes of building LLVM types, a forward-declared
enumeration type with a fixed underlying type is complete. Fixes
<rdar://problem/10916155>.

llvm-svn: 151403
2012-02-24 22:40:36 +00:00
Chad Rosier f62290a19b Reapply r151172 - Unwind path cleanup for array new list initializers - with a
test case that only runs on debug builds.

llvm-svn: 151311
2012-02-24 00:13:55 +00:00
Douglas Gregor d153103c5a Replace a use of hasTrivialDefaultConstructor() with the appropriate
isTrivial() call.

llvm-svn: 151259
2012-02-23 17:07:43 +00:00
Richard Smith c899892485 PR12067: When emitting an evaluated constant structure in C++11 mode, don't
forget the vptrs.

llvm-svn: 151245
2012-02-23 08:33:23 +00:00
Eli Friedman 91f5ae5022 Try to handle qualifiers more consistently for array InitListExprs. Fixes <rdar://problem/10907510>, and makes the ASTs a bit more self-consistent.
(I've chosen to keep the qualifiers, but it isn't a strong preference; if anyone prefers removing them, please yell.)

llvm-svn: 151229
2012-02-23 02:25:10 +00:00
Eric Christopher 55b2bfa7c1 Add a quick TODO.
llvm-svn: 151217
2012-02-23 00:43:12 +00:00
Eric Christopher 27bc9fee2b Fold debug scope emission into the cleanup scope.
llvm-svn: 151216
2012-02-23 00:43:07 +00:00
Chad Rosier 1a3c3d4537 Revert r151172: Unwind path cleanup for array new list initializers.
llvm-svn: 151203
2012-02-22 21:36:06 +00:00
Sebastian Redl 674c77e555 Unwind path cleanup for array new list initializers.
llvm-svn: 151172
2012-02-22 17:37:59 +00:00
Sebastian Redl f862eb6a9f CodeGen for array new list initializers. Doesn't correctly clean up in the face of exceptions yet.
llvm-svn: 151171
2012-02-22 17:37:52 +00:00
Bill Wendling f1a3fcac0d Use an ArrayRef when we can instead of passing in a SmallVectorImpl reference.
llvm-svn: 151150
2012-02-22 09:30:11 +00:00
Eli Friedman 91d5bb1ee5 Make sure null initialization in arrays works correctly with ARC types. <rdar://problem/10907547>.
llvm-svn: 151133
2012-02-22 05:38:59 +00:00
Douglas Gregor ed90df3800 Generate an AST for the conversion from a lambda closure type to a
block pointer that returns a block literal which captures (by copy)
the lambda closure itself. Some aspects of the block literal are left
unspecified, namely the capture variable (which doesn't actually
exist) and the body (which will be filled in by IRgen because it can't
be written as an AST).

Because we're switching to this model, this patch also eliminates
tracking the copy-initialization expression for the block capture of
the conversion function, since that information is now embedded in the
synthesized block literal. -1 side tables FTW.

llvm-svn: 151131
2012-02-22 05:02:47 +00:00
Aaron Ballman 3c42441b2c Adding support for Microsoft's thiscall calling convention. Clang side of the patch.
llvm-svn: 151122
2012-02-22 03:04:13 +00:00
Nick Lewycky 4506204640 Emit the exact size for the invariant intrinsics.
llvm-svn: 151010
2012-02-21 00:26:58 +00:00
Eric Christopher 8678a4a987 Formatting.
llvm-svn: 150996
2012-02-20 23:02:36 +00:00
Fariborz Jahanian caabf1bb64 objc IRGen: force CSE of load of ivar offsets by setting
the 'invariant.load' metadata tag onto those loads.
// rdar://10840980

llvm-svn: 150994
2012-02-20 22:42:22 +00:00
Eric Christopher 66562a4a54 Remove the type retaining from the clang frontend. This is now
handled by the caching and rauw. Also fix one cache that wasn't
being added to highlighted by this patch. Update all testcases
accordingly.

This should fix the deall failure.

llvm-svn: 150977
2012-02-20 18:05:24 +00:00
Eric Christopher e908a7a92c Make forward declarations for objective-c types use the new
temporary forward declaration nodes. Fixes a problem building
Chrome.

llvm-svn: 150976
2012-02-20 18:05:04 +00:00
Chandler Carruth a2a5410e6d Add 3dNOW intrinsic header to x86intrin.h, conditioned on __3dNOW__ to
match the behavior of GCC. Also add a test for these intrinsics, which
apparently have *zero* tests. =[ Not surprisingly, Clang crashed when
compiling these.

Fix the bug in CodeGen where we failed to bitcast the argument type to
x86mmx prior to calling the LLVM intrinsic. This fixes an assert on the
new 3dnow-builtins.c test.

This is one issue impacting the efforts to get Clang to emulate the
Microsoft intrinsics headers -- 3dnow intrinsics are implictitly made
available there.

llvm-svn: 150948
2012-02-20 07:35:45 +00:00
Sebastian Redl d026dc499c Make heap-allocation of std::initializer_list 'work'.
llvm-svn: 150931
2012-02-19 16:03:09 +00:00
Sebastian Redl 4e04dd1979 Make std::initializer_list member initializers 'work'.
llvm-svn: 150930
2012-02-19 15:41:54 +00:00
Sebastian Redl e6c32e6293 Refuse to compile global std::initializer_lists instead of doing completely the wrong thing.
llvm-svn: 150928
2012-02-19 14:53:49 +00:00
Sebastian Redl 8eb351d72e Get recursive initializer lists to work and add a test. Codegen of std::initializer_list is now complete. Onward to array new.
llvm-svn: 150926
2012-02-19 12:28:02 +00:00
Ahmed Charles 289896d2f3 Remove dead code.
llvm-svn: 150919
2012-02-19 11:57:29 +00:00
Richard Smith 0b6b8e490c Fix wrong-code bug: __imag on a scalar lvalue should produce a zero rvalue,
rather than an lvalue referring to the scalar.

llvm-svn: 150889
2012-02-18 20:53:32 +00:00
Chad Rosier 1d9cdb6c42 Fix comment.
llvm-svn: 150859
2012-02-18 01:20:35 +00:00
Eric Christopher 1c3785aae9 Add in a caching mechanism so that forward declarations are replaced
with full types if they exist.

rdar://10809898 and rdar://10209967 and rdar://10400981

llvm-svn: 150858
2012-02-18 00:50:17 +00:00
Eric Christopher 1a0c882a22 Formatting.
llvm-svn: 150857
2012-02-18 00:50:14 +00:00
Eric Christopher 71006f2378 Remove UpdateCompletedType from the debug info emission. We now
emit less than complete types on purpose on occasion and so
our caches aren't useful for this kind of lazy emitting.

llvm-svn: 150856
2012-02-18 00:50:08 +00:00
Chad Rosier f0cccf5bdb Remove redundant check.
llvm-svn: 150855
2012-02-18 00:37:07 +00:00
Richard Smith 132bea96ad Don't emit optimization-specific intrinsic at -O0.
llvm-svn: 150838
2012-02-17 20:12:52 +00:00
Sebastian Redl c83ed8248e Basic code generation support for std::initializer_list.
We now generate temporary arrays to back std::initializer_list objects
initialized with braces. The initializer_list is then made to point at
the array. We support both ptr+size and start+end forms, although
the latter is untested.

Array lifetime is correct for temporary std::initializer_lists (e.g.
call arguments) and local variables. It is untested for new expressions
and member initializers.

Things left to do:
Massively increase the amount of testing. I need to write tests for
start+end init lists, temporary objects created as a side effect of
initializing init list objects, new expressions, member initialization,
creation of temporary objects (e.g. std::vector) for initializer lists,
and probably more.
Get lifetime "right" for member initializers and new expressions. Not
that either are very useful.
Implement list-initialization of array new expressions.

llvm-svn: 150803
2012-02-17 08:42:25 +00:00
Richard Smith 08a5144621 The clang half of r150794: after the construction of a global or static const
variable ends, if the variable has a trivial destructor and no mutable
subobjects then emit an llvm.invariant.start call for it. globalopt knows to
make the variable const when evaluating this.

llvm-svn: 150798
2012-02-17 07:31:37 +00:00
Eric Christopher 2939e6e136 Index "12" holds the vtable, not "9".
Fixes lots of gdb testsuite failures.

llvm-svn: 150797
2012-02-17 07:09:48 +00:00
Richard Smith e070fd2ac8 Bug fix: do not emit static const local variables with mutable members
as constants.

Refactor and simplify all the separate checks for whether a type can be
emitted as a constant.

llvm-svn: 150793
2012-02-17 06:48:11 +00:00
Richard Smith ae819500a1 When performing IRGen on a global, emit it as a constant if:
1) It has a const-qualified type, and
 2) It has no mutable members, and
 3) It has no dynamic initialization, and
 4) It has trivial destruction.
Remove the unnecessary requirement that the type be POD. This allows us to
mark all constexpr objects with no mutable members as 'constant'.

llvm-svn: 150792
2012-02-17 04:54:50 +00:00
John McCall a729c62b81 Whether an argument is required (in contrast with being an
optional argument passed through the variadic ellipsis)
potentially affects how we need to lower it.  Propagate
this information down to the various getFunctionInfo(...)
overloads on CodeGenTypes.  Furthermore, rename those
overloads to clarify their distinct purposes, and make
sure we're calling the right one in the right place.
This has a nice side-effect of making it easier to construct
a function type, since the 'variadic' bit is no longer
separable.

This shouldn't really change anything for our existing
platforms, with one minor exception --- we should now call
variadic ObjC methods with the ... in the "right place"
(see the test case), which I guess matters for anyone
running GNUStep on MIPS.  Mostly it's just a substantial
clean-up.

llvm-svn: 150788
2012-02-17 03:33:10 +00:00
Douglas Gregor 355efbb2e0 Rework the Sema/AST/IRgen dance for the lambda closure type's
conversion to function pointer. Rather than having IRgen synthesize
the body of this function, we instead introduce a static member
function "__invoke" with the same signature as the lambda's
operator() in the AST. Sema then generates a body for the conversion
to function pointer which simply returns the address of __invoke. This
approach makes it easier to evaluate a call to the conversion function
as a constant, makes the linkage of the __invoke function follow the
normal rules for member functions, and may make life easier down the
road if we ever want to constexpr'ify some of lambdas.

Note that IR generation is responsible for filling in the body of
__invoke (Sema just adds a dummy body), because the body can't
generally be expressed in C++.

Eli, please review!

llvm-svn: 150783
2012-02-17 03:02:34 +00:00
Eric Christopher 4c006e557d Reapply r150631:
"Add a completed/incomplete type difference. This allows us to have
    partial types for contexts and forward decls while allowing us to
    complete types later on for debug purposes.

    This piggy-backs on the metadata replacement and rauw changes
    for temporary nodes and takes advantage of the incremental
    support I added in earlier. This allows us to, if we decide,
    to limit adding methods and variables to structures in order
    to limit the amount of debug information output into a .o file.

    The caching is a bit complicated though so any thoughts on
    untangling that are welcome."

with a fix:

 - Remove all RAUW during type construction by adding stub versions
   of types that we later complete.

and some TODOs:

 - Add an RAUW cache for forward declared types so that we can replace
   them at the end of compilation.
 - Remove the code that updates on completed types because we no
   longer need to have that happen. We emit incomplete types on
   purpose and only want to know when we want to complete them.

llvm-svn: 150752
2012-02-16 22:54:45 +00:00
Eli Friedman b971d49765 Elide copy construction in new expressions. PR11757.
llvm-svn: 150738
2012-02-16 22:45:48 +00:00
Sebastian Redl 6047f07e81 Revert "Revert "Make CXXNewExpr contain only a single initialier, and not hold the used constructor itself.""
This reintroduces commit r150682 with a fix for the Bullet benchmark crash.

llvm-svn: 150685
2012-02-16 12:22:20 +00:00
Sebastian Redl c3a3c60040 Revert "Make CXXNewExpr contain only a single initialier, and not hold the used constructor itself."
It leads to a compiler crash in the Bullet benchmark.

This reverts commit r12014.

llvm-svn: 150684
2012-02-16 11:35:52 +00:00
Sebastian Redl 86fab844bb Make CXXNewExpr contain only a single initialier, and not hold the used constructor itself.
Holding the constructor directly makes no sense when list-initialized arrays come into play. The constructor is now held in a CXXConstructExpr, if construction is what is done. The new design can also distinguish properly between list-initialization and direct-initialization, as well as implicit default-initialization constructors and explicit value-initialization constructors. Finally, doing it this way removes redundance from the AST because CXXNewExpr doesn't try to handle both the allocation and the initialization responsibilities.

This breaks the static analysis of new expressions. I've filed PR12014 to track this.

llvm-svn: 150682
2012-02-16 10:58:10 +00:00
Eli Friedman 5b44688d6b Initial implementation of IRGen for the lambda conversion-to-function-pointer operator.
llvm-svn: 150660
2012-02-16 03:47:28 +00:00