[flang] [llvm] [flang][device] Enable Stop functions on device build (PR #133803)

Valentin Clement バレンタイン クレメン via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 31 15:31:33 PDT 2025


================
@@ -65,8 +65,25 @@ static void CloseAllExternalUnits(const char *why) {
   Fortran::runtime::io::ExternalFileUnit::CloseAll(handler);
 }
 
-[[noreturn]] void RTNAME(StopStatement)(
+[[noreturn]] RT_API_ATTRS void RTNAME(StopStatement)(
     int code, bool isErrorStop, bool quiet) {
+#if defined(RT_DEVICE_COMPILATION)
+  if (Fortran::runtime::executionEnvironment.noStopMessage && code == 0) {
+    quiet = true;
+  }
+  if (!quiet) {
+    if (isErrorStop) {
+      std::printf("Fortran ERROR STOP");
+    } else {
+      std::printf("Fortran STOP");
+    }
+    if (code != EXIT_SUCCESS) {
+      std::printf(": code %d\n", code);
+    }
+    std::printf('\n');
+  }
+  assert();
----------------
clementval wrote:

Yeah that is probably better. Thanks. I updated the patch. 

https://github.com/llvm/llvm-project/pull/133803


More information about the llvm-commits mailing list