[clang] Explicitly set the EmulatedTLS codegen option. NFC.
authorMartin Storsjö <martin@martin.st>
Fri, 26 Aug 2022 13:47:07 +0000 (16:47 +0300)
committerMartin Storsjö <martin@martin.st>
Tue, 13 Sep 2022 07:40:54 +0000 (10:40 +0300)
commitfbfe1db4a95a73ed6a0767db0ab7d449fc03405e
tree4611185760c7e1715a1b251e83ff20c865af4f13
parent6bf1b4e8e0776e6f27013434d8b632016ccc795c
[clang] Explicitly set the EmulatedTLS codegen option. NFC.

Set the EmulatedTLS option based on `Triple::hasDefaultEmulatedTLS()`
if the user didn't specify it; set `ExplicitEmulatedTLS` to true
in `llvm::TargetOptions` and set `EmulatedTLS` to Clang's
opinion of what the default or preference is.

This avoids any risk of deviance between the two.

This affects one check of `getCodeGenOpts().EmulatedTLS` in
`shouldAssumeDSOLocal` in CodeGenModule, but as that check only
is done for `TT.isWindowsGNUEnvironment()`, and
`hasDefaultEmulatedTLS()` returns false for such environments
it doesn't make any current testable difference - thus NFC.

Some mingw distributions carry a downstream patch, that enables
emulated TLS by default for mingw targets in `hasDefaultEmulatedTLS()`
- and for such cases, this patch does make a difference and fixes the
detection of emulated TLS, if it is implicitly enabled.

Differential Revision: https://reviews.llvm.org/D132916
clang/include/clang/Basic/CodeGenOptions.def
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Frontend/CompilerInvocation.cpp