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

ZhaoQi via All-commits all-commits at lists.llvm.org
Thu Aug 28 19:59:14 PDT 2025


  Branch: refs/heads/users/zhaoqi5/reland-9c994f5
  Home:   https://github.com/llvm/llvm-project
  Commit: 7b5c4556b07f647a2f724544eee2deca5f94bd92
      https://github.com/llvm/llvm-project/commit/7b5c4556b07f647a2f724544eee2deca5f94bd92
  Author: ZhaoQi <zhaoqi01 at loongson.cn>
  Date:   2025-08-29 (Fri, 29 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.


  Commit: 0d9f18b85338719030cbeeb403db6c5eb46a7991
      https://github.com/llvm/llvm-project/commit/0d9f18b85338719030cbeeb403db6c5eb46a7991
  Author: Qi Zhao <zhaoqi01 at loongson.cn>
  Date:   2025-08-29 (Fri, 29 Aug 2025)

  Changed paths:
    M llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCTargetDesc.cpp

  Log Message:
  -----------
  fix ubsan bots failures


Compare: https://github.com/llvm/llvm-project/compare/7b5c4556b07f%5E...0d9f18b85338

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