aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorQiongsi Wu <qwu@ibm.com>2023-05-15 11:14:05 -0400
committerQiongsi Wu <qwu@ibm.com>2023-05-15 11:31:00 -0400
commit9715af434579022b5ef31781be40b722d7e63bee (patch)
treed0b5518500e54d9acc47d604f41dbd573e7154de /clang/lib/Frontend/CompilerInvocation.cpp
parent3a8671330788322efc0ba625277ab6bb37cbd7e2 (diff)
downloadllvm-9715af434579022b5ef31781be40b722d7e63bee.zip
llvm-9715af434579022b5ef31781be40b722d7e63bee.tar.gz
llvm-9715af434579022b5ef31781be40b722d7e63bee.tar.bz2
[AIX][clang] Storage Locations for Constant Pointers
This patch adds clang options `-mxcoff-roptr` and `-mno-xcoff-roptr` to specify storage locations for constant pointers on AIX. When the `-mxcoff-roptr` option is in effect, constant pointers, virtual function tables, and virtual type tables are placed in read-only storage. When the `-mno-xcoff-roptr` option is in effect, pointers, virtual function tables, and virtual type tables are placed are placed in read/write storage. This patch depends on https://reviews.llvm.org/D144189. Reviewed By: hubert.reinterpretcast, stephenpeckham Differential Revision: https://reviews.llvm.org/D144190
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index cbd2663..c111607 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1560,6 +1560,9 @@ void CompilerInvocation::GenerateCodeGenArgs(
if (Opts.EnableAIXExtendedAltivecABI)
GenerateArg(Args, OPT_mabi_EQ_vec_extabi, SA);
+ if (Opts.XCOFFReadOnlyPointers)
+ GenerateArg(Args, OPT_mxcoff_roptr, SA);
+
if (!Opts.OptRecordPasses.empty())
GenerateArg(Args, OPT_opt_record_passes, Opts.OptRecordPasses, SA);
@@ -1933,6 +1936,25 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
}
}
+ if (Arg *A = Args.getLastArg(OPT_mxcoff_roptr)) {
+ if (!T.isOSAIX())
+ Diags.Report(diag::err_drv_unsupported_opt_for_target)
+ << A->getSpelling() << T.str();
+
+ // Since the storage mapping class is specified per csect,
+ // without using data sections, it is less effective to use read-only
+ // pointers. Using read-only pointers may cause other RO variables in the
+ // same csect to become RW when the linker acts upon `-bforceimprw`;
+ // therefore, we require that separate data sections
+ // are used when `-mxcoff-roptr` is in effect. We respect the setting of
+ // data-sections since we have not found reasons to do otherwise that
+ // overcome the user surprise of not respecting the setting.
+ if (!Args.hasFlag(OPT_fdata_sections, OPT_fno_data_sections, false))
+ Diags.Report(diag::err_roptr_requires_data_sections);
+
+ Opts.XCOFFReadOnlyPointers = true;
+ }
+
if (Arg *A = Args.getLastArg(OPT_mabi_EQ_quadword_atomics)) {
if (!T.isOSAIX() || T.isPPC32())
Diags.Report(diag::err_drv_unsupported_opt_for_target)