diff options
author | Martin Storsjö <martin@martin.st> | 2022-08-26 16:47:07 +0300 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2022-09-13 10:40:54 +0300 |
commit | fbfe1db4a95a73ed6a0767db0ab7d449fc03405e (patch) | |
tree | 4611185760c7e1715a1b251e83ff20c865af4f13 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 6bf1b4e8e0776e6f27013434d8b632016ccc795c (diff) | |
download | llvm-fbfe1db4a95a73ed6a0767db0ab7d449fc03405e.zip llvm-fbfe1db4a95a73ed6a0767db0ab7d449fc03405e.tar.gz llvm-fbfe1db4a95a73ed6a0767db0ab7d449fc03405e.tar.bz2 |
[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
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 9ac522a..201b996 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1492,13 +1492,8 @@ void CompilerInvocation::GenerateCodeGenArgs( F.Filename, SA); } - // TODO: Consider removing marshalling annotations from f[no_]emulated_tls. - // That would make it easy to generate the option only **once** if it was - // explicitly set to non-default value. - if (Opts.ExplicitEmulatedTLS) { - GenerateArg( - Args, Opts.EmulatedTLS ? OPT_femulated_tls : OPT_fno_emulated_tls, SA); - } + GenerateArg( + Args, Opts.EmulatedTLS ? OPT_femulated_tls : OPT_fno_emulated_tls, SA); if (Opts.FPDenormalMode != llvm::DenormalMode::getIEEE()) GenerateArg(Args, OPT_fdenormal_fp_math_EQ, Opts.FPDenormalMode.str(), SA); @@ -1862,9 +1857,9 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, Opts.LinkBitcodeFiles.push_back(F); } - if (Args.getLastArg(OPT_femulated_tls) || - Args.getLastArg(OPT_fno_emulated_tls)) { - Opts.ExplicitEmulatedTLS = true; + if (!Args.getLastArg(OPT_femulated_tls) && + !Args.getLastArg(OPT_fno_emulated_tls)) { + Opts.EmulatedTLS = T.hasDefaultEmulatedTLS(); } if (Arg *A = Args.getLastArg(OPT_ftlsmodel_EQ)) { |