diff options
author | diggerlin <digger.llvm@gmail.com> | 2021-03-09 10:38:00 -0500 |
---|---|---|
committer | diggerlin <digger.llvm@gmail.com> | 2021-03-09 10:38:00 -0500 |
commit | 46d4d1fea401de1d22fe746077a4ca4dd7e137b4 (patch) | |
tree | 742c70ca5b2d76ef3ecc2471380e9f8cf4844781 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | aaf16b80dd4cdeb84caae8f3785ce7e4cc7a0f69 (diff) | |
download | llvm-46d4d1fea401de1d22fe746077a4ca4dd7e137b4.zip llvm-46d4d1fea401de1d22fe746077a4ca4dd7e137b4.tar.gz llvm-46d4d1fea401de1d22fe746077a4ca4dd7e137b4.tar.bz2 |
[AIX] do not emit visibility attribute into IR when there is -mignore-xcoff-visibility
SUMMARY:
n the patch https://reviews.llvm.org/D87451 "add new option -mignore-xcoff-visibility"
we did as "The option -mignore-xcoff-visibility has no effect on visibility attribute when compile with -emit-llvm option to generated LLVM IR."
in these patch we let -mignore-xcoff-visibility effect on generating IR too. the new feature only work on AIX OS
Reviewer: Jason Liu,
Differential Revision: https://reviews.llvm.org/D89986
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 89e485a..2606e9f 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1483,9 +1483,6 @@ void CompilerInvocation::GenerateCodeGenArgs( GenerateArg(Args, Opt, SA); } - if (Opts.IgnoreXCOFFVisibility) - GenerateArg(Args, OPT_mignore_xcoff_visibility, SA); - if (Opts.EnableAIXExtendedAltivecABI) GenerateArg(Args, OPT_mabi_EQ_vec_extabi, SA); @@ -1831,27 +1828,6 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, } } - // This is the reason why '-fvisibility' needs to be always generated: - // its absence implies '-mignore-xcoff-visibility'. - // - // Suppose the original cc1 command line does contain '-fvisibility default': - // '-mignore-xcoff-visibility' should not be implied. - // * If '-fvisibility' is not generated (as most options with default values - // don't), its absence would imply '-mignore-xcoff-visibility'. This changes - // the command line semantics. - // * If '-fvisibility' is generated regardless of its presence and value, - // '-mignore-xcoff-visibility' won't be implied and the command line - // semantics are kept intact. - // - // When the original cc1 command line does **not** contain '-fvisibility', - // '-mignore-xcoff-visibility' is implied. The generated command line will - // contain both '-fvisibility default' and '-mignore-xcoff-visibility' and - // subsequent calls to `CreateFromArgs`/`generateCC1CommandLine` will always - // produce the same arguments. - if (T.isOSAIX() && (Args.hasArg(OPT_mignore_xcoff_visibility) || - !Args.hasArg(OPT_fvisibility))) - Opts.IgnoreXCOFFVisibility = 1; - if (Arg *A = Args.getLastArg(OPT_mabi_EQ_vec_default, OPT_mabi_EQ_vec_extabi)) { if (!T.isOSAIX()) @@ -3342,6 +3318,9 @@ void CompilerInvocation::GenerateLangArgs(const LangOptions &Opts, Twine(Major) + "." + Twine(Minor) + "." + Twine(Patch), SA); } + if (Opts.IgnoreXCOFFVisibility) + GenerateArg(Args, OPT_mignore_xcoff_visibility, SA); + if (Opts.SignedOverflowBehavior == LangOptions::SOB_Trapping) { GenerateArg(Args, OPT_ftrapv, SA); GenerateArg(Args, OPT_ftrapv_handler, Opts.OverflowHandler, SA); @@ -3649,6 +3628,30 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args, Opts.GNUCVersion = Major * 100 * 100 + Minor * 100 + Patch; } + // In AIX OS, the -mignore-xcoff-visibility is enable by default if there is + // no -fvisibility=* option. + // This is the reason why '-fvisibility' needs to be always generated: + // its absence implies '-mignore-xcoff-visibility'. + // + // Suppose the original cc1 command line does contain '-fvisibility default': + // '-mignore-xcoff-visibility' should not be implied. + // * If '-fvisibility' is not generated (as most options with default values + // don't), its absence would imply '-mignore-xcoff-visibility'. This changes + // the command line semantics. + // * If '-fvisibility' is generated regardless of its presence and value, + // '-mignore-xcoff-visibility' won't be implied and the command line + // semantics are kept intact. + // + // When the original cc1 command line does **not** contain '-fvisibility', + // '-mignore-xcoff-visibility' is implied. The generated command line will + // contain both '-fvisibility default' and '-mignore-xcoff-visibility' and + // subsequent calls to `CreateFromArgs`/`generateCC1CommandLine` will always + // produce the same arguments. + + if (T.isOSAIX() && (Args.hasArg(OPT_mignore_xcoff_visibility) || + !Args.hasArg(OPT_fvisibility))) + Opts.IgnoreXCOFFVisibility = 1; + if (Args.hasArg(OPT_ftrapv)) { Opts.setSignedOverflowBehavior(LangOptions::SOB_Trapping); // Set the handler, if one is specified. |