Skip to content

Commit

Permalink
[BOLT] Simplify is[I]Relative functions
Browse files Browse the repository at this point in the history
Use get[I]Relative to simplify function bodies.
  • Loading branch information
linsinan1995 committed Sep 23, 2024
1 parent 7d731c2 commit 51559b5
Showing 1 changed file with 3 additions and 25 deletions.
28 changes: 3 additions & 25 deletions bolt/lib/Core/Relocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 51559b5

Please sign in to comment.