From: Jean Perier Date: Fri, 1 Mar 2019 14:47:47 +0000 (-0800) Subject: [flang] made fenv errors internal errors X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fa3a179fec64570c7305b963e78c7181d53cf755;p=platform%2Fupstream%2Fllvm.git [flang] made fenv errors internal errors Original-commit: flang-compiler/f18@f776c8db91d6cd3bee295d73b92f52688d59b362 Tree-same-pre-rewrite: false --- diff --git a/flang/lib/evaluate/rte.cc b/flang/lib/evaluate/rte.cc index ed350f25ec8a..fcf96af6e050 100644 --- a/flang/lib/evaluate/rte.cc +++ b/flang/lib/evaluate/rte.cc @@ -18,6 +18,7 @@ // that are guaranteed to exist from the C++ standard. #include "rte.h" +#include "../common/idioms.h" #include #include #include @@ -70,9 +71,9 @@ void HostRte::LoadTargetRteLibrary(const TargetRteLibrary &lib) { if (error) { } else { // Note: below is the only reinterpret_cast from an object pointer to - // function pointer As per C++11 and later rules on reinterpret_cast, it is - // implementation defined whether this is supported. POSIX mandates that - // such cast from function pointers to void* are defined. Hence this + // function pointer As per C++11 and later rules on reinterpret_cast, it + // is implementation defined whether this is supported. POSIX mandates + // that such cast from function pointers to void* are defined. Hence this // reinterpret_cast is and MUST REMAIN inside ifdef related to POSIX. AddProcedure(HostRteProcedureSymbol{ sym.second, reinterpret_cast>(func)}); @@ -238,14 +239,12 @@ void HostFloatingPointEnvironment::SetUpHostFloatingPointEnvironment( FoldingContext &context) { errno = 0; if (feholdexcept(&originalFenv_) != 0) { - context.messages().Say( - "Folding with host runtime: feholdexcept() failed: %s"_en_US, + common::die("Folding with host runtime: feholdexcept() failed: %s", std::strerror(errno)); return; } if (fegetenv(¤tFenv_) != 0) { - context.messages().Say( - "Folding with host runtime: fegetenv() failed: %s"_en_US, + common::die("Folding with host runtime: fegetenv() failed: %s", std::strerror(errno)); return; } @@ -259,10 +258,12 @@ void HostFloatingPointEnvironment::SetUpHostFloatingPointEnvironment( } #else // TODO other architectures + context.messages().Say( + "TODO: flushing mode for subnormals is not set for this host architecture when folding with host runtime functions"_en_US); #endif errno = 0; if (fesetenv(¤tFenv_) != 0) { - context.messages().Say("Folding with host rte: fesetenv() failed: %s"_en_US, + common::die("Folding with host runtime: fesetenv() failed: %s", std::strerror(errno)); return; } @@ -272,8 +273,9 @@ void HostFloatingPointEnvironment::SetUpHostFloatingPointEnvironment( case RoundingMode::Up: fesetround(FE_UPWARD); break; case RoundingMode::Down: fesetround(FE_DOWNWARD); break; case RoundingMode::TiesAwayFromZero: + fesetround(FE_TONEAREST); context.messages().Say( - "Folding with host runtime: TiesAwayFromZero rounding not available"_en_US); + "TiesAwayFromZero rounding mode is not available not available when folding constants with host runtime. Using TiesToEven instead."_en_US); break; } errno = 0; @@ -315,8 +317,8 @@ void HostFloatingPointEnvironment::CheckAndRestoreFloatingPointEnvironment( errno = 0; if (fesetenv(&originalFenv_) != 0) { std::fprintf(stderr, "fesetenv() failed: %s\n", std::strerror(errno)); - context.messages().Say( - "Folding with host rte: fesetenv() while restoring fenv failed: %s"_en_US, + common::die( + "Folding with host runtime: fesetenv() failed while restoring fenv: %s", std::strerror(errno)); } errno = 0;