|
Revision tags: llvmorg-20.1.0, llvmorg-20.1.0-rc3, llvmorg-20.1.0-rc2, llvmorg-20.1.0-rc1, llvmorg-21-init, llvmorg-19.1.7, llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4, llvmorg-19.1.3, llvmorg-19.1.2, llvmorg-19.1.1, llvmorg-19.1.0, llvmorg-19.1.0-rc4, llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init, llvmorg-18.1.8, llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2, llvmorg-17.0.0-rc1, llvmorg-18-init, llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2, llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3, llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init, llvmorg-15.0.7, llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3, llvmorg-15.0.2, llvmorg-15.0.1, llvmorg-15.0.0, llvmorg-15.0.0-rc3, llvmorg-15.0.0-rc2, llvmorg-15.0.0-rc1, llvmorg-16-init |
|
| #
97af17c5 |
| 03-Jul-2022 |
Iain Sandoe <[email protected]> |
re-land [C++20][Modules] Update handling of implicit inlines [P1779R3]
re-land fixes an unwanted interaction with module-map modules, seen in Greendragon testing.
This provides updates to [class.mf
re-land [C++20][Modules] Update handling of implicit inlines [P1779R3]
re-land fixes an unwanted interaction with module-map modules, seen in Greendragon testing.
This provides updates to [class.mfct]: Pre C++20 [class.mfct]p2: A member function may be defined (8.4) in its class definition, in which case it is an inline member function (7.1.2) Post C++20 [class.mfct]p1: If a member function is attached to the global module and is defined in its class definition, it is inline.
and [class.friend]: Pre-C++20 [class.friend]p5 A function can be defined in a friend declaration of a class . . . . Such a function is implicitly inline. Post C++20 [class.friend]p7 Such a function is implicitly an inline function if it is attached to the global module.
We add the output of implicit-inline to the TextNodeDumper, and amend a couple of existing tests to account for this, plus add tests for the cases covered above.
Differential Revision: https://reviews.llvm.org/D129045
show more ...
|
| #
c7fd7512 |
| 11-Jul-2022 |
Jonas Devlieghere <[email protected]> |
Revert "[C++20][Modules] Update handling of implicit inlines [P1779R3]"
This reverts commit ef0fa9f0ef3e as a follow up to b19d3ee7120b which reverted commit ac507102d258. See https://reviews.llvm.o
Revert "[C++20][Modules] Update handling of implicit inlines [P1779R3]"
This reverts commit ef0fa9f0ef3e as a follow up to b19d3ee7120b which reverted commit ac507102d258. See https://reviews.llvm.org/D126189 for more details.
show more ...
|
| #
ef0fa9f0 |
| 03-Jul-2022 |
Iain Sandoe <[email protected]> |
[C++20][Modules] Update handling of implicit inlines [P1779R3]
This provides updates to [class.mfct]: Pre C++20 [class.mfct]p2: A member function may be defined (8.4) in its class definition, in
[C++20][Modules] Update handling of implicit inlines [P1779R3]
This provides updates to [class.mfct]: Pre C++20 [class.mfct]p2: A member function may be defined (8.4) in its class definition, in which case it is an inline member function (7.1.2) Post C++20 [class.mfct]p1: If a member function is attached to the global module and is defined in its class definition, it is inline.
and [class.friend]: Pre-C++20 [class.friend]p5 A function can be defined in a friend declaration of a class . . . . Such a function is implicitly inline. Post C++20 [class.friend]p7 Such a function is implicitly an inline function if it is attached to the global module.
We add the output of implicit-inline to the TextNodeDumper, and amend a couple of existing tests to account for this, plus add tests for the cases covered above.
Differential Revision: https://reviews.llvm.org/D129045
show more ...
|
| #
f7819ce1 |
| 01-Jul-2022 |
Serge Pavlov <[email protected]> |
[FPEnv] Allow CompoundStmt to keep FP options
This is a recommit of b822efc7404bf09ccfdc1ab7657475026966c3b2, reverted in dc34d8df4c48b3a8f474360970cae8a58e6c84f0. The commit caused fails because th
[FPEnv] Allow CompoundStmt to keep FP options
This is a recommit of b822efc7404bf09ccfdc1ab7657475026966c3b2, reverted in dc34d8df4c48b3a8f474360970cae8a58e6c84f0. The commit caused fails because the test ast-print-fp-pragmas.c did not specify particular target, and it failed on targets which do not support constrained intrinsics. The original commit message is below.
AST does not have special nodes for pragmas. Instead a pragma modifies some state variables of Sema, which in turn results in modified attributes of AST nodes. This technique applies to floating point operations as well. Every AST node that can depend on FP options keeps current set of them.
This technique works well for options like exception behavior or fast math options. They represent instructions to the compiler how to modify code generation for the affected nodes. However treatment of FP control modes has problems with this technique. Modifying FP control mode (like rounding direction) usually requires operations on hardware, like writing to control registers. It must be done prior to the first operation that depends on the control mode. In particular, such operations are required for implementation of `pragma STDC FENV_ROUND`, compiler should set up necessary rounding direction at the beginning of compound statement where the pragma occurs. As there is no representation for pragmas in AST, the code generation becomes a complicated task in this case.
To solve this issue FP options are kept inside CompoundStmt. Unlike to FP options in expressions, these does not affect any operation on FP values, but only inform the codegen about the FP options that act in the body of the statement. As all pragmas that modify FP environment may occurs only at the start of compound statement or at global level, such solution works for all relevant pragmas. The options are kept as a difference from the options in the enclosing compound statement or default options, it helps codegen to set only changed control modes.
Differential Revision: https://reviews.llvm.org/D123952
show more ...
|
| #
dc34d8df |
| 01-Jul-2022 |
Serge Pavlov <[email protected]> |
Revert "[FPEnv] Allow CompoundStmt to keep FP options"
On some buildbots test `ast-print-fp-pragmas.c` fails, need to investigate it.
This reverts commit 0401fd12d4aa0553347fe34d666fb236d8719173. T
Revert "[FPEnv] Allow CompoundStmt to keep FP options"
On some buildbots test `ast-print-fp-pragmas.c` fails, need to investigate it.
This reverts commit 0401fd12d4aa0553347fe34d666fb236d8719173. This reverts commit b822efc7404bf09ccfdc1ab7657475026966c3b2.
show more ...
|
|
Revision tags: llvmorg-14.0.6, llvmorg-14.0.5, llvmorg-14.0.4, llvmorg-14.0.3, llvmorg-14.0.2, llvmorg-14.0.1, llvmorg-14.0.0, llvmorg-14.0.0-rc4, llvmorg-14.0.0-rc3, llvmorg-14.0.0-rc2, llvmorg-14.0.0-rc1, llvmorg-15-init, llvmorg-13.0.1, llvmorg-13.0.1-rc3, llvmorg-13.0.1-rc2, llvmorg-13.0.1-rc1, llvmorg-13.0.0, llvmorg-13.0.0-rc4, llvmorg-13.0.0-rc3, llvmorg-13.0.0-rc2, llvmorg-13.0.0-rc1, llvmorg-14-init, llvmorg-12.0.1, llvmorg-12.0.1-rc4, llvmorg-12.0.1-rc3, llvmorg-12.0.1-rc2, llvmorg-12.0.1-rc1, llvmorg-12.0.0, llvmorg-12.0.0-rc5, llvmorg-12.0.0-rc4, llvmorg-12.0.0-rc3, llvmorg-12.0.0-rc2, llvmorg-11.1.0, llvmorg-11.1.0-rc3, llvmorg-12.0.0-rc1, llvmorg-13-init, llvmorg-11.1.0-rc2, llvmorg-11.1.0-rc1, llvmorg-11.0.1, llvmorg-11.0.1-rc2, llvmorg-11.0.1-rc1, llvmorg-11.0.0, llvmorg-11.0.0-rc6, llvmorg-11.0.0-rc5, llvmorg-11.0.0-rc4 |
|
| #
b822efc7 |
| 28-Sep-2020 |
Serge Pavlov <[email protected]> |
[FPEnv] Allow CompoundStmt to keep FP options
AST does not have special nodes for pragmas. Instead a pragma modifies some state variables of Sema, which in turn results in modified attributes of AST
[FPEnv] Allow CompoundStmt to keep FP options
AST does not have special nodes for pragmas. Instead a pragma modifies some state variables of Sema, which in turn results in modified attributes of AST nodes. This technique applies to floating point operations as well. Every AST node that can depend on FP options keeps current set of them.
This technique works well for options like exception behavior or fast math options. They represent instructions to the compiler how to modify code generation for the affected nodes. However treatment of FP control modes has problems with this technique. Modifying FP control mode (like rounding direction) usually requires operations on hardware, like writing to control registers. It must be done prior to the first operation that depends on the control mode. In particular, such operations are required for implementation of `pragma STDC FENV_ROUND`, compiler should set up necessary rounding direction at the beginning of compound statement where the pragma occurs. As there is no representation for pragmas in AST, the code generation becomes a complicated task in this case.
To solve this issue FP options are kept inside CompoundStmt. Unlike to FP options in expressions, these does not affect any operation on FP values, but only inform the codegen about the FP options that act in the body of the statement. As all pragmas that modify FP environment may occurs only at the start of compound statement or at global level, such solution works for all relevant pragmas. The options are kept as a difference from the options in the enclosing compound statement or default options, it helps codegen to set only changed control modes.
Differential Revision: https://reviews.llvm.org/D123952
show more ...
|
| #
21eb1af4 |
| 16-Jun-2022 |
Roy Jacobson <[email protected]> |
[Concepts] Implement overload resolution for destructors (P0848)
This patch implements a necessary part of P0848, the overload resolution for destructors. It is now possible to overload destructors
[Concepts] Implement overload resolution for destructors (P0848)
This patch implements a necessary part of P0848, the overload resolution for destructors. It is now possible to overload destructors based on constraints, and the eligible destructor will be selected at the end of the class.
The approach this patch takes is to perform the overload resolution in Sema::ActOnFields and to mark the selected destructor using a new property in FunctionDeclBitfields.
CXXRecordDecl::getDestructor is then modified to use this property to return the correct destructor.
This closes https://github.com/llvm/llvm-project/issues/45614.
Reviewed By: #clang-language-wg, erichkeane
Differential Revision: https://reviews.llvm.org/D126194
show more ...
|
| #
6ba1b907 |
| 12-Apr-2022 |
Haojian Wu <[email protected]> |
Reland "[AST] Add a new TemplateKind for template decls found via a using decl.""
This is the template version of https://reviews.llvm.org/D114251.
This patch introduces a new template name kind (U
Reland "[AST] Add a new TemplateKind for template decls found via a using decl.""
This is the template version of https://reviews.llvm.org/D114251.
This patch introduces a new template name kind (UsingTemplateName). The UsingTemplateName stores the found using-shadow decl (and underlying template can be retrieved from the using-shadow decl). With the new template name, we can be able to find the using decl that a template typeloc (e.g. TemplateSpecializationTypeLoc) found its underlying template, which is useful for tooling use cases (include cleaner etc).
This patch merely focuses on adding the node to the AST.
Next steps: - support using-decl in qualified template name; - update the clangd and other tools to use this new node; - add ast matchers for matching different kinds of template names;
Differential Revision: https://reviews.llvm.org/D123127
show more ...
|
| #
95f0f69f |
| 12-Apr-2022 |
Haojian Wu <[email protected]> |
Revert "[AST] Add a new TemplateKind for template decls found via a using decl."
It breaks arm build, there is no free bit for the extra UsingShadowDecl in TemplateName::StorageType.
Reverting it t
Revert "[AST] Add a new TemplateKind for template decls found via a using decl."
It breaks arm build, there is no free bit for the extra UsingShadowDecl in TemplateName::StorageType.
Reverting it to build the buildbot back until we comeup with a fix.
This reverts commit 5a5be4044f0bceb71bb6a81f6955704691b389ed.
show more ...
|
| #
5a5be404 |
| 11-Apr-2022 |
Haojian Wu <[email protected]> |
[AST] Add a new TemplateKind for template decls found via a using decl.
This is the template version of https://reviews.llvm.org/D114251.
This patch introduces a new template name kind (UsingTempla
[AST] Add a new TemplateKind for template decls found via a using decl.
This is the template version of https://reviews.llvm.org/D114251.
This patch introduces a new template name kind (UsingTemplateName). The UsingTemplateName stores the found using-shadow decl (and underlying template can be retrieved from the using-shadow decl). With the new template name, we can be able to find the using decl that a template typeloc (e.g. TemplateSpecializationTypeLoc) found its underlying template, which is useful for tooling use cases (include cleaner etc).
This patch merely focuses on adding the node to the AST.
Next steps: - support using-decl in qualified template name; - update the clangd and other tools to use this new node; - add ast matchers for matching different kinds of template names;
Differential Revision: https://reviews.llvm.org/D123127
show more ...
|
| #
0cceee75 |
| 02-Mar-2022 |
Tom Honermann <[email protected]> |
[clang] Produce a "multiversion" annotation in textual AST output.
This change adds a "multiversion" annotation to textual AST output. For example: FunctionDecl 0xb6628b0 <t.c:1:1, col:13> col:5 m
[clang] Produce a "multiversion" annotation in textual AST output.
This change adds a "multiversion" annotation to textual AST output. For example: FunctionDecl 0xb6628b0 <t.c:1:1, col:13> col:5 multiversion foo 'int (void)'
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D121961
show more ...
|
| #
af27466c |
| 20-Dec-2021 |
Sam McCall <[email protected]> |
Reland "[AST] Add UsingType: a sugar type for types found via UsingDecl"
This reverts commit cc56c66f27e131b914082d3bd21180646e842e9a. Fixed a bad assertion, the target of a UsingShadowDecl must not
Reland "[AST] Add UsingType: a sugar type for types found via UsingDecl"
This reverts commit cc56c66f27e131b914082d3bd21180646e842e9a. Fixed a bad assertion, the target of a UsingShadowDecl must not have *local* qualifiers, but it can be a typedef whose underlying type is qualified.
show more ...
|
| #
cc56c66f |
| 20-Dec-2021 |
Sam McCall <[email protected]> |
Revert "[AST] Add UsingType: a sugar type for types found via UsingDecl"
This reverts commit e1600db19d6303f84b995acb9340459694e06ea9.
Breaks sanitizer tests, at least on windows: https://lab.llvm.
Revert "[AST] Add UsingType: a sugar type for types found via UsingDecl"
This reverts commit e1600db19d6303f84b995acb9340459694e06ea9.
Breaks sanitizer tests, at least on windows: https://lab.llvm.org/buildbot/#/builders/127/builds/21592/steps/4/logs/stdio
show more ...
|
| #
e1600db1 |
| 19-Nov-2021 |
Sam McCall <[email protected]> |
[AST] Add UsingType: a sugar type for types found via UsingDecl
Currently there's no way to find the UsingDecl that a typeloc found its underlying type through. Compare to DeclRefExpr::getFoundDecl(
[AST] Add UsingType: a sugar type for types found via UsingDecl
Currently there's no way to find the UsingDecl that a typeloc found its underlying type through. Compare to DeclRefExpr::getFoundDecl().
Design decisions: - a sugar type, as there are many contexts this type of use may appear in - UsingType is a leaf like TypedefType, the underlying type has no TypeLoc - not unified with UnresolvedUsingType: a single name is appealing, but being sometimes-sugar is often fiddly. - not unified with TypedefType: the UsingShadowDecl is not a TypedefNameDecl or even a TypeDecl, and users think of these differently. - does not cover other rarer aliases like objc @compatibility_alias, in order to be have a concrete API that's easy to understand. - implicitly desugared by the hasDeclaration ASTMatcher, to avoid breaking existing patterns and following the precedent of ElaboratedType.
Scope: - This does not cover types associated with template names introduced by using declarations. A future patch should introduce a sugar TemplateName variant for this. (CTAD deduced types fall under this) - There are enough AST matchers to fix the in-tree clang-tidy tests and probably any other matchers, though more may be useful later.
Caveats: - This changes a fairly common pattern in the AST people may depend on matching. Previously, typeLoc(loc(recordType())) matched whether a struct was referred to by its original scope or introduced via using-decl. Now, the using-decl case is not matched, and needs a separate matcher. This is similar to the case of typedefs but nevertheless both adds complexity and breaks existing code.
Differential Revision: https://reviews.llvm.org/D114251
show more ...
|
| #
424733c1 |
| 05-Oct-2021 |
Corentin Jabot <[email protected]> |
Implement if consteval (P1938)
Modify the IfStmt node to suppoort constant evaluated expressions.
Add a new ExpressionEvaluationContext::ImmediateFunctionContext to keep track of immediate function
Implement if consteval (P1938)
Modify the IfStmt node to suppoort constant evaluated expressions.
Add a new ExpressionEvaluationContext::ImmediateFunctionContext to keep track of immediate function contexts.
This proved easier/better/probably more efficient than walking the AST backward as it allows diagnosing nested if consteval statements.
show more ...
|
| #
ef227b32 |
| 30-Jun-2021 |
Richard Smith <[email protected]> |
Add dumping support for RequiresExpr.
In passing, fix an ast-print bug that inserted a spurious extra `;` after a concept definition.
|
| #
61cdaf66 |
| 11-Jun-2021 |
Simon Pilgrim <[email protected]> |
[ADT] Remove APInt/APSInt toString() std::string variants
<string> is currently the highest impact header in a clang+llvm build:
https://commondatastorage.googleapis.com/chromium-browser-clang/llvm
[ADT] Remove APInt/APSInt toString() std::string variants
<string> is currently the highest impact header in a clang+llvm build:
https://commondatastorage.googleapis.com/chromium-browser-clang/llvm-include-analysis.html
One of the most common places this is being included is the APInt.h header, which needs it for an old toString() implementation that returns std::string - an inefficient method compared to the SmallString versions that it actually wraps.
This patch replaces these APInt/APSInt methods with a pair of llvm::toString() helpers inside StringExtras.h, adjusts users accordingly and removes the <string> from APInt.h - I was hoping that more of these users could be converted to use the SmallString methods, but it appears that most end up creating a std::string anyhow. I avoided trying to use the raw_ostream << operators as well as I didn't want to lose having the integer radix explicit in the code.
Differential Revision: https://reviews.llvm.org/D103888
show more ...
|
| #
aef5d8fd |
| 04-Jun-2021 |
Matheus Izvekov <[email protected]> |
[clang] NFC: Rename rvalue to prvalue
This renames the expression value categories from rvalue to prvalue, keeping nomenclature consistent with C++11 onwards.
C++ has the most complicated taxonomy
[clang] NFC: Rename rvalue to prvalue
This renames the expression value categories from rvalue to prvalue, keeping nomenclature consistent with C++11 onwards.
C++ has the most complicated taxonomy here, and every other language only uses a subset of it, so it's less confusing to use the C++ names consistently, and mentally remap to the C names when working on that context (prvalue -> rvalue, no xvalues, etc).
Renames: * VK_RValue -> VK_PRValue * Expr::isRValue -> Expr::isPRValue * SK_QualificationConversionRValue -> SK_QualificationConversionPRValue * JSON AST Dumper Expression nodes value category: "rvalue" -> "prvalue"
Signed-off-by: Matheus Izvekov <[email protected]>
Reviewed By: rsmith
Differential Revision: https://reviews.llvm.org/D103720
show more ...
|
| #
b2d0c16e |
| 05-May-2021 |
Nathan Sidwell <[email protected]> |
[clang] p1099 using enum part 2
This implements the 'using enum maybe-qualified-enum-tag ;' part of 1099. It introduces a new 'UsingEnumDecl', subclassed from 'BaseUsingDecl'. Much of the diff is th
[clang] p1099 using enum part 2
This implements the 'using enum maybe-qualified-enum-tag ;' part of 1099. It introduces a new 'UsingEnumDecl', subclassed from 'BaseUsingDecl'. Much of the diff is the boilerplate needed to get the new class set up.
There is one case where we accept ill-formed, but I believe this is merely an extended case of an existing bug, so consider it orthogonal. AFAICT in class-scope the c++20 rule is that no 2 using decls can bring in the same target decl ([namespace.udecl]/8). But we already accept:
struct A { enum { a }; }; struct B : A { using A::a; }; struct C : B { using A::a; using B::a; }; // same enumerator
this patch permits mixtures of 'using enum Bob;' and 'using Bob::member;' in the same way.
Differential Revision: https://reviews.llvm.org/D102241
show more ...
|
| #
eba69b59 |
| 23-Apr-2021 |
Erich Keane <[email protected]> |
Reimplement __builtin_unique_stable_name-
The original version of this was reverted, and @rjmcall provided some advice to architect a new solution. This is that solution.
This implements a builtin
Reimplement __builtin_unique_stable_name-
The original version of this was reverted, and @rjmcall provided some advice to architect a new solution. This is that solution.
This implements a builtin to provide a unique name that is stable across compilations of this TU for the purposes of implementing the library component of the unnamed kernel feature of SYCL. It does this by running the Itanium mangler with a few modifications.
Because it is somewhat common to wrap non-kernel-related lambdas in macros that aren't present on the device (such as for logging), this uniquely generates an ID for all lambdas involved in the naming of a kernel. It uses the lambda-mangling number to do this, except replaces this with its own number (starting at 10000 for readabililty reasons) for lambdas used to name a kernel.
Additionally, this implements itself as constexpr with a slight catch: if a name would be invalidated by the use of this lambda in a later kernel invocation, it is diagnosed as an error (see the Sema tests).
Differential Revision: https://reviews.llvm.org/D103112
show more ...
|
| #
797ad701 |
| 18-May-2021 |
Ten Tzen <[email protected]> |
[Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1
This patch is the Part-1 (FE Clang) implementation of HW Exception handling.
This new feature adds the support of Hardware Exception
[Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1
This patch is the Part-1 (FE Clang) implementation of HW Exception handling.
This new feature adds the support of Hardware Exception for Microsoft Windows SEH (Structured Exception Handling). This is the first step of this project; only X86_64 target is enabled in this patch.
Compiler options: For clang-cl.exe, the option is -EHa, the same as MSVC. For clang.exe, the extra option is -fasync-exceptions, plus -triple x86_64-windows -fexceptions and -fcxx-exceptions as usual.
NOTE:: Without the -EHa or -fasync-exceptions, this patch is a NO-DIFF change.
The rules for C code: For C-code, one way (MSVC approach) to achieve SEH -EHa semantic is to follow three rules: * First, no exception can move in or out of _try region., i.e., no "potential faulty instruction can be moved across _try boundary. * Second, the order of exceptions for instructions 'directly' under a _try must be preserved (not applied to those in callees). * Finally, global states (local/global/heap variables) that can be read outside of _try region must be updated in memory (not just in register) before the subsequent exception occurs.
The impact to C++ code: Although SEH is a feature for C code, -EHa does have a profound effect on C++ side. When a C++ function (in the same compilation unit with option -EHa ) is called by a SEH C function, a hardware exception occurs in C++ code can also be handled properly by an upstream SEH _try-handler or a C++ catch(...). As such, when that happens in the middle of an object's life scope, the dtor must be invoked the same way as C++ Synchronous Exception during unwinding process.
Design: A natural way to achieve the rules above in LLVM today is to allow an EH edge added on memory/computation instruction (previous iload/istore idea) so that exception path is modeled in Flow graph preciously. However, tracking every single memory instruction and potential faulty instruction can create many Invokes, complicate flow graph and possibly result in negative performance impact for downstream optimization and code generation. Making all optimizations be aware of the new semantic is also substantial.
This design does not intend to model exception path at instruction level. Instead, the proposed design tracks and reports EH state at BLOCK-level to reduce the complexity of flow graph and minimize the performance-impact on CPP code under -EHa option.
One key element of this design is the ability to compute State number at block-level. Our algorithm is based on the following rationales:
A _try scope is always a SEME (Single Entry Multiple Exits) region as jumping into a _try is not allowed. The single entry must start with a seh_try_begin() invoke with a correct State number that is the initial state of the SEME. Through control-flow, state number is propagated into all blocks. Side exits marked by seh_try_end() will unwind to parent state based on existing SEHUnwindMap[]. Note side exits can ONLY jump into parent scopes (lower state number). Thus, when a block succeeds various states from its predecessors, the lowest State triumphs others. If some exits flow to unreachable, propagation on those paths terminate, not affecting remaining blocks. For CPP code, object lifetime region is usually a SEME as SEH _try. However there is one rare exception: jumping into a lifetime that has Dtor but has no Ctor is warned, but allowed:
Warning: jump bypasses variable with a non-trivial destructor
In that case, the region is actually a MEME (multiple entry multiple exits). Our solution is to inject a eha_scope_begin() invoke in the side entry block to ensure a correct State.
Implementation: Part-1: Clang implementation described below.
Two intrinsic are created to track CPP object scopes; eha_scope_begin() and eha_scope_end(). _scope_begin() is immediately added after ctor() is called and EHStack is pushed. So it must be an invoke, not a call. With that it's also guaranteed an EH-cleanup-pad is created regardless whether there exists a call in this scope. _scope_end is added before dtor(). These two intrinsics make the computation of Block-State possible in downstream code gen pass, even in the presence of ctor/dtor inlining.
Two intrinsic, seh_try_begin() and seh_try_end(), are added for C-code to mark _try boundary and to prevent from exceptions being moved across _try boundary. All memory instructions inside a _try are considered as 'volatile' to assure 2nd and 3rd rules for C-code above. This is a little sub-optimized. But it's acceptable as the amount of code directly under _try is very small.
Part-2 (will be in Part-2 patch): LLVM implementation described below.
For both C++ & C-code, the state of each block is computed at the same place in BE (WinEHPreparing pass) where all other EH tables/maps are calculated. In addition to _scope_begin & _scope_end, the computation of block state also rely on the existing State tracking code (UnwindMap and InvokeStateMap).
For both C++ & C-code, the state of each block with potential trap instruction is marked and reported in DAG Instruction Selection pass, the same place where the state for -EHsc (synchronous exceptions) is done. If the first instruction in a reported block scope can trap, a Nop is injected before this instruction. This nop is needed to accommodate LLVM Windows EH implementation, in which the address in IPToState table is offset by +1. (note the purpose of that is to ensure the return address of a call is in the same scope as the call address.
The handler for catch(...) for -EHa must handle HW exception. So it is 'adjective' flag is reset (it cannot be IsStdDotDot (0x40) that only catches C++ exceptions). Suppress push/popTerminate() scope (from noexcept/noTHrow) so that HW exceptions can be passed through.
Original llvm-dev [RFC] discussions can be found in these two threads below: https://lists.llvm.org/pipermail/llvm-dev/2020-March/140541.html https://lists.llvm.org/pipermail/llvm-dev/2020-April/141338.html
Differential Revision: https://reviews.llvm.org/D80344/new/
show more ...
|
| #
2fd11e0b |
| 04-Jan-2021 |
Thorsten Schütt <[email protected]> |
Revert "[NFC, Refactor] Modernize StorageClass from Specifiers.h to a scoped enum (II)"
This reverts commit efc82c4ad2bcb256a4f4c20238d08cd3afba4d2d.
|
| #
efc82c4a |
| 23-Dec-2020 |
Thorsten Schütt <[email protected]> |
[NFC, Refactor] Modernize StorageClass from Specifiers.h to a scoped enum (II)
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D93765
|
|
Revision tags: llvmorg-11.0.0-rc3 |
|
| #
6314f412 |
| 17-Sep-2020 |
Serge Pavlov <[email protected]> |
[FPEnv] Evaluate constant expressions under non-default rounding modes
The change implements evaluation of constant floating point expressions under non-default rounding modes. The main objective wa
[FPEnv] Evaluate constant expressions under non-default rounding modes
The change implements evaluation of constant floating point expressions under non-default rounding modes. The main objective was to support evaluation of global variable initializers, where constant rounding mode may be specified by `#pragma STDC FENV_ROUND`.
Differential Revision: https://reviews.llvm.org/D87822
show more ...
|
| #
f1cd6593 |
| 12-Sep-2020 |
Serge Pavlov <[email protected]> |
[AST][FPEnv] Keep FP options in trailing storage of CastExpr
This is recommit of 6c8041aa0f, reverted in de044f7562 because of some fails. Original commit message is below.
This change allow a Cast
[AST][FPEnv] Keep FP options in trailing storage of CastExpr
This is recommit of 6c8041aa0f, reverted in de044f7562 because of some fails. Original commit message is below.
This change allow a CastExpr to have optional FPOptionsOverride object, stored in trailing storage. Of all cast nodes only ImplicitCastExpr, CStyleCastExpr, CXXFunctionalCastExpr and CXXStaticCastExpr are allowed to have FPOptions.
Differential Revision: https://reviews.llvm.org/D85960
show more ...
|