Skip to content

Commit 46f34a9

Browse files
committed
Fixes for review
1 parent 5dafc66 commit 46f34a9

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

Diff for: lld/ELF/Arch/LoongArch.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -1014,8 +1014,8 @@ static bool relax(Ctx &ctx, InputSection &sec) {
10141014
// * ld.d $a0, $a0, %ie_pc_lo12(sym)
10151015
//
10161016
// The code sequence converted is as follows:
1017-
// * lu12i.w $a0, %le_hi20(sym) # le_hi20 != 0, otherwise NOP
1018-
// * ori $a0 $a0, %le_lo12(sym)
1017+
// * lu12i.w $a0, %le_hi20(sym) # le_hi20 != 0, otherwise NOP
1018+
// * ori $a0, src, %le_lo12(sym) # le_hi20 != 0, src = $a0, otherwise src = $zero
10191019
//
10201020
// When relaxation enables, redundant NOPs can be removed.
10211021
void LoongArch::tlsIeToLe(uint8_t *loc, const Relocation &rel,
@@ -1036,7 +1036,7 @@ void LoongArch::tlsIeToLe(uint8_t *loc, const Relocation &rel,
10361036
case R_LARCH_TLS_IE_PC_LO12:
10371037
if (isUInt12)
10381038
write32le(loc, insn(ORI, getD5(currInsn), R_ZERO,
1039-
val)); // ori $a0, $r0, %le_lo12
1039+
val)); // ori $a0, $zero, %le_lo12
10401040
else
10411041
write32le(loc, insn(ORI, getD5(currInsn), getJ5(currInsn),
10421042
lo12(val))); // ori $a0, $a0, %le_lo12
@@ -1064,7 +1064,7 @@ void LoongArch::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
10641064
continue;
10651065
case R_RELAX_TLS_IE_TO_LE:
10661066
if (rel.type == R_LARCH_TLS_IE_PC_HI20) {
1067-
// LoongArch does not support IE to LE optimize in the extreme code
1067+
// LoongArch does not support IE to LE optimization in the extreme code
10681068
// model. In this case, the relocs are as follows:
10691069
//
10701070
// * i -- R_LARCH_TLS_IE_PC_HI20
@@ -1079,8 +1079,9 @@ void LoongArch::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
10791079
val = SignExtend64(sec.getRelocTargetVA(ctx, rel, secAddr + rel.offset),
10801080
bits);
10811081
relocateNoSym(loc, rel.type, val);
1082-
} else
1082+
} else {
10831083
tlsIeToLe(loc, rel, val);
1084+
}
10841085
continue;
10851086
default:
10861087
break;

Diff for: lld/ELF/Relocations.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,7 @@ unsigned RelocationScanner::handleTlsRelocation(RelExpr expr, RelType type,
13751375
return 1;
13761376
}
13771377

1378-
// LoongArch support IE to LE optimization in non-extreme code model.
1378+
// LoongArch supports IE to LE optimization in non-extreme code model.
13791379
bool execOptimizeInLoongArch =
13801380
ctx.arg.emachine == EM_LOONGARCH &&
13811381
(type == R_LARCH_TLS_IE_PC_HI20 || type == R_LARCH_TLS_IE_PC_LO12);

Diff for: lld/test/ELF/loongarch-relax-tls-ie.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ ld.d $a1, $a1, %ie_pc_lo12(b)
5151
add.d $a1, $a1, $tp
5252

5353
# Test instructions are interleaved.
54-
# PCALAU12I has an R_LARCH_RELAX. We preform relaxation.
54+
# PCALAU12I has an R_LARCH_RELAX. We perform relaxation.
5555
pcalau12i $a2, %ie_pc_hi20(a)
5656
.reloc .-4, R_LARCH_RELAX, 0
5757
pcalau12i $a3, %ie_pc_hi20(b)

0 commit comments

Comments
 (0)