[PATCH] D139924: LTO C API: always parse modules in opaque pointer mode.
Tim Northover via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 13 02:22:35 PST 2022
t.p.northover created this revision.
t.p.northover added a reviewer: steven_wu.
Herald added subscribers: ormris, hiraditya, inglorion, mcrosier.
Herald added a project: All.
t.p.northover requested review of this revision.
Herald added a project: LLVM.
Once an LLVMContext has been told it needs to track pointer types, it can no longer be used to parse opaque modules. However, we are likely (at least for a while) to have old LTO .o files in the SDK that need to interoperate with just-generated ones, so deciding opaqueness based on the first module read causes linker failures.
This makes the llvm-c LTO interface (used by ld64) parse any object it sees in opaque mode, even if type data is present, which guarantees compatibility.
https://reviews.llvm.org/D139924
Files:
llvm/tools/lto/lto.cpp
Index: llvm/tools/lto/lto.cpp
===================================================================
--- llvm/tools/lto/lto.cpp
+++ llvm/tools/lto/lto.cpp
@@ -106,6 +106,7 @@
static LLVMContext Context;
LTOContext = &Context;
+ LTOContext->setOpaquePointers(true);
LTOContext->setDiagnosticHandler(
std::make_unique<LTOToolDiagnosticHandler>(), true);
initialized = true;
@@ -133,7 +134,10 @@
// Module must be destructed before its context gets destructed.
~LibLTOCodeGenerator() { resetMergedModule(); }
- void init() { setDiagnosticHandler(handleLibLTODiagnostic, nullptr); }
+ void init() {
+ OwnedContext->setOpaquePointers(true);
+ setDiagnosticHandler(handleLibLTODiagnostic, nullptr);
+ }
std::unique_ptr<MemoryBuffer> NativeObjectFile;
std::unique_ptr<LLVMContext> OwnedContext;
@@ -271,6 +275,7 @@
// Create a local context. Ownership will be transferred to LTOModule.
std::unique_ptr<LLVMContext> Context = std::make_unique<LLVMContext>();
+ Context->setOpaquePointers(true);
Context->setDiagnosticHandler(std::make_unique<LTOToolDiagnosticHandler>(),
true);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139924.482403.patch
Type: text/x-patch
Size: 1173 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221213/12112266/attachment.bin>
More information about the llvm-commits
mailing list