This is an archive of the discontinued LLVM Phabricator instance.

Support for the mno-tls-direct-seg-refs flag
ClosedPublic

Authored by nruslan on Oct 10 2018, 12:01 PM.

Details

Summary

Allows to disable direct TLS segment access (%fs or %gs). GCC supports a similar flag, it can be useful in some circumstances, e.g. when a thread context block needs to be updated directly from user space. More info and specific use cases: https://bugs.llvm.org/show_bug.cgi?id=16145

There is another revision for clang as well.

Related: D53102

Diff Detail

Repository
rL LLVM

Event Timeline

nruslan created this revision.Oct 10 2018, 12:01 PM
hans added a comment.Oct 11 2018, 7:21 AM

Looks good to me. Craig should probably sign off too though.

lib/Target/X86/X86ISelDAGToDAG.cpp
168 ↗(On Diff #169068)

nit: period at the end.

987 ↗(On Diff #169068)

Looks very simple :-) I'm not really familiar with this, but I assume you've tested that it does the right thing.

test/CodeGen/X86/tls.ll
457 ↗(On Diff #169068)

I know this file seems to go for brevity of function names, but I'd still suggest calling it something more descriptive, or adding a comment so it's more obvious to the reader what's going on.

nruslan marked 3 inline comments as done.Oct 11 2018, 9:13 AM
nruslan added inline comments.
lib/Target/X86/X86ISelDAGToDAG.cpp
987 ↗(On Diff #169068)

Yeah, it seems to pass tests. I also added one more test.

test/CodeGen/X86/tls.ll
457 ↗(On Diff #169068)

added a comment there

nruslan updated this revision to Diff 169226.Oct 11 2018, 9:15 AM
nruslan marked 2 inline comments as done.

@hans , @craig.topper : I updated the LLVM patch as well to reflect all requested changes + added one more test case.

Should we have a test with -fast-isel as well? It looks like it might fallback to SelectionDAG when it sees TLS, but I'm not sure.

nruslan added a comment.EditedOct 11 2018, 11:19 AM

@craig.topper : Do you mean adding a couple of more labels (x86/x64 Linux) in tls.ll with the -fast-isel option enabled and expanding these two new test cases?

@craig.topper : Do you mean adding a couple of more labels (x86/x64 Linux) in tls.ll with the -fast-isel option enabled and expanding these two new test cases?

Yeah. That should work. Ideally it will generate the same code as not fast-isel and you won't need a new filecheck prefix, but we're probably not that lucky.

@craig.topper : Do you mean adding a couple of more labels (x86/x64 Linux) in tls.ll with the -fast-isel option enabled and expanding these two new test cases?

Yeah. That should work. Ideally it will generate the same code as not fast-isel and you won't need a new filecheck prefix, but we're probably not that lucky.

@craig.topper : I extended tests in the patch. Please take a look if that is what you have meant.

nruslan updated this revision to Diff 169293.Oct 11 2018, 1:36 PM

new patch

This revision is now accepted and ready to land.Oct 11 2018, 1:39 PM

@hans : is everything ok, can someone check it in?

@hans : is everything ok, can someone check it in?

Seems good, let me build and run the tests on a buildbot and I'll commit it if it's all fine, as it's approved by the code owner for X86.

This revision was automatically updated to reflect the committed changes.