This is an archive of the discontinued LLVM Phabricator instance.

[ELF/AArch64] Add aarch64 TLS IE to LE relax for local symbol test
ClosedPublic

Authored by zatrazz on Mar 21 2016, 2:19 PM.

Details

Summary

This patch add a TLS relax optimization test when transforming
Initial-Exec to Local-Exec for local symbols (which can not be preempted).

This patch is based upon http://reviews.llvm.org/D18332

Diff Detail

Event Timeline

zatrazz updated this revision to Diff 51229.Mar 21 2016, 2:19 PM
zatrazz retitled this revision from to [ELF/AArch64] Fix TLS IE to LE relax for local symbols.
zatrazz updated this object.
zatrazz added reviewers: ruiu, rafael.
zatrazz set the repository for this revision to rL LLVM.
zatrazz added a project: lld.
zatrazz added subscribers: llvm-commits, emaste, grimar, rengolin.

This one fixes only test it seems ? Looks you forgot to provide source code change, or:

when you write "This patch is based upon xxx", why don't you just put that one as dependency ?

In fact the rebase against your patch to implement TLSDESC made the changes not necessary. The original change as basically:

bool AArch64TargetInfo::needsGot(uint32_t Type, SymbolBody &S) const {

  • if (Type == R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC ||
  • Type == R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21)
  • return true;

+ if (isTlsInitialExecRel(Type))
+ return canBePreempted(&S);

Where the TLSDESC [1] now does:

bool AArch64TargetInfo::refersToGotEntry(uint32_t Type,

                                       const SymbolBody &S) const {
switch (Type) {
case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
  return !canRelaxTls(Type, &S);
case R_AARCH64_ADR_GOT_PAGE:
case R_AARCH64_LD64_GOT_LO12_NC:
  return true;
default:
  return false;
}

}

bool AArch64TargetInfo::needsGot(uint32_t Type, SymbolBody &S) const {

return refersToGotEntry(Type, S) || needsPlt<ELF64LE>(Type, S);

}

Where 'canRelaxTls' now have the snippet required:

// Initial-Exec relocs can be relaxed to Local-Exec if the symbol is locally
// defined.
if (isTlsInitialExecRel(Type))
  return !S->isPreemptible();

So maybe to rename this change to 'Add aarch64 TLS IE to LE relax for local symbol test'?

[1] http://reviews.llvm.org/D18330

In fact the rebase against your patch to implement TLSDESC made the changes not necessary. The original change as basically:
...
So maybe to rename this change to 'Add aarch64 TLS IE to LE relax for local symbol test'?

[1] http://reviews.llvm.org/D18330

Yes, I think you need to change the description and commit text accordingly to what this patch actually do.

zatrazz retitled this revision from [ELF/AArch64] Fix TLS IE to LE relax for local symbols to [ELF/AArch64] Add aarch64 TLS IE to LE relax for local symbol test.Mar 22 2016, 3:57 AM
zatrazz updated this object.
rengolin added inline comments.Mar 30 2016, 6:51 AM
test/ELF/aarch64-tls-iele.s
17

I think there should be an "ldr" in between these two pairs, in which case the test would fail?

Either adding a:

CHECK-NEXT: ldr

in between the two pairs, or changing the third line to:

CHECK: 11008:  00 00 a0 d2   movz   x0, #0, lsl #16

should work.

zatrazz added inline comments.Mar 30 2016, 10:17 AM
test/ELF/aarch64-tls-iele.s
17

There is no need of 'ldr' because the idea of TLS IE to LE isto exactly remove the ldr and changing it to movz.

rengolin accepted this revision.Mar 30 2016, 10:23 AM
rengolin added a reviewer: rengolin.

Right, makes sense to me. It's just a test, so I'll risk an approval. :)

LGTM.

This revision is now accepted and ready to land.Mar 30 2016, 10:23 AM
zatrazz closed this revision.Mar 30 2016, 12:24 PM