Page MenuHomePhabricator

[X86] Add support for llvm.thread.pointer
Needs ReviewPublic

Authored by koriakin on Apr 27 2016, 1:27 AM.

Details

Summary

This will be used for __builtin_thread_pointer in clang.

Diff Detail

Repository
rL LLVM

Event Timeline

koriakin retitled this revision from to [X86] Add support for llvm.thread.pointer.
koriakin updated this object.
koriakin added reviewers: nadav, bruno.
koriakin set the repository for this revision to rL LLVM.
koriakin added a subscriber: llvm-commits.
reames added a subscriber: reames.May 4 2016, 11:59 AM

This is missing documentation. It *looks* like you're trying to get the
thread local storage pointer. Is that correct? This can't be reviewed
without context and documented intent.

Philip

This is missing documentation. It *looks* like you're trying to get the
thread local storage pointer. Is that correct? This can't be reviewed
without context and documented intent.

Philip

This is indeed intended to fetch the TLS pointer: http://llvm.org/docs/LangRef.html#llvm-thread-pointer-intrinsic . For x86, this is simply the FS/GS base, ie. pointer to end of the TLS area. The intent is to support __builtin_thread_pointer() in clang, which comes useful in some strange places (eg. sanitizer_common uses it for aarch64, and could use it for x86 too if only gcc supported it as well).

Hi Marcin,

Would this work for all x86 platforms? Is this supposed to be Linux specific? If so, lacks appropriate checking.

@Manman, would this work out-of-the-box for Darwin?

lib/Target/X86/X86ISelLowering.cpp
17827

What these constants mean? Please document it a comment

majnemer added inline comments.
lib/Target/X86/X86ISelLowering.cpp
17825

This isn't true for windows.