summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/rtti-linkage.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Revert r332028; see PR37545 for details.Richard Smith2018-05-211-34/+22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332879 91177308-0d34-0410-b5e6-96231b3b80d8
* [Itanium] Emit type info names with external linkage.Eric Fiselier2018-05-101-22/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The Itanium ABI requires that the type info for pointer-to-incomplete types to have internal linkage, so that it doesn't interfere with the type info once completed. Currently it also marks the type info name as internal as well. However, this causes a bug with the STL implementations, which use the type info name pointer to perform ordering and hashing of type infos. For example: ``` // header.h struct T; extern std::type_info const& Info; // tu_one.cpp #include "header.h" std::type_info const& Info = typeid(T*); // tu_two.cpp #include "header.h" struct T {}; int main() { auto &TI1 = Info; auto &TI2 = typeid(T*); assert(TI1 == TI2); // Fails assert(TI1.hash_code() == TI2.hash_code()); // Fails } ``` This patch fixes the STL bug by emitting the type info name as linkonce_odr when the type-info is for a pointer-to-incomplete type. Note that libc++ could fix this without a compiler change, but the quality of fix would be poor. The library would either have to: (A) Always perform strcmp/string hashes. (B) Determine if we have a pointer-to-incomplete type, and only do strcmp then. This would require an ABI break for libc++. Reviewers: rsmith, rjmccall, majnemer, vsapsai Reviewed By: rjmccall Subscribers: smeenai, cfe-commits Differential Revision: https://reviews.llvm.org/D46665 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332028 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "[Itanium] Emit type info names with external linkage."Eric Fiselier2018-05-101-34/+22
| | | | | | | This reverts commit r331957. It seems to be causing failures on ppc64le-linux. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331963 91177308-0d34-0410-b5e6-96231b3b80d8
* [Itanium] Emit type info names with external linkage.Eric Fiselier2018-05-101-22/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The Itanium ABI requires that the type info for pointer-to-incomplete types to have internal linkage, so that it doesn't interfere with the type info once completed. Currently it also marks the type info name as internal as well. However, this causes a bug with the STL implementations, which use the type info name pointer to perform ordering and hashing of type infos. For example: ``` // header.h struct T; extern std::type_info const& Info; // tu_one.cpp #include "header.h" std::type_info const& Info = typeid(T*); // tu_two.cpp #include "header.h" struct T {}; int main() { auto &TI1 = Info; auto &TI2 = typeid(T*); assert(TI1 == TI2); // Fails assert(TI1.hash_code() == TI2.hash_code()); // Fails } ``` This patch fixes the STL bug by emitting the type info name as linkonce_odr when the type-info is for a pointer-to-incomplete type. Note that libc++ could fix this without a compiler change, but the quality of fix would be poor. The library would either have to: (A) Always perform strcmp/string hashes. (B) Determine if we have a pointer-to-incomplete type, and only do strcmp then. This would require an ABI break for libc++. Reviewers: rsmith, rjmccall, majnemer, vsapsai Reviewed By: rjmccall Subscribers: smeenai, cfe-commits Differential Revision: https://reviews.llvm.org/D46665 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331957 91177308-0d34-0410-b5e6-96231b3b80d8
* Emit DeferredDeclsToEmit in a DFS order.Rafael Espindola2015-01-221-4/+4
| | | | | | | | | | | | | | Currently we emit DeferredDeclsToEmit in reverse order. This patch changes that. The advantages of the change are that * The output order is a bit closer to the source order. The change to test/CodeGenCXX/pod-member-memcpys.cpp is a good example. * If we decide to deffer more, it will not cause as large changes in the estcases as it would without this patch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226751 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGen: Don't set hidden visibility on symbols with local linkageDuncan P. N. Exon Smith2014-05-071-22/+25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208258 91177308-0d34-0410-b5e6-96231b3b80d8
* RTTI symbols for visible local types may need weak linkage.John McCall2014-03-101-0/+38
| | | | | | | | | | | Previously, we would always emit them with internal linkage, but with hidden visibility when the function was hidden, which is an illegal combination, which could lead LLVM to actually emit them as strong hidden symbols with hilarious results. rdar://16265084 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203503 91177308-0d34-0410-b5e6-96231b3b80d8
* type_info objects are not unnamed_addr: the ABI requires us toJohn McCall2014-02-081-23/+23
| | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201020 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove the -fhidden-weak-vtables -cc1 option. It was dead,John McCall2014-02-081-6/+6
| | | | | | gross, and increasingly replaced through other mechanisms. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201011 91177308-0d34-0410-b5e6-96231b3b80d8
* When emitting RTTI for a non-class type, compute the visibility of the RTTI ↵Anders Carlsson2011-01-291-1/+1
| | | | | | data based on the explicit visibility of the type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124553 91177308-0d34-0410-b5e6-96231b3b80d8
* Update tests.Anders Carlsson2011-01-291-1/+1
| | | | | | | | I'm still not sure if having the typenames be visible with -hidden-weak-vtables, but I think it makes sense. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124549 91177308-0d34-0410-b5e6-96231b3b80d8
* Mark VTables and RTTI data linkonce_odr instead of weak_odr, with the ↵Anders Carlsson2011-01-241-16/+16
| | | | | | | | | | exception of explicit template instantiations, which have to be weak_odr. This fixes PR6996. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124089 91177308-0d34-0410-b5e6-96231b3b80d8
* Set unnamed_addr in every type info.Rafael Espindola2011-01-111-18/+18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123293 91177308-0d34-0410-b5e6-96231b3b80d8
* Set unnamed_addr for type infos that we are confortable marking as hidden. IRafael Espindola2011-01-111-5/+5
| | | | | | think it is safe to mark all type infos with unnamed_addr, but I am not sure. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123275 91177308-0d34-0410-b5e6-96231b3b80d8
* Give hidden visibility to RTTI for derived types. This is kindof a hackyJohn McCall2010-12-171-0/+10
| | | | | | | | way to do this, but it fixes rdar://problem/8778973 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122033 91177308-0d34-0410-b5e6-96231b3b80d8
* test/CodeGenCXX/rtti-linkage.cpp: Get rid of sort(1) to remove XFAIL: win32.NAKAMURA Takumi2010-11-081-41/+36
| | | | | | On the certain system, bogus SORT.EXE is picked up. Its sort-order is incompatible to POSIX. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118391 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't let typeinfo name symbols be 'internal hidden', it can lead to linker ↵Argyrios Kyrtzidis2010-10-111-1/+2
| | | | | | | | conflicts with similarly named classes in anonymous namespaces. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116185 91177308-0d34-0410-b5e6-96231b3b80d8
* Just disable the hidden-visibility optimization for now by hiding it behindJohn McCall2010-08-121-1/+1
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110979 91177308-0d34-0410-b5e6-96231b3b80d8
* It turns out that linkers (at least, the Darwin linker) don't necessarilyJohn McCall2010-08-051-1/+1
| | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110374 91177308-0d34-0410-b5e6-96231b3b80d8
* Emit standard-library RTTI with external linkage, not weak_odr.John McCall2010-08-041-4/+18
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110192 91177308-0d34-0410-b5e6-96231b3b80d8
* typeid() produces type information for the cv-unqualified version ofDouglas Gregor2010-06-021-0/+11
| | | | | | | the type. Thanks to Anders for the bug report! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105314 91177308-0d34-0410-b5e6-96231b3b80d8
* XFAIL a test on Win32.Daniel Dunbar2010-05-141-0/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103762 91177308-0d34-0410-b5e6-96231b3b80d8
* Rework when and how vtables are emitted, by tracking where vtables areDouglas Gregor2010-05-131-32/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103718 91177308-0d34-0410-b5e6-96231b3b80d8
* Drastically simplify the computation of linkage for typeinfo by usingDouglas Gregor2010-03-311-0/+1
| | | | | | | | | the existing (and already well-tested) linkage computation for types, with minor tweaks for dynamic classes and (pointers to) incomplete types. Fixes PR6597. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99968 91177308-0d34-0410-b5e6-96231b3b80d8
* If the key function of a record is inline, then the RTTI data should have ↵Anders Carlsson2009-12-311-0/+9
| | | | | | weak_odr linkage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92371 91177308-0d34-0410-b5e6-96231b3b80d8
* More RTTI cleanup, test that RTTI classes have the correct vtables.Anders Carlsson2009-12-301-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92284 91177308-0d34-0410-b5e6-96231b3b80d8
* Handle enum types as well.Anders Carlsson2009-12-291-0/+9
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92276 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix function type RTTI linkage and add tests.Anders Carlsson2009-12-291-1/+16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92266 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove cv-qualifiers from the argument to typeidDouglas Gregor2009-12-231-4/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92041 91177308-0d34-0410-b5e6-96231b3b80d8
* Add tests for structs inside anonymous namespaces.Anders Carlsson2009-12-211-2/+17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91806 91177308-0d34-0410-b5e6-96231b3b80d8
* Incomplete structs should also have internal linkage.Anders Carlsson2009-12-211-0/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91805 91177308-0d34-0410-b5e6-96231b3b80d8
* Correcly handle pointers to member pointer types where the class or the ↵Anders Carlsson2009-12-201-0/+19
| | | | | | pointee is incomplete. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91804 91177308-0d34-0410-b5e6-96231b3b80d8
* Rework the way pointer types are handled by the RTTI builder. We now get the ↵Anders Carlsson2009-12-201-2/+17
| | | | | | right linkage for indirect pointers to incomplete structs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91799 91177308-0d34-0410-b5e6-96231b3b80d8
* 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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91446 91177308-0d34-0410-b5e6-96231b3b80d8
* Use GetAddrOfRTTI when getting the RTTI pointer for a base class.Anders Carlsson2009-12-111-0/+16
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91127 91177308-0d34-0410-b5e6-96231b3b80d8