This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Rename canRelax to toExecRelax. NFC
ClosedPublic

Authored by MaskRay on Jul 6 2020, 10:08 AM.

Details

Summary

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.

Diff Detail

Event Timeline

MaskRay created this revision.Jul 6 2020, 10:08 AM
psmith accepted this revision.Jul 7 2020, 1:33 AM

LGTM it looks like a good simplification. Worth waiting a little bit to see if there are any objections.

This revision is now accepted and ready to land.Jul 7 2020, 1:33 AM
grimar accepted this revision.Jul 7 2020, 1:46 AM

LGTM too. A question/suggestion for a follow-up is inlined.

lld/ELF/Relocations.cpp
211

It looks like we can get rid of this variable now? I.e. looks like isLocalInExecutable can be replaced with !sym.isPreemptible everywhere.

MaskRay marked 2 inline comments as done.Jul 7 2020, 9:20 AM
MaskRay added inline comments.
lld/ELF/Relocations.cpp
211

We can't delete it.

if (!sharedToExecRelax) {
  // if (isLocalInExecutable)
  // cannot be changed to
  // if (!sym.isPreemptible
}
MaskRay marked 2 inline comments as done.Jul 7 2020, 9:25 AM
MaskRay added inline comments.
lld/ELF/Relocations.cpp
311

Initial-Exec -> Local-Exec is a relaxation from executable to executable. sharedToExecRelax is not an appropriate name. Shall we rename the variable?

Technically, a shared object can use Initial-Exec as well if it is part of initial modules (via transitive DT_NEEDED; DF_STATIC_TLS).

psmith added inline comments.Jul 8 2020, 12:58 AM
lld/ELF/Relocations.cpp
311

Perhaps just toExecRelax or canExecRelax?

MaskRay marked 2 inline comments as done.Jul 8 2020, 10:26 AM
MaskRay added inline comments.
lld/ELF/Relocations.cpp
311

Thanks. toExecRelax sounds good.

MaskRay updated this revision to Diff 276483.Jul 8 2020, 10:27 AM
MaskRay marked an inline comment as done.
MaskRay retitled this revision from [ELF] Rename canRelax to sharedToExecRelax. NFC to [ELF] Rename canRelax to toExecRelax. NFC.
MaskRay edited the summary of this revision. (Show Details)

sharedToExecRelax -> toExecRelax

This revision was automatically updated to reflect the committed changes.