Skip to content

Commit 2cbc2e3

Browse files
authored
[NFC][MC][AArch64] Do not use else after return in getRelocType (#89818)
After #89563, we do not use else after return in code corresponding to `R_AARCH64_AUTH_ABS64` reloc in `getRelocType`. This patch removes use of else after return in other places in `getRelocType`.
1 parent 99e7350 commit 2cbc2e3

File tree

1 file changed

+32
-45
lines changed

1 file changed

+32
-45
lines changed

llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp

Lines changed: 32 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
146146
"ILP32 8 byte PC relative data "
147147
"relocation not supported (LP64 eqv: PREL64)");
148148
return ELF::R_AARCH64_NONE;
149-
} else
150-
return ELF::R_AARCH64_PREL64;
149+
}
150+
return ELF::R_AARCH64_PREL64;
151151
case AArch64::fixup_aarch64_pcrel_adr_imm21:
152152
if (SymLoc != AArch64MCExpr::VK_ABS)
153153
Ctx.reportError(Fixup.getLoc(),
@@ -162,9 +162,8 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
162162
"invalid fixup for 32-bit pcrel ADRP instruction "
163163
"VK_ABS VK_NC");
164164
return ELF::R_AARCH64_NONE;
165-
} else {
166-
return ELF::R_AARCH64_ADR_PREL_PG_HI21_NC;
167165
}
166+
return ELF::R_AARCH64_ADR_PREL_PG_HI21_NC;
168167
}
169168
if (SymLoc == AArch64MCExpr::VK_GOT && !IsNC)
170169
return R_CLS(ADR_GOT_PAGE);
@@ -286,14 +285,12 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
286285
if (SymLoc == AArch64MCExpr::VK_TPREL && IsNC)
287286
return R_CLS(TLSLE_LDST32_TPREL_LO12_NC);
288287
if (SymLoc == AArch64MCExpr::VK_GOT && IsNC) {
289-
if (IsILP32) {
288+
if (IsILP32)
290289
return ELF::R_AARCH64_P32_LD32_GOT_LO12_NC;
291-
} else {
292-
Ctx.reportError(Fixup.getLoc(),
293-
"LP64 4 byte unchecked GOT load/store relocation "
294-
"not supported (ILP32 eqv: LD32_GOT_LO12_NC");
295-
return ELF::R_AARCH64_NONE;
296-
}
290+
Ctx.reportError(Fixup.getLoc(),
291+
"LP64 4 byte unchecked GOT load/store relocation "
292+
"not supported (ILP32 eqv: LD32_GOT_LO12_NC");
293+
return ELF::R_AARCH64_NONE;
297294
}
298295
if (SymLoc == AArch64MCExpr::VK_GOT && !IsNC) {
299296
if (IsILP32) {
@@ -309,25 +306,20 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
309306
return ELF::R_AARCH64_NONE;
310307
}
311308
if (SymLoc == AArch64MCExpr::VK_GOTTPREL && IsNC) {
312-
if (IsILP32) {
309+
if (IsILP32)
313310
return ELF::R_AARCH64_P32_TLSIE_LD32_GOTTPREL_LO12_NC;
314-
} else {
315-
Ctx.reportError(Fixup.getLoc(),
316-
"LP64 32-bit load/store "
317-
"relocation not supported (ILP32 eqv: "
318-
"TLSIE_LD32_GOTTPREL_LO12_NC)");
319-
return ELF::R_AARCH64_NONE;
320-
}
311+
Ctx.reportError(Fixup.getLoc(), "LP64 32-bit load/store "
312+
"relocation not supported (ILP32 eqv: "
313+
"TLSIE_LD32_GOTTPREL_LO12_NC)");
314+
return ELF::R_AARCH64_NONE;
321315
}
322316
if (SymLoc == AArch64MCExpr::VK_TLSDESC && !IsNC) {
323-
if (IsILP32) {
317+
if (IsILP32)
324318
return ELF::R_AARCH64_P32_TLSDESC_LD32_LO12;
325-
} else {
326-
Ctx.reportError(Fixup.getLoc(),
327-
"LP64 4 byte TLSDESC load/store relocation "
328-
"not supported (ILP32 eqv: TLSDESC_LD64_LO12)");
329-
return ELF::R_AARCH64_NONE;
330-
}
319+
Ctx.reportError(Fixup.getLoc(),
320+
"LP64 4 byte TLSDESC load/store relocation "
321+
"not supported (ILP32 eqv: TLSDESC_LD64_LO12)");
322+
return ELF::R_AARCH64_NONE;
331323
}
332324

333325
Ctx.reportError(Fixup.getLoc(),
@@ -344,12 +336,11 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
344336
if (AddressLoc == AArch64MCExpr::VK_LO15)
345337
return ELF::R_AARCH64_LD64_GOTPAGE_LO15;
346338
return ELF::R_AARCH64_LD64_GOT_LO12_NC;
347-
} else {
348-
Ctx.reportError(Fixup.getLoc(), "ILP32 64-bit load/store "
349-
"relocation not supported (LP64 eqv: "
350-
"LD64_GOT_LO12_NC)");
351-
return ELF::R_AARCH64_NONE;
352339
}
340+
Ctx.reportError(Fixup.getLoc(), "ILP32 64-bit load/store "
341+
"relocation not supported (LP64 eqv: "
342+
"LD64_GOT_LO12_NC)");
343+
return ELF::R_AARCH64_NONE;
353344
}
354345
if (SymLoc == AArch64MCExpr::VK_DTPREL && !IsNC)
355346
return R_CLS(TLSLD_LDST64_DTPREL_LO12);
@@ -360,24 +351,20 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
360351
if (SymLoc == AArch64MCExpr::VK_TPREL && IsNC)
361352
return R_CLS(TLSLE_LDST64_TPREL_LO12_NC);
362353
if (SymLoc == AArch64MCExpr::VK_GOTTPREL && IsNC) {
363-
if (!IsILP32) {
354+
if (!IsILP32)
364355
return ELF::R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC;
365-
} else {
366-
Ctx.reportError(Fixup.getLoc(), "ILP32 64-bit load/store "
367-
"relocation not supported (LP64 eqv: "
368-
"TLSIE_LD64_GOTTPREL_LO12_NC)");
369-
return ELF::R_AARCH64_NONE;
370-
}
356+
Ctx.reportError(Fixup.getLoc(), "ILP32 64-bit load/store "
357+
"relocation not supported (LP64 eqv: "
358+
"TLSIE_LD64_GOTTPREL_LO12_NC)");
359+
return ELF::R_AARCH64_NONE;
371360
}
372361
if (SymLoc == AArch64MCExpr::VK_TLSDESC) {
373-
if (!IsILP32) {
362+
if (!IsILP32)
374363
return ELF::R_AARCH64_TLSDESC_LD64_LO12;
375-
} else {
376-
Ctx.reportError(Fixup.getLoc(), "ILP32 64-bit load/store "
377-
"relocation not supported (LP64 eqv: "
378-
"TLSDESC_LD64_LO12)");
379-
return ELF::R_AARCH64_NONE;
380-
}
364+
Ctx.reportError(Fixup.getLoc(), "ILP32 64-bit load/store "
365+
"relocation not supported (LP64 eqv: "
366+
"TLSDESC_LD64_LO12)");
367+
return ELF::R_AARCH64_NONE;
381368
}
382369
Ctx.reportError(Fixup.getLoc(),
383370
"invalid fixup for 64-bit load/store instruction");

0 commit comments

Comments
 (0)