Skip to content

Commit 69ff327

Browse files
committed
Add check for register.
1 parent 1b1804e commit 69ff327

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lld/ELF/Arch/LoongArch.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,11 @@ static void relaxPCHi20Lo12(Ctx &ctx, const InputSection &sec, size_t i,
816816
// addi.w/d.
817817
// * The destination register of pcalau12i is guaranteed to be used only by
818818
// the immediately following instruction.
819+
const uint32_t currInsn = read32le(sec.content().data() + rHi20.offset);
819820
const uint32_t nextInsn = read32le(sec.content().data() + rLo12.offset);
821+
// Check if use the same register.
822+
if (getD5(currInsn) != getJ5(nextInsn) || getJ5(nextInsn) != getD5(nextInsn))
823+
return;
820824

821825
sec.relaxAux->relocTypes[i] = R_LARCH_RELAX;
822826
sec.relaxAux->relocTypes[i + 2] = R_LARCH_PCREL20_S2;

0 commit comments

Comments
 (0)