aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGVTables.cpp
AgeCommit message (Collapse)AuthorFilesLines
2014-02-08Remove the -fhidden-weak-vtables -cc1 option. It was dead,John McCall1-43/+1
gross, and increasingly replaced through other mechanisms. llvm-svn: 201011
2014-02-05MS ABI: Mangle member pointer template argumentsReid Kleckner1-6/+2
Member pointers are mangled as they would be represented at runtime. They can be a single integer literal, single decl, or a tuple with some more numbers tossed in. With Clang today, most of those numbers will be zero because we reject pointers to members of virtual bases. This change required moving VTableContextBase ownership from CodeGenVTables to ASTContext, because mangling now depends on vtable layout. I also hoisted the inheritance model helpers up to be inline static methods of MSInheritanceAttr. This makes the AST code that deals with member pointers much more readable. MSVC doesn't appear to have stable manglings of null member pointers: - Null data memptrs in function templates have a mangling collision with the first field of a non-polymorphic single inheritance class. - The mangling of null data memptrs changes if you add casts. - Large null function memptrs in class templates crash MSVC. Clang uses the class template mangling for null data memptrs and the function template mangling for null function memptrs to deal with this. Reviewers: majnemer Differential Revision: http://llvm-reviews.chandlerc.com/D2695 llvm-svn: 200857
2014-01-25Rename getResultType() on function and method declarations to getReturnType()Alp Toker1-3/+3
A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
2013-12-20Eliminate the ItaniumVTableContext object from CodeGenVTablesReid Kleckner1-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
2013-12-17[ms-cxxabi] The 'most derived' ctor parameter usually comes lastReid Kleckner1-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
2013-12-09Avoid adding some decls to DeferredDeclsToEmit.Rafael Espindola1-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
2013-12-07CodeGen: Don't emit linkage on thunks that aren't emitted because they're ↵Benjamin Kramer1-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
2013-12-05Correct hyphenations in comments and assert messagesAlp Toker1-1/+1
This patch tries to avoid unrelated changes other than fixing a few hyphen-related ambiguities in nearby lines. llvm-svn: 196466
2013-11-15[-cxx-abi microsoft] Emit thunks for pointers to virtual member functionsHans Wennborg1-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
2013-11-05Fix vbtable indices when a class shares the vbptr with a non-virtual baseTimur Iskhodzhanov1-8/+7
llvm-svn: 194082
2013-11-04Use aliases for more constructors and destructors.Rafael Espindola1-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
2013-10-30Add CodeGenABITypes.h for use in LLDB.Mark Lacey1-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
2013-10-30Make thunk this/return adjustment ABI-specific. Also, fix the return ↵Timur Iskhodzhanov1-64/+9
adjustment when using -cxx-abi microsoft Reviewed at http://llvm-reviews.chandlerc.com/D2026 llvm-svn: 193679
2013-10-11Use castAs instead of cast in thunk generationReid Kleckner1-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
2013-10-09Code cleanup: rename VTableContext to ItaniumVTableContext, VTableBuilder to ↵Timur Iskhodzhanov1-1/+1
ItaniumVTableBuilder and clang-format code around llvm-svn: 192288
2013-10-09Reland 192220 "Abstract out parts of thunk emission code, add support for ↵Timur Iskhodzhanov1-25/+24
simple thunks when using -cxx-abi microsoft" with relaxed assertions llvm-svn: 192285
2013-10-08Revert 192220 as it fails on an assertionTimur Iskhodzhanov1-24/+25
llvm-svn: 192225
2013-10-08Abstract out parts of thunk emission code, add support for simple thunks ↵Timur Iskhodzhanov1-25/+24
when using -cxx-abi microsoft Reviewed at http://llvm-reviews.chandlerc.com/D1787 llvm-svn: 192220
2013-10-03Extract ABI-specific parts of MangleContext into separate classesTimur Iskhodzhanov1-3/+3
Reviewed at http://llvm-reviews.chandlerc.com/D1807 llvm-svn: 191878
2013-10-02Thread a SourceLocation into the EmitCheck for "load_invalid_value". This occursNick Lewycky1-1/+1
when scalars are loaded / undergo lvalue-to-rvalue conversion. llvm-svn: 191808
2013-09-27Abstract out the emission of vtables, add basic support for vtable emission ↵Timur Iskhodzhanov1-75/+4
when using -cxx-abi microsoft Reviewed at http://llvm-reviews.chandlerc.com/D1532 llvm-svn: 191523
2013-09-03Don't emit an available_externally vtable pointing to linkonce_odr funcs.Rafael Espindola1-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
2013-08-27Revert "PR14569: Omit debug info for thunks"David Blaikie1-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
2013-08-27PR14569: Omit debug info for thunksDavid Blaikie1-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
2013-08-26Simplify/clean up debug info suppression in CodeGenFunctionDavid Blaikie1-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
2013-08-22DebugInfo: emit the definition of types when construction vtables are ↵David Blaikie1-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
2013-08-20Revert "Revert "Revert "Revert "DebugInfo: Omit debug info for dynamic ↵David Blaikie1-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
2013-08-19Revert "Revert "Revert "DebugInfo: Omit debug info for dynamic classes in ↵Michael Gottesman1-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
2013-08-18Revert "Revert "DebugInfo: Omit debug info for dynamic classes in TUs that ↵David Blaikie1-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
2013-08-17Revert "DebugInfo: Omit debug info for dynamic classes in TUs that do not ↵David Blaikie1-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
2013-08-16DebugInfo: Omit debug info for dynamic classes in TUs that do not have the ↵David Blaikie1-0/+3
vtable for that class This reduces Clang's .dwo (fission debug info) size by 23% over Clang+LLVM. llvm-svn: 188576
2013-07-30Add MicrosoftVFTableContext to ASTTimur Iskhodzhanov1-1/+25
llvm-svn: 187409
2013-06-30Restore r184205 and associated commits (after commit of r185290)Stephen Lin1-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
2013-06-19Revert r184205 and associated patches while investigating issue with broken ↵Stephen Lin1-2/+1
buildbot (possible interaction with LTO) <rdar://problem/14209661> llvm-svn: 184384
2013-06-19[ms-cxxabi] Emit and install appropriately mangled vbtablesReid Kleckner1-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
2013-06-18CodeGen: Have 'this'-returning constructors and destructors to take ↵Stephen Lin1-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
2013-06-05[ms-cxxabi] Thread GlobalDecls through to CodeGenModule::getFunctionLinkage.Peter Collingbourne1-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
2013-05-13Cleanup handling of UniqueExternalLinkage.Rafael Espindola1-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
2013-03-07Change hasAggregateLLVMType, which conflates complex andJohn McCall1-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
2013-02-27Better support for constructors with -cxx-abi microsoft, partly fixes PR12784Timur Iskhodzhanov1-2/+6
llvm-svn: 176186
2013-02-20Add a new 'type_visibility' attribute to allow users toJohn McCall1-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
2013-02-16Emit vtables for an extern template class as available_externally, not asRichard Smith1-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
2013-01-25The standard ARM C++ ABI dictates that inline functions areJohn McCall1-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
2012-12-04Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth1-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
2012-10-25Initialize debug info for special cases of functions that lack declarations ↵Alexey Samsonov1-1/+4
and are generated by Clang (global initializers/destructors, thunks) . Fixes PR13942. llvm-svn: 166676
2012-10-24Remove the HiddenWeakTemplateVTables CodeGen option. It's currently unused.Douglas Gregor1-2/+1
llvm-svn: 166561
2012-10-16PR13684: Emit vtable entries for deleted functions as __cxa_deleted_function.David Blaikie1-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
2012-09-21Call CGM.SetLLVMFunctionAttributesForDefinition on thunks so that they getRafael Espindola1-0/+2
attributes like uwtable. Without uwtable a stack unwinder would be unable to go past the thunks. llvm-svn: 164411
2012-09-19Update clang for API change.Benjamin Kramer1-1/+3
llvm-svn: 164218
2012-09-14Fix thunk emission for covariant virtual functions in cases which requireEli Friedman1-7/+16
both a virtual and a non-virtual offset. PR13832. llvm-svn: 163866