summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/vtable-linkage.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [CodeGen] Align rtti and vtable dataDavid Green2018-09-121-14/+14
| | | | | | | | | | Previously the alignment on the newly created rtti/typeinfo data was largely not set, meaning that DataLayout::getPreferredAlignment was free to overalign it to 16 bytes. This causes unnecessary code bloat. Differential Revision: https://reviews.llvm.org/D51416 llvm-svn: 342053
* Emit available_externally vtables opportunisticallyPiotr Padlewski2017-06-011-2/+4
| | | | | | | | | | | | | | Summary: We can emit vtable definition having inline function if they are all emitted. Reviewers: rjmccall, rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33437 llvm-svn: 304394
* Make '-disable-llvm-optzns' an alias for '-disable-llvm-passes'.Chandler Carruth2016-12-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Much to my surprise, '-disable-llvm-optzns' which I thought was the magical flag I wanted to get at the raw LLVM IR coming out of Clang deosn't do that. It still runs some passes over the IR. I don't want that, I really want the *raw* IR coming out of Clang and I strongly suspect everyone else using it is in the same camp. There is actually a flag that does what I want that I didn't know about called '-disable-llvm-passes'. I suspect many others don't know about it either. It both does what I want and is much simpler. This removes the confusing version and makes that spelling of the flag an alias for '-disable-llvm-passes'. I've also moved everything in Clang to use the 'passes' spelling as it seems both more accurate (*all* LLVM passes are disabled, not just optimizations) and much easier to remember and spell correctly. This is part of simplifying how Clang drives LLVM to make it cleaner to wire up to the new pass manager. Differential Revision: https://reviews.llvm.org/D28047 llvm-svn: 290392
* Make two vtable tests tolerate C++11.Paul Robinson2016-12-201-0/+9
| | | | | | | | | In C++11 we don't emit vtables as eagerly as we do for C++03, so fiddle the tests to emit them when the test expects them. Differential Revision: http://reviews.llvm.org/D27994 llvm-svn: 290205
* [Clang] Remove unwanted --check-prefix=CHECK from unit tests. NFC.Mandeep Singh Grang2016-04-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Removed unwanted --check-prefix=CHECK from the following unit tests: test/CXX/special/class.copy/implicit-move-def.cpp test/CodeGen/cleanup-destslot-simple.c test/CodeGen/inline-asm-immediate-ubsan.c test/CodeGen/mips-interrupt-attr.c test/CodeGenCXX/cfi-stats.cpp test/CodeGenCXX/copy-constructor-elim.cpp test/CodeGenCXX/microsoft-templ-uuidof.cpp test/CodeGenCXX/vtable-linkage.cpp test/CodeGenObjC/messages-2.m test/Driver/noinline.c test/Index/remap-load.c test/Index/retain-comments-from-system-headers.c test/OpenMP/task_if_codegen.cpp test/Preprocessor/comment_save_macro.c Patch by: Mandeep Singh Grang (mgrang) Reviewers: rafael, ABataev, rengolin Projects: #clang-c Differential Revision: http://reviews.llvm.org/D19232 llvm-svn: 266843
* Generating available_externally vtables for outline virtual functionsPiotr Padlewski2015-07-241-5/+6
| | | | | | | | | | | | | | Generating available_externally vtables for optimizations purposes. Unfortunatelly ItaniumABI doesn't guarantee that we will be able to refer to virtual inline method by name. But when we don't have any inline virtual methods, and key function is not defined in this TU, we can generate that there will be vtable and mark it as available_externally. This is patch will help devirtualize better. Differential Revision: http://reviews.llvm.org/D11441 llvm-svn: 243090
* Use a trivial comdat for C++ tables.Rafael Espindola2015-01-151-22/+22
| | | | | | | | | This produces comdats for vtables, typeinfo, typeinfo names, and vtts. When combined with llvm not producing implicit comdats, not doing this would cause code bloat on ELF and link errors on COFF. llvm-svn: 226227
* type_info objects are not unnamed_addr: the ABI requires us toJohn McCall2014-02-081-10/+10
| | | | | | | | | | unique them and permits the implementation of dynamic_cast (and anything else which knows it's working with a complete class type) to compare their addresses directly. rdar://16005328 llvm-svn: 201020
* Remove the -fhidden-weak-vtables -cc1 option. It was dead,John McCall2014-02-081-12/+0
| | | | | | gross, and increasingly replaced through other mechanisms. llvm-svn: 201011
* Don't emit an available_externally vtable pointing to linkonce_odr funcs.Rafael Espindola2013-09-031-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes pr13124. From the discussion at http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-June/022606.html we know that we cannot make funcions in a weak_odr vtable also weak_odr. They should remain linkonce_odr. The side effect is that we cannot emit a available_externally vtable unless we also emit a copy of the function. This also has an issue: If codegen is going to output a function, sema has to mark it used. Given llvm.org/pr9114, it looks like sema cannot be more aggressive at marking functions used because of vtables. This leaves us with a few unpleasant options: * Marking functions in vtables used if possible. This sounds a bit sloppy, so we should avoid it. * Producing available_externally vtables only when all the functions in it are already used or weak_odr. This would cover cases like -------------------- struct foo { virtual ~foo(); }; struct bar : public foo { virtual void zed(); }; void f() { foo *x(new bar); delete x; } void g(bar *x) { x->~bar(); // force the destructor to be used } -------------------------- and ---------------------------------- template<typename T> struct bar { virtual ~bar(); }; template<typename T> bar<T>::~bar() { } // make the destructor weak_odr instead of linkonce_odr extern template class bar<int>; void f() { bar<int> *x(new bar<int>); delete x; } ---------------------------- These look like corner cases, so it is unclear if it is worth it. * And finally: Just nuke this optimization. That is what this patch implements. llvm-svn: 189852
* Use CHECK-DAG in this test.Rafael Espindola2013-08-261-79/+57
| | | | llvm-svn: 189280
* Emit vtables for an extern template class as available_externally, not asRichard Smith2013-02-161-0/+26
| | | | | | | linkonce_odr. Emit construction vtables as internal in this case, since the ABI does not guarantee that they will be availble externally. llvm-svn: 175330
* fix a bunch of comment typos found by codespell. Patch byChris Lattner2011-04-151-1/+1
| | | | | | Luis Felipe Strano Moraes! llvm-svn: 129559
* Give VTTs the right visibility.Anders Carlsson2011-01-291-1/+3
| | | | llvm-svn: 124540
* Mark VTables and RTTI data linkonce_odr instead of weak_odr, with the ↵Anders Carlsson2011-01-241-20/+20
| | | | | | | | exception of explicit template instantiations, which have to be weak_odr. This fixes PR6996. llvm-svn: 124089
* Also set unnamed_addr on declarations.Rafael Espindola2011-01-151-3/+3
| | | | llvm-svn: 123531
* Only add unnamed_addr to definitions.Rafael Espindola2011-01-131-3/+3
| | | | llvm-svn: 123354
* Set unnamed_addr in every type info.Rafael Espindola2011-01-111-12/+12
| | | | llvm-svn: 123293
* Set unnamed_addr for type infos that we are confortable marking as hidden. IRafael Espindola2011-01-111-1/+1
| | | | | | think it is safe to mark all type infos with unnamed_addr, but I am not sure. llvm-svn: 123275
* Add unnamed_addr to vtables.Rafael Espindola2011-01-111-18/+18
| | | | llvm-svn: 123272
* Make sure the VTables for template instantiations are emitted even if the ↵Argyrios Kyrtzidis2010-10-111-0/+15
| | | | | | key function doesn't have a body. llvm-svn: 116186
* Just disable the hidden-visibility optimization for now by hiding it behindJohn McCall2010-08-121-2/+15
| | | | | | | | 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-6/+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
* Emit standard-library RTTI with external linkage, not weak_odr.John McCall2010-08-041-3/+3
| | | | | | | | | | 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-4/+12
| | | | | | haven't been explicitly instantiated. llvm-svn: 110189
* Emit weak vtables of non-template classes with hidden visibility.John McCall2010-08-031-2/+3
| | | | llvm-svn: 110107
* IRgen/C++: When mark vtables used, make sure to still append to the ↵Daniel Dunbar2010-05-251-1/+15
| | | | | | | | | VTableUse array if we promote a vtable from being just used to having its definition required. This ensures that we properly inform the consumer about whether the vtable is required or not, previously we could fail to do so when the vtable was in the VTableUses array before the decl which marked it as required. - I think this can be cleaned up, since this means we may notify the consumer about the vtable twice, but I didn't see an easy fix for this without more substantial refactoring. - Doug, please review! llvm-svn: 104577
* Rework when and how vtables are emitted, by tracking where vtables areDouglas Gregor2010-05-131-32/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "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
* Don't produce a vtable for a class if we have an explicit template ↵Rafael Espindola2010-04-031-4/+2
| | | | | | | | instantiation declaration and no key function. We will produce the vtable at the explicit template instantiation. Fixes PR6748 llvm-svn: 100266
* Flip the switch and use the new vtable layout code for everything. I've ↵Anders Carlsson2010-03-301-10/+10
| | | | | | verified that this passes a self-host but I'll let the bots self host as well before removing the now dead code. llvm-svn: 99861
* Fix for PR5967: Make const-marking for LLVM globals correct for cases requiringEli Friedman2010-01-081-6/+6
| | | | | | | run-time initialization, and emit run-time initializers aggresively to avoid ordering issues with deferred globals. llvm-svn: 92976
* Test linkage of typeinfo and typeinfo names for class templatesDouglas Gregor2010-01-071-1/+13
| | | | llvm-svn: 92897
* Revert my available_externally vtables experiment. It's breaking the ↵Douglas Gregor2010-01-061-1/+1
| | | | | | LLVM-with-Clang build with linker errors that I have yet to investigate. llvm-svn: 92822
* Make use of available_externally linkage for vtables when theDouglas Gregor2010-01-051-0/+37
| | | | | | | | | | non-inline key function of a class template instantiation, when no key function is present, the class template instantiation itself was instantiated with an explicit instantiation declaration (aka extern template). I'm fairly certain that the C++0x specification gives us this lattitude, although GCC doesn't take advantage of it. llvm-svn: 92779
* Improve key-function computation for templates. In particular:Douglas Gregor2010-01-051-0/+46
| | | | | | | | | | | | | | | | - All classes can have a key function; templates don't change that. non-template classes when computing the key function. - We always mark all of the virtual member functions of class template instantiations. - The vtable for an instantiation of a class template has weak linkage. We could probably use available_externally linkage for vtables of classes instantiated by explicit instantiation declarations (extern templates), but GCC doesn't do this and I'm not 100% that the ABI permits it. llvm-svn: 92753
* Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.Daniel Dunbar2009-12-151-1/+1
| | | | | | | | | - This is designed to make it obvious that %clang_cc1 is a "test variable" which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it can be useful to redefine what gets run as 'clang -cc1' (for example, to set a default target). llvm-svn: 91446
* Fix linkage of type info and vtable for classes without linkage.Eli Friedman2009-12-111-0/+8
| | | | llvm-svn: 91152
* Improve linkage of RTTI data structures. Introduce ↵Anders Carlsson2009-12-111-0/+6
| | | | | | CodeGenModule::GetAddrOfRTTI which figures out the right linkage of the RTTI information for the given type and whether it should be defined or not. I will migrate clients over to GetAddrOfRTTI in subsequent commits (with tests). llvm-svn: 91098
* More linkage improvements.Anders Carlsson2009-12-061-0/+10
| | | | llvm-svn: 90687
* If a class does not have a key function, its linkage should be weak_odr.Anders Carlsson2009-12-051-0/+10
| | | | llvm-svn: 90680
* Use createGlobalVariable for creating vtable variables too.Anders Carlsson2009-12-051-10/+16
| | | | llvm-svn: 90679
* Factor vtable related GlobalVariable creation out into a separate function. ↵Anders Carlsson2009-12-051-0/+18
Add vtable linkage test. llvm-svn: 90667
OpenPOWER on IntegriCloud