summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/ItaniumCXXABI.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert Itanium parts of "Don't copy objects with trivial, deleted copy ctors"Reid Kleckner2014-05-151-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | This undoes half of r208786. It had problems with lazily declared special members in cases like this: struct A { A(); A &operator=(A &&o); void *p; }; void foo(A); void bar() { foo({}); } In this case, the copy and move constructors are implicitly deleted. However, Clang doesn't eagerly declare the copy ctor in the AST, so we pass the struct in registers. Furthermore, GCC passes this in registers even though this class should be uncopyable. Revert this for now until the dust settles. llvm-svn: 208836
* Don't copy objects with trivial, deleted copy ctorsReid Kleckner2014-05-141-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This affects both the Itanium and Microsoft C++ ABIs. This is in anticipation of a change to the Itanium C++ ABI, and should match GCC's current behavior. The new text will likely be: """ Pass an object of class type by value if every copy constructor and move constructor is deleted or trivial and at least one of them is not deleted, and the destructor is trivial. """ http://sourcerytools.com/pipermail/cxx-abi-dev/2014-May/002728.html On x86 Windows, we can mostly use the same logic, where we use inalloca instead of passing by address. However, on Win64, there are register parameters, and we have to do what MSVC does. MSVC ignores the presence of non-trivial move constructors and only considers the presence of non-trivial or deleted copy constructors. If a non-trivial or deleted copy ctor is present, it passes the argument indirectly. This change fixes bugs and makes us more ABI compatible with both GCC and MSVC. Fixes PR19668. Reviewers: rsmith Differential Revision: http://reviews.llvm.org/D3660 llvm-svn: 208786
* Push record return type classification into CGCXXABIReid Kleckner2014-05-131-5/+16
| | | | | | | | | | | | In the Microsoft C++ ABI, instance methods always return records indirectly via the second hidden parameter. This was implemented in X86_32ABIInfo, but not WinX86_64ABIInfo. Rather than exposing a handful of boolean methods in the CGCXXABI interface, we can expose a single method that applies C++ ABI return value classification rules. llvm-svn: 208733
* CodeGen: Don't set hidden visibility on symbols with local linkageDuncan P. N. Exon Smith2014-05-071-1/+2
| | | | llvm-svn: 208258
* CodeGen: Assign linkage to thread-wrappers correctlyDavid Majnemer2014-05-051-2/+3
| | | | | | | | | | We would sometimes incorrectly give a thread-wrapper external linkage instead of internal linkage if we had only CodeGen'd it's declaration, not it's definition. This fixes PR19655. llvm-svn: 207988
* CodeGen: Unify handling guard variables in the Itanium C++ ABIJustin Bogner2014-04-231-41/+39
| | | | | | | | | | | | | | | We previously treated ARM separately from the generic Itanium ABI for initializing guard variables. This code duplication led to things like the ARM path missing the memory barrier for threadsafe handling, and a highly misleading comment about how we were (mis)using the generic ABI for ARM64 when really it went through the ARM codepath. This unifies the two code paths. Functionally, this changes the ARM and ARM64 codepath to use one byte loads instead of 4 and 8, respectively, and adds the missing atomic acquire to these loads. Other architectures are unchanged. llvm-svn: 206937
* RTTI: refactor the uniqueness question into CGCXXABI.Tim Northover2014-03-301-0/+3
| | | | | | | This also brings the code into closer conformance with usual LLVM coding style and other surrounding conventions. llvm-svn: 205158
* ARM64: initial clang support commit.Tim Northover2014-03-291-0/+15
| | | | | | | | | | | This adds Clang support for the ARM64 backend. There are definitely still some rough edges, so please bring up any issues you see with this patch. As with the LLVM commit though, we think it'll be more useful for merging with AArch64 from within the tree. llvm-svn: 205100
* PR19254: If a thread_local data member of a class is accessed via member accessRichard Smith2014-03-261-8/+7
| | | | | | syntax, don't forget to run its initializer. llvm-svn: 204869
* Fix PR19104: Incorrect handling of non-virtual calls of virtual methodsTimur Iskhodzhanov2014-03-141-3/+0
| | | | | | Reviewed at http://llvm-reviews.chandlerc.com/D3054 llvm-svn: 203949
* PR19113: Emit 'vtable' TBAA metadata when loading a vptr in a ↵Richard Smith2014-03-121-2/+1
| | | | | | pointer-to-member-function call. llvm-svn: 203691
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-121-70/+74
| | | | | | class. llvm-svn: 203643
* Sema: Do not assert when dereferencing member pointer using virtual ↵David Majnemer2014-02-201-10/+8
| | | | | | | | | | | | | | inheritance with an incomplete class type The MS ABI requires that we determine the vbptr offset if have a virtual inheritance model. Instead, raise an error pointing to the diagnostic when this happens. This fixes PR18583. Differential Revision: http://llvm-reviews.chandlerc.com/D2842 llvm-svn: 201824
* Remove dead code.Rafael Espindola2014-02-191-2/+0
| | | | | | Clang never produces a linker private object, so this code is dead. llvm-svn: 201627
* Remove the -fhidden-weak-vtables -cc1 option. It was dead,John McCall2014-02-081-1/+1
| | | | | | gross, and increasingly replaced through other mechanisms. llvm-svn: 201011
* [ms-cxxabi] The 'most derived' ctor parameter usually comes lastReid Kleckner2013-12-171-38/+31
| | | | | | | | | | | | | | Unlike Itanium's VTTs, the 'most derived' boolean or bitfield is the last parameter for non-variadic constructors, rather than the second. For variadic constructors, the 'most derived' parameter comes after the 'this' parameter. This affects constructor calls and constructor decls in a variety of places. Reviewers: timurrrr Differential Revision: http://llvm-reviews.chandlerc.com/D2405 llvm-svn: 197518
* Move C++ destructor emission into CGCXXABIReid Kleckner2013-12-131-2/+29
| | | | | | | No functionality change. Only Itanium C++ destructors have implicit VTT parameters. llvm-svn: 197194
* Remove getVTT* in favor of getStructorImplicitParameter*Reid Kleckner2013-12-131-5/+4
| | | | | | | No functionality change. The only remaining uses were in ItaniumCXXABI, which knows the implicit parameter is a VTT. llvm-svn: 197189
* Output destructors and constructors in a more natural order.Rafael Espindola2013-12-091-12/+12
| | | | | | | | | | | | | | | | With this patch we output the in the order C2 C1 D2 D1 D0 Which means that a destructor or constructor that call another is output after the callee. This is a bit easier to read IHMO and a tiny bit more efficient as we don't put a decl in DeferredDeclsToEmit. llvm-svn: 196784
* Fix PR17738 - add support for vtordisp thunks when using -cxx-abi microsoftTimur Iskhodzhanov2013-11-061-1/+2
| | | | llvm-svn: 194132
* Fix vbtable indices when a class shares the vbptr with a non-virtual baseTimur Iskhodzhanov2013-11-051-9/+12
| | | | llvm-svn: 194082
* Make thunk this/return adjustment ABI-specific. Also, fix the return ↵Timur Iskhodzhanov2013-10-301-0/+68
| | | | | | | | adjustment when using -cxx-abi microsoft Reviewed at http://llvm-reviews.chandlerc.com/D2026 llvm-svn: 193679
* Code cleanup: rename VTableContext to ItaniumVTableContext, VTableBuilder to ↵Timur Iskhodzhanov2013-10-091-2/+2
| | | | | | ItaniumVTableBuilder and clang-format code around llvm-svn: 192288
* Reland 192220 "Abstract out parts of thunk emission code, add support for ↵Timur Iskhodzhanov2013-10-091-0/+7
| | | | | | simple thunks when using -cxx-abi microsoft" with relaxed assertions llvm-svn: 192285
* Revert 192220 as it fails on an assertionTimur Iskhodzhanov2013-10-081-7/+0
| | | | llvm-svn: 192225
* Abstract out parts of thunk emission code, add support for simple thunks ↵Timur Iskhodzhanov2013-10-081-0/+7
| | | | | | | | when using -cxx-abi microsoft Reviewed at http://llvm-reviews.chandlerc.com/D1787 llvm-svn: 192220
* Extract ABI-specific parts of MangleContext into separate classesTimur Iskhodzhanov2013-10-031-1/+5
| | | | | | Reviewed at http://llvm-reviews.chandlerc.com/D1807 llvm-svn: 191878
* Abstract out the emission of vtables, add basic support for vtable emission ↵Timur Iskhodzhanov2013-09-271-5/+127
| | | | | | | | when using -cxx-abi microsoft Reviewed at http://llvm-reviews.chandlerc.com/D1532 llvm-svn: 191523
* [ms-cxxabi] Implement guard variables for static initializationReid Kleckner2013-09-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Static locals requiring initialization are not thread safe on Windows. Unfortunately, it's possible to create static locals that are actually externally visible with inline functions and templates. As a result, we have to implement an initialization guard scheme that is compatible with TUs built by MSVC, which makes thread safety prohibitively difficult. MSVC's scheme is that every function that requires a guard gets an i32 bitfield. Each static local is assigned a bit that indicates if it has been initialized, up to 32 bits, at which point a new bitfield is created. MSVC rejects inline functions with more than 32 static locals, and the externally visible mangling (?_B) only allows for one guard variable per function. On Eli's recommendation, I used MangleNumberingContext to track which bit each static corresponds to. Implements PR16888. Reviewers: rjmccall, eli.friedman Differential Revision: http://llvm-reviews.chandlerc.com/D1416 llvm-svn: 190427
* Revert "PR14569: Omit debug info for thunks"David Blaikie2013-08-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This reverts commit r189320. Alexey Samsonov and Dmitry Vyukov presented some arguments for keeping these around - though it still seems like those tasks could be solved by a tool just using the symbol table. In a very small number of cases, thunks may be inlined & debug info might be able to save profilers & similar tools from misclassifying those cases as part of the caller. The extra changes here plumb through the VarDecl for various cases to CodeGenFunction - this provides better fidelity through a few APIs but generally just causes the CGF::StartFunction to fallback to using the name of the IR function as the name in the debug info. The changes to debug-info-global-ctor-dtor.cpp seem like goodness. The two names that go missing (in favor of only emitting those names as linkage names) are names that can be demangled - emitting them only as the linkage name should encourage tools to do just that. Again, thanks to Dinesh Dwivedi for investigation/work on this issue. llvm-svn: 189421
* Abstract out virtual calls and virtual function prologue code generation; ↵Timur Iskhodzhanov2013-08-211-2/+19
| | | | | | implement them for -cxx-abi microsoft llvm-svn: 188870
* Emit the constructor for abstract classes when using -cxx-abi microsoft, ↵Timur Iskhodzhanov2013-08-041-0/+18
| | | | | | fixes PR16735 llvm-svn: 187709
* Use ARM-style representation for C++ method pointers under PNaCl/EmscriptenMark Seaborn2013-07-241-16/+33
| | | | | | | | | | | | | | | | | | | Before this change, Clang uses the x86 representation for C++ method pointers when generating code for PNaCl. However, the resulting code will assume that function pointers are 0 mod 2. This assumption is not safe for PNaCl, where function pointers could have any value (especially in future sandboxing models). So, switch to using the ARM representation for PNaCl code, which makes no assumptions about the alignment of function pointers. Since we're changing the "le32" target, this change also applies to Emscripten. The change is beneficial for Emscripten too. Emscripten has a workaround to make function pointers 0 mod 2. This change would allow the workaround to be removed. See: https://code.google.com/p/nativeclient/issues/detail?id=3450 llvm-svn: 187051
* [ms-cxxabi] Emit linkonce complete dtors in TUs that need themReid Kleckner2013-07-221-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on Peter Collingbourne's destructor patches. Prior to this change, clang was considering ?1 to be the complete destructor and the base destructor, which was wrong. This lead to crashes when clang tried to emit two LLVM functions with the same name. In this ABI, TUs with non-inline dtors might not emit a complete destructor. They are emitted as inline thunks in TUs that need them, and they always delegate to the base dtors of the complete class and its virtual bases. This change uses the DeferredDecls machinery to emit complete dtors as needed. Currently in clang try body destructors can catch exceptions thrown by virtual base destructors. In the Microsoft C++ ABI, clang may not have the destructor definition, in which case clang won't wrap the virtual virtual base destructor calls in a try-catch. Diagnosing this in user code is TODO. Finally, for classes that don't use virtual inheritance, MSVC always calls the base destructor (?1) directly. This is a useful code size optimization that avoids emitting lots of extra thunks or aliases. Implementing it also means our existing tests continue to pass, and is consistent with MSVC's output. We can do the same for Itanium by tweaking GetAddrOfCXXDestructor, but it will require further testing. Reviewers: rjmccall CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1066 llvm-svn: 186828
* Simplify the CodeGenFunction::Build*Virtual*Call family of functionsTimur Iskhodzhanov2013-07-191-1/+2
| | | | llvm-svn: 186657
* Restore r184205 and associated commits (after commit of r185290)Stephen Lin2013-06-301-87/+36
| | | | | | This allows clang to use the backend parameter attribute 'returned' when generating 'this'-returning constructors and destructors in ARM and MSVC C++ ABIs. llvm-svn: 185291
* [ms-cxxabi] Move CodeGenVTables::needsVTTParameter to ItaniumCXXABI.Peter Collingbourne2013-06-281-1/+23
| | | | | | | | | This function only makes sense there. Eventually it should no longer be part of the CGCXXABI interface, as it is an Itanium-specific detail. Differential Revision: http://llvm-reviews.chandlerc.com/D821 llvm-svn: 185213
* Revert r184205 and associated patches while investigating issue with broken ↵Stephen Lin2013-06-191-36/+87
| | | | | | | | buildbot (possible interaction with LTO) <rdar://problem/14209661> llvm-svn: 184384
* Corrections to r184205 ('this'-return optimization) due to the wrong version ↵Stephen Lin2013-06-191-27/+21
| | | | | | | | | of the patch being committed originally. 1) Removed useless return value of CGCXXABI::EmitConstructorCall and CGCXXABI::EmitVirtualDestructorCall and implementations 2) Corrected last portion of CodeGenCXX/constructor-destructor-return-this to correctly test for non-'this'-return of virtual destructor calls llvm-svn: 184330
* [ms-cxxabi] Emit and install appropriately mangled vbtablesReid Kleckner2013-06-191-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | In Itanium, dynamic classes have one vtable with several different address points for dynamic base classes that can't share vtables. In the MS C++ ABI, each vbtable that can't be shared gets its own symbol, similar to how ctor vtables work in Itanium. However, instead of mangling the subobject offset into the symbol, the unique portions of the inheritance path are mangled into the symbol to make it unique. This patch implements the MSVC 2012 scheme for forming unique vbtable symbol names. MSVC 2010 use the same mangling with a different subset of the path. Implementing that mangling and possibly others is TODO. Each vbtable is an array of i32 offsets from the vbptr that points to it to another virtual base subobject. The first entry of a vbtable always points to the base of the current subobject, implying that it is the same no matter which parent class contains it. Reviewers: rjmccall Differential Revision: http://llvm-reviews.chandlerc.com/D636 llvm-svn: 184309
* CodeGen: Have 'this'-returning constructors and destructors to take ↵Stephen Lin2013-06-181-76/+31
| | | | | | | | | | advantage of the new backend 'returned' attribute. The backend will now use the generic 'returned' attribute to form tail calls where possible, as well as avoid save-restores of 'this' in some cases (specifically the cases that matter for the ARM C++ ABI). This patch also reverts a prior front-end only partial implementation of these optimizations, since it's no longer required. llvm-svn: 184205
* [ms-cxxabi] Implement MSVC virtual base adjustmentReid Kleckner2013-05-291-0/+26
| | | | | | | | | | | | While we can't yet emit vbtables, this allows us to find virtual bases of objects constructed in other TUs. This make iostream hello world work, since basic_ostream virtually inherits from basic_ios. Differential Revision: http://llvm-reviews.chandlerc.com/D795 llvm-svn: 182870
* [ms-cxxabi] Implement member pointer conversionsReid Kleckner2013-05-091-16/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This only supports converting along non-virtual inheritance paths by changing the field offset or the non-virtual base adjustment. This implements three kinds of conversions: - codegen for Value conversions - Constant emission for APValue - Constant folding for CastExprs In almost all constant initialization settings EmitMemberPointer(APValue) is called, except when the expression contains a reinterpret cast. reinterpret casts end up being a big corner case because the null value changes between different kinds of member pointers. Reviewers: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D741 llvm-svn: 181543
* Use the Itanium ABI for thread_local on Darwin.Bill Wendling2013-05-021-1/+5
| | | | | | | | | | | After some discussion, it was decided to use the Itanium ABI for thread_local on Darwin OS X platforms. This involved a couple of changes. First, we use "_tlv_atexit" instead of "__cxa_thread_atexit". Secondly, the global variables are marked with 'internal' linkage, because we want all access to be calls to the Itanium-specific entry point, which has normal linkage. <rdar://problem/13733006> llvm-svn: 180941
* Implement CodeGen for C++11 thread_local, following the Itanium ABI ↵Richard Smith2013-04-191-0/+143
| | | | | | specification as discussed on cxx-abi-dev. llvm-svn: 179858
* Set SRet flags properly in '-cxx-abi microsoft'.Timur Iskhodzhanov2013-04-171-0/+14
| | | | | | | | | Also, - abstract out the indirect/in memory/in registers decisions into the CGCXXABI - fix handling of empty struct arguments for '-cxx-abi microsoft' - add/fix tests llvm-svn: 179681
* Standardize accesses to the TargetInfo in IR-gen.John McCall2013-04-161-1/+1
| | | | | | Patch by Stephen Lin! llvm-svn: 179638
* CodeGen support for function-local static thread_local variables withRichard Smith2013-04-141-11/+18
| | | | | | | | | non-constant constructors or non-trivial destructors. Plus bugfixes for thread_local references bound to temporaries (the temporaries themselves are lifetime-extended to become thread_local), and the corresponding case for std::initializer_list. llvm-svn: 179496
* [cxxabi] Get ptrdiff_t from the CodeGenModule instead of caching itReid Kleckner2013-03-221-32/+16
| | | | | | As the comment says, it's a little silly to cache it in the ABI code. llvm-svn: 177738
* Exploit this-return of a callsite in a this-return function.Manman Ren2013-03-201-5/+6
| | | | | | | | | | | | | | For constructors/desctructors that return 'this', if there exists a callsite that returns 'this' and is immediately before the return instruction, make sure we are using the return value from the callsite. We don't need to keep 'this' alive through the callsite. It also enables optimizations in the backend, such as tail call optimization. Updated from r177211. rdar://12818789 llvm-svn: 177541
OpenPOWER on IntegriCloud