[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:25:36 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-bolt

Author: None (dinyy)

<details>
<summary>Changes</summary>

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@<!-- -->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

---
Full diff: https://github.com/llvm/llvm-project/pull/136231.diff


1 Files Affected:

- (modified) bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp (+2) 


``````````diff
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:

``````````

</details>


https://github.com/llvm/llvm-project/pull/136231


More information about the llvm-commits mailing list