Skip to content

Commit 4eb0bc7

Browse files
committed
Auto merge of #83260 - durin42:llvm-update, r=nagisa
rustc: changes to allow an llvm update This lets LLVM be built using 2b5f3f4, which is only a few weeks old. The next change in LLVM (5de2d18) breaks rustc again by removing a function that's exposed into the Rust code, but I'll file a bug about that separately. Please scrutinize the `thinLTOResolvePrevailingInIndex` call, as I'm not at all sure an empty config is right. I'm also suspicious that a specific alignment could be specified in the call to CreateAtomicCmpXchg, but I don't know enough to figure that out. Thanks!
2 parents 9b6339e + 9431e85 commit 4eb0bc7

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,17 @@ extern "C" void LLVMRustCoverageWriteFilenamesSectionToBuffer(
2323
const char* const Filenames[],
2424
size_t FilenamesLen,
2525
RustStringRef BufferOut) {
26+
#if LLVM_VERSION_GE(13,0)
27+
SmallVector<std::string,32> FilenameRefs;
28+
for (size_t i = 0; i < FilenamesLen; i++) {
29+
FilenameRefs.push_back(std::string(Filenames[i]));
30+
}
31+
#else
2632
SmallVector<StringRef,32> FilenameRefs;
2733
for (size_t i = 0; i < FilenamesLen; i++) {
2834
FilenameRefs.push_back(StringRef(Filenames[i]));
2935
}
36+
#endif
3037
auto FilenamesWriter = coverage::CoverageFilenamesSectionWriter(
3138
makeArrayRef(FilenameRefs));
3239
RawRustStringOstream OS(BufferOut);

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -1437,9 +1437,17 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
14371437
Ret->ResolvedODR[ModuleIdentifier][GUID] = NewLinkage;
14381438
};
14391439

1440+
#if LLVM_VERSION_GE(13,0)
1441+
// Uses FromPrevailing visibility scheme which works for many binary
1442+
// formats. We probably could and should use ELF visibility scheme for many of
1443+
// our targets, however.
1444+
lto::Config conf;
1445+
thinLTOResolvePrevailingInIndex(conf, Ret->Index, isPrevailing, recordNewLinkage,
1446+
Ret->GUIDPreservedSymbols);
1447+
#else
14401448
thinLTOResolvePrevailingInIndex(Ret->Index, isPrevailing, recordNewLinkage,
14411449
Ret->GUIDPreservedSymbols);
1442-
1450+
#endif
14431451
// Here we calculate an `ExportedGUIDs` set for use in the `isExported`
14441452
// callback below. This callback below will dictate the linkage for all
14451453
// summaries in the index, and we basically just only want to ensure that dead

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,18 @@ LLVMRustBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Target,
382382
LLVMValueRef Old, LLVMValueRef Source,
383383
LLVMAtomicOrdering Order,
384384
LLVMAtomicOrdering FailureOrder, LLVMBool Weak) {
385+
#if LLVM_VERSION_GE(13,0)
386+
// Rust probably knows the alignment of the target value and should be able to
387+
// specify something more precise than MaybeAlign here. See also
388+
// https://reviews.llvm.org/D97224 which may be a useful reference.
389+
AtomicCmpXchgInst *ACXI = unwrap(B)->CreateAtomicCmpXchg(
390+
unwrap(Target), unwrap(Old), unwrap(Source), llvm::MaybeAlign(), fromRust(Order),
391+
fromRust(FailureOrder));
392+
#else
385393
AtomicCmpXchgInst *ACXI = unwrap(B)->CreateAtomicCmpXchg(
386394
unwrap(Target), unwrap(Old), unwrap(Source), fromRust(Order),
387395
fromRust(FailureOrder));
396+
#endif
388397
ACXI->setWeak(Weak);
389398
return wrap(ACXI);
390399
}

0 commit comments

Comments
 (0)