This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Add NZCV Def for TLSDESC_CALLSEQ
ClosedPublic

Authored by MuellerMP on Feb 2 2023, 2:17 AM.

Details

Summary

The glibc and older musl handlers of tlsdesc_dynamic use a cmp instruction which will clobber NZCV.

See glibc's _dl_tlsdesc_dynamic:
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/aarch64/dl-tlsdesc.S;hb=refs/heads/release/2.37/master

See v1.1.21 Musl's __tlsdesc_dynamic:
https://git.musl-libc.org/cgit/musl/tree/src/ldso/aarch64/tlsdesc.s?h=v1.1.21

Diff Detail

Event Timeline

MuellerMP created this revision.Feb 2 2023, 2:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 2 2023, 2:17 AM
MuellerMP requested review of this revision.Feb 2 2023, 2:17 AM
MuellerMP retitled this revision from [AArch64] Add NZVC Def for TLSDESC_CALLSEQ to [AArch64] Add NZCV Def for TLSDESC_CALLSEQ.Feb 2 2023, 2:27 AM
MuellerMP updated this revision to Diff 494217.Feb 2 2023, 2:29 AM
MuellerMP updated this revision to Diff 494218.Feb 2 2023, 2:32 AM

This sounds good, as far as I understand. Can you run update_llc_test_checks on the test file to generate the output, perhaps with a comment explaining what it is testing?

MuellerMP updated this revision to Diff 494544.Feb 3 2023, 1:15 AM

Ran update_llc_test_checks on the test and added a comment to it.

MuellerMP added a comment.EditedFeb 3 2023, 1:16 AM

In my research for this case i stumbled over the glibc arm implementation and a TLSDESC RFC targeted towards arm.
They provide information as to why flags is assumed to be clobbered in this case.

References:
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/arm/dl-tlsdesc.S;hb=refs/heads/release/2.37/master#l85
https://www.fsfla.org/~lxoliva/writeups/TLS/RFC-TLSDESC-ARM.txt

I'm not too sure though if a "-stop-after=irtranslator" test for the "implicit-def dead $nzcv" might be a better unit test.
Right now my test seems much more like a integration type of test which asserts the implications of the def.

dmgreen accepted this revision.Feb 6 2023, 12:36 AM

Thanks. LGTM

This revision is now accepted and ready to land.Feb 6 2023, 12:36 AM

Hey!
Since I don't have commit access, I would appreciate if someone else could commit this.

Oh yeah - can do! What "name <email@whathaveyou.com>" should be used for attribution?

MuellerMP added a comment.EditedFeb 13 2023, 7:00 AM

Thanks! You can use: "MuellerMP <mirkomueller97@live.de>"

This revision was automatically updated to reflect the committed changes.