summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/MicrosoftCXXABI.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert 192220 as it fails on an assertionTimur Iskhodzhanov2013-10-081-12/+0
| | | | llvm-svn: 192225
* Abstract out parts of thunk emission code, add support for simple thunks ↵Timur Iskhodzhanov2013-10-081-0/+12
| | | | | | | | 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-6/+10
| | | | | | 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/+139
| | | | | | | | 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-6/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [-cxx-abi microsoft] Change the vdtor implicit should_call_delete argument ↵Timur Iskhodzhanov2013-08-271-6/+6
| | | | | | type to int llvm-svn: 189336
* Abstract out virtual calls and virtual function prologue code generation; ↵Timur Iskhodzhanov2013-08-211-7/+115
| | | | | | 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/+7
| | | | | | fixes PR16735 llvm-svn: 187709
* Add MicrosoftVFTableContext to ASTTimur Iskhodzhanov2013-07-301-18/+1
| | | | llvm-svn: 187409
* [ms-cxxabi] Emit linkonce complete dtors in TUs that need themReid Kleckner2013-07-221-1/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-37/+35
| | | | | | 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] Destroy temporary record arguments in the calleeReid Kleckner2013-06-211-1/+1
| | | | | | | | | | | | | | | | | | Itanium destroys them in the caller at the end of the full expression, but MSVC destroys them in the callee. This is further complicated by the need to emit EH-only destructor cleanups in the caller. This should help clang compile MSVC's debug iterators more correctly. There is still an outstanding issue in PR5064 of a memcpy emitted by the LLVM backend, which is not correct for C++ records. Fixes PR16226. Reviewers: rjmccall Differential Revision: http://llvm-reviews.chandlerc.com/D929 llvm-svn: 184543
* Revert r184205 and associated patches while investigating issue with broken ↵Stephen Lin2013-06-191-35/+37
| | | | | | | | 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-33/+26
| | | | | | | | | 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-6/+69
| | | | | | | | | | | | | | | | | | | | | | | | | 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-29/+34
| | | | | | | | | | 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] Fix vbptr offsets in memptrs when the vbptr is in an nvbaseReid Kleckner2013-06-051-6/+2
| | | | | | | | Also addresses a review comment from John from on r180985 by removing the "== -1" check, since it's now reusing the correct code which has the comment. llvm-svn: 183318
* [ms-cxxabi] Factor out some loops into helpers for readabilityReid Kleckner2013-06-041-29/+33
| | | | | | | No functionality change, covered by the existing virtual base adjustment tests. llvm-svn: 183251
* [ms-cxxabi] Implement MSVC virtual base adjustmentReid Kleckner2013-05-291-14/+112
| | | | | | | | | | | | 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-19/+285
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [ms-cxxabi] Emit non-virtual member function pointersReid Kleckner2013-05-031-18/+87
| | | | | | | | | | | | | | Without any conversion, this is pretty straightforward. Most of the fields can be zeros. The order is: - field offset or pointer - nonvirtual adjustment (for MI functions) - vbptr offset (for unspecified) - virtual adjustment offset (for virtual inheritance) Differential Revision: http://llvm-reviews.chandlerc.com/D699 llvm-svn: 180985
* [ms-cxxabi] Implement member pointer comparisonsReid Kleckner2013-04-301-0/+72
| | | | | | | | | | | | | | | | | | Summary: Like Itanium, comparisons are basically bitwise comparisons of the two values, with an exception for null member function pointers. If two function pointers are null, only the function pointer field matters for comparison purposes. The rest of the bits can be arbitrary. We take advantage of this in isZeroInitializable(), and it may matter once we start emitting conversions. Reviewers: rjmccall CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D695 llvm-svn: 180800
* Set SRet flags properly in '-cxx-abi microsoft'.Timur Iskhodzhanov2013-04-171-0/+11
| | | | | | | | | 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
* CodeGen support for function-local static thread_local variables withRichard Smith2013-04-141-0/+3
| | | | | | | | | 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
* [ms-cxxabi] Implement member pointer emission and dereferencingReid Kleckner2013-04-111-52/+281
| | | | | | | | | | | | | | | | | | | | | Summary: Handles all inheritance models for both data and function member pointers. Also implements isZeroInitializable() and refactors some of the null member pointer code. MSVC supports converting member pointers through virtual bases, which clang does not (yet?) support. Implementing that extension is covered by http://llvm.org/15713 Reviewers: rjmccall CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D613 llvm-svn: 179305
* [ms-cxxabi] Implement member data pointers for non-dynamic classesReid Kleckner2013-03-221-0/+116
| | | | | | | | | | | | | | | | | | | | Summary: For non-dynamic classes (no virtual bases), member data pointers are simple offsets from the base of the record. Dynamic classes use an aggregate for member data pointers and are therefore currently unsupported. Unlike Itanium, the ms ABI uses 0 to represent null for polymorphic classes. Non-polymorphic classes use -1 like Itanium, since 0 is a valid field offset. Reviewers: rjmccall CC: timurrrr, cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D558 llvm-svn: 177753
* Exploit this-return of a callsite in a this-return function.Manman Ren2013-03-201-2/+3
| | | | | | | | | | | | | | 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
* revert r177211 due to its potential issuesManman Ren2013-03-161-3/+2
| | | | llvm-svn: 177222
* Exploit this-return of a callsite in a this-return function.Manman Ren2013-03-161-2/+3
| | | | | | | | | | | | | 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. rdar://12818789 llvm-svn: 177211
* Better support for constructors with -cxx-abi microsoft, partly fixes PR12784Timur Iskhodzhanov2013-02-271-3/+83
| | | | llvm-svn: 176186
* Abstract out emitting the vdtor calls and do it properly when using -cxx-abi ↵Timur Iskhodzhanov2013-02-151-0/+31
| | | | | | microsoft; also fix vdtor calls for the ARM ABI llvm-svn: 175271
* Emit virtual/deleting destructors properly with -cxx-abi microsoft, PR15058Timur Iskhodzhanov2013-02-131-4/+41
| | | | llvm-svn: 175045
* The standard ARM C++ ABI dictates that inline functions areJohn McCall2013-01-251-7/+0
| | | | | | | | never key functions. We did not implement that rule for the iOS ABI, which was driven by what was implemented in gcc-4.2. However, implement it now for other ARM-based platforms. llvm-svn: 173515
* First step towards vftable generation with -cxx-abi microsoft PR13231Timur Iskhodzhanov2013-01-211-1/+1
| | | | llvm-svn: 173035
* Cleanup some clang code to use new type functions instead of using cast<>.Micah Villmow2012-10-251-2/+2
| | | | llvm-svn: 166684
* PR13684: Emit vtable entries for deleted functions as __cxa_deleted_function.David Blaikie2012-10-161-0/+3
| | | | | | | | This is consistent/interoperable with GCC 4.7 (& __cxa_deleted_function isn't present in 4.4 - not sure when it got added, but you'll need something with that function available for this to work). llvm-svn: 166069
* When performing a ::delete of an object with a virtual destructor,John McCall2012-09-251-0/+11
| | | | | | | | | | | | | | be sure to delete the complete object pointer, not the original pointer. This is necessary if the base being deleted is at a non-zero offset in the complete object. This is only required for objects with virtual destructors because deleting an object via a base-class subobject when the base does not have a virtual destructor is undefined behavior. Noticed while reviewing the last four years of cxx-abi-dev activity. llvm-svn: 164597
* In the MS ABI, ctors return 'this'. Patch by Dmitry Sokolov.John McCall2012-09-251-12/+35
| | | | llvm-svn: 164592
* [Windows] Abstract pure virtual method calls in the ABI. Fix the Windows ABI ↵Joao Matos2012-07-171-0/+2
| | | | | | to forward to the correct function. llvm-svn: 160373
* IRGen: Factor v-table generation into the CGCXXABI object.Charles Davis2012-06-231-0/+6
| | | | llvm-svn: 159091
* Abstract the emission of global destructors into ABI-specific codeJohn McCall2012-05-011-0/+16
| | | | | | | | | | | | | and only consider using __cxa_atexit in the Itanium logic. The default logic is to use atexit(). Emit "guarded" initializers in Microsoft mode unconditionally. This is definitely not correct, but it's closer to correct than just not emitting the initializer. Based on a patch by Timur Iskhodzhanov! llvm-svn: 155894
* Refactor the C++ ABI code a little bit to take advantage ofJohn McCall2012-05-011-7/+67
| | | | | | | | what I'm going to treat as basically universal properties of array-cookie code. Implement MS array cookies on top of that. Based on a patch by Timur Iskhodzhanov! llvm-svn: 155886
* ErrorUnsupported on array cookies in the MS C++ ABI code;John McCall2012-04-041-0/+7
| | | | | | patch by Timur Iskhodzhanov. llvm-svn: 153990
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-2/+2
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* fix a bunch of comment typos found by codespell. Patch byChris Lattner2011-04-151-1/+1
| | | | | | Luis Felipe Strano Moraes! llvm-svn: 129559
* Notes on dynamic array cookies in MSVC.John McCall2011-01-271-0/+23
| | | | | | My thanks to chapuni for his help in investigating this. llvm-svn: 124351
* Move name mangling support from CodeGen to AST. In thePeter Collingbourne2011-01-131-1157/+1
| | | | | | | | | | | | | | process, perform a number of refactorings: - Move MiscNameMangler member functions to MangleContext - Remove GlobalDecl dependency from MangleContext - Make MangleContext abstract and move Itanium/Microsoft functionality to their own classes/files - Implement ASTContext::createMangleContext and have CodeGen use it No (intended) functionality change. llvm-svn: 123386
* The -fshort-wchar option causes wchar_t to become unsigned, in addition to beingChris Lattner2010-12-251-1/+2
| | | | | | | 16-bits in size. Implement this by splitting WChar into two enums, like we have for char. This fixes a miscompmilation of XULRunner, PR8856. llvm-svn: 122558
* Introduce a new type, PackExpansionType, to capture types that areDouglas Gregor2010-12-201-0/+4
| | | | | | | | | | | | | | | | | | | | pack expansions, e.g. given template<typename... Types> struct tuple; template<typename... Types> struct tuple_of_refs { typedef tuple<Types&...> types; }; the type of the "types" typedef is a PackExpansionType whose pattern is Types&. This commit introduces support for creating pack expansions for template type arguments, as above, but not for any other kind of pack expansion, nor for any form of instantiation. llvm-svn: 122223
OpenPOWER on IntegriCloud