summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGVTables.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Simplify thunks code.Anders Carlsson2011-02-061-7/+6
| | | | llvm-svn: 124983
* Pass a 'ForVTable' flag to GetAddrOfThunk and pass it along to ↵Anders Carlsson2011-02-051-5/+6
| | | | | | | | GetOrCreateLLVMFunction so that we won't assert when building a thunk for an implicit virtual member function that is not marked used. llvm-svn: 124967
* Re-land r124768, with a fix for PR9130.Anders Carlsson2011-02-051-2/+2
| | | | | | We now emit everything except unused implicit virtual member functions when building the vtable. llvm-svn: 124935
* Revert 124768.Rafael Espindola2011-02-031-2/+2
| | | | | | | This reopens PR99114, but that one at least can be avoided with an #include. PR9130 cannot. llvm-svn: 124780
* Don't try to mark virtual members referenced for classes where the key functionAnders Carlsson2011-02-031-2/+2
| | | | | | | | | | | is not defined in the current translation unit. Doing so lead to compile errors such as PR9114. Instead, when CodeGen is building the vtable, don't try to emit a definition for functions that aren't marked used in the current translation unit. Fixes PR9114. llvm-svn: 124768
* When building with optimizations, emit vtables where the key is not in the Anders Carlsson2011-01-301-0/+6
| | | | | | | | | | | | | | | | | | | | | | | current translation unit as available_externally. This helps devirtualize the second example in PR3100, comment 18: struct S { S() {}; virtual void xyzzy(); }; inline void foo(S *s) { s->xyzzy(); } void bar() { S s; foo(&s); } This involved four major changes: 1. In DefineUsedVTables, always mark virtual member functions as referenced for non-template classes and class template specializations. 2. In CodeGenVTables::ShouldEmitVTableInThisTU return true if optimizations are enabled, even if the key function is not implemented in this translation unit. We don't ever do this for code compiled with -fapple-kext, because we don't ever want to devirtualize virtual member function calls in that case. 3. Give the correct linkage for vtables where the key function is not defined. 4. Update the linkage for RTTI structures when necessary. llvm-svn: 124565
* Change CodeGenModule::setTypeVisibility to take a TypeVisibilityKind enum ↵Anders Carlsson2011-01-291-1/+1
| | | | | | instead of an "IsForRTTI" flag. llvm-svn: 124546
* Get rid of an unneeded parameter from setGlobalVisibility.Anders Carlsson2011-01-291-1/+1
| | | | llvm-svn: 124541
* Make emitting a VTT a two-step process, much like emitting a VTable. You ↵Anders Carlsson2011-01-291-1/+4
| | | | | | first get the address of the VTT, and then pass it to EmitVTTDefinition. llvm-svn: 124539
* Use CGM.CreateOrReplaceCXXRuntimeVariable in CGVTables.cppAnders Carlsson2011-01-291-47/+4
| | | | llvm-svn: 124538
* Remove IsDefinition from CodeGenModule::setTypeVisibility; it is always true.Anders Carlsson2011-01-291-1/+1
| | | | llvm-svn: 124529
* More work to support -fapple-kext regarding Fariborz Jahanian2011-01-281-0/+7
| | | | | | | indirect vf calls and addition of extra entry at bottom of vtbls. llvm-svn: 124507
* Also set unnamed_addr on declarations.Rafael Espindola2011-01-151-1/+1
| | | | llvm-svn: 123531
* Only add unnamed_addr to definitions.Rafael Espindola2011-01-131-1/+1
| | | | llvm-svn: 123354
* Add unnamed_addr to vtables.Rafael Espindola2011-01-111-2/+5
| | | | llvm-svn: 123272
* Rename RecordLayout::getPrimaryBaseWasVirtual to isPrimaryBaseVirtual.Anders Carlsson2010-11-241-6/+6
| | | | llvm-svn: 120133
* Move code off the primary base info iterator. No functionality change.Anders Carlsson2010-11-241-4/+14
| | | | llvm-svn: 120132
* When re-using a vtable slot for the nearest overridden method, just becauseJohn McCall2010-11-091-1/+10
| | | | | | | | | | | | there's no return adjustment from the overridden to the overrider doesn't mean there isn't a return adjustment from the overrider to the final overrider. This matters if we're emitting a virtual this-adjustment thunk because the overrider virtually inherits from the class providing the nearest overridden method. Do the appropriate return adjustment in this case. Fixes PR7611. llvm-svn: 118466
* Rename getBaseClassOffset to getBaseClassOffsetInBits and introduce a ↵Anders Carlsson2010-10-311-27/+28
| | | | | | getBaseClassOffset which returns the offset in CharUnits. Do the same thing for getVBaseClassOffset. llvm-svn: 117881
* Better solution: calculate the visibility of functions and variablesJohn McCall2010-10-301-2/+2
| | | | | | | | | | independently of whether they're definitions, then teach IR generation to ignore non-explicit visibility when emitting declarations. Use this to make sure that RTTI, vtables, and VTTs get the right visibility. More of rdar://problem/8613093 llvm-svn: 117781
* Make sure the VTables for template instantiations are emitted even if the ↵Argyrios Kyrtzidis2010-10-111-3/+22
| | | | | | key function doesn't have a body. llvm-svn: 116186
* Teach IR generation to return 'this' from constructors and destructorsJohn McCall2010-08-311-20/+16
| | | | | | under the ARM ABI. llvm-svn: 112588
* Just disable the hidden-visibility optimization for now by hiding it behindJohn McCall2010-08-121-1/+4
| | | | | | | | a -cc1 option. The Darwin linker complains about mixed visibility when linking gcc-built objects with clang-built objects, and the optimization isn't really that valuable. Platforms with less ornery linkers can feel free to enable this. llvm-svn: 110979
* It turns out that linkers (at least, the Darwin linker) don't necessarilyJohn McCall2010-08-051-10/+6
| | | | | | | | | | | do the right thing with mixed-visibility symbols, so disable the visibility optimization where that's possible, i.e. with template classes (since it's possible that an arbitrary template might be subject to an explicit instantiation elsewhere). 447.dealII actually does this. I've put the code under an option that's currently not hooked up to anything. llvm-svn: 110374
* Extend the visibility-hidden optimization to linkonce_odr thunks forJohn McCall2010-08-041-1/+51
| | | | | | | | | functions with in-line definitions, since such thunks will be emitted at any use of the function. Completes the feature work for rdar://problem/7523229. llvm-svn: 110285
* Emit standard-library RTTI with external linkage, not weak_odr.John McCall2010-08-041-33/+1
| | | | | | | | | | Apply hidden visibility to most RTTI; libstdc++ does not rely on exact pointer equality for the type info (just the type info names). Apply the same optimization to RTTI that we do to vtables. Fixes PR5962. llvm-svn: 110192
* Extend the hidden-visibility vtables optimization to template classes thatJohn McCall2010-08-041-10/+26
| | | | | | haven't been explicitly instantiated. llvm-svn: 110189
* Emit weak vtables of non-template classes with hidden visibility.John McCall2010-08-031-0/+16
| | | | llvm-svn: 110107
* Remove the vast majority of the Destroy methods from the AST library,Douglas Gregor2010-07-251-3/+0
| | | | | | since we aren't going to be calling them ever. llvm-svn: 109377
* Make sure to set the visible on a vtable; VTTs and typeinfo alreadyDouglas Gregor2010-06-141-0/+3
| | | | | | handle visibility properly. Fixes <rdar://problem/8091955>. llvm-svn: 105977
* Remove now unused code.Anders Carlsson2010-06-041-235/+13
| | | | llvm-svn: 105448
* Use CXXRecordDecl::getFinalOverriders to get final overriders. This speeds ↵Anders Carlsson2010-06-041-1/+119
| | | | | | up vtable layout by moving away from the old final overrider computation code that had O(N^2) complexity in some cases. llvm-svn: 105447
* Don't try to emit the vtable for a class just because we're emitting aJohn McCall2010-06-021-12/+18
| | | | | | | | virtual function from it. Fixes PR7241. llvm-svn: 105345
* More cleanup.Anders Carlsson2010-06-011-14/+10
| | | | llvm-svn: 105301
* More cleanup.Anders Carlsson2010-06-011-35/+10
| | | | llvm-svn: 105299
* Cleanup.Anders Carlsson2010-06-011-8/+9
| | | | llvm-svn: 105296
* Remove unused parameter to FinalOverriders::PropagateOverrider.Anders Carlsson2010-05-301-5/+3
| | | | llvm-svn: 105171
* Correctly pass aggregates by reference when emitting thunks.John McCall2010-05-261-8/+1
| | | | llvm-svn: 104778
* If a function definition has any sort of weak linkage, its static localJohn McCall2010-05-251-1/+1
| | | | | | | | | | | | variables should have that linkage. Otherwise, its static local variables should have internal linkage. To avoid computing this excessively, set a function's linkage before we emit code for it. Previously we were assigning weak linkage to the static variables of static inline functions in C++, with predictably terrible results. This fixes that and also gives better linkage than 'weak' when merging is required. llvm-svn: 104581
* When generating the call arguments in a thunk to call the thunkee, doDouglas Gregor2010-05-211-3/+9
| | | | | | | | not make copies non-POD arguments or arguments passed by reference: just copy the pointers directly. This eliminates another source of the dreaded memcpy-of-non-PODs. Fixes PR7188. llvm-svn: 104327
* When creating a this-adjustment thunk where the return value is of C++Douglas Gregor2010-05-201-2/+9
| | | | | | | | | class type (that uses a return slot), pass the return slot to the callee directly rather than allocating new storage and trying to copy the object. This appears to have been the cause of the remaining two Boost.Interprocess failures. llvm-svn: 104215
* Rework when and how vtables are emitted, by tracking where vtables areDouglas Gregor2010-05-131-47/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "used" (e.g., we will refer to the vtable in the generated code) and when they are defined (i.e., because we've seen the key function definition). Previously, we were effectively tracking "potential definitions" rather than uses, so we were a bit too eager about emitting vtables for classes without key functions. The new scheme: - For every use of a vtable, Sema calls MarkVTableUsed() to indicate the use. For example, this occurs when calling a virtual member function of the class, defining a constructor of that class type, dynamic_cast'ing from that type to a derived class, casting to/through a virtual base class, etc. - For every definition of a vtable, Sema calls MarkVTableUsed() to indicate the definition. This happens at the end of the translation unit for classes whose key function has been defined (so we can delay computation of the key function; see PR6564), and will also occur with explicit template instantiation definitions. - For every vtable defined/used, we mark all of the virtual member functions of that vtable as defined/used, unless we know that the key function is in another translation unit. This instantiates virtual member functions when needed. - At the end of the translation unit, Sema tells CodeGen (via the ASTConsumer) which vtables must be defined (CodeGen will define them) and which may be used (for which CodeGen will define the vtables lazily). From a language perspective, both the old and the new schemes are permissible: we're allowed to instantiate virtual member functions whenever we want per the standard. However, all other C++ compilers were more lazy than we were, and our eagerness was both a performance issue (we instantiated too much) and a portability problem (we broke Boost test cases, which now pass). Notes: (1) There's a ton of churn in the tests, because the order in which vtables get emitted to IR has changed. I've tried to isolate some of the larger tests from these issues. (2) Some diagnostics related to implicitly-instantiated/implicitly-defined virtual member functions have moved to the point of first use/definition. It's better this way. (3) I could use a review of the places where we MarkVTableUsed, to see if I missed any place where the language effectively requires a vtable. Fixes PR7114 and PR6564. llvm-svn: 103718
* Fix typo in comment; 80 col violationDouglas Gregor2010-05-061-3/+3
| | | | llvm-svn: 103204
* Pass the globaldecl into GetOrCreateLLVMFunction so that llvmChris Lattner2010-05-051-1/+1
| | | | | | | | | function attributes like byval get applied to the function definition. This fixes PR7058 and makes i386 llvm/clang bootstrap pass all the same tests as x86-64 bootstrap for me (the llvmc tests still fail in both). llvm-svn: 103131
* Vtable -> VTable renames across the board.Anders Carlsson2010-04-171-31/+31
| | | | llvm-svn: 101666
* Fix a bug where we would sometimes incorrectly mark an vtable function as ↵Anders Carlsson2010-04-171-6/+3
| | | | | | unused. llvm-svn: 101643
* Fix another bug where we wouldn't generate secondary vtables for ↵Anders Carlsson2010-04-111-5/+9
| | | | | | construction vtables in some cases. llvm-svn: 100998
* More renames.Anders Carlsson2010-04-111-46/+46
| | | | llvm-svn: 100991
* Rename a function parameter.Anders Carlsson2010-04-111-6/+10
| | | | llvm-svn: 100990
* Fix a bug where we were adding too many vcall offsets in some cases.Anders Carlsson2010-04-111-20/+7
| | | | llvm-svn: 100985
OpenPOWER on IntegriCloud