[lld] 169ec2d - [ELF] Rename canRelax to toExecRelax. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 8 10:28:39 PDT 2020
Author: Fangrui Song
Date: 2020-07-08T10:27:31-07:00
New Revision: 169ec2d6b006ea31114a7d6ddc3f002d3cb4acb3
URL: https://github.com/llvm/llvm-project/commit/169ec2d6b006ea31114a7d6ddc3f002d3cb4acb3
DIFF: https://github.com/llvm/llvm-project/commit/169ec2d6b006ea31114a7d6ddc3f002d3cb4acb3.diff
LOG: [ELF] Rename canRelax to toExecRelax. NFC
In the absence of TLS relaxation (rewrite of code sequences),
there is still an applicable optimization:
[gd]: General Dynamic: resolve DTPMOD to 1 and/or resolve DTPOFF statically
All the other relaxations are only performed when transiting to
executable (`!config->shared`).
Since [gd] is handled differently, we can fold `!config->shared` into canRelax
and simplify its use sites. Rename the variable to reflect to new semantics.
Reviewed By: grimar, psmith
Differential Revision: https://reviews.llvm.org/D83243
Added:
Modified:
lld/ELF/Relocations.cpp
Removed:
################################################################################
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 42341f67afee..751ded397768 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -197,9 +197,9 @@ handleTlsRelocation(RelType type, Symbol &sym, InputSectionBase &c,
return 1;
}
- bool canRelax = config->emachine != EM_ARM &&
- config->emachine != EM_HEXAGON &&
- config->emachine != EM_RISCV;
+ bool toExecRelax = !config->shared && config->emachine != EM_ARM &&
+ config->emachine != EM_HEXAGON &&
+ config->emachine != EM_RISCV;
// If we are producing an executable and the symbol is non-preemptable, it
// must be defined and the code sequence can be relaxed to use Local-Exec.
@@ -217,7 +217,7 @@ handleTlsRelocation(RelType type, Symbol &sym, InputSectionBase &c,
if (oneof<R_TLSLD_GOT, R_TLSLD_GOTPLT, R_TLSLD_PC, R_TLSLD_HINT>(
expr)) {
// Local-Dynamic relocs can be relaxed to Local-Exec.
- if (canRelax && !config->shared) {
+ if (toExecRelax) {
c.relocations.push_back(
{target->adjustRelaxExpr(type, nullptr, R_RELAX_TLS_LD_TO_LE), type,
offset, addend, &sym});
@@ -238,7 +238,7 @@ handleTlsRelocation(RelType type, Symbol &sym, InputSectionBase &c,
}
// Local-Dynamic relocs can be relaxed to Local-Exec.
- if (expr == R_DTPREL && canRelax && !config->shared) {
+ if (expr == R_DTPREL && toExecRelax) {
c.relocations.push_back(
{target->adjustRelaxExpr(type, nullptr, R_RELAX_TLS_LD_TO_LE), type,
offset, addend, &sym});
@@ -260,7 +260,7 @@ handleTlsRelocation(RelType type, Symbol &sym, InputSectionBase &c,
if (oneof<R_AARCH64_TLSDESC_PAGE, R_TLSDESC, R_TLSDESC_CALL, R_TLSDESC_PC,
R_TLSGD_GOT, R_TLSGD_GOTPLT, R_TLSGD_PC>(expr)) {
- if (!canRelax || config->shared) {
+ if (!toExecRelax) {
if (in.got->addDynTlsEntry(sym)) {
uint64_t off = in.got->getGlobalDynOffset(sym);
@@ -308,7 +308,7 @@ handleTlsRelocation(RelType type, Symbol &sym, InputSectionBase &c,
// defined.
if (oneof<R_GOT, R_GOTPLT, R_GOT_PC, R_AARCH64_GOT_PAGE_PC, R_GOT_OFF,
R_TLSIE_HINT>(expr) &&
- canRelax && isLocalInExecutable) {
+ toExecRelax && isLocalInExecutable) {
c.relocations.push_back({R_RELAX_TLS_IE_TO_LE, type, offset, addend, &sym});
return 1;
}
More information about the llvm-commits
mailing list