summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGException.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [MS] Don't escape MS C++ names with \01Reid Kleckner2018-03-161-1/+1
| | | | | | | It is not needed after LLVM r327734. Now it will be easier to copy-paste IR symbol names from Clang. llvm-svn: 327738
* CodeGen: simplify and validate exception personalitiesSaleem Abdulrasool2018-03-091-19/+13
| | | | | | | | | | | | Simplify the dispatching for the personality routines. This really had no test coverage previously, so add test coverage for the various cases. This turns out to be pretty complicated as the various languages and models interact to change personalities around. You really should feel bad for the compiler if you are using exceptions. There is no reason for this type of cruelty. llvm-svn: 327105
* [WinEH] Allow for multiple terminatepadsReid Kleckner2018-01-021-14/+41
| | | | | | | | | Fixes verifier errors with Windows EH and OpenMP, which injects a terminate scope around parallel blocks. Fixes PR35778 llvm-svn: 321676
* Silence a bunch of implicit fallthrough warningsAdrian Prantl2017-12-191-1/+1
| | | | llvm-svn: 321115
* [EH] Use __CxxFrameHandler3 for C++ EH in MS environmentsReid Kleckner2017-11-291-4/+1
| | | | | | | | Fixes regression introduced by r319297. MSVC environments still use SEH unwind opcodes but they should use the Microsoft C++ EH personality, not the mingw one. llvm-svn: 319363
* Toolchain: Normalize dwarf, sjlj and seh ehMartell Malone2017-11-291-9/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a re-apply of r319294. adds -fseh-exceptions and -fdwarf-exceptions flags clang will check if the user has specified an exception model flag, in the absense of specifying the exception model clang will then check the driver default and append the model flag for that target to cc1 -fno-exceptions has a higher priority then specifying the model move __SEH__ macro definitions out of Targets into InitPreprocessor behind the -fseh-exceptions flag move __ARM_DWARF_EH__ macrodefinitions out of verious targets and into InitPreprocessor behind the -fdwarf-exceptions flag and arm|thumb check remove unused USESEHExceptions from the MinGW Driver fold USESjLjExceptions into a new GetExceptionModel function that gives the toolchain classes more flexibility with eh models Reviewers: rnk, mstorsjo Differential Revision: https://reviews.llvm.org/D39673 llvm-svn: 319297
* Revert "Toolchain: Normalize dwarf, sjlj and seh eh"Martell Malone2017-11-291-7/+9
| | | | | | | | This reverts rL319294. The windows sanitizer does not like seh on x86. Will re apply with None type for x86 llvm-svn: 319295
* Toolchain: Normalize dwarf, sjlj and seh ehMartell Malone2017-11-291-9/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | adds -fseh-exceptions and -fdwarf-exceptions flags clang will check if the user has specified an exception model flag, in the absense of specifying the exception model clang will then check the driver default and append the model flag for that target to cc1 clang cc1 assumes dwarf is the default if none is passed and -fno-exceptions has a higher priority then specifying the model move __SEH__ macro definitions out of Targets into InitPreprocessor behind the -fseh-exceptions flag move __ARM_DWARF_EH__ macrodefinitions out of verious targets and into InitPreprocessor behind the -fdwarf-exceptions flag and arm|thumb check remove unused USESEHExceptions from the MinGW Driver fold USESjLjExceptions into a new GetExceptionModel function that gives the toolchain classes more flexibility with eh models Reviewers: rnk, mstorsjo Differential Revision: https://reviews.llvm.org/D39673 llvm-svn: 319294
* CodeGen: simplify EH personality selection (NFC)Saleem Abdulrasool2017-11-021-8/+9
| | | | | | | Fix a typo in the comment, reorder to ensure that the ordering matches across the ObjC/ObjC++ cases. NFCI. llvm-svn: 317146
* [SEH] Use the SEH personality on frontend-outlined funcletsReid Kleckner2017-10-131-1/+6
| | | | | | | | This allows __try inside __finally to work. Fixes PR34939 llvm-svn: 315707
* Extract IRGen's constant-emitter into its own helper class and clean upJohn McCall2017-08-151-1/+3
| | | | | | | | | | | | the interface. The ultimate goal here is to make it easier to do some more interesting things in constant emission, like emit constant initializers that have ignorable side-effects, or doing the majority of an initialization in-place and then patching up the last few things with calls. But for now this is mostly just a refactoring. llvm-svn: 310964
* [DebugInfo] Add kind of ImplicitParamDecl for emission of FlagObjectPointer.Alexey Bataev2017-06-091-6/+7
| | | | | | | | | | | | | | | | | 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
* Suppress all uses of LLVM_END_WITH_NULL. NFC.Serge Guelton2017-05-091-7/+6
| | | | | | | | | | Use variadic templates instead of relying on <cstdarg> + sentinel. This enforces better type checking and makes code more readable. Differential revision: https://reviews.llvm.org/D32550 llvm-svn: 302572
* [ObjC++] Use the correct EH personality in GNU modeBenjamin Kramer2017-04-011-2/+2
| | | | | | | | | Previously, it would just always use the ObjC DWARF personality, even with SjLj or SEH exceptions. Patch by Jonathan Schleifer, test case by me. llvm-svn: 299306
* Update Clang for LLVM rename AttributeSet -> AttributeListReid Kleckner2017-03-211-1/+1
| | | | llvm-svn: 298394
* stop using associative comdats for SEH filter functionsBob Haarman2017-02-221-11/+0
| | | | | | | | | | | | Summary: We implement structured exception handling (SEH) by generating filter functions for functions that use exceptions. Currently, we use associative comdats to ensure that the filter functions are preserved if and only if the functions we generated them for are preserved. This can lead to problems when generating COFF objects - LLVM may decide to inline a function that uses SEH and remove its body, at which point we will end up with a comdat that COFF cannot represent. To avoid running into that situation, this change makes us not use associative comdats for SEH filter functions. We can still get the benefits we used the associative comdats for: we will always preserve filter functions we use, and dead stripping can eliminate the ones we don't use. Reviewers: rnk, pcc, ruiu Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D30117 llvm-svn: 295872
* Use the correct ObjC EH personalityBenjamin Kramer2017-01-081-0/+8
| | | | | | | | This fixes ObjC exceptions on Win64 (which uses SEH), among others. Patch by Jonathan Schleifer! llvm-svn: 291408
* CodeGen: fix runtime function dll storageSaleem Abdulrasool2016-12-151-4/+3
| | | | | | | | | | | | | | | | | 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
* Refactor call emission to package the function pointer together withJohn McCall2016-10-261-1/+2
| | | | | | | | | | | 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
* [CUDA] Mark device functions as nounwind.Justin Lebar2016-10-041-0/+4
| | | | | | | | | | | | | | | | | | | Summary: This prevents clang from emitting 'invoke's and catch statements. Things previously mostly worked thanks to TryToMarkNoThrow() in CodeGenFunction. But this is not a proper IPO, and it doesn't properly handle cases like mutual recursion. Fixes bug 30593. Reviewers: tra Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25166 llvm-svn: 283272
* [SEH] Remove nounwind/noinline from outlined finally funcletsReid Kleckner2016-03-111-6/+0
| | | | | | With the new EH representation this is no longer necessary. llvm-svn: 263269
* Preserve ExtParameterInfos into CGFunctionInfo.John McCall2016-03-111-7/+3
| | | | | | | | | As part of this, make the function-arrangement interfaces a little simpler and more semantic. NFC. llvm-svn: 263191
* Reword a misleading comment discussing landingpads and SEHReid Kleckner2016-03-011-2/+4
| | | | | | SEH doesn't use landingpads anymore. llvm-svn: 262382
* [MSVC Compat] Correctly handle finallys nested within finallysDavid Majnemer2016-03-011-5/+5
| | | | | | | | | We'd lose track of the parent CodeGenFunction, leading us to get confused with regard to which function a nested finally belonged to. Differential Revision: http://reviews.llvm.org/D17752 llvm-svn: 262379
* [WinEH] Make sure terminate handlers have funclet operandsDavid Majnemer2016-02-241-1/+3
| | | | | | | Calls to the terminate handler must be annotated within the exception region they are within. llvm-svn: 261751
* Reland "[SEH] Use llvm.x86.seh.recoverfp for SEH filters on x64 as well as ↵Reid Kleckner2015-12-161-19/+25
| | | | | | | | 32bit" I forgot to initialize RecoverFP. llvm-svn: 255731
* Revert "[SEH] Use llvm.x86.seh.recoverfp for SEH filters on x64 as well as ↵Reid Kleckner2015-12-161-20/+15
| | | | | | | | 32bit" This reverts commit r255710. llvm-svn: 255728
* [SEH] Use llvm.x86.seh.recoverfp for SEH filters on x64 as well as 32bitReid Kleckner2015-12-151-15/+20
| | | | llvm-svn: 255710
* [MS ABI] Don't rely on terminatepadDavid Majnemer2015-12-141-7/+6
| | | | | | | | | | | | | | | We'd like to remove support for terminatepad from LLVM. To do this, we need to move Clang off of it first. The intent behind terminatepad was to carefully model exception specifications for the MSVC personality. However, we don't support exception specifications for the MSVC personality and neither does MSVC. Instead, MSVC supports all-or-nothing exception specifications. We can model this limited usage using cleanuppads which call std::terminate. Differential Revision: http://reviews.llvm.org/D15478 llvm-svn: 255521
* Update clang to use the updated LLVM EH instructionsDavid Majnemer2015-12-121-42/+32
| | | | | | | | | | Depends on D15139. Reviewers: rnk Differential Revision: http://reviews.llvm.org/D15140 llvm-svn: 255423
* CodeGen: Remove implicit ilist iterator conversions, NFCDuncan P. N. Exon Smith2015-11-061-3/+2
| | | | | | | Make ilist iterator conversions explicit in clangCodeGen. Eventually I'll remove them everywhere. llvm-svn: 252358
* Watch and TV OS: wire up basic ABI choicesTim Northover2015-10-301-0/+2
| | | | | | | This sets the mostly expected Darwin default ABI options for these two platforms. Active changes from these defaults for watchOS are in a later patch. llvm-svn: 251708
* [WinEH] Push cleanupendpad scopes around exceptional cleanupsReid Kleckner2015-10-081-27/+3
| | | | | | | We were only doing this for SEH as a special case. Generalize it to all cleanups. llvm-svn: 249748
* [WinEH] Remove NewMSEH and enable its behavior by defaultReid Kleckner2015-10-081-38/+26
| | | | | | | Testing has shown that it is at least as reliable as the old landingpad pattern matching code. llvm-svn: 249647
* [SEH] Fix x64 __exception_code in __except blocksReid Kleckner2015-10-071-8/+15
| | | | | | | Use llvm.eh.exceptioncode to get the code out of EAX for x64. For 32-bit, the filter is responsible for storing it to memory for us. llvm-svn: 249497
* Fix Clang-tidy modernize-use-nullptr warnings in source directories; other ↵Hans Wennborg2015-10-061-7/+7
| | | | | | | | | | minor cleanups Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D13406 llvm-svn: 249484
* Use the MSVC SEH personalities on MingwReid Kleckner2015-09-171-2/+4
| | | | | | | | Mingw generally wraps an old copy of msvcrt.dll which has these personalities, so things should work out, or so I hear. I haven't tested it. llvm-svn: 247902
* [WinEH] Fix a build issue in CGException.cppReid Kleckner2015-09-161-2/+1
| | | | | | I was constructing an object without filling in all the fields. llvm-svn: 247851
* [WinEH] Pass the catch adjectives to catchpad directlyReid Kleckner2015-09-161-18/+23
| | | | | | | | | 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
* [CodeGen] Teach SimplifyPersonality about the updated LandingPadInstVedant Kumar2015-09-111-28/+38
| | | | | | | | | | | | | | | When uses of personality functions were moved from LandingPadInst to Function, we forgot to update SimplifyPersonality(). This patch corrects that. Note: SimplifyPersonality() is an optimization which replaces personality functions with the default C++ personality when possible. Without this update, some ObjC++ projects fail to link against C++ libraries (seeing as the exception ABI had effectively changed). rdar://problem/22155434 llvm-svn: 247421
* [SEH] Use cleanupendpad so that WinEHPrepare gets the coloring rightReid Kleckner2015-09-101-14/+38
| | | | | | | Cleanupendpad is a lot like catchendpad, so we can reuse the same EHScopeStack type. llvm-svn: 247349
* [SEH] Use catchret in the new EH IR like we do for C++Reid Kleckner2015-09-101-1/+13
| | | | | | Also add tests for SEH with the new IRGen. llvm-svn: 247318
* Collect SEH captures in a set instead of a vector to avoidJohn McCall2015-09-081-4/+4
| | | | | | | | doing redundant work if a variable is used multiple times. Fixes PR24751. llvm-svn: 247075
* Compute and preserve alignment more faithfully in IR-generation.John McCall2015-09-081-36/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [WinEH] Update to new EH pad/ret signatures (with tokens required)Joseph Tremoulet2015-08-231-4/+3
| | | | | | | | | | | | | | | Summary: The signatures of the methods in LLVM for creating EH pads/rets are changing to require token arguments on rets and assume token return type on pads. Update creation code accordingly. Reviewers: majnemer, rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D12109 llvm-svn: 245798
* Devirtualize EHScopeStack::Cleanup's dtor because it's never destroyed ↵David Blaikie2015-08-181-4/+4
| | | | | | polymorphically llvm-svn: 245378
* [MS ABI] Switch catchpad/cleanuppad to use tokensDavid Majnemer2015-08-151-4/+4
| | | | llvm-svn: 245153
* [CodeGen] Fold memcpy into SmallVector initializer. No functionality change.Benjamin Kramer2015-08-041-3/+2
| | | | llvm-svn: 243992
* [MS ABI] Hook clang up to the new EH instructionsDavid Majnemer2015-07-311-19/+146
| | | | | | | | | | 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-32/+4
| | | | | | | | This makes it possible to use EHPersonality in other parts of CodeGen. Differential Revision: http://reviews.llvm.org/D11440 llvm-svn: 242971
OpenPOWER on IntegriCloud