[compiler-rt] [compiler-rt][sanitizer] Add Windows MIPS32 support (PR #145110)

Hervé Poussineau via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 30 22:27:18 PDT 2025


https://github.com/hpoussin updated https://github.com/llvm/llvm-project/pull/145110

>From 60789dacbb176160f5979e166713bfb71e7a542e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= <hpoussin at reactos.org>
Date: Sat, 21 Jun 2025 00:00:11 +0200
Subject: [PATCH] [compiler-rt][sanitizer] Add Windows MIPS32 support

---
 .../lib/sanitizer_common/sanitizer_stoptheworld_win.cpp      | 2 ++
 compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp    | 5 +++++
 compiler-rt/lib/sanitizer_common/sanitizer_win.cpp           | 3 +++
 3 files changed, 10 insertions(+)

diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_win.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_win.cpp
index f114acea79c9c..fa15f8a9f06a9 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_win.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_win.cpp
@@ -49,6 +49,8 @@ struct SuspendedThreadsListWindows final : public SuspendedThreadsList {
 #    define SP_REG Esp
 #  elif SANITIZER_ARM | SANITIZER_ARM64
 #    define SP_REG Sp
+#  elif SANITIZER_MIPS32
+#    define SP_REG IntSp
 #  else
 #    error Architecture not supported!
 #  endif
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp
index 6fc18396ca63b..30ba812afc4b0 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cpp
@@ -75,6 +75,11 @@ void BufferedStackTrace::UnwindSlow(uptr pc, void *context, u32 max_depth) {
   stack_frame.AddrPC.Offset = ctx.Pc;
   stack_frame.AddrFrame.Offset = ctx.R11;
   stack_frame.AddrStack.Offset = ctx.Sp;
+#      elif SANITIZER_MIPS32
+  int machine_type = IMAGE_FILE_MACHINE_R4000;
+  stack_frame.AddrPC.Offset = ctx.Fir;
+  stack_frame.AddrFrame.Offset = ctx.IntS8;
+  stack_frame.AddrStack.Offset = ctx.IntSp;
 #      else
   int machine_type = IMAGE_FILE_MACHINE_I386;
   stack_frame.AddrPC.Offset = ctx.Eip;
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
index fd0f989ee392b..48ebe78c4031e 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
@@ -1011,6 +1011,9 @@ void SignalContext::InitPcSpBp() {
 #    if SANITIZER_ARM
   bp = (uptr)context_record->R11;
   sp = (uptr)context_record->Sp;
+#    elif SANITIZER_MIPS32
+  bp = (uptr)context_record->IntS8;
+  sp = (uptr)context_record->IntSp;
 #    else
   bp = (uptr)context_record->Ebp;
   sp = (uptr)context_record->Esp;



More information about the llvm-commits mailing list