aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGException.cpp
AgeCommit message (Collapse)AuthorFilesLines
2020-06-23Remove clang::Codegen::EHPadEndScope as unusedDavid Blaikie1-13/+0
Unused since r255423 / D15140 / 4e52d6f811a2269e946c19e77245148bd9221f99 Found indirectly by assessing -debug-info-kind=constructors and observing the EHPadEndScope type was never emitted because the constructor is never called. (all credit to Amy Huang for identifying this issue)
2020-05-21[WebAssembly] Warn on exception spec only when Wasm EH is usedHeejin Ahn1-2/+2
Summary: In D80061 we added warning for exception specifications with types (such as `throw(int)`), but it was enabled every time the target was wasm, which means it warned (and ignored) exception specifications even if wasm EH was not used. This fixes it and we only have the warning when we enable `-fwasm-exceptions`. Reviewers: dschuff Subscribers: sbc100, jgravelle-google, sunfish, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D80362
2020-05-19[WebAssembly] Handle exception specificationsHeejin Ahn1-0/+21
Summary: Wasm currently does not fully handle exception specifications. Rather than crashing, - This treats `throw()` in the same way as `noexcept`. - This ignores and prints a warning for `throw(type, ..)`, for a temporary measure. This warning is controlled by `-Wwasm-exception-spec`, which is on by default. You can suppress the warning by using `-Wno-wasm-exception-spec`. Reviewers: dschuff Subscribers: sbc100, jgravelle-google, sunfish, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D80061
2020-05-15Revert "[WebAssembly] Handle exception specifications"Heejin Ahn1-21/+0
This reverts commit bca347508c86647f9d44992275c9a364fbd9fb0d. This broke clang/test/Misc/warning-flags.c, because the newly added warning option in this commit didn't have a matching flag.
2020-05-15[WebAssembly] Handle exception specificationsHeejin Ahn1-0/+21
Summary: Wasm currently does not fully handle exception specifications. Rather than crashing, this treats `throw()` in the same way as `noexcept`, and ignores and prints a warning for `throw(type, ..)`, for a temporary measure. Reviewers: dschuff Subscribers: sbc100, jgravelle-google, sunfish, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D79655
2020-04-30[Windows SEH] Fix abnormal-exits in _tryAaron Smith1-0/+13
Summary: Per Windows SEH Spec, except _leave, all other early exits of a _try (goto/return/continue/break) are considered abnormal exits. In those cases, the first parameter passes to its _finally funclet should be TRUE to indicate an abnormal-termination. One way to implement abnormal exits in _try is to invoke Windows runtime _local_unwind() (MSVC approach) that will invoke _dtor funclet where abnormal-termination flag is always TRUE when calling _finally. Obviously this approach is less optimal and is complicated to implement in Clang. Clang today has a NormalCleanupDestSlot mechanism to dispatch multiple exits at the end of _try. Since _leave (or try-end fall-through) is always Indexed with 0 in that NormalCleanupDestSlot, this fix takes the advantage of that mechanism and just passes NormalCleanupDest ID as 1st Arg to _finally. Reviewers: rnk, eli.friedman, JosephTremoulet, asmith, efriedma Reviewed By: efriedma Subscribers: efriedma, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D77936
2020-02-12[clang] Add -fignore-exceptionsjasonliu1-5/+7
Summary: This is trying to implement the functionality proposed in: http://lists.llvm.org/pipermail/cfe-dev/2017-April/053417.html An exception can throw, but no cleanup is going to happen. A module compiled with exceptions on, can catch the exception throws from module compiled with -fignore-exceptions. The use cases for enabling this option are: 1. Performance analysis of EH instrumentation overhead 2. The ability to QA non EH functionality when EH functionality is not available. 3. User of EH enabled headers knows the calls won't throw in their program and wants the performance gain from ignoring EH construct. The implementation tried to accomplish that by removing any landing pad code that might get generated. Reviewed by: aaron.ballman Differential Revision: https://reviews.llvm.org/D72644
2020-01-17[clang] Set function attributes on SEH filter functions correctly.Sanne Wouda1-1/+1
Summary: When compiling with -munwind-tables, the SEH filter funclet needs the uwtable function attribute, which gets automatically added if we use SetInternalFunctionAttributes. The filter funclet is internal so this seems appropriate. Reviewers: rnk Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72786
2019-12-11[IR] Split out target specific intrinsic enums into separate headersReid Kleckner1-2/+3
This has two main effects: - Optimizes debug info size by saving 221.86 MB of obj file size in a Windows optimized+debug build of 'all'. This is 3.03% of 7,332.7MB of object file size. - Incremental step towards decoupling target intrinsics. The enums are still compact, so adding and removing a single target-specific intrinsic will trigger a rebuild of all of LLVM. Assigning distinct target id spaces is potential future work. Part of PR34259 Reviewers: efriedma, echristo, MaskRay Reviewed By: echristo, MaskRay Differential Revision: https://reviews.llvm.org/D71320
2019-09-12[WebAssembly] Add -fwasm-exceptions for wasm EHHeejin Ahn1-4/+1
Summary: This adds `-fwasm-exceptions` (in similar fashion with `-fdwarf-exceptions` or `-fsjlj-exceptions`) that turns on everything with wasm exception handling from the frontend to the backend. We currently have `-mexception-handling` in clang frontend, but this is only about the architecture capability and does not turn on other necessary options such as the exception model in the backend. (This can be turned on with `llc -exception-model=wasm`, but llc is not invoked separately as a command line tool, so this option has to be transferred from clang.) Turning on `-fwasm-exceptions` in clang also turns on `-mexception-handling` if not specified, and will error out if `-mno-exception-handling` is specified. Reviewers: dschuff, tlively, sbc100 Subscribers: aprantl, jgravelle-google, sunfish, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67208 llvm-svn: 371708
2019-07-22Updated the signature for some stack related intrinsics (CLANG)Christudasan Devadasan1-1/+2
Modified the intrinsics int_addressofreturnaddress, int_frameaddress & int_sponentry. This commit depends on the changes in rL366679 Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D64563 llvm-svn: 366683
2019-07-16Fix parameter name comments using clang-tidy. NFC.Rui Ueyama1-4/+4
This patch applies clang-tidy's bugprone-argument-comment tool to LLVM, clang and lld source trees. Here is how I created this patch: $ git clone https://github.com/llvm/llvm-project.git $ cd llvm-project $ mkdir build $ cd build $ cmake -GNinja -DCMAKE_BUILD_TYPE=Debug \ -DLLVM_ENABLE_PROJECTS='clang;lld;clang-tools-extra' \ -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLLVM_ENABLE_LLD=On \ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ../llvm $ ninja $ parallel clang-tidy -checks='-*,bugprone-argument-comment' \ -config='{CheckOptions: [{key: StrictMode, value: 1}]}' -fix \ ::: ../llvm/lib/**/*.{cpp,h} ../clang/lib/**/*.{cpp,h} ../lld/**/*.{cpp,h} llvm-svn: 366177
2019-03-16[WebAssembly] Use rethrow intrinsic in the rethrow blockHeejin Ahn1-1/+3
Summary: Because in wasm we merge all catch clauses into one big catchpad, in case none of the types in catch handlers matches after we test against each of them, we should unwind to the next EH enclosing scope. For this, we should NOT use a call to `__cxa_rethrow` but rather a call to our own rethrow intrinsic, because what we're trying to do here is just to transfer the control flow into the next enclosing EH pad (or the caller). Calls to `__cxa_rethrow` should only be used after a call to `__cxa_begin_catch`. Reviewers: dschuff Subscribers: sbc100, jgravelle-google, sunfish, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59353 llvm-svn: 356317
2019-02-05[opaque pointer types] Pass function types for runtime function calls.James Y Knight1-30/+30
Emit{Nounwind,}RuntimeCall{,OrInvoke} have been modified to take a FunctionCallee as an argument, and CreateRuntimeFunction has been modified to return a FunctionCallee. All callers have been updated. Additionally, CreateBuiltinFunction is removed, as it was redundant with CreateRuntimeFunction after some previous changes. Differential Revision: https://reviews.llvm.org/D57668 llvm-svn: 353184
2019-02-03[opaque pointer types] Trivial changes towards CallInst requiringJames Y Knight1-6/+6
explicit function types. llvm-svn: 353009
2019-01-30Cleanup: replace uses of CallSite with CallBase.James Y Knight1-1/+0
llvm-svn: 352595
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2019-01-16[SEH] Pass the frame pointer from SEH finally to finally functionsSanjin Sijaric1-2/+10
Pass the frame pointer that the first finally block receives onto the nested finally block, instead of generating it using localaddr. Differential Revision: https://reviews.llvm.org/D56463 llvm-svn: 351302
2019-01-16[EH] Rename llvm.x86.seh.recoverfp intrinsic to llvm.eh.recoverfpEli Friedman1-1/+1
This is the clang counterpart to D56747. Patch by Mandeep Singh Grang. Differential Revision: https://reviews.llvm.org/D56748 llvm-svn: 351284
2018-11-13[NFC] Move storage of dispatch-version to GlobalDeclErich Keane1-1/+1
As suggested by Richard Smith, and initially put up for review here: https://reviews.llvm.org/D53341, this patch removes a hack that was used to ensure that proper target-feature lists were used when emitting cpu-dispatch (and eventually, target-clones) implementations. As a part of this, the GlobalDecl object is proliferated to a bunch more locations. Originally, this was put up for review (see above) to get acceptance on the approach, though discussion with Richard in San Diego showed he approved of the approach taken here. Thus, I believe this is acceptable for Review-After-commit Differential Revision: https://reviews.llvm.org/D53341 Change-Id: I0a0bd673340d334d93feac789d653e03d9f6b1d5 llvm-svn: 346757
2018-11-09Use the correct address space when bitcasting func pointer to int pointerDylan McKay1-1/+5
When we cast a function pointer to an int pointer, at some pointer later it gets bitcasted back to a function and called. In backends that have a nonzero program memory address space specified in the data layout, the old code would lose the address space data. When LLVM later attempted to generate the bitcast from i8* to i8(..)* addrspace(1), it would fail because the pointers are not in the same address space. With this patch, the address space of the function will carry on to the address space of the i8* pointer. This is because all function pointers in Harvard architectures need to be assigned to the correct address space. This has no effect to any in-tree backends except AVR. llvm-svn: 346548
2018-10-30NFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects)Erik Pilkington1-3/+3
We haven't supported compiling ObjC1 for a long time (and never will again), so there isn't any reason to keep these separate. This patch replaces LangOpts::ObjC1 and LangOpts::ObjC2 with LangOpts::ObjC. Differential revision: https://reviews.llvm.org/D53547 llvm-svn: 345637
2018-10-15[TI removal] Make `getTerminator()` return a generic `Instruction`.Chandler Carruth1-1/+1
This removes the primary remaining API producing `TerminatorInst` which will reduce the rate at which code is introduced trying to use it and generally make it much easier to remove the remaining APIs across the codebase. Also clean up some of the stragglers that the previous mechanical update of variables missed. Users of LLVM and out-of-tree code generally will need to update any explicit variable types to handle this. Replacing `TerminatorInst` with `Instruction` (or `auto`) almost always works. Most of these edits were made in prior commits using the perl one-liner: ``` perl -i -ple 's/TerminatorInst(\b.* = .*getTerminator\(\))/Instruction\1/g' ``` This also my break some rare use cases where people overload for both `Instruction` and `TerminatorInst`, but these should be easily fixed by removing the `TerminatorInst` overload. llvm-svn: 344504
2018-09-24[CodeGen] Revert commit https://reviews.llvm.org/rL342717Calixte Denizet1-2/+1
llvm-svn: 342912
2018-09-21[CodeGen] Add to emitted DebugLoc information about coverage when it's requiredCalixte Denizet1-1/+2
Summary: Some lines have a hit counter where they should not have one. Cleanup stuff is located to the last line of the body which is most of the time a '}'. And Exception stuff is added at the beginning of a function and at the end (represented by '{' and '}'). So in such cases, the DebugLoc used in GCOVProfiling.cpp must be marked as not covered. This patch is a followup of https://reviews.llvm.org/D49915. Tests in projects/compiler_rt are fixed by: https://reviews.llvm.org/D49917 Reviewers: marco-c, davidxl Reviewed By: marco-c Subscribers: dblaikie, cfe-commits, sylvestre.ledru Differential Revision: https://reviews.llvm.org/D49916 llvm-svn: 342717
2018-08-10Add Windows support for the GNUstep Objective-C ABI V2.David Chisnall1-1/+6
Summary: Introduces funclet-based unwinding for Objective-C and fixes an issue where global blocks can't have their isa pointers initialised on Windows. After discussion with Dustin, this changes the name mangling of Objective-C types to prevent a C++ catch statement of type struct X* from catching an Objective-C object of type X*. Reviewers: rjmccall, DHowett-MSFT Reviewed By: rjmccall, DHowett-MSFT Subscribers: mgrang, mstorsjo, smeenai, cfe-commits Differential Revision: https://reviews.llvm.org/D50144 llvm-svn: 339428
2018-08-09Port getLocEnd -> getEndLocStephen Kelly1-2/+2
Reviewers: teemperor! Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50351 llvm-svn: 339386
2018-08-09Port getLocStart -> getBeginLocStephen Kelly1-2/+2
Reviewers: teemperor! Subscribers: jholewinski, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50350 llvm-svn: 339385
2018-07-30Remove trailing spaceFangrui Song1-4/+4
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
2018-06-08[CodeGen] Always use MSVC personality for windows-msvc targetsShoaib Meenai1-6/+10
The windows-msvc target is meant to be ABI compatible with MSVC, including the exception handling. Ensure that a windows-msvc triple always equates to the MSVC personality being used. This mostly affects the GNUStep and ObjFW Obj-C runtimes. To the best of my knowledge, those are normally not used with windows-msvc triples. I believe WinObjC is based on GNUStep (or it at least uses libobjc2), but that also takes the approach of wrapping Obj-C exceptions in C++ exceptions, so the MSVC personality function is the right one to use there as well. Differential Revision: https://reviews.llvm.org/D47862 llvm-svn: 334253
2018-06-04Remove llvm::Triple argument from get***Personality() functions. NFC.Heejin Ahn1-17/+18
Summary: Because `llvm::Triple` can be derived from `TargetInfo`, it is simpler to take only `TargetInfo` argument. Reviewers: sbc100 Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D47620 llvm-svn: 333938
2018-06-01[WebAssembly] Hide new Wasm EH behind its feature flagHeejin Ahn1-8/+14
Summary: clang's current wasm EH implementation is a non-MVP feature in progress. We had a `-mexception-handling` wasm feature but were not using it. This patch hides the non-MVP wasm EH behind a flag, so it does not affect other code for now. Reviewers: dschuff Subscribers: sbc100, jgravelle-google, sunfish, cfe-commits Differential Revision: https://reviews.llvm.org/D47614 llvm-svn: 333716
2018-05-31[WebAssembly] Use Windows EH instructions for Wasm EHHeejin Ahn1-3/+168
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
2018-05-03Track the result of evaluating a computed noexcept specification on theRichard Smith1-9/+5
FunctionProtoType. We previously re-evaluated the expression each time we wanted to know whether the type is noexcept or not. We now evaluate the expression exactly once. This is not quite "no functional change": it fixes a crasher bug during AST deserialization where we would try to evaluate the noexcept specification in a situation where we have not deserialized sufficient portions of the AST to permit such evaluation. llvm-svn: 331428
2018-03-16[MS] Don't escape MS C++ names with \01Reid Kleckner1-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
2018-03-09CodeGen: simplify and validate exception personalitiesSaleem Abdulrasool1-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
2018-01-02[WinEH] Allow for multiple terminatepadsReid Kleckner1-14/+41
Fixes verifier errors with Windows EH and OpenMP, which injects a terminate scope around parallel blocks. Fixes PR35778 llvm-svn: 321676
2017-12-19Silence a bunch of implicit fallthrough warningsAdrian Prantl1-1/+1
llvm-svn: 321115
2017-11-29[EH] Use __CxxFrameHandler3 for C++ EH in MS environmentsReid Kleckner1-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
2017-11-29Toolchain: Normalize dwarf, sjlj and seh ehMartell Malone1-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
2017-11-29Revert "Toolchain: Normalize dwarf, sjlj and seh eh"Martell Malone1-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
2017-11-29Toolchain: Normalize dwarf, sjlj and seh ehMartell Malone1-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
2017-11-02CodeGen: simplify EH personality selection (NFC)Saleem Abdulrasool1-8/+9
Fix a typo in the comment, reorder to ensure that the ordering matches across the ObjC/ObjC++ cases. NFCI. llvm-svn: 317146
2017-10-13[SEH] Use the SEH personality on frontend-outlined funcletsReid Kleckner1-1/+6
This allows __try inside __finally to work. Fixes PR34939 llvm-svn: 315707
2017-08-15Extract IRGen's constant-emitter into its own helper class and clean upJohn McCall1-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
2017-06-09[DebugInfo] Add kind of ImplicitParamDecl for emission of FlagObjectPointer.Alexey Bataev1-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
2017-05-09Suppress all uses of LLVM_END_WITH_NULL. NFC.Serge Guelton1-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
2017-04-01[ObjC++] Use the correct EH personality in GNU modeBenjamin Kramer1-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
2017-03-21Update Clang for LLVM rename AttributeSet -> AttributeListReid Kleckner1-1/+1
llvm-svn: 298394
2017-02-22stop using associative comdats for SEH filter functionsBob Haarman1-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