llvm-project/clang/lib/Sema
Serge Pavlov f7819ce166 [FPEnv] Allow CompoundStmt to keep FP options
This is a recommit of b822efc740,
reverted in dc34d8df4c. 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
2022-07-03 17:06:26 +07:00
..
AnalysisBasedWarnings.cpp [NFC] Replace not-null and not-isa check with a not-isa_and_nonnull 2022-05-10 13:34:07 -07:00
CMakeLists.txt Revert "wip" 2022-06-17 13:36:53 -05:00
CodeCompleteConsumer.cpp [clangd][ObjC] Filter ObjC method completions on the remaining selector 2022-05-20 11:49:16 -04:00
CoroutineStmtBuilder.h
DeclSpec.cpp Revert "Rename llvm::array_lengthof into llvm::size to match std::size from C++17" 2022-01-26 16:55:53 +01:00
DelayedDiagnostic.cpp
IdentifierResolver.cpp Reland "[Clang][Sema] Fix invalid redefinition error in if/switch/for statement" 2022-04-21 01:18:58 +08:00
JumpDiagnostics.cpp [clang] Add range accessor for ObjCAtTryStmt catch_stmts and use it 2021-10-27 08:57:05 -04:00
MultiplexExternalSemaSource.cpp [clang][AST] Improve AST Reader/Writer memory footprint 2021-05-20 15:34:29 -07:00
OpenCLBuiltins.td [OpenCL] Fix atomic_fetch_add/sub half overloads 2022-06-17 09:53:45 +01:00
ParsedAttr.cpp [clang] Reject non-declaration C++11 attributes on declarations 2022-06-15 11:58:26 +02:00
Scope.cpp Revert D119136 "[clang] Implement Change scope of lambda trailing-return-type" and its follow-up 2022-04-20 10:57:12 -07:00
ScopeInfo.cpp [clang] Disallow mixing SEH and Objective-C exceptions 2021-10-20 14:18:12 -04:00
Sema.cpp [FPEnv] Allow CompoundStmt to keep FP options 2022-07-03 17:06:26 +07:00
SemaAccess.cpp [C++2b] Implement multidimentional subscript operator 2022-02-08 12:10:47 -05:00
SemaAttr.cpp [clang-cl] Handle some pragma alloc_text corner cases handled by MSVC 2022-06-29 06:45:59 -07:00
SemaAvailability.cpp [clang] Don't use Optional::getValue (NFC) 2022-06-20 22:59:26 -07:00
SemaCUDA.cpp [clang] Don't use Optional::hasValue (NFC) 2022-06-25 22:26:24 -07:00
SemaCXXScopeSpec.cpp [C++20] [Module] Support reachable definition initially/partially 2022-06-29 12:48:48 +08:00
SemaCast.cpp [randstruct] Add randomize structure layout support 2022-04-09 13:15:36 -07:00
SemaChecking.cpp [clang][BPF] Update comment to include TYPE_MATCH 2022-06-29 18:32:06 -07:00
SemaCodeComplete.cpp Revert "Don't use Optional::hasValue (NFC)" 2022-06-25 11:56:50 -07:00
SemaConcept.cpp Revert "Re-apply "Deferred Concept Instantiation Implementation""" 2022-07-01 11:20:16 -07:00
SemaConsumer.cpp
SemaCoroutine.cpp [NFC] [Coroutines] Add test for ambiguous allocation functions in 2022-06-06 14:23:35 +08:00
SemaDecl.cpp [OpenMP] Add variant extension that applies to declarations 2022-06-29 15:04:26 -04:00
SemaDeclAttr.cpp [HLSL] Change WaveActiveCountBits to wrapper of __builtin_hlsl_wave_active_count_bits 2022-06-30 06:16:51 -07:00
SemaDeclCXX.cpp [FPEnv] Allow CompoundStmt to keep FP options 2022-07-03 17:06:26 +07:00
SemaDeclObjC.cpp [clang] Don't use Optional::hasValue (NFC) 2022-06-20 10:51:34 -07:00
SemaExceptionSpec.cpp [OpenMP] Initial parsing and semantic support for 'parallel masked taskloop simd' construct 2022-07-01 08:57:15 -07:00
SemaExpr.cpp [Clang] Rename StringLiteral::isAscii() => isOrdinary() [NFC] 2022-06-29 18:28:51 +02:00
SemaExprCXX.cpp [FPEnv] Allow CompoundStmt to keep FP options 2022-07-03 17:06:26 +07:00
SemaExprMember.cpp Add some helpers to better check Scope's kind. NFC 2022-04-16 11:31:40 +08:00
SemaExprObjC.cpp [Clang] Rename StringLiteral::isAscii() => isOrdinary() [NFC] 2022-06-29 18:28:51 +02:00
SemaFixItUtils.cpp [clang] NFC: Rename rvalue to prvalue 2021-06-09 12:27:10 +02:00
SemaInit.cpp [Clang] Rename StringLiteral::isAscii() => isOrdinary() [NFC] 2022-06-29 18:28:51 +02:00
SemaLambda.cpp [clang] Don't use Optional::getValue (NFC) 2022-06-20 22:59:26 -07:00
SemaLookup.cpp [C++20] [Module] Support reachable definition initially/partially 2022-06-29 12:48:48 +08:00
SemaModule.cpp [C++20] [Module] Support reachable definition initially/partially 2022-06-29 12:48:48 +08:00
SemaObjCProperty.cpp [Clang][Sema] Fix attribute mismatch warning for ObjC class properties 2022-01-11 12:10:18 +00:00
SemaOpenMP.cpp [FPEnv] Allow CompoundStmt to keep FP options 2022-07-03 17:06:26 +07:00
SemaOverload.cpp Revert "Re-apply "Deferred Concept Instantiation Implementation""" 2022-07-01 11:20:16 -07:00
SemaPseudoObject.cpp [clang] NFC: Rename rvalue to prvalue 2021-06-09 12:27:10 +02:00
SemaSYCL.cpp [SYCL] Diagnose uses of zero length arrays 2021-12-29 15:30:18 +03:00
SemaStmt.cpp [FPEnv] Allow CompoundStmt to keep FP options 2022-07-03 17:06:26 +07:00
SemaStmtAsm.cpp [Clang] Rename StringLiteral::isAscii() => isOrdinary() [NFC] 2022-06-29 18:28:51 +02:00
SemaStmtAttr.cpp [clang][parse] Move source range into ParsedAttibutesView 2022-03-24 08:11:57 +01:00
SemaTemplate.cpp Revert "Re-apply "Deferred Concept Instantiation Implementation""" 2022-07-01 11:20:16 -07:00
SemaTemplateDeduction.cpp Revert "Re-apply "Deferred Concept Instantiation Implementation""" 2022-07-01 11:20:16 -07:00
SemaTemplateInstantiate.cpp Revert "Re-apply "Deferred Concept Instantiation Implementation""" 2022-07-01 11:20:16 -07:00
SemaTemplateInstantiateDecl.cpp Revert "Re-apply "Deferred Concept Instantiation Implementation""" 2022-07-01 11:20:16 -07:00
SemaTemplateVariadic.cpp Use range based for loop in Sema::CheckParameterPacksForExpansion. NFC 2022-04-22 13:31:31 +08:00
SemaType.cpp [C++20] [Module] Support reachable definition initially/partially 2022-06-29 12:48:48 +08:00
TreeTransform.h Generate the capture for the field when the field is used in openmp 2022-07-01 17:09:01 -07:00
TypeLocBuilder.cpp
TypeLocBuilder.h
UsedDeclVisitor.h [HIP][OpenMP] Fix assertion in deferred diag 2021-10-25 11:07:40 -04:00