From 51559b550bd2a7f07d6ab8480ac408f30e6ce215 Mon Sep 17 00:00:00 2001 From: Sinan Lin Date: Mon, 23 Sep 2024 18:20:19 +0800 Subject: [PATCH] [BOLT] Simplify is[I]Relative functions Use get[I]Relative to simplify function bodies. --- bolt/lib/Core/Relocation.cpp | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/bolt/lib/Core/Relocation.cpp b/bolt/lib/Core/Relocation.cpp index 49064bb4e49b753..2cded3bc0bf7808 100644 --- a/bolt/lib/Core/Relocation.cpp +++ b/bolt/lib/Core/Relocation.cpp @@ -879,31 +879,9 @@ bool Relocation::isX86GOTPC64(uint64_t Type) { bool Relocation::isNone(uint64_t Type) { return Type == getNone(); } -bool Relocation::isRelative(uint64_t Type) { - switch (Arch) { - default: - llvm_unreachable("Unsupported architecture"); - case Triple::aarch64: - return Type == ELF::R_AARCH64_RELATIVE; - case Triple::riscv64: - return Type == ELF::R_RISCV_RELATIVE; - case Triple::x86_64: - return Type == ELF::R_X86_64_RELATIVE; - } -} +bool Relocation::isRelative(uint64_t Type) { return Type == getRelative(); } -bool Relocation::isIRelative(uint64_t Type) { - switch (Arch) { - default: - llvm_unreachable("Unsupported architecture"); - case Triple::aarch64: - return Type == ELF::R_AARCH64_IRELATIVE; - case Triple::riscv64: - return Type == ELF::R_RISCV_IRELATIVE; - case Triple::x86_64: - return Type == ELF::R_X86_64_IRELATIVE; - } -} +bool Relocation::isIRelative(uint64_t Type) { return Type == getIRelative(); } bool Relocation::isTLS(uint64_t Type) { switch (Arch) { @@ -1003,7 +981,7 @@ uint64_t Relocation::getRelative() { case Triple::aarch64: return ELF::R_AARCH64_RELATIVE; case Triple::riscv64: - llvm_unreachable("not implemented"); + return ELF::R_RISCV_RELATIVE; case Triple::x86_64: return ELF::R_X86_64_RELATIVE; }