[compiler-rt] d64a9fe - [compiler-rt][RISCV] Initialize length only when __init_riscv_feature… (#115449)

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 6 03:37:15 PST 2026


Author: Kito Cheng
Date: 2026-03-06T19:37:11+08:00
New Revision: d64a9fe7814d4061aaaf067fef5b1393f4f1529e

URL: https://github.com/llvm/llvm-project/commit/d64a9fe7814d4061aaaf067fef5b1393f4f1529e
DIFF: https://github.com/llvm/llvm-project/commit/d64a9fe7814d4061aaaf067fef5b1393f4f1529e.diff

LOG: [compiler-rt][RISCV] Initialize length only when __init_riscv_feature… (#115449)

…_bits success

That could give us a simple way to detect `__init_riscv_feature_bits`
got fail.

See also https://github.com/riscv-non-isa/riscv-c-api-doc/pull/95

Added: 
    

Modified: 
    compiler-rt/lib/builtins/cpu_model/riscv.c

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/builtins/cpu_model/riscv.c b/compiler-rt/lib/builtins/cpu_model/riscv.c
index c02f6e9961ca4..413e45f3f618c 100644
--- a/compiler-rt/lib/builtins/cpu_model/riscv.c
+++ b/compiler-rt/lib/builtins/cpu_model/riscv.c
@@ -337,6 +337,8 @@ static void initRISCVFeature(struct riscv_hwprobe Hwprobes[]) {
 
   for (i = 0; i < RISCV_FEATURE_BITS_LENGTH; i++)
     __riscv_feature_bits.features[i] = features[i];
+
+  __riscv_feature_bits.length = RISCV_FEATURE_BITS_LENGTH;
 }
 
 #endif // defined(__linux__)
@@ -364,8 +366,6 @@ void __init_riscv_feature_bits(void *PlatformArgs) {
   if (FeaturesBitCached)
     return;
 
-  __riscv_feature_bits.length = RISCV_FEATURE_BITS_LENGTH;
-
 #if defined(__linux__)
   struct riscv_hwprobe Hwprobes[] = {
       {RISCV_HWPROBE_KEY_BASE_BEHAVIOR, 0}, {RISCV_HWPROBE_KEY_IMA_EXT_0, 0},


        


More information about the llvm-commits mailing list