[lld] [lld][LoongArch] Relax R_LARCH_PCALA_HI20 and R_LARCH_PCALA_LO12 (PR #112696)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 17 05:29:11 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 1b4a173fa41e02eddec9f1cf41324aa4ea8a7fa5 8f9e9c8e264b72ab161e2963da1bc82059d5a551 --extensions cpp -- lld/ELF/Arch/LoongArch.cpp lld/ELF/InputSection.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/lld/ELF/Arch/LoongArch.cpp b/lld/ELF/Arch/LoongArch.cpp
index e7276c23d0..ca3a7fe010 100644
--- a/lld/ELF/Arch/LoongArch.cpp
+++ b/lld/ELF/Arch/LoongArch.cpp
@@ -823,9 +823,11 @@ void LoongArch::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
// Relax pcalau12i,addi.d => pcaddi.
static void relaxPcalaAddi(const InputSection &sec, size_t i, uint64_t loc,
- Relocation &r_hi, uint32_t &remove) {
+ Relocation &r_hi, uint32_t &remove) {
const uint64_t symval =
- (r_hi.expr == R_LOONGARCH_PLT_PAGE_PC ? r_hi.sym->getPltVA(ctx) : r_hi.sym->getVA()) + r_hi.addend;
+ (r_hi.expr == R_LOONGARCH_PLT_PAGE_PC ? r_hi.sym->getPltVA(ctx)
+ : r_hi.sym->getVA()) +
+ r_hi.addend;
const int64_t dist = symval - loc;
uint32_t pca = read32le(sec.content().data() + r_hi.offset);
uint32_t add = read32le(sec.content().data() + r_hi.offset + 4);
@@ -833,11 +835,10 @@ static void relaxPcalaAddi(const InputSection &sec, size_t i, uint64_t loc,
if (!LARCH_INSN_ADDI_D(add)
// Is pcalau12i $rd + addi.d $rd, $rd?
- || LARCH_GET_RD(add) != rd
- || LARCH_GET_RJ(add) != rd
+ || LARCH_GET_RD(add) != rd ||
+ LARCH_GET_RJ(add) != rd
// 4 bytes align
- || symval & 0x3
- || !isInt<22>(dist))
+ || symval & 0x3 || !isInt<22>(dist))
return;
// remove the first insn
@@ -886,8 +887,7 @@ static bool relax(Ctx &ctx, InputSection &sec) {
break;
}
case R_LARCH_PCALA_HI20:
- if (isPair(relocs, i)
- && relocs[i + 2].type == R_LARCH_PCALA_LO12)
+ if (isPair(relocs, i) && relocs[i + 2].type == R_LARCH_PCALA_LO12)
relaxPcalaAddi(sec, i, loc, r, remove);
break;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/112696
More information about the llvm-commits
mailing list