Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
17d001d
bootstrap readme: make easy to read when editor wrapping is not enabled
tshepang Dec 8, 2025
cfb6a1f
simplify how inline asm handles `MaybeUninit`
WaffleLapkin Dec 13, 2025
ddcd55f
Don't allow codegen attributes on trait methods
JonathanBrouwer Nov 9, 2025
8fa10c0
Add regression test for codegen attributes on required trait methods
JonathanBrouwer Nov 9, 2025
7d57c6f
Rename dep_root field of CrateOrigin to dep_root_for_errors
bjorn3 Nov 27, 2025
a0f8dff
Use CrateDepKind::Explicit for the profiler runtime
bjorn3 Nov 27, 2025
c7a99e2
Rename variants of CrateDepKind to be more descriptive
bjorn3 Nov 27, 2025
aff1f2a
Handle CrateOrigin::Injected in CrateOrigin::private_dep
bjorn3 Nov 27, 2025
0e1e72a
Remove dependencies field of CrateMetadata
bjorn3 Nov 28, 2025
1fe0a85
Add rv64IM
kevaundray Nov 10, 2025
2846968
add riscv64im to ignore list for stage0
kevaundray Nov 10, 2025
9ba7852
refactor readme
kevaundray Nov 10, 2025
7cf3556
document that mpmc channels deliver an item to (at most) one receiver
david-d-h Dec 15, 2025
9c14e3f
std: sys: fs: uefi: Implement set_times and set_perm
Ayush1325 Nov 29, 2025
ddd5aad
feat: dlopen Enzyme
sgasho Nov 24, 2025
4d12cb0
refactor: initialize EnzymeWrapper in LlvmCodegenBackend::init
sgasho Dec 15, 2025
58aeab5
add trailing line at compiler/rustc_codegen_llvm/Cargo.toml
sgasho Dec 15, 2025
6d139ca
Update books
rustbot Dec 15, 2025
72c84a6
assert impossible branch is impossible
yaahc Dec 4, 2025
c194e9e
do not add `I-prioritize` when `F-*` labels are present
cyrgani Dec 15, 2025
f05ed90
Use the embeddable filename for coverage artifacts
Urgau Dec 15, 2025
bb6d936
Provide an extended framework for type visit, for use in rust-analyzer
ChayimFriedman2 Dec 10, 2025
bd1e142
Rollup merge of #148756 - JonathanBrouwer:link_section_targets2, r=jd…
Zalathar Dec 16, 2025
0ea7d0b
Rollup merge of #148790 - kevaundray:kw/rv64im-unknown-elf, r=davidtw…
Zalathar Dec 16, 2025
3be45cb
Rollup merge of #149271 - sgasho:enzyme-dlopen, r=bjorn3
Zalathar Dec 16, 2025
2de952e
Rollup merge of #149459 - Ayush1325:uefi-fs-setinfo, r=joboet
Zalathar Dec 16, 2025
4f2188f
Rollup merge of #149771 - tshepang:patch-2, r=Zalathar
Zalathar Dec 16, 2025
d30f83a
Rollup merge of #149856 - ChayimFriedman2:no-copy-solver-v3, r=jackh726
Zalathar Dec 16, 2025
461d0d0
Rollup merge of #149950 - WaffleLapkin:inlines-ur-mu-into-asm, r=jdon…
Zalathar Dec 16, 2025
0d0f136
Rollup merge of #150014 - bjorn3:metadata_loader_cleanups, r=jieyouxu
Zalathar Dec 16, 2025
2739ccb
Rollup merge of #150021 - david-d-h:main, r=ChrisDenton
Zalathar Dec 16, 2025
fd755c6
Rollup merge of #150029 - rustbot:docs-update, r=ehuss
Zalathar Dec 16, 2025
06bc79b
Rollup merge of #150031 - yaahc:derive-helper-ambig-assert, r=petroch…
Zalathar Dec 16, 2025
3687a78
Rollup merge of #150034 - cyrgani:triagebotconf, r=BoxyUwU
Zalathar Dec 16, 2025
f9d6cb5
Rollup merge of #150036 - Urgau:filenames-coverage-150020, r=Zalathar
Zalathar Dec 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3613,6 +3613,7 @@ dependencies = [
"gimli 0.31.1",
"itertools",
"libc",
"libloading 0.9.0",
"measureme",
"object 0.37.3",
"rustc-demangle",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ impl<S: Stage> CombineAttributeParser<S> for AllowConstFnUnstableParser {
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Fn),
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::Trait { body: false })),
Allow(Target::Method(MethodKind::Trait { body: true })),
Allow(Target::Method(MethodKind::TraitImpl)),
]);
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ impl<S: Stage> NoArgsAttributeParser<S> for ColdParser {
Allow(Target::Fn),
Allow(Target::Method(MethodKind::Trait { body: true })),
Allow(Target::Method(MethodKind::TraitImpl)),
Allow(Target::Method(MethodKind::Trait { body: false })),
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::ForeignFn),
Allow(Target::Closure),
Expand Down Expand Up @@ -343,7 +342,7 @@ impl<S: Stage> NoArgsAttributeParser<S> for TrackCallerParser {
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::Trait { body: true })),
Allow(Target::Method(MethodKind::TraitImpl)),
Allow(Target::Method(MethodKind::Trait { body: false })),
Allow(Target::Method(MethodKind::Trait { body: false })), // `#[track_caller]` is inherited from trait methods
Allow(Target::ForeignFn),
Allow(Target::Closure),
Warn(Target::MacroDef),
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_attr_parsing/src/attributes/link_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,6 @@ impl<S: Stage> SingleAttributeParser<S> for LinkSectionParser {
Allow(Target::Static),
Allow(Target::Fn),
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::Trait { body: false })),
Allow(Target::Method(MethodKind::Trait { body: true })),
Allow(Target::Method(MethodKind::TraitImpl)),
]);
Expand Down Expand Up @@ -587,12 +586,12 @@ impl<S: Stage> SingleAttributeParser<S> for LinkageParser {
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Fn),
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::Trait { body: false })),
Allow(Target::Method(MethodKind::Trait { body: true })),
Allow(Target::Method(MethodKind::TraitImpl)),
Allow(Target::Static),
Allow(Target::ForeignStatic),
Allow(Target::ForeignFn),
Warn(Target::Method(MethodKind::Trait { body: false })), // Not inherited
]);

