diff options
author | Fangrui Song <maskray@google.com> | 2020-05-25 15:05:35 -0700 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2020-05-25 20:48:18 -0700 |
commit | 9d55e4ee1367b440bb8402ce3a33d5a8b99aee06 (patch) | |
tree | 1024ddefbaea1a434eba08774b01235d08303a47 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 793cc518b9428a0b7a40c59d4ecd5939a7bc84f7 (diff) | |
download | llvm-9d55e4ee1367b440bb8402ce3a33d5a8b99aee06.zip llvm-9d55e4ee1367b440bb8402ce3a33d5a8b99aee06.tar.gz llvm-9d55e4ee1367b440bb8402ce3a33d5a8b99aee06.tar.bz2 |
Make explicit -fno-semantic-interposition (in -fpic mode) infer dso_local
-fno-semantic-interposition is currently the CC1 default. (The opposite
disables some interprocedural optimizations.) However, it does not infer
dso_local: on most targets accesses to ExternalLinkage functions/variables
defined in the current module still need PLT/GOT.
This patch makes explicit -fno-semantic-interposition infer dso_local,
so that PLT/GOT can be eliminated if targets implement local aliases
for AsmPrinter::getSymbolPreferLocal (currently only x86).
Currently we check whether the module flag "SemanticInterposition" is 0.
If yes, infer dso_local. In the future, we can infer dso_local unless
"SemanticInterposition" is 1: frontends other than clang will also
benefit from the optimization if they don't bother setting the flag.
(There will be risks if they do want ELF interposition: they need to set
"SemanticInterposition" to 1.)
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index b4bc027..f98490c 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -3049,6 +3049,9 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, } Opts.SemanticInterposition = Args.hasArg(OPT_fsemantic_interposition); + // An explicit -fno-semantic-interposition infers dso_local. + Opts.ExplicitNoSemanticInterposition = + Args.hasArg(OPT_fno_semantic_interposition); // -mrtd option if (Arg *A = Args.getLastArg(OPT_mrtd)) { |