Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 20d3aa9

Browse files
authored
[NFC][ELF] Remove redundant and unused file argument from deleteFallThruJmpInsn (#180540)
This was added in 9431787 ("LLD Support for Basic Block Sections") and was only ever used for getRelocTargetVA. It was always redundant even back then, as it was always the same as is.file, and so passing it separately made it confusing and less obvious which file it was referring to, but 2b5cb1b ("[ELF] getRelocTargetVA: pass Ctx and Relocation. NFC") removed that one use so it is now completely unused. Remove it, and if anyone ever finds a need for it, they can just use is.file like should have been done in the first place.
1 parent 74c8891 commit 20d3aa9

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

lld/ELF/Arch/X86_64.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class X86_64 : public TargetInfo {
4747
void relocateAlloc(InputSection &sec, uint8_t *buf) const override;
4848
bool adjustPrologueForCrossSplitStack(uint8_t *loc, uint8_t *end,
4949
uint8_t stOther) const override;
50-
bool deleteFallThruJmpInsn(InputSection &is, InputFile *file,
50+
bool deleteFallThruJmpInsn(InputSection &is,
5151
InputSection *nextIS) const override;
5252
bool relaxOnce(int pass) const override;
5353
void applyBranchToBranchOpt() const override;
@@ -184,8 +184,8 @@ static bool isRelocationForJmpInsn(Relocation &R) {
184184
// next section.
185185
// TODO: Delete this once psABI reserves a new relocation type for fall thru
186186
// jumps.
187-
static bool isFallThruRelocation(InputSection &is, InputFile *file,
188-
InputSection *nextIS, Relocation &r) {
187+
static bool isFallThruRelocation(InputSection &is, InputSection *nextIS,
188+
Relocation &r) {
189189
if (!isRelocationForJmpInsn(r))
190190
return false;
191191

@@ -246,7 +246,7 @@ static JmpInsnOpcode invertJmpOpcode(const JmpInsnOpcode opcode) {
246246
// 10: je bar #jne flipped to je and the jmp is deleted.
247247
// aa.BB.foo:
248248
// ...
249-
bool X86_64::deleteFallThruJmpInsn(InputSection &is, InputFile *file,
249+
bool X86_64::deleteFallThruJmpInsn(InputSection &is,
250250
InputSection *nextIS) const {
251251
const unsigned sizeOfDirectJmpInsn = 5;
252252

@@ -270,7 +270,7 @@ bool X86_64::deleteFallThruJmpInsn(InputSection &is, InputFile *file,
270270
if (*(secContents + r.offset - 1) != 0xe9)
271271
return false;
272272

273-
if (isFallThruRelocation(is, file, nextIS, r)) {
273+
if (isFallThruRelocation(is, nextIS, r)) {
274274
// This is a fall thru and can be deleted.
275275
r.expr = R_NONE;
276276
r.offset = 0;
@@ -297,7 +297,7 @@ bool X86_64::deleteFallThruJmpInsn(InputSection &is, InputFile *file,
297297
if (jmpOpcodeB == J_UNKNOWN)
298298
return false;
299299

300-
if (!isFallThruRelocation(is, file, nextIS, rB))
300+
if (!isFallThruRelocation(is, nextIS, rB))
301301
return false;
302302

303303
// jmpCC jumps to the fall thru block, the branch can be flipped and the

lld/ELF/Target.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class TargetInfo {
124124
// jump consecutively, it tries to flip the conditional jump to convert the
125125
// direct jump into a fall thru and delete it. Returns true if a jump
126126
// instruction can be deleted.
127-
virtual bool deleteFallThruJmpInsn(InputSection &is, InputFile *file,
127+
virtual bool deleteFallThruJmpInsn(InputSection &is,
128128
InputSection *nextIS) const {
129129
return false;
130130
}

lld/ELF/Writer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,7 @@ template <class ELFT> void Writer<ELFT>::optimizeBasicBlockJumps() {
17421742
for (size_t i = 0, e = sections.size(); i != e; ++i) {
17431743
InputSection *next = i + 1 < sections.size() ? sections[i + 1] : nullptr;
17441744
InputSection &sec = *sections[i];
1745-
numDeleted += ctx.target->deleteFallThruJmpInsn(sec, sec.file, next);
1745+
numDeleted += ctx.target->deleteFallThruJmpInsn(sec, next);
17461746
}
17471747
if (numDeleted > 0) {
17481748
ctx.script->assignAddresses();

0 commit comments

Comments
 (0)