[compiler-rt] [libFuzzer] Use the correct RISCV target detection macro in `GetPreviousInstructionPc` (PR #228453)

Rong Mantle Bao via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 22:00:12 PDT 2026


https://github.com/CSharperMantle updated https://github.com/llvm/llvm-project/pull/228453

>From 205825bd84b35b3570532c81e25d87dc82772b7b Mon Sep 17 00:00:00 2001
From: Rong Bao <rong.bao at csmantle.top>
Date: Fri, 2 Oct 2026 22:11:43 +0800
Subject: [PATCH] [libFuzzer] Remove unused helper GetPreviousInstructionPc()

This function hasn't been used since 2891b257c24c ("[libFuzzer] remove
stale code"), and it contains a typo in the RISCV #ifdef arm. Removing
this altogether.
---
 compiler-rt/lib/fuzzer/FuzzerTracePC.cpp | 19 -------------------
 1 file changed, 19 deletions(-)

diff --git a/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp b/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp
index d439ec2f0982d7..a5976db3f801a8 100644
--- a/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp
@@ -128,25 +128,6 @@ void TracePC::HandleCallerCallee(uintptr_t Caller, uintptr_t Callee) {
   ValueProfileMap.AddValueModPrime(Idx);
 }
 
-/// \return the address of the previous instruction.
-/// Note: the logic is copied from `sanitizer_common/sanitizer_stacktrace.h`
-inline ALWAYS_INLINE uintptr_t GetPreviousInstructionPc(uintptr_t PC) {
-#if defined(__arm__)
-  // T32 (Thumb) branch instructions might be 16 or 32 bit long,
-  // so we return (pc-2) in that case in order to be safe.
-  // For A32 mode we return (pc-4) because all instructions are 32 bit long.
-  return (PC - 3) & (~1);
-#elif defined(__sparc__) || defined(__mips__)
-  return PC - 8;
-#elif defined(__riscv__)
-  return PC - 2;
-#elif defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
-  return PC - 1;
-#else
-  return PC - 4;
-#endif
-}
-
 /// \return the address of the next instruction.
 /// Note: the logic is copied from `sanitizer_common/sanitizer_stacktrace.cpp`
 ALWAYS_INLINE uintptr_t TracePC::GetNextInstructionPc(uintptr_t PC) {



More information about the llvm-commits mailing list