summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/MicrosoftCXXABI.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [modules ts] Basic for module linkage.Richard Smith2017-07-071-0/+2
| | | | | | | | | | In addition to the formal linkage rules, the Modules TS includes cases where internal-linkage symbols within a module interface unit can be referenced from outside the module via exported inline functions / templates. We give such declarations "module-internal linkage", which is formally internal linkage, but results in an externally-visible symbol. llvm-svn: 307434
* [DebugInfo] Add kind of ImplicitParamDecl for emission of FlagObjectPointer.Alexey Bataev2017-06-091-14/+15
| | | | | | | | | | | | | | | | | Summary: If the first parameter of the function is the ImplicitParamDecl, codegen automatically marks it as an implicit argument with `this` or `self` pointer. Added internal kind of the ImplicitParamDecl to separate 'this', 'self', 'vtt' and other implicit parameters from other kind of parameters. Reviewers: rjmccall, aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33735 llvm-svn: 305075
* Emit available_externally vtables opportunisticallyPiotr Padlewski2017-06-011-0/+3
| | | | | | | | | | | | | | Summary: We can emit vtable definition having inline function if they are all emitted. Reviewers: rjmccall, rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33437 llvm-svn: 304394
* Spelling mistakes in comments. NFCI. (PR27635)Simon Pilgrim2017-03-301-1/+1
| | | | llvm-svn: 299083
* Update Clang for LLVM rename AttributeSet -> AttributeListReid Kleckner2017-03-211-12/+11
| | | | llvm-svn: 298394
* Promote ConstantInitBuilder to be a public CodeGen API; it'sJohn McCall2017-03-021-1/+1
| | | | | | a generally useful utility for other frontends. NFC. llvm-svn: 296806
* [CodeGen] Fix ExtParameterInfo bugs in C++ CodeGen code.George Burgess IV2017-02-231-1/+1
| | | | | | | | | | | | | | | | This patch makes use of the prefix/suffix ABI argument distinction that was introduced in r295870, so that we now emit ExtParameterInfo at the correct offset for member calls that have added ABI arguments. I don't see a good way to test the generated param info, since we don't actually seem to use it in CGFunctionInfo outside of Swift. Any suggestions/thoughts for how to better test this are welcome. :) This patch also fixes a small bug with inheriting constructors: if we decide not to pass args into an base class ctor, we would still generate ExtParameterInfo as though we did. The added test-case is for that behavior. llvm-svn: 296024
* [CodeGen] Note where we add ABI-specific args in ctors. NFC.George Burgess IV2017-02-221-23/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | Meta: The ultimate goal is to teach ExtParameterInfo about pass_object_size attributes. This is necessary for that, since our ExtParameterInfo is a bit buggy in C++. I plan to actually make use of this Prefix/Suffix info in the near future, but I like small single-purpose changes. Especially when those changes are hard to actually test... At the moment, some of our C++-specific CodeGen pretends that ABIs can only add arguments to the beginning of a function call. This isn't quite correct: args can be appended to the end, as well. It hasn't mattered much until now, since we seem to only use this "number of arguments added" data when calculating the ExtParameterInfo to use when making a CGFunctionInfo. Said ExtParameterInfo is currently only used for ParameterABIs (Swift) and ns_consumed (ObjC). So, this patch allows ABIs to indicate whether args they added were at the beginning or end of an argument list. We can use this information to emit ExtParameterInfos more correctly, though like said, that bit is coming soon. No tests since this is theoretically a nop. llvm-svn: 295870
* Move vtable type metadata emission behind a cc1-level flag.Peter Collingbourne2017-01-181-1/+1
| | | | | | | | | | | | | In ThinLTO mode, type metadata will require the module to be written as a multi-module bitcode file, which is currently incompatible with the Darwin linker. It is also useful to be able to enable or disable multi-module bitcode for testing purposes. This introduces a cc1-level flag, -f{,no-}lto-unit, which is used by the driver to enable multi-module bitcode on all but Darwin+ThinLTO, and can also be used to enable/disable the feature manually. Differential Revision: https://reviews.llvm.org/D28877 llvm-svn: 292448
* CodeGen: update comment about RTTI fieldSaleem Abdulrasool2017-01-011-1/+1
| | | | | | | | | | The MS ABI RTTI has a reserved field which is used as a cache for the demangled name. It must be zero-initialized, which is used as a hint by the runtime to say that the cache has not been populated. Since this field is populated at runtime, the RTTI structures must be placed in the .data section rather than .rdata. NFC llvm-svn: 290799
* CodeGen: fix runtime function dll storageSaleem Abdulrasool2016-12-151-4/+8
| | | | | | | | | | | | | | | | | Properly attribute DLL storage to runtime functions. When generating the runtime function, scan for an existing declaration which may provide an explicit declaration (local storage) or a DLL import or export storage from the user. Honour that if available. Otherwise, if building with a local visibility of the public or standard namespaces (-flto-visibility-public-std), give the symbols local storage (it indicates a /MT[d] link, so static runtime). Otherwise, assume that the link is dynamic, and give the runtime function dllimport storage. This allows for implementations to get the correct storage as long as they are properly declared, the user to override the import storage, and in case no explicit storage is given, use of the import storage. llvm-svn: 289776
* CodeGen: New vtable group representation: struct of vtable arrays.Peter Collingbourne2016-12-131-9/+7
| | | | | | | | | In a future change, this representation will allow us to use the new inrange annotation on getelementptr to allow the optimizer to split vtable groups. Differential Revision: https://reviews.llvm.org/D22296 llvm-svn: 289584
* [MS-ABI]V-base dtor called more than needed when throw happens in v-base ↵Erich Keane2016-12-071-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ctor in window. Need add "complete object flag" check in eh cleanup code. The problem only happen on window ( A MS-ABI issuer ) The nature of the problem is virtual base dtor called more than it is needed after exception throw in inheriting base class(with virtual bases) ctor. The root problem is when throw happen, not all virtual base classes have been contructed, so not all virtual base dtors are need to call for ehcleanup. clang has code to handle vbase initialization: basically add check for "complete object flag" before call to v-base ctor. But that part is missing for cleanup code. To fix this add similar code as v-base init to cleanup code, same algorithm. 1> Add new routine: EmitDtorCompleteObjectHandler With corresponding to EmitCtorCompleteObjectHandler 2> In the EmitDestructorCal Call EmitDtorCompleteObjectHandler when generate ehcleanup inside ctor. Just add check for "complete object flag" before call to v-base dtor. Without my change: ehcleanup: ; preds = %ctor.skip_vbases %13 = cleanuppad within none [], !dbg !66 %14 = bitcast %struct.class_0* %this1 to i8*, !dbg !66 %15 = getelementptr inbounds i8, i8* %14, i64 8, !dbg !66 %16 = bitcast i8* %15 to %struct.class_2*, !dbg !66 call void @"\01??1class_2@@UEAA@XZ"(%struct.class_2* %16) #6 [ "funclet"(token %13) ], !dbg !66 cleanupret from %13 unwind to caller, !dbg !66 with my change: ehcleanup: ; preds = %ctor.skip_vbases %13 = cleanuppad within none [], !dbg !66 %14 = bitcast %struct.class_0* %this1 to i8*, !dbg !66 %15 = getelementptr inbounds i8, i8* %14, i64 8, !dbg !66 %16 = bitcast i8* %15 to %struct.class_2*, !dbg !66 %is_complete_object4 = icmp ne i32 %is_most_derived2, 0, !dbg !66 br i1 %is_complete_object4, label %Dtor.dtor_vbase, label %Dtor.skip_vbase, !d bg !66 Dtor.dtor_vbase: ; preds = %ehcleanup call void @"\01??1class_2@@UEAA@XZ"(%struct.class_2* %16) #6 [ "funclet"(token %13) ], !dbg !66 br label %Dtor.skip_vbase, !dbg !66 Dtor.skip_vbase: ; preds = %Dtor.dtor_vbase, %ehcleanup cleanupret from %13 unwind to caller, !dbg !66 Please let me know you need more info. Patch by Jennifer Yu. Differential Revision: https://reviews.llvm.org/D27358 llvm-svn: 288869
* Make CGVTables use ConstantInitBuilder. NFC.John McCall2016-11-281-3/+5
| | | | llvm-svn: 288081
* Remove C++ default arg side table for MS ABI ctor closuresReid Kleckner2016-11-231-5/+5
| | | | | | | | | | | | | | | | | | | Summary: We don't need a side table in ASTContext to hold CXXDefaultArgExprs. The important part of building the CXXDefaultArgExprs was to ODR use the default argument expressions, not to make AST nodes. Refactor the code to only check the default argument, and remove the side table in ASTContext which wasn't being serialized. Fixes PR31121 Reviewers: thakis, rsmith, majnemer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27007 llvm-svn: 287774
* Sema, CodeGen: Ensure that an implicit copy ctor is available more often ↵Peter Collingbourne2016-11-221-9/+16
| | | | | | | | | | | | | | | | under the Microsoft C++ ABI. This is needed because whether the constructor is deleted can control whether we pass structs by value directly. To fix this properly we probably want a more direct way for CodeGen to ask whether the constructor was deleted. Fixes PR31049. Differential Revision: https://reviews.llvm.org/D26822 llvm-svn: 287600
* Fix PR31029 by attaching an artificial debug location to msabi thunks.Adrian Prantl2016-11-161-0/+3
| | | | | | This was a latent bug that was recently uncovered by r286400. llvm-svn: 287134
* [MS ABI] Reuse getVFPtrOffsets instead of using getClassAtVTableLocationDavid Majnemer2016-10-271-40/+16
| | | | | | | | | | | | getClassAtVTableLocation hunts through virtual bases without using the MDC layout which is indicative of a bug. Instead, reuse the getVFPtrOffsets machinery to calculate which subobject within the MDC is responsible for the vfptr. Differential Revision: https://reviews.llvm.org/D25895 llvm-svn: 285315
* Refactor call emission to package the function pointer together withJohn McCall2016-10-261-17/+28
| | | | | | | | | | | abstract information about the callee. NFC. The goal here is to make it easier to recognize indirect calls and trigger additional logic in certain cases. That logic will come in a later patch; in the meantime, I felt that this was a significant improvement to the code. llvm-svn: 285258
* MS ABI: Fix assert when generating virtual function call with virtual bases ↵Hans Wennborg2016-10-191-9/+2
| | | | | | | | | | | | and -flto (PR30731) getClassAtVTableLocation() was calling ASTRecordLayout::getBaseClassOffset() on a virtual base, causing an assert. Differential Revision: https://reviews.llvm.org/D25779 llvm-svn: 284624
* Use unique_ptr for VPtrLocationsMap and VPtrInfoVector.Justin Lebar2016-10-101-29/+29
| | | | | | | | | | Reviewers: timshen Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25422 llvm-svn: 283770
* [MS ABI] Add /include directives for dynamic TLSDavid Majnemer2016-09-121-0/+8
| | | | | | | | | MSVC emits /include directives in the .drective section for the __dyn_tls_init function (decorated as ___dyn_tls_init@12 for 32-bit). This fixes PR30347. llvm-svn: 281189
* CodeGen: Clean up implementation of vtable initializer builder. NFC.Peter Collingbourne2016-09-081-5/+3
| | | | | | | | | | | | | - Simplify signature of CreateVTableInitializer function. - Move vtable component builder to a separate function. - Remove unnecessary accessors from VTableLayout class. This is in preparation for a future change that will alter the type of the vtable initializer. Differential Revision: https://reviews.llvm.org/D22642 llvm-svn: 280897
* [MS] Pass non-trivially-copyable objects indirectly on Windows ARMReid Kleckner2016-08-251-0/+6
| | | | | | | | | | This isn't exactly what MSVC does, unfortunately. MSVC does not pass objects with destructors but no copy constructors by address. More ARM expertise is required to really understand what should be done here. Fixes PR29136. llvm-svn: 279764
* Don't crash when generating code for __attribute__((naked)) member functions.Justin Lebar2016-07-271-0/+4
| | | | | | | | | | | | | | Summary: Previously this crashed inside EmitThisParam(). There should be no prelude for naked functions, so just skip the whole thing. Reviewers: majnemer Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D22715 llvm-svn: 276925
* [MS] Improve VPtrInfo field names and doc commentsReid Kleckner2016-07-201-16/+16
| | | | | | | | | 'ReusingBase' was a terrible name. It might actually refer to the most derived class, which is not a base. 'BaseWithVPtr' was also bad, since again, it could refer to the most derived class. It was actually the first base to introduce the vptr, so now it is 'IntroducingObject'. llvm-svn: 276120
* [MS ABI] Support throwing/catching __unaligned typesDavid Majnemer2016-07-121-7/+15
| | | | | | | | We need to mark the appropriate bits in ThrowInfo and HandlerType so that the personality routine can correctly handle qualification conversions. llvm-svn: 275154
* [MS ABI] Some code cleanupsDavid Majnemer2016-07-091-9/+6
| | | | | | | | Don't create unnecessary truncations if the result will not be used. Also prefer preforming math before the truncation, it makes it a little easier to reason about. llvm-svn: 274984
* [DebugInfo] Set DISubprogram ThisAdjustment in the MS ABIReid Kleckner2016-07-011-1/+1
| | | | llvm-svn: 274326
* CodeGen: Start emitting checked loads when both trapping CFI and ↵Peter Collingbourne2016-06-251-6/+13
| | | | | | | | -fwhole-program-vtables are enabled. Differential Revision: http://reviews.llvm.org/D21122 llvm-svn: 273757
* CodeGen: Update Clang to use the new type metadata.Peter Collingbourne2016-06-241-16/+13
| | | | | | Differential Revision: http://reviews.llvm.org/D21054 llvm-svn: 273730
* Update clang for D20348Peter Collingbourne2016-06-141-7/+7
| | | | | | Differential Revision: http://reviews.llvm.org/D20339 llvm-svn: 272710
* [MS ABI] Delegating constructors should not assume they are most derivedDavid Majnemer2016-05-131-9/+11
| | | | | | | | A constructor needs to know whether or not it is most derived in order to determine if it is responsible for virtual bases. Delegating constructors assumed they were most derived. llvm-svn: 269465
* Re-apply r267784, r267824 and r267830.Peter Collingbourne2016-04-281-10/+7
| | | | | | I have updated the compiler-rt tests. llvm-svn: 267903
* Revert r267784, r267824 and r267830.Benjamin Kramer2016-04-281-7/+10
| | | | | | | | | | It makes compiler-rt tests fail if the gold plugin is enabled. Revert "Rework interface for bitset-using features to use a notion of LTO visibility." Revert "Driver: only produce CFI -fvisibility= error when compiling." Revert "clang/test/CodeGenCXX/cfi-blacklist.cpp: Exclude ms targets. They would be non-cfi." llvm-svn: 267871
* Rework interface for bitset-using features to use a notion of LTO visibility.Peter Collingbourne2016-04-271-10/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Bitsets, and the compiler features they rely on (vtable opt, CFI), only have visibility within the LTO'd part of the linkage unit. Therefore, only enable these features for classes with hidden LTO visibility. This notion is based on object file visibility or (on Windows) dllimport/dllexport attributes. We provide the [[clang::lto_visibility_public]] attribute to override the compiler's LTO visibility inference in cases where the class is defined in the non-LTO'd part of the linkage unit, or where the ABI supports calling classes derived from abstract base classes with hidden visibility in other linkage units (e.g. COM on Windows). If the cross-DSO CFI mode is enabled, bitset checks are emitted even for classes with public LTO visibility, as that mode uses a separate mechanism to cause bitsets to be exported. This mechanism replaces the whole-program-vtables blacklist, so remove the -fwhole-program-vtables-blacklist flag. Because __declspec(uuid()) now implies [[clang::lto_visibility_public]], the support for the special attr:uuid blacklist entry is removed. Differential Revision: http://reviews.llvm.org/D18635 llvm-svn: 267784
* Silencing warnings from MSVC 2015 Update 2. Both of these changes silence ↵Aaron Ballman2016-03-301-1/+1
| | | | | | "C4334 '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)". NFC. llvm-svn: 264932
* EmitCXXStructorCall -> EmitCXXDestructorCall. NFC.Alexey Samsonov2016-03-101-8/+7
| | | | | | | This function is only used in Microsoft ABI and only to emit destructors. Rename/simplify it accordingly. llvm-svn: 263081
* Add whole-program vtable optimization feature to Clang.Peter Collingbourne2016-02-241-11/+8
| | | | | | | | | This patch introduces the -fwhole-program-vtables flag, which enables the whole-program vtable optimization feature (D16795) in Clang. Differential Revision: http://reviews.llvm.org/D16821 llvm-svn: 261767
* [MS ABI] Correctly handle dllimport'd explicit instantiation declaration w/ ↵David Majnemer2016-02-221-0/+3
| | | | | | | | | | | | | | vbases We gave a VBTable dllimport storage class and external linkage while also providing an initializer. An initializer is only valid if the VBTable has available_externally linkage. Fix this by setting the linkage to available_externally in situ while generating the initializer. This fixes PR26686. llvm-svn: 261535
* Revert "Revert r260388 "[MS ABI] Never reference dllimport'd vtables""David Majnemer2016-02-111-4/+11
| | | | | | | | | | | | | This reverts commit r260449. We would supress our emission of vftable definitions if we thought another translation unit would provide the definition because we saw an explicit instantiation declaration. This is not the case with dllimport, we want to synthesize a definition of the vftable regardless. This fixes PR26569. llvm-svn: 260548
* Revert r260388 "[MS ABI] Never reference dllimport'd vtables"Hans Wennborg2016-02-101-11/+4
| | | | | | | This caused the compiler to fail with "invalid linkage type for global declaration" (PR26569). llvm-svn: 260449
* Silence some MSVC false positive warnings about integer zexts and falling ↵Reid Kleckner2016-02-101-1/+1
| | | | | | off the end of a covered switch llvm-svn: 260411
* [MS ABI] Never reference dllimport'd vtablesDavid Majnemer2016-02-101-4/+11
| | | | | | | | | | | | | Referencing a dllimported vtable is impossible in a constexpr constructor. It would be friendlier to C++ programmers if we synthesized a copy of the vftable which referenced imported virtual functions. This would let us initialize the object in a way which preserves both the intent to import functionality from another DLL while also making constexpr work. Differential Revision: http://reviews.llvm.org/D17061 llvm-svn: 260388
* [MS ABI] Cleanup emitVTableDefinitionsDavid Majnemer2016-02-091-6/+6
| | | | | | | Use the VFTable components to determine whether or not we should emit RTTI data instead of duplicating the VFTableBuilder's logic. llvm-svn: 260238
* [MS ABI] Don't emit RTTI descriptors for dllimport vtablesDavid Majnemer2016-02-071-1/+3
| | | | | | | | A dllimport'd vtable always points one past the RTTI data, this means that the initializer will never end up referencing the data. Our emission is a harmless waste. llvm-svn: 260062
* Use a consistent spelling for vtables.Eric Christopher2016-01-291-1/+1
| | | | llvm-svn: 259137
* Cross-DSO control flow integrity (Clang part).Evgeniy Stepanov2015-12-151-8/+5
| | | | | | | | | | | | | | Clang-side cross-DSO CFI. * Adds a command line flag -f[no-]sanitize-cfi-cross-dso. * Links a runtime library when enabled. * Emits __cfi_slowpath calls is bitset test fails. * Emits extra hash-based bitsets for external CFI checks. * Sets a module flag to enable __cfi_check generation during LTO. This mode does not yet support diagnostics. llvm-svn: 255694
* Update clang to use the updated LLVM EH instructionsDavid Majnemer2015-12-121-2/+2
| | | | | | | | | | Depends on D15139. Reviewers: rnk Differential Revision: http://reviews.llvm.org/D15140 llvm-svn: 255423
* Add the `pass_object_size` attribute to clang.George Burgess IV2015-12-021-3/+2
| | | | | | | | | | | | | `pass_object_size` is our way of enabling `__builtin_object_size` to produce high quality results without requiring inlining to happen everywhere. A link to the design doc for this attribute is available at the Differential review link below. Differential Revision: http://reviews.llvm.org/D13263 llvm-svn: 254554
OpenPOWER on IntegriCloud