[llvm] [BOLT][Instrumentation]correct profile data handling for direct function calls (PR #136231)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 17 17:24:48 PDT 2025
https://github.com/dinyy created https://github.com/llvm/llvm-project/pull/136231
This PR fixes an issue where the basic instrumentation test was failing for RISCV targets. The generated branch profile did not match the expected output in [bolt/test/runtime/RISCV/basic-instrumentation.s](https://github.com/llvm/llvm-project/blob/main/bolt/test/runtime/RISCV/basic-instrumentation.s)
Before the fix, the output contained incomplete branch information and missing critical transitions:
> 1 __do_global_dtors_aux/1 8 1 __do_global_dtors_aux/1 a 0 1
1 __do_global_dtors_aux/1 16 1 __do_global_dtors_aux/1 18 0 1
1 __do_global_dtors_aux/1 20 1 __do_global_dtors_aux/1 22 0 1
1 __do_global_dtors_aux/1 20 0 [unknown] 0 0 1
0 [unknown] 0 1 _start 0 0 1
0 [unknown] 0 1 load_gp/1 0 0 1
0 [unknown] 0 1 __do_global_dtors_aux/1 0 0 1
0 [unknown] 0 1 frame_dummy/1 0 0 1
0 [unknown] 0 1 main 0 0 1
0 [unknown] 0 1 f 0 0 1
After the fix, the output now correctly shows all expected branch transitions:
> 1 _start 0 1 load_gp/1 0 0 1
1 _start 1c 1 __libc_start_main at PLT 0 0 1
1 __do_global_dtors_aux/1 8 1 __do_global_dtors_aux/1 a 0 1
1 __do_global_dtors_aux/1 16 1 __do_global_dtors_aux/1 18 0 1
1 __do_global_dtors_aux/1 20 1 __do_global_dtors_aux/1 22 0 1
1 __do_global_dtors_aux/1 22 1 deregister_tm_clones/1 0 0 1
1 frame_dummy/1 0 1 register_tm_clones/1 0 0 1
1 main 4 1 f 0 0 1
1 __do_global_dtors_aux/1 20 0 [unknown] 0 0 1
0 [unknown] 0 1 _start 0 0 1
0 [unknown] 0 1 __do_global_dtors_aux/1 0 0 1
0 [unknown] 0 1 frame_dummy/1 0 0 1
0 [unknown] 0 1 main 0 0 1
>From 7c9bbb2b8ed8c35e97f570732f76abb5d99f1340 Mon Sep 17 00:00:00 2001
From: yjn <1076891326 at qq.com>
Date: Fri, 18 Apr 2025 08:12:26 +0800
Subject: [PATCH] [BOLT][Instrumentation]correct profile data handling for
direct function calls
---
bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp b/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp
index 0e27d29019e95..b6976e606cf51 100644
--- a/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp
+++ b/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp
@@ -322,6 +322,8 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
default:
return false;
case RISCV::C_J:
+ case RISCV::PseudoCALL:
+ case RISCV::PseudoTAIL:
OpNum = 0;
return true;
case RISCV::AUIPC:
More information about the llvm-commits
mailing list