[llvm] [llubi] Implements common library functions (PR #190147)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 6 09:33:24 PDT 2026


================
@@ -240,11 +260,23 @@ int main(int argc, char **argv) {
   ubi::EventHandler NoopHandler;
   VerboseEventHandler VerboseHandler;
   ubi::AnyValue RetVal;
+  ubi::ProgramExitInfo ExitInfo;
   if (!Ctx.runFunction(*EntryFn, Args, RetVal,
-                       Verbose ? VerboseHandler : NoopHandler)) {
-    WithColor::error() << "Execution of function '" << EntryFunc
-                       << "' failed.\n";
-    return 1;
+                       Verbose ? VerboseHandler : NoopHandler, ExitInfo)) {
+    if (!ExitInfo.isExitedByLibcall()) {
+      WithColor::error() << "Execution of function '" << EntryFunc
+                         << "' failed.\n";
+      return 1;
+    }
+    switch (ExitInfo.Kind) {
+    case ubi::ProgramExitInfo::ProgramExitKind::Exited:
+      return static_cast<int>(ExitInfo.ExitCode & 0xFF);
+    case ubi::ProgramExitInfo::ProgramExitKind::Aborted:
+    case ubi::ProgramExitInfo::ProgramExitKind::Terminated:
+      return 1;
----------------
nikic wrote:

Would it make sense to return 134 here, as the standard abort exit code?

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


More information about the llvm-commits mailing list