[llvm] [BOLT][RISCV] : Adjust the operand order of AMOADD to maintain consis… (PR #171580)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 8 17:04:57 PST 2026


https://github.com/hunenghui updated https://github.com/llvm/llvm-project/pull/171580

>From 504ca96976dd4d7dee678aafa305cf4d93e131d5 Mon Sep 17 00:00:00 2001
From: hunenghui <hunenghui at ultrarisc.com>
Date: Wed, 10 Dec 2025 10:30:39 +0800
Subject: [PATCH 1/2] [bolt][RISCV] : Adjust the operand order of AMOADD to
 maintain consistency with the instruction description.

---
 bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp b/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp
index 7c4a8781fd57d..50faa377d5ebe 100644
--- a/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp
+++ b/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp
@@ -548,8 +548,8 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
                  MCPhysReg RegCnt) const {
     Inst = MCInstBuilder(RISCV::AMOADD_D)
                .addReg(RegAtomic)
-               .addReg(RegTo)
-               .addReg(RegCnt);
+               .addReg(RegCnt)
+               .addReg(RegTo);
   }
 
   InstructionListType createRegCmpJE(MCPhysReg RegNo, MCPhysReg RegTmp,

>From 6b32d57e39d0fe03e972c75896b0d9ca9311e110 Mon Sep 17 00:00:00 2001
From: hunenghui <hnh_lipr at 163.com>
Date: Thu, 8 Jan 2026 18:05:06 +0800
Subject: [PATCH 2/2] add a test file

---
 .../test/runtime/RISCV/instrumentation-call.c | 27 +++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 bolt/test/runtime/RISCV/instrumentation-call.c

diff --git a/bolt/test/runtime/RISCV/instrumentation-call.c b/bolt/test/runtime/RISCV/instrumentation-call.c
new file mode 100644
index 0000000000000..8f69e3abef10e
--- /dev/null
+++ b/bolt/test/runtime/RISCV/instrumentation-call.c
@@ -0,0 +1,27 @@
+/* Checks that BOLT correctly handles instrumentation of executables.
+
+REQUIRES: system-linux,bolt-runtime
+
+RUN: %clang %cflags %s -o %t.exe -Wl,-q
+
+RUN: llvm-bolt %t.exe --instrument --instrumentation-file=%t.fdata \
+RUN:   -o %t.instrumented
+
+# Instrumented program needs to finish returning zero
+RUN: %t.instrumented 1 2 3 | FileCheck %s -check-prefix=CHECK-OUTPUT
+
+CHECK-OUTPUT: fib(4) = 3
+*/
+
+#include <stdio.h>
+
+int fib(int x) {
+  if (x < 2)
+    return x;
+  return fib(x - 1) + fib(x - 2);
+}
+
+int main(int argc, char **argv) {
+  printf("fib(%d) = %d\n", argc, fib(argc));
+  return 0;
+}



More information about the llvm-commits mailing list