-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
llvm-wrapper: adapt for LLVM API changes #129749
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1205,7 +1205,11 @@ struct LLVMRustThinLTOData { | |
// Not 100% sure what these are, but they impact what's internalized and | ||
// what's inlined across modules, I believe. | ||
#if LLVM_VERSION_GE(18, 0) | ||
#if LLVM_VERSION_GE(20, 0) | ||
FunctionImporter::ImportListsTy ImportLists; | ||
#else | ||
DenseMap<StringRef, FunctionImporter::ImportMapTy> ImportLists; | ||
#endif | ||
DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists; | ||
DenseMap<StringRef, GVSummaryMapTy> ModuleToDefinedGVSummaries; | ||
#else | ||
|
@@ -1414,13 +1418,13 @@ LLVMRustPrepareThinLTOInternalize(const LLVMRustThinLTOData *Data, | |
return true; | ||
} | ||
|
||
extern "C" bool LLVMRustPrepareThinLTOImport(const LLVMRustThinLTOData *Data, | ||
extern "C" bool LLVMRustPrepareThinLTOImport(LLVMRustThinLTOData *Data, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the problem here is that this It looks like this function is called from optimize_thin_module, which I believe is run in parallel, so we might end up resizing the map while another thread holds a reference to it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can't really fix this without LLVM exposing an additional API. I left a comment on the PR at llvm/llvm-project#106427 (comment). |
||
LLVMModuleRef M, | ||
LLVMTargetMachineRef TM) { | ||
Module &Mod = *unwrap(M); | ||
TargetMachine &Target = *unwrap(TM); | ||
|
||
const auto &ImportList = Data->ImportLists.lookup(Mod.getModuleIdentifier()); | ||
const auto &ImportList = Data->ImportLists[Mod.getModuleIdentifier()]; | ||
auto Loader = [&](StringRef Identifier) { | ||
const auto &Memory = Data->ModuleMap.lookup(Identifier); | ||
auto &Context = Mod.getContext(); | ||
|
@@ -1603,7 +1607,7 @@ extern "C" void LLVMRustComputeLTOCacheKey(RustStringRef KeyOut, | |
LLVMRustThinLTOData *Data) { | ||
SmallString<40> Key; | ||
llvm::lto::Config conf; | ||
const auto &ImportList = Data->ImportLists.lookup(ModId); | ||
const auto &ImportList = Data->ImportLists[ModId]; | ||
const auto &ExportList = Data->ExportLists.lookup(ModId); | ||
const auto &ResolvedODR = Data->ResolvedODR.lookup(ModId); | ||
const auto &DefinedGlobals = Data->ModuleToDefinedGVSummaries.lookup(ModId); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need this conditional. On older versions you can use the typedef as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the typedef
FunctionImporter::ImportListsTy
is new as well: llvm/llvm-project@4f15039#diff-870a2d0fa51c9349d66da88fd1938cef621de9b4ac0c96d71d694b90dbefbfebR153.