diff options
author | Matthias Braun <matze@braunis.de> | 2022-05-17 20:33:22 -0700 |
---|---|---|
committer | Matthias Braun <matze@braunis.de> | 2022-06-01 18:05:53 -0700 |
commit | 850d53a197f9ffbf5708b7bd795056335e81e9b7 (patch) | |
tree | b603ba420faf60c193035255d61fd65ff031dc40 /llvm/tools/gold | |
parent | a92ed167f2c98d332ad7ce5b0544444b8e917bc0 (diff) | |
download | llvm-850d53a197f9ffbf5708b7bd795056335e81e9b7.zip llvm-850d53a197f9ffbf5708b7bd795056335e81e9b7.tar.gz llvm-850d53a197f9ffbf5708b7bd795056335e81e9b7.tar.bz2 |
LTO: Decide upfront whether to use opaque/non-opaque pointer types
LTO code may end up mixing bitcode files from various sources varying in
their use of opaque pointer types. The current strategy to decide
between opaque / typed pointers upon the first bitcode file loaded does
not work here, since we could be loading a non-opaque bitcode file first
and would then be unable to load any files with opaque pointer types
later.
So for LTO this:
- Adds an `lto::Config::OpaquePointer` option and enforces an upfront
decision between the two modes.
- Adds `-opaque-pointers`/`-no-opaque-pointers` options to the gold
plugin; disabled by default.
- `--opaque-pointers`/`--no-opaque-pointers` options with
`-plugin-opt=-opaque-pointers`/`-plugin-opt=-no-opaque-pointers`
aliases to lld; disabled by default.
- Adds an `-lto-opaque-pointers` option to the `llvm-lto2` tool.
- Changes the clang driver to pass `-plugin-opt=-opaque-pointers` to
the linker in LTO modes when clang was configured with opaque
pointers enabled by default.
This fixes https://github.com/llvm/llvm-project/issues/55377
Differential Revision: https://reviews.llvm.org/D125847
Diffstat (limited to 'llvm/tools/gold')
-rw-r--r-- | llvm/tools/gold/gold-plugin.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp index 019bfe0..a9814c6 100644 --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -208,6 +208,8 @@ namespace options { static std::string stats_file; // Asserts that LTO link has whole program visibility static bool whole_program_visibility = false; + // Use opaque pointer types. + static bool opaque_pointers = true; // Optimization remarks filename, accepted passes and hotness options static std::string RemarksFilename; @@ -308,6 +310,10 @@ namespace options { RemarksFormat = std::string(opt); } else if (opt.consume_front("stats-file=")) { stats_file = std::string(opt); + } else if (opt == "opaque-pointers") { + opaque_pointers = true; + } else if (opt == "no-opaque-pointers") { + opaque_pointers = false; } else { // Save this option to pass to the code generator. // ParseCommandLineOptions() expects argv[0] to be program name. Lazily @@ -957,6 +963,8 @@ static std::unique_ptr<LTO> createLTO(IndexWriteCallback OnIndexWrite, Conf.HasWholeProgramVisibility = options::whole_program_visibility; + Conf.OpaquePointers = options.opaque_pointers; + Conf.StatsFile = options::stats_file; return std::make_unique<LTO>(std::move(Conf), Backend, options::ParallelCodeGenParallelismLevel); |