const TEMPLATE: AttributeTemplate = template!(NameValueStr: [
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/repr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ impl<S: Stage> AttributeParser<S> for AlignParser {
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::Trait { body: true })),
Allow(Target::Method(MethodKind::TraitImpl)),
Allow(Target::Method(MethodKind::Trait { body: false })),
Allow(Target::Method(MethodKind::Trait { body: false })), // `#[align]` is inherited from trait methods
Allow(Target::ForeignFn),
]);

Expand Down
14 changes: 2 additions & 12 deletions compiler/rustc_codegen_cranelift/src/inline_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -857,19 +857,9 @@ fn call_inline_asm<'tcx>(

fn asm_clif_type<'tcx>(fx: &FunctionCx<'_, '_, 'tcx>, ty: Ty<'tcx>) -> Option<types::Type> {
match ty.kind() {
// Adapted from https://github.com/rust-lang/rust/blob/f3c66088610c1b80110297c2d9a8b5f9265b013f/compiler/rustc_hir_analysis/src/check/intrinsicck.rs#L136-L151
// Adapted from https://github.com/rust-lang/rust/blob/df44a57fd29fca899ce473f85ed64efd0708dd7c/compiler/rustc_hir_typeck/src/inline_asm.rs#L180-L183
ty::Adt(adt, args) if fx.tcx.is_lang_item(adt.did(), LangItem::MaybeUninit) => {
let fields = &adt.non_enum_variant().fields;
let ty = fields[FieldIdx::ONE].ty(fx.tcx, args);
let ty::Adt(ty, args) = ty.kind() else {
unreachable!("expected first field of `MaybeUninit` to be an ADT")
};
assert!(
ty.is_manually_drop(),
"expected first field of `MaybeUninit` to be `ManuallyDrop`"
);
let fields = &ty.non_enum_variant().fields;
let ty = fields[FieldIdx::ZERO].ty(fx.tcx, args);
let ty = args.type_at(0);
fx.clif_type(ty)
}
_ => fx.clif_type(ty),
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_llvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ bitflags = "2.4.1"
gimli = "0.31"
itertools = "0.12"
libc = "0.2"
libloading = { version = "0.9.0", optional = true }
measureme = "12.0.1"
object = { version = "0.37.0", default-features = false, features = ["std", "read"] }
rustc-demangle = "0.1.21"
Expand Down Expand Up @@ -46,7 +47,7 @@ tracing = "0.1"
[features]
# tidy-alphabetical-start
check_only = ["rustc_llvm/check_only"]
llvm_enzyme = []
llvm_enzyme = ["dep:libloading"]
llvm_offload = []
# tidy-alphabetical-end

29 changes: 14 additions & 15 deletions compiler/rustc_codegen_llvm/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,31 +528,34 @@ fn thin_lto(
}
}

