summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGVTables.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Eliminate the ItaniumVTableContext object from CodeGenVTablesReid Kleckner2013-12-201-15/+8
| | | | | | | | | | | | | Now CodeGenVTables has only one VTableContext object, which is either Itanium or Microsoft. Fixes a FIXME with no functionality change intended. Ideally we could avoid the downcasts by pushing the things that reference the Itanium vtable context into ItaniumCXXABI.cpp, but we're not there yet. llvm-svn: 197845
* [ms-cxxabi] The 'most derived' ctor parameter usually comes lastReid Kleckner2013-12-171-1/+4
| | | | | | | | | | | | | | 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
* Avoid adding some decls to DeferredDeclsToEmit.Rafael Espindola2013-12-091-1/+2
| | | | | | | | Before this patch GetOrCreateLLVMFunction would add a decl to DeferredDeclsToEmit even when it was being called by the function trying to emit that decl. llvm-svn: 196753
* CodeGen: Don't emit linkage on thunks that aren't emitted because they're ↵Benjamin Kramer2013-12-071-3/+4
| | | | | | | | | | | | vararg. This can happen when we're trying to emit a thunk with available_externally linkage with optimization enabled but bail because it doesn't make sense for vararg functions. PR18098. llvm-svn: 196658
* Correct hyphenations in comments and assert messagesAlp Toker2013-12-051-1/+1
| | | | | | | This patch tries to avoid unrelated changes other than fixing a few hyphen-related ambiguities in nearby lines. llvm-svn: 196466
* [-cxx-abi microsoft] Emit thunks for pointers to virtual member functionsHans Wennborg2013-11-151-40/+62
| | | | | | | | | | | | | | | | Instead of storing the vtable offset directly in the function pointer and doing a branch to check for virtualness at each call site, the MS ABI generates a thunk for calling the function at a specific vtable offset, and puts that in the function pointer. This patch adds support for emitting such thunks. However, it doesn't support pointers to virtual member functions that are variadic, have an incomplete aggregate return type or parameter, or are overriding a function in a virtual base class. Differential Revision: http://llvm-reviews.chandlerc.com/D2104 llvm-svn: 194827
* Fix vbtable indices when a class shares the vbptr with a non-virtual baseTimur Iskhodzhanov2013-11-051-8/+7
| | | | llvm-svn: 194082
* Use aliases for more constructors and destructors.Rafael Espindola2013-11-041-4/+0
| | | | | | | | | | | | | | | | With this patch we produce alias for cases like template<typename T> struct foobar { foobar() { } }; template struct foobar<void>; We just have to be careful to produce the same aliases in every TU because of comdats. llvm-svn: 194000
* Add CodeGenABITypes.h for use in LLDB.Mark Lacey2013-10-301-0/+1
| | | | | | | | | | | | | | | | | | CodeGenABITypes is a wrapper built on top of CodeGenModule that exposes some of the functionality of CodeGenTypes (held by CodeGenModule), specifically methods that determine the LLVM types appropriate for function argument and return values. I addition to CodeGenABITypes.h, CGFunctionInfo.h is introduced, and the definitions of ABIArgInfo, RequiredArgs, and CGFunctionInfo are moved into this new header from the private headers ABIInfo.h and CGCall.h. Exposing this functionality is one part of making it possible for LLDB to determine the actual ABI locations of function arguments and return values, making it possible for it to determine this for any supported target without hard-coding ABI knowledge in the LLDB code. llvm-svn: 193717
* Make thunk this/return adjustment ABI-specific. Also, fix the return ↵Timur Iskhodzhanov2013-10-301-64/+9
| | | | | | | | adjustment when using -cxx-abi microsoft Reviewed at http://llvm-reviews.chandlerc.com/D2026 llvm-svn: 193679
* Use castAs instead of cast in thunk generationReid Kleckner2013-10-111-1/+1
| | | | | | | | Calling convention attributes can add sugar to methods that we have to look through. This fixes an assertion failure in the provided test case. llvm-svn: 192496
* Code cleanup: rename VTableContext to ItaniumVTableContext, VTableBuilder to ↵Timur Iskhodzhanov2013-10-091-1/+1
| | | | | | 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-25/+24
| | | | | | simple thunks when using -cxx-abi microsoft" with relaxed assertions llvm-svn: 192285
* Revert 192220 as it fails on an assertionTimur Iskhodzhanov2013-10-081-24/+25
| | | | llvm-svn: 192225
* Abstract out parts of thunk emission code, add support for simple thunks ↵Timur Iskhodzhanov2013-10-081-25/+24
| | | | | | | | 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-3/+3
| | | | | | Reviewed at http://llvm-reviews.chandlerc.com/D1807 llvm-svn: 191878
* Thread a SourceLocation into the EmitCheck for "load_invalid_value". This occursNick Lewycky2013-10-021-1/+1
| | | | | | when scalars are loaded / undergo lvalue-to-rvalue conversion. llvm-svn: 191808
* Abstract out the emission of vtables, add basic support for vtable emission ↵Timur Iskhodzhanov2013-09-271-75/+4
| | | | | | | | when using -cxx-abi microsoft Reviewed at http://llvm-reviews.chandlerc.com/D1532 llvm-svn: 191523
* Don't emit an available_externally vtable pointing to linkonce_odr funcs.Rafael Espindola2013-09-031-20/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert "PR14569: Omit debug info for thunks"David Blaikie2013-08-271-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | 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
* PR14569: Omit debug info for thunksDavid Blaikie2013-08-271-0/+1
| | | | | | | | | | | | | | | | | | This was added in r166676 based on PR13942 on the basis that tools may need debug information for any executable code/function for some fairly broad/non-specific purposes. It seems to me (as noted in PR14569) that the major/only purpose is in backtraces, which should generally not apply to thunks as they won't appear in the stack themselves. By removing them we fix PR14569 and reduce the size of Clang's debug info. Strangely enough this doesn't seem to have a substantial impact on Clang's self-hosted debug info (at least looking at DWO file size) size at all. Not sure if I failed to test this correctly but I only observed a 0.004% change in DWO file size over Clang+LLVM. With thanks to Dinesh Dwivedi for work on this PR. llvm-svn: 189320
* Simplify/clean up debug info suppression in CodeGenFunctionDavid Blaikie2013-08-261-3/+0
| | | | | | | | | | CodeGenFunction is run on only one function - a new object is made for each new function. I would add an assertion/flag to this effect, but there's an exception: ObjC properties involve emitting helper functions that are all emitted by the same CodeGenFunction object, so such a check is not possible/correct. llvm-svn: 189277
* DebugInfo: emit the definition of types when construction vtables are ↵David Blaikie2013-08-221-3/+6
| | | | | | | | | | required as these types may never end up emitting the full class data This might be able to be optimized further by only doing this in the absence of a key function, but it doesn't look like GCC is doing that so I'm not rushing to do it just yet. llvm-svn: 189022
* Revert "Revert "Revert "Revert "DebugInfo: Omit debug info for dynamic ↵David Blaikie2013-08-201-0/+3
| | | | | | | | | | | | | | classes in TUs that do not have the vtable for that class"""" This reverts commit r188687 (reverts r188642 (reverts 188600 (reverts 188576))). With added test coverage & fix for -gline-tables-only. Thanks Michael Gottesman for reverting this patch when it demonstrated problems & providing a reproduction/details to help me track this down. llvm-svn: 188739
* Revert "Revert "Revert "DebugInfo: Omit debug info for dynamic classes in ↵Michael Gottesman2013-08-191-3/+0
| | | | | | | | | | | | | TUs that do not have the vtable for that class""" This reverts commit r188642. This change is causing LTO builds to cause our 16 GB machines to swap and OOM all weekend. I am going to work with Dave Blaikie to resolve the issue. Sorry Dave =(. llvm-svn: 188687
* Revert "Revert "DebugInfo: Omit debug info for dynamic classes in TUs that ↵David Blaikie2013-08-181-0/+3
| | | | | | | | | | | | do not have the vtable for that class"" This reverts commit r188600. r188640/r188639 fixed the root cause of the crash-on-valid that r188600 originally introduced. This now appears to bootstrap debug clang successfully to the best of my testing. llvm-svn: 188642
* Revert "DebugInfo: Omit debug info for dynamic classes in TUs that do not ↵David Blaikie2013-08-171-3/+0
| | | | | | | | | | have the vtable for that class" This reverts commit r188576. Reverting while I investigate a selfhosting buildbot failure on Darwin. llvm-svn: 188600
* DebugInfo: Omit debug info for dynamic classes in TUs that do not have the ↵David Blaikie2013-08-161-0/+3
| | | | | | | | | vtable for that class This reduces Clang's .dwo (fission debug info) size by 23% over Clang+LLVM. llvm-svn: 188576
* Add MicrosoftVFTableContext to ASTTimur Iskhodzhanov2013-07-301-1/+25
| | | | llvm-svn: 187409
* Restore r184205 and associated commits (after commit of r185290)Stephen Lin2013-06-301-1/+2
| | | | | | 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
* Revert r184205 and associated patches while investigating issue with broken ↵Stephen Lin2013-06-191-2/+1
| | | | | | | | buildbot (possible interaction with LTO) <rdar://problem/14209661> llvm-svn: 184384
* [ms-cxxabi] Emit and install appropriately mangled vbtablesReid Kleckner2013-06-191-8/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+2
| | | | | | | | | | 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] Thread GlobalDecls through to CodeGenModule::getFunctionLinkage.Peter Collingbourne2013-06-051-2/+2
| | | | | | | | This is so that we can give destructor variants different linkage later. Differential Revision: http://llvm-reviews.chandlerc.com/D819 llvm-svn: 183324
* Cleanup handling of UniqueExternalLinkage.Rafael Espindola2013-05-131-1/+1
| | | | | | | | | | | | | This patch renames getLinkage to getLinkageInternal. Only code that needs to handle UniqueExternalLinkage specially should call this. Linkage, as defined in the c++ standard, is provided by getFormalLinkage. It maps UniqueExternalLinkage to ExternalLinkage. Most places in the compiler actually want isExternallyVisible, which handles UniqueExternalLinkage as internal. llvm-svn: 181677
* Change hasAggregateLLVMType, which conflates complex andJohn McCall2013-03-071-1/+1
| | | | | | | | | | | | | | | aggregate types in a profoundly wrong way that has to be worked around in every call site, to getEvaluationKind, which classifies and distinguishes between all of these cases. Also, normalize the API for loading and storing complexes. I'm working on a larger patch and wanted to pull these changes out, but it would have be annoying to detangle them from each other. llvm-svn: 176656
* Better support for constructors with -cxx-abi microsoft, partly fixes PR12784Timur Iskhodzhanov2013-02-271-2/+6
| | | | llvm-svn: 176186
* Add a new 'type_visibility' attribute to allow users toJohn McCall2013-02-201-1/+1
| | | | | | | | | | | | | | control the visibility of a type for the purposes of RTTI and template argument restrictions independently of how visibility propagates to its non-type member declarations. Also fix r175326 to not ignore template argument visibility on a template explicit instantiation when a member has an explicit attribute but the instantiation does not. The type_visibility work is rdar://11880378 llvm-svn: 175587
* Emit vtables for an extern template class as available_externally, not asRichard Smith2013-02-161-8/+10
| | | | | | | 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
* The standard ARM C++ ABI dictates that inline functions areJohn McCall2013-01-251-32/+176
| | | | | | | | 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
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-1/+1
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* Initialize debug info for special cases of functions that lack declarations ↵Alexey Samsonov2012-10-251-1/+4
| | | | | | and are generated by Clang (global initializers/destructors, thunks) . Fixes PR13942. llvm-svn: 166676
* Remove the HiddenWeakTemplateVTables CodeGen option. It's currently unused.Douglas Gregor2012-10-241-2/+1
| | | | llvm-svn: 166561
* PR13684: Emit vtable entries for deleted functions as __cxa_deleted_function.David Blaikie2012-10-161-1/+12
| | | | | | | | 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
* Call CGM.SetLLVMFunctionAttributesForDefinition on thunks so that they getRafael Espindola2012-09-211-0/+2
| | | | | | | attributes like uwtable. Without uwtable a stack unwinder would be unable to go past the thunks. llvm-svn: 164411
* Update clang for API change.Benjamin Kramer2012-09-191-1/+3
| | | | llvm-svn: 164218
* Fix thunk emission for covariant virtual functions in cases which requireEli Friedman2012-09-141-7/+16
| | | | | | both a virtual and a non-virtual offset. PR13832. llvm-svn: 163866
* Fix line endings.Eli Friedman2012-09-141-5/+5
| | | | llvm-svn: 163865
* Don't crash *or* insert a bogus autorelease when emitting aJohn McCall2012-07-311-0/+3
| | | | | | this-adjustment thunk in ARC++. llvm-svn: 161014
* Fixed whitespace issue introduced in r160373.Joao Matos2012-07-171-8/+7
| | | | llvm-svn: 160388
OpenPOWER on IntegriCloud