[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 07:21:04 PDT 2026


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

Per [RISC-V C API specs](https://github.com/riscv-non-isa/riscv-c-api-doc/blob/25091956af52dee37fc22c9f14da52598412cc48/src/c-api.adoc#preprocessor-definitions), the correct macro name for detecting the RISCV target is `__riscv`, not `__riscv__` as in the current code.

This was found when surveying RISCV-specific code in [a downstream project](https://searchfox.org/firefox-main/rev/084057e952e7dbf376f6c3765ad242aec3785dc6/tools/fuzzing/libfuzzer/FuzzerTracePC.cpp#141) that vendored libFuzzer.

>From dbdd77b11e119e8d06dca4589315ee1e50c3c3fe 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] Use the correct RISCV target detection macro in
 GetPreviousInstructionPc

This fixes the typo "__riscv__" to "__riscv". Per specs, the latter is
the correct spelling.

Link: https://github.com/riscv-non-isa/riscv-c-api-doc/blob/25091956af52dee37fc22c9f14da52598412cc48/src/c-api.adoc#preprocessor-definitions
---
 compiler-rt/lib/fuzzer/FuzzerTracePC.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp b/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp
index d439ec2f0982d7b..87816f8e323f236 100644
--- a/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp
@@ -138,7 +138,7 @@ inline ALWAYS_INLINE uintptr_t GetPreviousInstructionPc(uintptr_t PC) {
   return (PC - 3) & (~1);
 #elif defined(__sparc__) || defined(__mips__)
   return PC - 8;
-#elif defined(__riscv__)
+#elif defined(__riscv)
   return PC - 2;
 #elif defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
   return PC - 1;



More information about the llvm-commits mailing list