fn enable_autodiff_settings(ad: &[config::AutoDiff]) {
#[cfg(feature = "llvm_enzyme")]
pub(crate) fn enable_autodiff_settings(ad: &[config::AutoDiff]) {
let mut enzyme = llvm::EnzymeWrapper::get_instance();

for val in ad {
// We intentionally don't use a wildcard, to not forget handling anything new.
match val {
config::AutoDiff::PrintPerf => {
llvm::set_print_perf(true);
enzyme.set_print_perf(true);
}
config::AutoDiff::PrintAA => {
llvm::set_print_activity(true);
enzyme.set_print_activity(true);
}
config::AutoDiff::PrintTA => {
llvm::set_print_type(true);
enzyme.set_print_type(true);
}
config::AutoDiff::PrintTAFn(fun) => {
llvm::set_print_type(true); // Enable general type printing
llvm::set_print_type_fun(&fun); // Set specific function to analyze
enzyme.set_print_type(true); // Enable general type printing
enzyme.set_print_type_fun(&fun); // Set specific function to analyze
}
config::AutoDiff::Inline => {
llvm::set_inline(true);
enzyme.set_inline(true);
}
config::AutoDiff::LooseTypes => {
llvm::set_loose_types(true);
enzyme.set_loose_types(true);
}
config::AutoDiff::PrintSteps => {
llvm::set_print(true);
enzyme.set_print(true);
}
// We handle this in the PassWrapper.cpp
config::AutoDiff::PrintPasses => {}
Expand All @@ -571,9 +574,9 @@ fn enable_autodiff_settings(ad: &[config::AutoDiff]) {
}
}
// This helps with handling enums for now.
llvm::set_strict_aliasing(false);
enzyme.set_strict_aliasing(false);
// FIXME(ZuseZ4): Test this, since it was added a long time ago.
llvm::set_rust_rules(true);
enzyme.set_rust_rules(true);
}

pub(crate) fn run_pass_manager(
Expand Down Expand Up @@ -607,10 +610,6 @@ pub(crate) fn run_pass_manager(
if enable_ad { write::AutodiffStage::DuringAD } else { write::AutodiffStage::PostAD }
};

if enable_ad {
enable_autodiff_settings(&config.autodiff);
}

unsafe {
write::llvm_optimize(cgcx, dcx, module, None, config, opt_level, opt_stage, stage);
}
Expand Down
9 changes: 8 additions & 1 deletion compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,13 @@ pub(crate) unsafe fn llvm_optimize(

let llvm_plugins = config.llvm_plugins.join(",");

let enzyme_fn = if consider_ad {
let wrapper = llvm::EnzymeWrapper::get_instance();
wrapper.registerEnzymeAndPassPipeline
} else {
std::ptr::null()
};

let result = unsafe {
llvm::LLVMRustOptimize(
module.module_llvm.llmod(),
Expand All @@ -749,7 +756,7 @@ pub(crate) unsafe fn llvm_optimize(
vectorize_loop,
config.no_builtins,
config.emit_lifetime_markers,
run_enzyme,
enzyme_fn,
print_before_enzyme,
print_after_enzyme,
print_passes,
Expand Down
16 changes: 14 additions & 2 deletions compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustc_codegen_ssa::traits::{BaseTypeCodegenMethods, ConstCodegenMethods};
use rustc_data_structures::fx::FxIndexMap;
use rustc_index::IndexVec;
use rustc_middle::ty::TyCtxt;
use rustc_span::{RemapPathScopeComponents, SourceFile, StableSourceFileId};
use rustc_span::{FileName, RemapPathScopeComponents, SourceFile, StableSourceFileId};
use tracing::debug;

use crate::common::CodegenCx;
Expand Down Expand Up @@ -125,7 +125,19 @@ impl GlobalFileTable {

for file in all_files {
raw_file_table.entry(file.stable_id).or_insert_with(|| {
file.name.display(RemapPathScopeComponents::COVERAGE).to_string_lossy().into_owned()
// Prefer using the embeddable filename as this filename is going to
// end-up in the coverage artifacts (see rust-lang/rust#150020).
if let FileName::Real(real) = &file.name {
let (_work_dir, abs_name) =
real.embeddable_name(RemapPathScopeComponents::COVERAGE);

abs_name.to_string_lossy().into_owned()
} else {
file.name
.display(RemapPathScopeComponents::COVERAGE)
.to_string_lossy()
.into_owned()
}
});
}

Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_codegen_llvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,17 @@ impl CodegenBackend for LlvmCodegenBackend {

fn init(&self, sess: &Session) {
llvm_util::init(sess); // Make sure llvm is inited

#[cfg(feature = "llvm_enzyme")]
{
use rustc_session::config::AutoDiff;

use crate::back::lto::enable_autodiff_settings;
if sess.opts.unstable_opts.autodiff.contains(&AutoDiff::Enable) {
drop(llvm::EnzymeWrapper::get_or_init(&sess.opts.sysroot));
enable_autodiff_settings(&sess.opts.unstable_opts.autodiff);
}
}
}

fn provide(&self, providers: &mut Providers) {
Expand Down
Loading
Loading