Commit Graph

318 Commits

Author SHA1 Message Date
Anders Carlsson 11e5140db9 Vtable -> VTable renames across the board.
llvm-svn: 101666
2010-04-17 20:15:18 +00:00
Anders Carlsson f141dd1b95 Remove the old vtable layout code.
llvm-svn: 99869
2010-03-30 03:43:47 +00:00
Anders Carlsson 95e0223baf Remove old thunks code.
llvm-svn: 99374
2010-03-24 00:57:54 +00:00
Anders Carlsson 995891667f Use the canonical destructor, which fixes the self-host build. Thanks to Eli for noticing.
llvm-svn: 99260
2010-03-23 05:15:24 +00:00
Anders Carlsson af82f63b47 Always emit associated thunks when emitting the function itself. Remove getVtableAddressPoint, it's not used.
llvm-svn: 99252
2010-03-23 04:31:31 +00:00
Anders Carlsson a864caff8c Rename CGVtableInfo to CodeGenVTables in preparation of adding another VTableInfo class.
llvm-svn: 99250
2010-03-23 04:11:45 +00:00
John McCall 7ec5043c2c Change CodeGenModule to rely on the Module's symbol table instead of
shadowing it in the GlobalDeclMap.  Eliminates the string-uniquing
requirement for mangled names, which should help C++ codegen times a little.
Forces us to do string lookups instead of pointer lookups, which might hurt
codegen times a little across the board.  We'll see how it plays out.

Removing the string-uniquing requirement implicitly fixes any bugs like
PR6635 which arose from the fact that we had multiple uniquing tables for
different kinds of identifiers.

llvm-svn: 99012
2010-03-19 23:29:14 +00:00
Rafael Espindola d51c9b9a9f Use static method in GlobalValue
llvm-svn: 97872
2010-03-06 07:35:18 +00:00
Rafael Espindola 4c489c7030 Don't produce an alias for a destructor if the target is weak.
This fixes bootstrap on ELF systems :-)

llvm-svn: 97773
2010-03-05 01:21:10 +00:00
John McCall 1950a11939 Don't emit derived-to-base destructor aliases if we don't have a definition
for the base destructor, because aliases to declarations aren't legal.

Fixes PR 6471.

llvm-svn: 97637
2010-03-03 03:40:11 +00:00
John McCall aea181de04 Fix an iterator-invalidation bug that was causing selfhost errors
on non-darwin platforms.  Fixes PR6411. Test case doesn't reduce,
unfortunately.

llvm-svn: 97055
2010-02-24 20:32:01 +00:00
John McCall f8ff7b9fd1 Perform two more constructor/destructor code-size optimizations:
1) emit base destructors as aliases to their unique base class destructors
under some careful conditions.  This is enabled for the same targets that can
support complete-to-base aliases, i.e. not darwin.

2) Emit non-variadic complete constructors for classes with no virtual bases
as calls to the base constructor.  This is enabled on all targets and in
theory can trigger in situations that the alias optimization can't (mostly
involving virtual bases, mostly not yet supported).

These are bundled together because I didn't think it worthwhile to split them,
not because they really need to be.

llvm-svn: 96842
2010-02-23 00:48:20 +00:00
John McCall d4324148d7 Re-introduce the ctor/dtor alias optimization, this time hidden behind a
command-line option which defaults off.

llvm-svn: 96649
2010-02-19 01:32:20 +00:00
John McCall 334ce7c1c4 Revert the ctor/dtor alias optimization for now; the buildbots can detect
some failure here that I can't.

llvm-svn: 96612
2010-02-18 21:31:48 +00:00
John McCall 67cea74745 Emit complete constructors and destructors as aliases to base constructors
and destructors when the two entities are semantically identical, i.e. when
the class has no virtual base classes.  We only do this for linkage types
for which aliases are supported, i.e. internal and external, i.e. not linkonce.

