Skip to content

Commit dcb7f44

Browse files
authored
[flang] Modifications to ieee_support_halting (#120976)
The F23 standard requires that a call to intrinsic module procedure ieee_support_halting be foldable to a constant at compile time in some contexts. See for example F23 Clause 10.1.11 [Specification expression] list item (13), Clause 1.1.12 [Constant expression] list item (11), and references to specification and constant expressions elsewhere, such as constraints C1012, C853, and C704. Some Arm processors allow a user to control processor behavior when an arithmetic exception is signaled, and some Arm processors do not have this capability. An Arm executable will run on either type of processor, so it is effectively unknown at compile time whether or not this support will be available at runtime. This is in conflict with the standard requirement. This patch addresses this conflict by implementing ieee_support_halting calls on Arm processors to check if this capability is present at runtime. A call to ieee_support_halting in a constant context, such as in the specification part of a program unit, will generate a compile time "cannot be computed as a constant value" error. The expectation is that such calls are unlikely to appear in production code. Code generation for other processors will continue to generate a compile time constant result for ieee_support_halting calls.
1 parent 711419e commit dcb7f44

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

flang/runtime/exceptions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ uint32_t RTNAME(MapException)(uint32_t excepts) {
8484
// Check if the processor has the ability to control whether to halt or
8585
// continue execution when a given exception is raised.
8686
bool RTNAME(SupportHalting)([[maybe_unused]] uint32_t except) {
87-
#ifdef _WIN32
88-
return false;
89-
#else
87+
#if (defined(__arm__) || defined(__aarch64__)) && !defined(_WIN32)
9088
except = RTNAME(MapException)(except);
9189
int currentSet = fegetexcept(), flipSet, ok;
9290
if (currentSet & except) {
@@ -99,6 +97,8 @@ bool RTNAME(SupportHalting)([[maybe_unused]] uint32_t except) {
9997
ok |= fedisableexcept(except);
10098
}
10199
return ok != -1 && currentSet != flipSet;
100+
#else
101+
return false;
102102
#endif
103103
}
104104

0 commit comments

Comments
 (0)