summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGCleanup.h
Commit message (Collapse)AuthorAgeFilesLines
* Remove trailing spaceFangrui Song2018-07-301-1/+1
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* Replace LLVM_ALIGNAS with just alignas.Richard Smith2018-07-171-1/+1
| | | | | | | Various places in Clang and LLVM are already using alignas; it seems our minimum host configuration now requires it. llvm-svn: 337330
* [WebAssembly] Use Windows EH instructions for Wasm EHHeejin Ahn2018-05-311-1/+6
| | | | | | | | | | | | | | | | | | | | | | | Summary: Because wasm control flow needs to be structured, using WinEH instructions to support wasm EH brings several benefits. This patch makes wasm EH uses Windows EH instructions, with some changes: 1. Because wasm uses a single catch block to catch all C++ exceptions, this merges all catch clauses into a single catchpad, within which we test the EH selector as in Itanium EH. 2. Generates a call to `__clang_call_terminate` in case a cleanup throws. Wasm does not have a runtime to handle this. 3. In case there is no catch-all clause, inserts a call to `__cxa_rethrow` at the end of a catchpad in order to unwind to an enclosing EH scope. Reviewers: majnemer, dschuff Subscribers: jfb, sbc100, jgravelle-google, sunfish, cfe-commits Differential Revision: https://reviews.llvm.org/D44931 llvm-svn: 333703
* Use the correct ObjC EH personalityBenjamin Kramer2017-01-081-0/+2
| | | | | | | | This fixes ObjC exceptions on Win64 (which uses SEH), among others. Patch by Jonathan Schleifer! llvm-svn: 291408
* Retire llvm::alignOf in favor of C++11 alignof.Benjamin Kramer2016-10-201-2/+1
| | | | | | No functionality change intended. llvm-svn: 284730
* Widen EHScope::ClenupBitFields::FixupDepth to avoid overflowing it (PR23490)Hans Wennborg2016-06-221-9/+11
| | | | | | | | | | | | | | It currently only takes 2048 gotos to overflow the FixupDepth bitfield, causing silent miscompilation. Apparently some parser generators run into this (see PR). I don't know that that data structure is terribly size sensitive anyway, and since there's no room to widen the bitfield, let's just use a separate word in EHCatchScope for it. Differential Revision: http://reviews.llvm.org/D21566 llvm-svn: 273434
* Update for LLVM function name change.Rui Ueyama2016-01-141-1/+1
| | | | llvm-svn: 257802
* Update clang to use the updated LLVM EH instructionsDavid Majnemer2015-12-121-8/+0
| | | | | | | | | | Depends on D15139. Reviewers: rnk Differential Revision: http://reviews.llvm.org/D15140 llvm-svn: 255423
* [WinEH] Remove NewMSEH and enable its behavior by defaultReid Kleckner2015-10-081-0/+4
| | | | | | | Testing has shown that it is at least as reliable as the old landingpad pattern matching code. llvm-svn: 249647
* [WinEH] Pass the catch adjectives to catchpad directlyReid Kleckner2015-09-161-3/+16
| | | | | | | | | This avoids building a fake LLVM IR global variable just to ferry an i32 down into LLVM codegen. It also puts a nail in the coffin of using MS ABI C++ EH with landingpads, since now we'll assert in the lpad code when flags are present. llvm-svn: 247843
* [SEH] Use cleanupendpad so that WinEHPrepare gets the coloring rightReid Kleckner2015-09-101-11/+11
| | | | | | | Cleanupendpad is a lot like catchendpad, so we can reuse the same EHScopeStack type. llvm-svn: 247349
* Compute and preserve alignment more faithfully in IR-generation.John McCall2015-09-081-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [MS ABI] Hook clang up to the new EH instructionsDavid Majnemer2015-07-311-4/+34
| | | | | | | | | | The new EH instructions make it possible for LLVM to generate .xdata tables that the MSVC personality routines will be happy about. Because this is experimental, hide it behind a -cc1 flag (-fnew-ms-eh). Differential Revision: http://reviews.llvm.org/D11405 llvm-svn: 243767
* Move EHPersonality to CGCleanupDavid Majnemer2015-07-221-0/+29
| | | | | | | | This makes it possible to use EHPersonality in other parts of CodeGen. Differential Revision: http://reviews.llvm.org/D11440 llvm-svn: 242971
* Fix alignment issues in Clang.James Y Knight2015-07-171-11/+20
| | | | | | | | | | | | | | | | | Some const-correctness changes snuck in here too, since they were in the area of code I was modifying. This seems to make Clang actually work without Bus Error on 32bit-sparc. Follow-up patches will factor out a trailing-object helper class, to make classes using the idiom of appending objects to other objects easier to understand, and to ensure (with static_assert) that required alignment guarantees continue to hold. Differential Revision: http://reviews.llvm.org/D10272 llvm-svn: 242554
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-2/+2
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-2/+2
| | | | | | | | | | | | 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
* Revert "Revert r234581, it might have caused a few miscompiles in Chromium."David Majnemer2015-04-221-1/+8
| | | | | | | | This reverts commit r234700. It turns out that the lifetime markers were not the cause of Chromium failing but a bug which was uncovered by optimizations exposed by the markers. llvm-svn: 235553
* Revert r234581, it might have caused a few miscompiles in Chromium.Nico Weber2015-04-111-8/+1
| | | | | | | If the revert helps, I'll get a repro this Monday. Else I'll put the change back in. llvm-svn: 234700
* Remove threshold for inserting lifetime markers for named temporariesArnaud A. de Grandmaison2015-04-101-1/+8
| | | | | | | | | | | | | | | | | | | Now that TailRecursionElimination has been fixed with r222354, the threshold on size for lifetime marker insertion can be removed. This only affects named temporary though, as the patch for unnamed temporaries is still in progress. My previous commit (r222993) was not handling debuginfo correctly, but this could only be seen with some asan tests. Basically, lifetime markers are just instrumentation for the compiler's usage and should not affect debug information; however, the cleanup infrastructure was assuming it contained only destructors, i.e. actual code to be executed, and was setting the breakpoint for the end of the function to the closing '}', and not the return statement, in order to show some destructors have been called when leaving the function. This is wrong when the cleanups are only lifetime markers, and this is now fixed. llvm-svn: 234581
* Remove two unused methods. No behavior change.Nico Weber2015-02-221-2/+0
| | | | llvm-svn: 230152
* Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for ↵Aaron Ballman2015-02-151-1/+1
| | | | | | requiring the macro. NFC; Clang edition. llvm-svn: 229339
* Update for LLVM API change to make Small(Ptr)Set::insert return ↵David Blaikie2014-11-191-2/+2
| | | | | | pair<iterator, bool> as per the C++ standard's associative container concept. llvm-svn: 222335
* Replace a destructor of EHCleanupScope with a Destroy() method to reflect ↵Kostya Serebryany2014-10-081-1/+3
| | | | | | | | | | | | | | | | | | | | | the current usage. Summary: The current code uses memset to re-initialize EHCleanupScope objects with breaks the assumptions of the upcoming asan's intra-object-overflow checker. If there is no DTOR, the new checker will refuse to work. Test Plan: bootstrap with asan Reviewers: rnk Reviewed By: rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5656 llvm-svn: 219331
* Header guard canonicalization, clang part.Benjamin Kramer2014-08-131-2/+2
| | | | | | Modifications made by clang-tidy with minor tweaks. llvm-svn: 215557
* Update for llvm api change.Rafael Espindola2014-06-041-2/+2
| | | | llvm-svn: 210204
* [C++11] Use 'nullptr'. CodeGen edition.Craig Topper2014-05-211-5/+5
| | | | llvm-svn: 209272
* Fix leak in lib/CodeGen/CGException.cpp, PR18318Kostya Serebryany2014-01-091-0/+9
| | | | | | | | | | | | | | Summary: This fixes the leak described in http://llvm.org/bugs/show_bug.cgi?id=18318 Reviewers: chandlerc, dblaikie Reviewed By: chandlerc CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2474 llvm-svn: 198857
* [CodeGen] Move EHScopeStack into its own headerReid Kleckner2013-06-191-462/+8
| | | | | | | CGCleanup.h isn't meant to be included by all of CodeGen according to John. llvm-svn: 184321
* Reapply r183721, reverted in r183776, with a fix for a bug in the former (weRichard Smith2013-06-121-0/+5
| | | | | | | | | | | | | | | | | | | | | | | were lacking ExprWithCleanups nodes in some cases where the new approach to lifetime extension needed them). Original commit message: Rework IR emission for lifetime-extended temporaries. Instead of trying to walk into the expression and dig out a single lifetime-extended entity and manually pull its cleanup outside the expression, instead keep a list of the cleanups which we'll need to emit when we get to the end of the full-expression. Also emit those cleanups early, as EH-only cleanups, to cover the case that the full-expression does not terminate normally. This allows IR generation to properly model temporary lifetime when multiple temporaries are extended by the same declaration. We have a pre-existing bug where an exception thrown from a temporary's destructor does not clean up lifetime-extended temporaries created in the same expression and extended to automatic storage duration; that is not fixed by this patch. llvm-svn: 183859
* Revert r183721. It caused cleanups to be delayed too long in some cases.Richard Smith2013-06-111-5/+0
| | | | | | Testcase to follow. llvm-svn: 183776
* Rework IR emission for lifetime-extended temporaries. Instead of trying to walkRichard Smith2013-06-111-0/+5
| | | | | | | | | | | | | | | | | into the expression and dig out a single lifetime-extended entity and manually pull its cleanup outside the expression, instead keep a list of the cleanups which we'll need to emit when we get to the end of the full-expression. Also emit those cleanups early, as EH-only cleanups, to cover the case that the full-expression does not terminate normally. This allows IR generation to properly model temporary lifetime when multiple temporaries are extended by the same declaration. We have a pre-existing bug where an exception thrown from a temporary's destructor does not clean up lifetime-extended temporaries created in the same expression and extended to automatic storage duration; that is not fixed by this patch. llvm-svn: 183721
* [CodeGen] Make CGCleanup.h include what it now usesReid Kleckner2013-06-091-6/+3
| | | | | | | Also move CGCleanup.h to the top of CGCleanup.cpp to verify that CGCleanup.h really includes what it needs. llvm-svn: 183632
* [CodeGen] Move EHScopeStack to CGCleanup.h from CodeGenFunction.hReid Kleckner2013-06-091-3/+457
| | | | | | | | | | No functionality change. CGCleanup.cpp provides the implementation for EHScopeStack, so it seems more consistent to place the class definition in CGCleanup.h. This should also help solve a header ordering problem that I have. llvm-svn: 183631
* Documentation cleanup:James Dennett2012-06-151-1/+1
| | | | | | | | * Escaped Objective-C @keywords in Doxygen comments; * Documented more accurate \params; * Exposed some more summaries using \brief. llvm-svn: 158559
* Simplify EH control flow by observing that EH scopes form a simpleJohn McCall2011-08-111-171/+150
| | | | | | | | | | | | | | | hierarchy of delegation, and that EH selector values are meaningful function-wide (good thing, too, or inlining wouldn't work). 2,3d 1a hierarchy of delegation and that EH selector values have the same meaning everywhere in the function instead of being meaningful only in the context of a specific selector. This removes the need for routing edges through EH cleanups, since a cleanup simply always branches to its enclosing scope. llvm-svn: 137293
* now that we have a centralized place to do so, add some using declarations forChris Lattner2011-07-201-2/+2
| | | | | | | some common llvm types: stringref and smallvector. This cleans up the codebase quite a bit. llvm-svn: 135576
* Move all the cleanups framework code into a single file.John McCall2011-01-281-0/+560
Pure motion. llvm-svn: 124484
OpenPOWER on IntegriCloud