llvm-svn: 96451
2010-02-17 03:52:49 +00:00
John McCall 347132b32f IRgen optimization: cache the value of 'this' and 'vtt' instead of
repeatedly reloading from an alloca.  We still need to create the alloca
for debug info purposes (although we currently create it in all cases
because of some abstraction boundaries that're hard to break down).

llvm-svn: 96403
2010-02-16 22:04:33 +00:00
John McCall ab26cfa58d Standardize the parsing of function type attributes in a way that
follows (as conservatively as possible) gcc's current behavior:  attributes
written on return types that don't apply there are applied to the function
instead, etc.  Only parse CC attributes as type attributes, not as decl attributes;
don't accepet noreturn as a decl attribute on ValueDecls, either (it still
needs to apply to other decls, like blocks).  Consistently consume CC/noreturn
information throughout codegen;  enforce this by removing their default values
in CodeGenTypes::getFunctionInfo().

llvm-svn: 95436
2010-02-05 21:31:56 +00:00
Anders Carlsson 27da15ba8e Move a few more functions away from CGCXX and to CGClass and CGExprCXX.
llvm-svn: 92399
2010-01-01 20:29:01 +00:00
Eli Friedman 1e26278b3b Add a sanity assertion so that we don't silently generate bad code; I'll file
a bug with a testcase hitting this assertion in a moment.

llvm-svn: 92175
2009-12-27 07:02:50 +00:00
Eli Friedman af76ad73ed Fix obvious mistake.
llvm-svn: 92172
2009-12-27 03:44:17 +00:00
Eli Friedman fddc26cc64 Make copy constructor elimination work in more cases; the case in question
here affects clang-on-clang.

llvm-svn: 92151
2009-12-24 23:33:34 +00:00
Anders Carlsson fb404888af Move a bunch of class related functions to CGClass.cpp, no functionality change.
llvm-svn: 92148
2009-12-24 22:46:43 +00:00
Anders Carlsson bfb3671b25 Pass the return value slot to all call exprs.
llvm-svn: 92145
2009-12-24 21:13:40 +00:00
Anders Carlsson 1749083e2e Fill in the return value slot in CGExprAgg::VisitCallExpr. This takes us halfway towards fixing PR5824.
llvm-svn: 92142
2009-12-24 20:40:36 +00:00
Anders Carlsson 61a401caec Pass ReturnValueSlot to EmitCall. No functionality change yet.
llvm-svn: 92138
2009-12-24 19:25:24 +00:00
Anders Carlsson 0435ed5875 Add a ReturnValueSlot class. Change the argument order in EmitCall to match the other overload better.
llvm-svn: 92136
2009-12-24 19:08:58 +00:00
Douglas Gregor 507eb87f05 Eliminate the ASTContext argument to CXXConstructorDecl::isCopyConstructor, since the context is available in the Decl
llvm-svn: 91862
2009-12-22 00:34:07 +00:00
Eli Friedman 70724ad2ff Work in progress for setting the vtable pointers for all bases correctly in
the constructor.  This doesn't handle cases requiring the VTT at the moment,
and generates unnecessary stores, but I think it's essentially correct.

llvm-svn: 91731
2009-12-18 23:47:41 +00:00
Eli Friedman 303e45750e Fix for PR5830: fix the computation of the offset to a virtual base.
llvm-svn: 91724
2009-12-18 23:27:44 +00:00
Anders Carlsson 28a133d602 CK_UserDefinedConversion is a valid kind when doing copy ctor elision.
llvm-svn: 91695
2009-12-18 17:29:21 +00:00
Douglas Gregor 357b6fd3e5 Address some of Anders comments
llvm-svn: 91670
2009-12-18 05:19:44 +00:00
Douglas Gregor e1314a64b8 Switch the initialization required by return statements over to the
new InitializationSequence. This fixes some bugs (e.g., PR5808),
changed some diagnostics, and caused more churn than expected. What's
new:

  - InitializationSequence now has a "C conversion sequence" category
    and step kind, which falls back to
  - Changed the diagnostics for returns to always have the result type
    of the function first and the type of the expression second.
    CheckSingleAssignmentConstraints to peform checking in C. 
  - Improved ASTs for initialization of return values. The ASTs now
    capture all of the temporaries we need to create, but
    intentionally do not bind the tempoary that is actually returned,
    so that it won't get destroyed twice.
  - Make sure to perform an (elidable!) copy of the class object that
    is returned from a class.
  - Fix copy elision in CodeGen to properly see through the
    subexpressions that occur with elidable copies.
  - Give "new" its own entity kind; as with return values and thrown
    objects, we don't bind the expression so we don't call a
    destructor for it.

