summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/ItaniumCXXABI.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Generating assumption loads of vptr after ctor call (fixed)Piotr Padlewski2015-09-151-37/+81
| | | | | | | | | | | | | | | | | | Generating call assume(icmp %vtable, %global_vtable) after constructor call for devirtualization purposes. For more info go to: http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html Edit: Fixed version because of PR24479 and other bug caused in chrome. After this patch got reverted because of ScalarEvolution bug (D12719) Merged after John McCall big patch (Added Address). http://reviews.llvm.org/D11859 http://reviews.llvm.org/D12865 llvm-svn: 247646
* Revert "Always_inline codegen rewrite" and 2 follow-ups.Evgeniy Stepanov2015-09-141-3/+0
| | | | | | | | | | Revert "Update cxx-irgen.cpp test to allow signext in alwaysinline functions." Revert "[CodeGen] Remove wrapper-free always_inline functions from COMDATs" Revert "Always_inline codegen rewrite." Reason for revert: PR24793. llvm-svn: 247620
* [opaque pointer type] Fix a few uses of PointerType::getElementType in favor ↵David Blaikie2015-09-141-2/+1
| | | | | | | | | | of uses of types already available elsewhere These are a few cleanups I happened to have from trying to go in a different direction recently, so just flushing them out while I have them. llvm-svn: 247593
* Revert "[opaque pointer type] update for LLVM API change"David Blaikie2015-09-141-2/+2
| | | | | | | | | | This was the wrong direction to take anyway (because ultimately the GlobalValue needed the pointee type again and /it/ used PointerType::getElementType eventually anyway)... let's go a different way. This reverts commit r236161. llvm-svn: 247586
* Always_inline codegen rewrite.Evgeniy Stepanov2015-09-121-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current implementation may end up emitting an undefined reference for an "inline __attribute__((always_inline))" function by generating an "available_externally alwaysinline" IR function for it and then failing to inline all the calls. This happens when a call to such function is in dead code. As the inliner is an SCC pass, it does not process dead code. Libc++ relies on the compiler never emitting such undefined reference. With this patch, we emit a pair of 1. internal alwaysinline definition (called F.alwaysinline) 2a. A stub F() { musttail call F.alwaysinline } -- or, depending on the linkage -- 2b. A declaration of F. The frontend ensures that F.inlinefunction is only used for direct calls, and the stub is used for everything else (taking the address of the function, really). Declaration (2b) is emitted in the case when "inline" is meant for inlining only (like __gnu_inline__ and some other cases). This approach, among other nice properties, ensures that alwaysinline functions are always internal, making it impossible for a direct call to such function to produce an undefined symbol reference. This patch is based on ideas by Chandler Carruth and Richard Smith. llvm-svn: 247494
* Revert "Specify target triple in alwaysinline tests."Evgeniy Stepanov2015-09-111-3/+0
| | | | | | | | | Revert "Always_inline codegen rewrite." Breaks gdb & lldb tests. Breaks on Fedora 22 x86_64. llvm-svn: 247491
* Always_inline codegen rewrite.Evgeniy Stepanov2015-09-111-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current implementation may end up emitting an undefined reference for an "inline __attribute__((always_inline))" function by generating an "available_externally alwaysinline" IR function for it and then failing to inline all the calls. This happens when a call to such function is in dead code. As the inliner is an SCC pass, it does not process dead code. Libc++ relies on the compiler never emitting such undefined reference. With this patch, we emit a pair of 1. internal alwaysinline definition (called F.alwaysinline) 2a. A stub F() { musttail call F.alwaysinline } -- or, depending on the linkage -- 2b. A declaration of F. The frontend ensures that F.inlinefunction is only used for direct calls, and the stub is used for everything else (taking the address of the function, really). Declaration (2b) is emitted in the case when "inline" is meant for inlining only (like __gnu_inline__ and some other cases). This approach, among other nice properties, ensures that alwaysinline functions are always internal, making it impossible for a direct call to such function to produce an undefined symbol reference. This patch is based on ideas by Chandler Carruth and Richard Smith. llvm-svn: 247465
* Revert "Generating assumption loads of vptr after ctor call (fixed)"Piotr Padlewski2015-09-101-60/+35
| | | | | | | | It seems that there is small bug, and we can't generate assume loads when some virtual functions have internal visibiliy This reverts commit 982bb7d966947812d216489b3c519c9825cacbf2. llvm-svn: 247332
* Generating assumption loads of vptr after ctor call (fixed)Piotr Padlewski2015-09-091-35/+60
| | | | | | | | | | | | | | | | | Generating call assume(icmp %vtable, %global_vtable) after constructor call for devirtualization purposes. For more info go to: http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html Edit: Fixed version because of PR24479. After this patch got reverted because of ScalarEvolution bug (D12719) Merged after John McCall big patch (Added Address). http://reviews.llvm.org/D11859 llvm-svn: 247199
* Compute and preserve alignment more faithfully in IR-generation.John McCall2015-09-081-144/+224
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce an Address type to bundle a pointer value with an alignment. Introduce APIs on CGBuilderTy to work with Address values. Change core APIs on CGF/CGM to traffic in Address where appropriate. Require alignments to be non-zero. Update a ton of code to compute and propagate alignment information. As part of this, I've promoted CGBuiltin's EmitPointerWithAlignment helper function to CGF and made use of it in a number of places in the expression emitter. The end result is that we should now be significantly more correct when performing operations on objects that are locally known to be under-aligned. Since alignment is not reliably tracked in the type system, there are inherent limits to this, but at least we are no longer confused by standard operations like derived-to-base conversions and array-to-pointer decay. I've also fixed a large number of bugs where we were applying the complete-object alignment to a pointer instead of the non-virtual alignment, although most of these were hidden by the very conservative approach we took with member alignment. Also, because IRGen now reliably asserts on zero alignments, we should no longer be subject to an absurd but frustrating recurring bug where an incomplete type would report a zero alignment and then we'd naively do a alignmentAtOffset on it and emit code using an alignment equal to the largest power-of-two factor of the offset. We should also now be emitting much more aggressive alignment attributes in the presence of over-alignment. In particular, field access now uses alignmentAtOffset instead of min. Several times in this patch, I had to change the existing code-generation pattern in order to more effectively use the Address APIs. For the most part, this seems to be a strict improvement, like doing pointer arithmetic with GEPs instead of ptrtoint. That said, I've tried very hard to not change semantics, but it is likely that I've failed in a few places, for which I apologize. ABIArgInfo now always carries the assumed alignment of indirect and indirect byval arguments. In order to cut down on what was already a dauntingly large patch, I changed the code to never set align attributes in the IR on non-byval indirect arguments. That is, we still generate code which assumes that indirect arguments have the given alignment, but we don't express this information to the backend except where it's semantically required (i.e. on byvals). This is likely a minor regression for those targets that did provide this information, but it'll be trivial to add it back in a later patch. I partially punted on applying this work to CGBuiltin. Please do not add more uses of the CreateDefaultAligned{Load,Store} APIs; they will be going away eventually. llvm-svn: 246985
* [WebAssembly] Initial WebAssembly support in clangDan Gohman2015-09-031-0/+17
| | | | | | | | | | This implements basic support for compiling (though not yet assembling or linking) for a WebAssembly target. Note that ABI details are not yet finalized, and may change. Differential Revision: http://reviews.llvm.org/D12002 llvm-svn: 246814
* Fix PR23472þ by emitting initialized variable and its guard in the same ↵Yaron Keren2015-09-031-3/+5
| | | | | | | | | | COMDAT only for ELF objects. http://llvm.org/pr23472 Reviewed by Reid Kleckner. llvm-svn: 246803
* PR17829: Proper diagnostic of mangled names conflictsAndrey Bokhanko2015-08-311-1/+1
| | | | | | | | | | Proper diagnostic and resolution of mangled names conflicts between C++ methods and C functions. This patch implements support for functions/methods only; support for variables is coming separately. Differential Revision: http://reviews.llvm.org/D11297 llvm-svn: 246438
* Revert r246214 and r246213Steven Wu2015-08-281-60/+35
| | | | | | These two commits causes llvm LTO bootstrap to hang in ScalarEvolution. llvm-svn: 246282
* Assume loads fix #2Piotr Padlewski2015-08-271-3/+2
| | | | | | | | | | | | | There was linker problem, and it turns out that it is not always safe to refer to vtable. If the vtable is used, then we can refer to it without any problem, but because we don't know when it will be used or not, we can only check if vtable is external or it is safe to to emit it speculativly (when class it doesn't have any inline virtual functions). It should be fixed in the future. http://reviews.llvm.org/D12385 llvm-svn: 246214
* Generating assumption loads of vptr after ctor call (fixed)Piotr Padlewski2015-08-271-32/+58
| | | | | | | | | | | | | | | Generating call assume(icmp %vtable, %global_vtable) after constructor call for devirtualization purposes. For more info go to: http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html Edit: Fixed version because of PR24479. http://reviews.llvm.org/D11859 llvm-svn: 246213
* Revert "Generating assumption loads of vptr after ctor call (fixed)"Piotr Padlewski2015-08-211-58/+32
| | | | | | | | Reverting because of 245721 This reverts commit 552658e2b60543c928030b09cc9b5dfcb40c3f28. llvm-svn: 245727
* Generating assumption loads of vptr after ctor call (fixed)Piotr Padlewski2015-08-211-32/+58
| | | | | | | | | | | | | | | Generating call assume(icmp %vtable, %global_vtable) after constructor call for devirtualization purposes. For more info go to: http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html Edit: Fixed version because of PR24479. http://reviews.llvm.org/D11859 llvm-svn: 245721
* Generating available_externally vtables bugfixPiotr Padlewski2015-08-191-6/+4
| | | | | | | | Bugfix revealed in r245264. http://reviews.llvm.org/D12128 llvm-svn: 245489
* Devirtualize EHScopeStack::Cleanup's dtor because it's never destroyed ↵David Blaikie2015-08-181-2/+2
| | | | | | polymorphically llvm-svn: 245378
* Revert "Generating assumption loads of vptr after ctor call (fixed)"Justin Bogner2015-08-181-58/+32
| | | | | | | | | | | Bootstrap bots were failing: http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_build/6382/ http://bb.pgr.jp/builders/clang-3stage-i686-linux/builds/2969 This reverts r245264. llvm-svn: 245267
* Generating assumption loads of vptr after ctor call (fixed)Piotr Padlewski2015-08-181-32/+58
| | | | | | | | | | | | | | | Generating call assume(icmp %vtable, %global_vtable) after constructor call for devirtualization purposes. For more info go to: http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html Edit: Fixed version because of PR24479. http://reviews.llvm.org/D11859 llvm-svn: 245264
* Revert r245257 "Generating assumption loads of vptr after ctor call"Hans Wennborg2015-08-181-58/+32
| | | | | | It caused PR24479 llvm-svn: 245260
* Generating assumption loads of vptr after ctor callPiotr Padlewski2015-08-171-32/+58
| | | | | | | | | | | | Generating call assume(icmp %vtable, %global_vtable) after constructor call for devirtualization purposes. For more info go to: http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html http://reviews.llvm.org/D11859 llvm-svn: 245257
* Remove and forbid raw_svector_ostream::flush() calls.Yaron Keren2015-08-131-7/+0
| | | | | | | | | | After r244870 flush() will only compare two null pointers and return, doing nothing but wasting run time. The call is not required any more as the stream and its SmallString are always in sync. Thanks to David Blaikie for reviewing. llvm-svn: 244928
* [ItaniumCXXABI] Don't import RTTI data for classes with key functionsDavid Majnemer2015-08-061-4/+14
| | | | | | | | | MinGW has some pretty strange behvaior around RTTI and dllimport/dllexport: - RTTI data is never imported - RTTI data is only exported if the class has no key function. llvm-svn: 244266
* Rangify for loops, NFC.Yaron Keren2015-08-011-3/+3
| | | | llvm-svn: 243841
* In case of an existing GlobalVariable, the comdat is created using the name ↵Yaron Keren2015-07-291-3/+3
| | | | | | | | | | | | | of the new GV (usually NAME.1) instead of the correct NAME of the old GV. Moving comdat creation after GV replacement solves this. Patch + testcase. Reviewed by Reid Kleckner. http://reviews.llvm.org/D11594 llvm-svn: 243525
* Remove unnecessary variable.Yaron Keren2015-07-291-12/+8
| | | | llvm-svn: 243517
* Getting rid of old iterator loopsPiotr Padlewski2015-07-281-7/+7
| | | | llvm-svn: 243431
* Generating available_externally vtables for outline virtual functionsPiotr Padlewski2015-07-241-0/+33
| | | | | | | | | | | | | | Generating available_externally vtables for optimizations purposes. Unfortunatelly ItaniumABI doesn't guarantee that we will be able to refer to virtual inline method by name. But when we don't have any inline virtual methods, and key function is not defined in this TU, we can generate that there will be vtable and mark it as available_externally. This is patch will help devirtualize better. Differential Revision: http://reviews.llvm.org/D11441 llvm-svn: 243090
* Rely on default zero-arg value for IRBuilder::CreateCall calls to zero-arg ↵David Blaikie2015-07-141-4/+4
| | | | | | | | functions Patch by servuswiegehtz at yahoo.de llvm-svn: 242168
* CodeGen: Do not give local-linkage functions externally available linkage, ↵Peter Collingbourne2015-07-011-1/+1
| | | | | | | | | | | | | | | | even temporarily. When an internal-linkage thunk is code gen'd, CodeGenVTables::emitThunk will first be called with ForVTable=true (which incorrectly set the thunk's linkage to available_externally under the Itanium ABI) and later with ForVTable=false (which reset it to internal). Because we will always see a call with ForVTable=false, this incorrect linkage never ended up in the final IR. However, the temporary presence of this linkage caused us to give such functions a comdat as a result of code introduced in r241102. To avoid this, check that the thunk is externally visible before giving it available_externally linkage. llvm-svn: 241136
* [CodeGen] Rename EmitMemberPointer to EmitMemberFunctionPointerDavid Majnemer2015-06-231-2/+3
| | | | llvm-svn: 240382
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-4/+4
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-4/+4
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* Implement diagnostic mode for -fsanitize=cfi*, -fsanitize=cfi-diag.Peter Collingbourne2015-06-191-4/+8
| | | | | | | | | | | | | | | | | This causes programs compiled with this flag to print a diagnostic when a control flow integrity check fails instead of aborting. Diagnostics are printed using UBSan's runtime library. The main motivation of this feature over -fsanitize=vptr is fidelity with the -fsanitize=cfi implementation: the diagnostics are printed under exactly the same conditions as those which would cause -fsanitize=cfi to abort the program. This means that the same restrictions apply regarding compiling all translation units with -fsanitize=cfi, cross-DSO virtual calls are forbidden, etc. Differential Revision: http://reviews.llvm.org/D10268 llvm-svn: 240109
* API update for streamlining of IRBuilder::CreateCall to just use ↵David Blaikie2015-05-181-4/+4
| | | | | | ArrayRef/initializer_list+braced init llvm-svn: 237625
* Revert r236879, "Do not emit thunks with available_externally linkage in ↵NAKAMURA Takumi2015-05-091-5/+8
| | | | | | | | comdats" It broke pecoff, at least i686-cygwin. llvm-svn: 236937
* Do not emit thunks with available_externally linkage in comdatsDerek Schuff2015-05-081-8/+5
| | | | | | | | | | | | | | Functions with available_externally linkage will not be emitted to object files (they will just be undefined symbols), so it does not make sense to put them in comdats. Creates a second overload of maybeSetTrivialComdat that uses the GlobalObject instead of the Decl, and uses that in several places that had the faulty logic. Differential Revision: http://reviews.llvm.org/D9580 llvm-svn: 236879
* [opaque pointer type] update for LLVM API changeDavid Blaikie2015-04-291-2/+2
| | | | llvm-svn: 236161
* Replace getPointeeType()->isFunctionType with isMemberDataPointerTypeDavid Majnemer2015-04-241-1/+1
| | | | llvm-svn: 235682
* [opaque pointer type] more GEP API migrationsDavid Blaikie2015-04-041-1/+1
| | | | llvm-svn: 234097
* [opaque pointer type] Update for GEP API changes in LLVMDavid Blaikie2015-04-021-3/+5
| | | | | | | | | | Now the GEP constant utility functions require the type to be explicitly passed (since eventually the pointer type will be opaque and not convey the required type information). For now callers can still pass nullptr (though none were needed here in Clang, which is nice) if convenienc/necessary, but eventually that will be disallowed as well. llvm-svn: 233937
* Implement CFI type checks for non-virtual calls.Peter Collingbourne2015-04-021-1/+2
| | | | | | | | | | | | This uses the same class metadata currently used for virtual call and cast checks. The new flag is -fsanitize=cfi-nvcall. For consistency, the -fsanitize=cfi-vptr flag has been renamed -fsanitize=cfi-vcall. Differential Revision: http://reviews.llvm.org/D8756 llvm-svn: 233874
* [MS ABI] Rework .xdata HandlerType emissionDavid Majnemer2015-03-291-1/+2
| | | | | | | | | | Utilizing IMAGEREL relocations for synthetic IR constructs isn't valuable, just clutter. While we are here, simplify HandlerType names by making the numeric value for the 'adjective' part of the mangled name instead of appending '.const', etc. The old scheme made for very long global names and leads to wordy things like '.std_bad_alloc' llvm-svn: 233503
* MS ABI: Fix a couple of -Winconsistent-missing-override warningsJustin Bogner2015-03-171-2/+2
| | | | llvm-svn: 232559
* MS ABI: Emit HandlerMap entries for C++ catchDavid Majnemer2015-03-171-1/+2
| | | | | | | | | | | | | The HandlerMap describes, to the runtime, what sort of catches surround the try. In principle, this structure has to be emitted by the backend because only it knows the layout of the stack (the runtime needs to know where on the stack the destination of a copy lives, etc.) but there is some C++ specific information that the backend can't reason about. Stick this information in special LLVM globals with the relevant "const", "volatile", "reference" info mangled into the name. llvm-svn: 232538
* WIPDavid Majnemer2015-03-171-3/+5
| | | | llvm-svn: 232537
* MS ABI: Don't use qualified pointee types for 'catch' EH TypeDescriptorsDavid Majnemer2015-03-151-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Qualifiers are located next to the TypeDescriptor in order to properly ensure that a pointer type can only be caught by a more qualified catch handler. This means that a catch handler of type 'const int *' requires an RTTI object for 'int *'. We got this correct for 'throw' but not for 'catch'. N.B. We don't currently have the means to store the qualifiers because LLVM's EH strategy is tailored to the Itanium scheme. The Itanium ABI stores qualifiers inside the type descriptor in such a way that the manner of qualification is stored in addition to the pointee type's descriptor. Perhaps the best way of modeling this for the MS ABI is using an aggregate type to bundle the qualifiers with the descriptor? This is tricky because we want to make it clear to the optimization passes which catch handlers invalidate other handlers. My current thoughts on a design for this is along the lines of: { { TypeDescriptor* TD, i32 QualifierFlags }, i32 MiscFlags } The idea is that the inner most aggregate is all that is needed to communicate that one catch handler might supercede another. The 'MiscFlags' field would be used to hold the bitpattern for the notion that the 'catch' handler does not need to invoke a copy-constructor because we are catching by reference. llvm-svn: 232318
OpenPOWER on IntegriCloud