[all-commits] [llvm/llvm-project] 9c994f: [sancov][LoongArch] Resolve pcaddu18i+jirl in eval...

ZhaoQi via All-commits all-commits at lists.llvm.org
Wed Aug 27 18:25:51 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9c994f54497b54d8c44d2c6979a4cdaa8e4d7833
      https://github.com/llvm/llvm-project/commit/9c994f54497b54d8c44d2c6979a4cdaa8e4d7833
  Author: ZhaoQi <zhaoqi01 at loongson.cn>
  Date:   2025-08-28 (Thu, 28 Aug 2025)

  Changed paths:
    M lld/test/ELF/loongarch-call36.s
    M llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCTargetDesc.cpp
    M llvm/tools/sancov/sancov.cpp

  Log Message:
  -----------
  [sancov][LoongArch] Resolve pcaddu18i+jirl in evaluateBranch and teach sancov (#155371)

This commit overrides `updateState` and `resetState` hooks in
`MCInstrAnalysis` in order to be able to analyze pcaddu18i+jirl pairs
inside `evaluateBranch`.

After this commit, `llvm-objdump` is able to correctly analyze and print
detailed information. `lld/test/ELF/loongarch-call36.s` shows the
changes.

Besides, this commit also teaches sancov to resolve such call sequences.
Without this commit, some tests in compiler-rt failed:

```
Failed Tests :
  SanitizerCommon-asan-loongarch64-Linux :: sanitizer_coverage_trace_pc_guard-dso.cpp
  SanitizerCommon-asan-loongarch64-Linux :: sanitizer_coverage_trace_pc_guard.cpp
  SanitizerCommon-lsan-loongarch64-Linux :: sanitizer_coverage_trace_pc_guard-dso.cpp
  SanitizerCommon-lsan-loongarch64-Linux :: sanitizer_coverage_trace_pc_guard.cpp
  SanitizerCommon-msan-loongarch64-Linux :: sanitizer_coverage_trace_pc_guard-dso.cpp
  SanitizerCommon-msan-loongarch64-Linux :: sanitizer_coverage_trace_pc_guard.cpp
```

The reason is that sancov could not resolve pcaddu18i+jirl call sequence
correctly and caused mismatches between coverage points in the binary
and the .sancov file:

```
ERROR: Coverage points in binary and .sancov file do not match.
```

NOTE: A similar issue might also occur on RISC-V when relaxation is
disabled (not verified). This commit can also fix for it.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list