Note that, with this patch, I've broken returning move-only types in
C++0x. We'll fix it later, when we tackle NRVO.

llvm-svn: 91669
2009-12-18 05:02:21 +00:00
Douglas Gregor 4f4b186215 When value-initializing a class with no user-defined constructors but
with a non-trivial default constructor, zero-initialize the storage
and then call the default constructor. Fixes PR5800.

llvm-svn: 91548
2009-12-16 18:50:27 +00:00
Eli Friedman d777cccb47 Don't force the emission of destructor definitions.
llvm-svn: 91394
2009-12-15 02:06:15 +00:00
Anders Carlsson 21122cf657 More array cookie improvements.
llvm-svn: 91247
2009-12-13 20:04:38 +00:00
Benjamin Kramer b11118bd0b Random string-related cleanups.
llvm-svn: 91119
2009-12-11 13:33:18 +00:00
Eli Friedman d5bc94e2eb Get rid of static variable.
llvm-svn: 91041
2009-12-10 02:21:21 +00:00
Anders Carlsson 633c6f6f36 Move more decl related functions to CGDeclCXX.cpp
llvm-svn: 91012
2009-12-10 00:30:05 +00:00
Anders Carlsson bc49cfed84 Add CGDeclCXX.cpp and move EmitCXXGlobalVarDeclInit there.
llvm-svn: 91006
2009-12-10 00:16:00 +00:00
Mike Stump 2600491817 Fix spacing.
llvm-svn: 91000
2009-12-10 00:05:14 +00:00
Eli Friedman 80888c7b38 Build fix.
llvm-svn: 90841
2009-12-08 06:54:20 +00:00
Eli Friedman bb5008a32a Fix for PR5707: make sure implicit copy constructors initialize the vtable
pointer.

llvm-svn: 90840
2009-12-08 06:46:18 +00:00
Eli Friedman 8aaff69e86 Fix some direct checks of expressions which might be surrounded by parentheses.
llvm-svn: 90825
2009-12-08 02:09:46 +00:00
Eli Friedman cd6a50f3e5 Make copy assignment operator synthesis not explode for classes with complex
or non-record aggregate members.

It might be worth spending some time to optimize this code (and the parallel
code for copy constructors) to memcpy in larger chunks, rather than copying
one member at a time.  Not sure exactly how beneficial that would be, but
it seems like could help for large classes with, for example, a vtable pointer
forcing the generation of a copy constructor.

llvm-svn: 90823
2009-12-08 01:57:53 +00:00
Eli Friedman 31bc3ad275 A bunch more thunk fixes from misc testing.
(Yes, I do intend to commit some tests for this.)

llvm-svn: 90818
2009-12-07 23:56:34 +00:00
Eli Friedman 8174f2c23c Work-in-progess rewrite of thunks: move thunk generation outside of vtable
generation, and make sure we generate thunks when the function is defined
rather than when the vtable is defined.

llvm-svn: 90722
2009-12-06 22:01:30 +00:00
Anders Carlsson b3f54b748d CodeGenModule::GenerateVtable now returns a pointer directly to the vtable and not to the address point.
llvm-svn: 90676
2009-12-05 21:28:12 +00:00
Anders Carlsson 5a1a84f9fa Simplify some code.
llvm-svn: 90670
2009-12-05 18:38:15 +00:00
Anders Carlsson ce460529c0 When generating a virtual destructor, don't try to make a virtual call to the base class destructor because then we'll just re-enter the same destructor!
This was done to fix PR5619, so I went ahead and passed a dummy VTT pointer for now.

llvm-svn: 90578
2009-12-04 19:33:17 +00:00
Eli Friedman 4039f35344 Fix thunk generation for thunks with a parameter with reference type.
llvm-svn: 90412
2009-12-03 04:49:52 +00:00