Add support for -mno-tls-direct-seg-refs to Clang
authorKristina Brooks <kristina@nym.hush.com>
Thu, 18 Oct 2018 14:07:02 +0000 (14:07 +0000)
committerKristina Brooks <kristina@nym.hush.com>
Thu, 18 Oct 2018 14:07:02 +0000 (14:07 +0000)
commit7f569b7c4f39881a1e4843f4f44ae413e67da65b
tree246c4f2a5c712e1910a57eae806c0d0d5a6389d7
parent7052cb35a1fc33951be1401597154cde94acc17a
Add support for -mno-tls-direct-seg-refs to Clang

This patch exposes functionality added in rL344723 to the Clang driver/frontend
as a flag and adds appropriate metadata.

Driver tests pass:
```
ninja check-clang-driver
-snip-
  Expected Passes    : 472
  Expected Failures  : 3
  Unsupported Tests  : 65
```

Odd failure in CodeGen tests but unrelated to this:
```
ninja check-clang-codegen
-snip-
/SourceCache/llvm-trunk-8.0/tools/clang/test/CodeGen/builtins-wasm.c:87:10:
error: cannot compile this builtin function yet
-snip-
Failing Tests (1):
    Clang :: CodeGen/builtins-wasm.c

  Expected Passes    : 1250
  Expected Failures  : 2
  Unsupported Tests  : 120
  Unexpected Failures: 1
```

Original commit:
[X86] Support for the mno-tls-direct-seg-refs flag
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

Patch by nruslan (Ruslan Nikolaev).

Differential Revision: https://reviews.llvm.org/D53102

llvm-svn: 344739
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/CodeGenOptions.def
clang/lib/CodeGen/CGCall.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/indirect-tls-seg-refs.c [new file with mode: 0644]
clang/test/Driver/indirect-tls-seg-refs.c [new file with mode: 0644]