Skip to content

Commit

Permalink
Merge branch 'rust-lang:master' into feat/enable-f16
Browse files Browse the repository at this point in the history
  • Loading branch information
lengrongfu authored Jun 27, 2024
2 parents dd8dc65 + a4ce33c commit 6391e70
Show file tree
Hide file tree
Showing 60 changed files with 1,513 additions and 1,276 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BasedOnStyle: LLVM
1 change: 1 addition & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Files: compiler/*
x
x.ps1
x.py
.clang-format
.editorconfig
.git-blame-ignore-revs
.gitattributes
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5627,6 +5627,7 @@ dependencies = [
"regex",
"rustc-hash",
"semver",
"similar",
"termcolor",
"walkdir",
]
Expand Down
9 changes: 8 additions & 1 deletion compiler/rustc_ast/src/attr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ impl MetaItem {
I: Iterator<Item = &'a TokenTree>,
{
// FIXME: Share code with `parse_path`.
let path = match tokens.next().map(|tt| TokenTree::uninterpolate(tt)).as_deref() {
let tt = tokens.next().map(|tt| TokenTree::uninterpolate(tt));
let path = match tt.as_deref() {
Some(&TokenTree::Token(
Token { kind: ref kind @ (token::Ident(..) | token::PathSep), span },
_,
Expand Down Expand Up @@ -368,6 +369,12 @@ impl MetaItem {
token::Nonterminal::NtPath(path) => (**path).clone(),
_ => return None,
},
Some(TokenTree::Token(
Token { kind: token::OpenDelim(_) | token::CloseDelim(_), .. },
_,
)) => {
panic!("Should be `AttrTokenTree::Delimited`, not delim tokens: {:?}", tt);
}
_ => return None,
};
let list_closing_paren_pos = tokens.peek().map(|tt| tt.span().hi());
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/tokenstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl AttrTokenStream {
// Inner attributes are only supported on extern blocks, functions,
// impls, and modules. All of these have their inner attributes
// placed at the beginning of the rightmost outermost braced group:
// e.g. fn foo() { #![my_attr} }
// e.g. fn foo() { #![my_attr] }
//
// Therefore, we can insert them back into the right location
// without needing to do any extra position tracking.
Expand Down
17 changes: 0 additions & 17 deletions compiler/rustc_codegen_ssa/src/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
.emit();
}
}
sym::coverage => {
let inner = attr.meta_item_list();
match inner.as_deref() {
Some([item]) if item.has_name(sym::off) => {
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_COVERAGE;
}
Some([item]) if item.has_name(sym::on) => {
// Allow #[coverage(on)] for being explicit, maybe also in future to enable
// coverage on a smaller scope within an excluded larger scope.
}
Some(_) | None => {
tcx.dcx()
.span_delayed_bug(attr.span, "unexpected value of coverage attribute");
}
}
}
sym::rustc_std_internal_symbol => {
codegen_fn_attrs.flags |= CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL
}
Expand Down Expand Up @@ -584,7 +568,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
}

if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_COVERAGE;
codegen_fn_attrs.inline = InlineAttr::Never;
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ libc = "0.2"
memmap2 = "0.2.1"
# tidy-alphabetical-end

[target.'cfg(any(target_arch = "powerpc", target_arch = "mips"))'.dependencies]
[target.'cfg(any(target_arch = "mips", target_arch = "powerpc", target_arch = "sparc"))'.dependencies]
portable-atomic = "1.5.1"

[features]
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_data_structures/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ cfg_match! {
[crate::owned_slice::OwnedSlice]
);

// PowerPC and MIPS platforms with 32-bit pointers do not
// MIPS, PowerPC and SPARC platforms with 32-bit pointers do not
// have AtomicU64 type.
#[cfg(not(any(target_arch = "powerpc", target_arch = "mips")))]
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc", target_arch = "sparc")))]
already_sync!(
[std::sync::atomic::AtomicU64]
);

#[cfg(any(target_arch = "powerpc", target_arch = "mips"))]
#[cfg(any(target_arch = "mips", target_arch = "powerpc", target_arch = "sparc"))]
already_sync!(
[portable_atomic::AtomicU64]
);
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_data_structures/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,12 @@ cfg_match! {

pub use std::sync::atomic::{AtomicBool, AtomicUsize, AtomicU32};

// PowerPC and MIPS platforms with 32-bit pointers do not
// MIPS, PowerPC and SPARC platforms with 32-bit pointers do not
// have AtomicU64 type.
#[cfg(not(any(target_arch = "powerpc", target_arch = "mips")))]
#[cfg(not(any(target_arch = "mips", target_arch = "powerpc", target_arch = "sparc")))]
pub use std::sync::atomic::AtomicU64;

#[cfg(any(target_arch = "powerpc", target_arch = "mips"))]
#[cfg(any(target_arch = "mips", target_arch = "powerpc", target_arch = "sparc"))]
pub use portable_atomic::AtomicU64;

pub use std::sync::Arc as Lrc;
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_expand/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ impl<'a> StripUnconfigured<'a> {
) => {
panic!("Nonterminal should have been flattened: {:?}", tree);
}
AttrTokenTree::Token(
Token { kind: TokenKind::OpenDelim(_) | TokenKind::CloseDelim(_), .. },
_,
) => {
panic!("Should be `AttrTokenTree::Delimited`, not delim tokens: {:?}", tree);
}
AttrTokenTree::Token(token, spacing) => {
Some(AttrTokenTree::Token(token, spacing)).into_iter()
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ fn main() {
|| target.starts_with("mips-")
|| target.starts_with("mipsel-")
|| target.starts_with("powerpc-")
|| target.starts_with("sparc-")
{
// 32-bit targets need to link libatomic.
println!("cargo:rustc-link-lib=atomic");
Expand Down
33 changes: 14 additions & 19 deletions compiler/rustc_llvm/llvm-wrapper/ArchiveWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ struct RustArchiveMember {
Archive::Child Child;

RustArchiveMember()
: Filename(nullptr), Name(nullptr),
Child(nullptr, nullptr, nullptr)
{
}
: Filename(nullptr), Name(nullptr), Child(nullptr, nullptr, nullptr) {}
~RustArchiveMember() {}
};

Expand All @@ -27,11 +24,8 @@ struct RustArchiveIterator {
std::unique_ptr<Error> Err;

RustArchiveIterator(Archive::child_iterator Cur, Archive::child_iterator End,
std::unique_ptr<Error> Err)
: First(true),
Cur(Cur),
End(End),
Err(std::move(Err)) {}
std::unique_ptr<Error> Err)
: First(true), Cur(Cur), End(End), Err(std::move(Err)) {}
};

enum class LLVMRustArchiveKind {
Expand Down Expand Up @@ -66,8 +60,8 @@ typedef Archive::Child const *LLVMRustArchiveChildConstRef;
typedef RustArchiveIterator *LLVMRustArchiveIteratorRef;

extern "C" LLVMRustArchiveRef LLVMRustOpenArchive(char *Path) {
ErrorOr<std::unique_ptr<MemoryBuffer>> BufOr =
MemoryBuffer::getFile(Path, /*IsText*/false, /*RequiresNullTerminator=*/false);
ErrorOr<std::unique_ptr<MemoryBuffer>> BufOr = MemoryBuffer::getFile(
Path, /*IsText*/ false, /*RequiresNullTerminator=*/false);
if (!BufOr) {
LLVMRustSetLastError(BufOr.getError().message().c_str());
return nullptr;
Expand Down Expand Up @@ -146,8 +140,8 @@ extern "C" const char *
LLVMRustArchiveChildName(LLVMRustArchiveChildConstRef Child, size_t *Size) {
Expected<StringRef> NameOrErr = Child->getName();
if (!NameOrErr) {
// rustc_codegen_llvm currently doesn't use this error string, but it might be
// useful in the future, and in the meantime this tells LLVM that the
// rustc_codegen_llvm currently doesn't use this error string, but it might
// be useful in the future, and in the meantime this tells LLVM that the
// error was not ignored and that it shouldn't abort the process.
LLVMRustSetLastError(toString(NameOrErr.takeError()).c_str());
return nullptr;
Expand All @@ -172,10 +166,9 @@ extern "C" void LLVMRustArchiveMemberFree(LLVMRustArchiveMemberRef Member) {
delete Member;
}

extern "C" LLVMRustResult
LLVMRustWriteArchive(char *Dst, size_t NumMembers,
const LLVMRustArchiveMemberRef *NewMembers,
bool WriteSymbtab, LLVMRustArchiveKind RustKind, bool isEC) {
extern "C" LLVMRustResult LLVMRustWriteArchive(
char *Dst, size_t NumMembers, const LLVMRustArchiveMemberRef *NewMembers,
bool WriteSymbtab, LLVMRustArchiveKind RustKind, bool isEC) {

std::vector<NewArchiveMember> Members;
auto Kind = fromRust(RustKind);
Expand Down Expand Up @@ -206,8 +199,10 @@ LLVMRustWriteArchive(char *Dst, size_t NumMembers,
#if LLVM_VERSION_LT(18, 0)
auto Result = writeArchive(Dst, Members, WriteSymbtab, Kind, true, false);
#else
auto SymtabMode = WriteSymbtab ? SymtabWritingMode::NormalSymtab : SymtabWritingMode::NoSymtab;
auto Result = writeArchive(Dst, Members, SymtabMode, Kind, true, false, nullptr, isEC);
auto SymtabMode = WriteSymbtab ? SymtabWritingMode::NormalSymtab
: SymtabWritingMode::NoSymtab;
auto Result =
writeArchive(Dst, Members, SymtabMode, Kind, true, false, nullptr, isEC);
#endif
if (!Result)
return LLVMRustResult::Success;
Expand Down
18 changes: 5 additions & 13 deletions compiler/rustc_llvm/llvm-wrapper/Linker.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "SuppressLLVMWarnings.h"
#include "llvm/Linker/Linker.h"
#include "SuppressLLVMWarnings.h"

#include "LLVMWrapper.h"

Expand All @@ -9,26 +9,18 @@ struct RustLinker {
Linker L;
LLVMContext &Ctx;

RustLinker(Module &M) :
L(M),
Ctx(M.getContext())
{}
RustLinker(Module &M) : L(M), Ctx(M.getContext()) {}
};

extern "C" RustLinker*
LLVMRustLinkerNew(LLVMModuleRef DstRef) {
extern "C" RustLinker *LLVMRustLinkerNew(LLVMModuleRef DstRef) {
Module *Dst = unwrap(DstRef);

return new RustLinker(*Dst);
}

extern "C" void
LLVMRustLinkerFree(RustLinker *L) {
delete L;
}
extern "C" void LLVMRustLinkerFree(RustLinker *L) { delete L; }

extern "C" bool
LLVMRustLinkerAdd(RustLinker *L, char *BC, size_t Len) {
extern "C" bool LLVMRustLinkerAdd(RustLinker *L, char *BC, size_t Len) {
std::unique_ptr<MemoryBuffer> Buf =
MemoryBuffer::getMemBufferCopy(StringRef(BC, Len));

Expand Down
Loading

0 comments on commit 6391e70

Please sign in to comment.