This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Support local-dynamic TLS relocation on AIX
AbandonedPublic

Authored by tingwang on Aug 10 2023, 8:17 PM.

Details

Reviewers
amyk
hubert.reinterpretcast
nemanjai
shchenz
stefanp
lkail
qiucf
Esme
Group Reviewers
Restricted Project
Summary

To enable TLS local-dynamic on AIX, according to docs, this patch need to generate below sequence of code:

.tc foo[TC],foo[TL]@ld              # Variable offset, ld relocation specifier
.tc mh[TC],mh[TC]@ml             # Module handle for the caller
lwz 3,mh[TC](2)      $$ For 64-bit: ld 3,mh[TC](2)
bla .__tls_get_mod                    # Modifies r0,r3,r4,r5,r11,lr,cr0
#r3 = &TLS for module
lwz 4,foo[TC](2)     $$ For 64-bit: ld 4,foo[TC](2)
add 5,3,4                                   # Compute &foo
.rename mh[TC], "_$TLSML"   # Symbol for the module handle must have the name "_$TLSML"

Diff Detail

Event Timeline

tingwang created this revision.Aug 10 2023, 8:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2023, 8:17 PM
tingwang requested review of this revision.Aug 10 2023, 8:17 PM
tingwang added inline comments.Aug 10 2023, 8:20 PM
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
2740

I noticed AIX assembler only accepts TC storage mapping class for the "_$TLSML" symbol, which is different from all other variables in large code model, so I handled this in an explicit way...

tingwang updated this revision to Diff 549265.Aug 11 2023, 12:16 AM

Address clang-format change.

tingwang updated this revision to Diff 549783.Aug 13 2023, 8:55 PM

Resubmit for pre-merge check - clang-format error.

lkail added inline comments.Sep 13 2023, 8:08 PM
llvm/lib/Target/PowerPC/PPCTLSDynamicCall.cpp
163

Add comment to describe code sequence of local-dynamic.

164

nit: Use complete type identifier rather than auto & since the type is simple.

184

nit: No need explicitly call Register(MCRegister).

193

Comment should be a complete sentence. Add assertion here to indicate handling of general-dynamic.

llvm/test/CodeGen/PowerPC/aix-tls-gd-double.ll
1

Why is test for general-dynamic changed?

qiucf added a comment.Sep 13 2023, 8:13 PM

This needs rebase after initial-exec landed.

lkail edited the summary of this revision. (Show Details)Sep 13 2023, 8:13 PM
tingwang abandoned this revision.Sep 13 2023, 10:54 PM

Thank you for looking into this one. I'm moving the review to https://github.com/llvm/llvm-project/pull/66316. Will update questions and answers there.