Skip to content

Commit 7c01c3d

Browse files
committed
cleanups
1 parent fd83e74 commit 7c01c3d

File tree

8 files changed

+8
-57
lines changed

8 files changed

+8
-57
lines changed

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ pub fn visit_bounds<T: MutVisitor>(bounds: &mut GenericBounds, vis: &mut T) {
381381
}
382382

383383
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
384-
pub fn visit_fn_sig<T: MutVisitor>(FnSig { header, decl, span, .. }: &mut FnSig, vis: &mut T) {
384+
pub fn visit_fn_sig<T: MutVisitor>(FnSig { header, decl, span }: &mut FnSig, vis: &mut T) {
385385
vis.visit_fn_header(header);
386386
vis.visit_fn_decl(decl);
387387
vis.visit_span(span);

compiler/rustc_codegen_llvm/src/back/lto.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ fn fat_lto(
273273
info!("pushing cached module {:?}", wp.cgu_name);
274274
(buffer, CString::new(wp.cgu_name).unwrap())
275275
}));
276-
277276
for module in modules {
278277
match module {
279278
FatLtoInput::InMemory(m) => in_memory.push(m),

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -628,15 +628,13 @@ fn get_params(fnc: &Value) -> Vec<&Value> {
628628
}
629629
}
630630

631-
// TODO: cleanup
631+
// TODO: Here we could start adding length checks for the shaddow args.
632632
unsafe fn create_wrapper<'a>(
633633
llmod: &'a llvm::Module,
634-
//module: &'a ModuleCodegen<ModuleLlvm>,
635634
fnc: &'a Value,
636635
u_type: &Type,
637636
fnc_name: String,
638637
) -> (&'a Value, &'a BasicBlock, Vec<&'a Value>, Vec<&'a Value>, CString) {
639-
//let llmod = module.module_llvm.llmod();
640638
let context = LLVMGetModuleContext(llmod);
641639
let inner_fnc_name = "inner_".to_string() + &fnc_name;
642640
let c_inner_fnc_name = CString::new(inner_fnc_name.clone()).unwrap();
@@ -656,22 +654,13 @@ unsafe fn create_wrapper<'a>(
656654
(outer_fnc, basic_block, outer_params, inner_params, c_inner_fnc_name)
657655
}
658656

659-
//pub(crate) fn get_type(t: LLVMTypeRef) -> CString {
660-
// unsafe { CString::from_raw(LLVMPrintTypeToString(t)) }
661-
//}
662-
663-
// TODO: Don't write a wrapper function, just unwrap the struct inside of the same fnc.
664-
// Might help during debugging, if you have one function less to jump trough
665657
pub(crate) unsafe fn extract_return_type<'a>(
666658
llmod: &'a llvm::Module,
667659
fnc: &'a Value,
668660
u_type: &Type,
669661
fnc_name: String,
670662
) -> &'a Value {
671-
//let llmod = module.module_llvm.llmod();
672663
let context = llvm::LLVMGetModuleContext(llmod);
673-
//dbg!("Unpacking", fnc_name.clone());
674-
//dbg!("From: ", f_type, " into ", u_type);
675664

676665
let inner_param_num = LLVMCountParams(fnc);
677666
let (outer_fnc, outer_bb, mut outer_args, _inner_args, c_inner_fnc_name) =
@@ -697,17 +686,9 @@ pub(crate) unsafe fn extract_return_type<'a>(
697686
let struct_ret = LLVMBuildExtractValue(builder, struct_ret, 0, c_inner_grad_name.as_ptr());
698687
let _ret = LLVMBuildRet(builder, struct_ret);
699688
let _terminator = LLVMGetBasicBlockTerminator(outer_bb);
700-
//assert!(LLVMIsNull(terminator)!=0, "no terminator");
701689
LLVMDisposeBuilder(builder);
702-
703690
let _fnc_ok =
704691
LLVMVerifyFunction(outer_fnc, llvm::LLVMVerifierFailureAction::LLVMAbortProcessAction);
705-
//dbg!(outer_fnc);
706-
//assert!(fnc_ok);
707-
//if let Err(e) = verify_function(outer_fnc) {
708-
// panic!("Creating a wrapper function failed! {}", e);
709-
//}
710-
711692
outer_fnc
712693
}
713694

@@ -792,16 +773,12 @@ pub(crate) unsafe fn enzyme_ad(
792773

793774
let void_type = LLVMVoidTypeInContext(llcx);
794775
if item.attrs.mode == DiffMode::Reverse && f_return_type != void_type {
795-
//dbg!("Reverse Mode sanitizer");
796-
//dbg!(f_type);
797-
//dbg!(f_return_type);
798776
let num_elem_in_ret_struct = LLVMCountStructElementTypes(f_return_type);
799777
if num_elem_in_ret_struct == 1 {
800778
let u_type = LLVMTypeOf(target_fnc);
801779
res = extract_return_type(llmod, res, u_type, rust_name2.clone()); // TODO: check if name or name2
802780
}
803781
}
804-
//dbg!(&target_fnc);
805782
LLVMSetValueName2(res, name2.as_ptr(), rust_name2.len());
806783
LLVMReplaceAllUsesWith(target_fnc, res);
807784
LLVMDeleteFunction(target_fnc);

compiler/rustc_codegen_ssa/src/back/lto.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ impl<B: WriteBackendMethods> LtoModuleCodegen<B> {
8888
) -> Result<LtoModuleCodegen<B>, FatalError> {
8989
match &self {
9090
LtoModuleCodegen::Fat { ref module, .. } => {
91-
//let module = module.take().unwrap();
9291
{
9392
B::autodiff(cgcx, &module, diff_fncs, typetrees, config)?;
9493
}

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ pub struct ModuleConfig {
118118
pub inline_threshold: Option<u32>,
119119
pub emit_lifetime_markers: bool,
120120
pub llvm_plugins: Vec<String>,
121-
pub enzyme_print_activity: bool,
122121
}
123122

124123
impl ModuleConfig {
@@ -196,7 +195,6 @@ impl ModuleConfig {
196195
false
197196
),
198197

199-
enzyme_print_activity: sess.opts.unstable_opts.enzyme_print_activity,
200198
sanitizer: if_regular!(sess.opts.unstable_opts.sanitizer, SanitizerSet::empty()),
201199
sanitizer_recover: if_regular!(
202200
sess.opts.unstable_opts.sanitizer_recover,
@@ -398,19 +396,19 @@ fn generate_lto_work<B: ExtraBackendMethods>(
398396

399397
if !needs_fat_lto.is_empty() {
400398
assert!(needs_thin_lto.is_empty());
401-
let mut lto_module =
399+
let mut module =
402400
B::run_fat_lto(cgcx, needs_fat_lto, import_only_modules).unwrap_or_else(|e| e.raise());
403401
if cgcx.lto == Lto::Fat {
404402
let config = cgcx.config(ModuleKind::Regular);
405-
lto_module = unsafe { lto_module.autodiff(cgcx, autodiff, typetrees, config).unwrap() };
403+
module = unsafe { module.autodiff(cgcx, autodiff, typetrees, config).unwrap() };
406404
}
407405
// We are adding a single work item, so the cost doesn't matter.
408-
vec![(WorkItem::LTO(lto_module), 0)]
406+
vec![(WorkItem::LTO(module), 0)]
409407
} else {
410408
assert!(needs_fat_lto.is_empty());
411-
let (lto_modules, copy_jobs) = B::run_thin_lto(cgcx, needs_thin_lto, import_only_modules)
409+
let (modules, copy_jobs) = B::run_thin_lto(cgcx, needs_thin_lto, import_only_modules)
412410
.unwrap_or_else(|e| e.raise());
413-
lto_modules
411+
modules
414412
.into_iter()
415413
.map(|module| {
416414
let cost = module.cost();

compiler/rustc_interface/src/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,6 @@ fn test_unstable_options_tracking_hash() {
767767
tracked!(debug_macros, true);
768768
tracked!(dep_info_omit_d_target, true);
769769
tracked!(dual_proc_macros, true);
770-
tracked!(enzyme_print_activity, false);
771770
tracked!(dwarf_version, Some(5));
772771
tracked!(emit_thin_lto, false);
773772
tracked!(export_executable_symbols, true);

compiler/rustc_monomorphize/src/partitioning.rs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@
9292
//! source-level module, functions from the same module will be available for
9393
//! inlining, even when they are not marked `#[inline]`.
9494
95-
// Manuel, fixing rebase
9695
use rustc_symbol_mangling::symbol_name_for_instance_in_crate;
9796
use rustc_middle::middle::typetree::{Kind, Type, TypeTree};
9897
use rustc_target::abi::FieldsShape;
@@ -1143,7 +1142,6 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Au
11431142
})
11441143
.collect();
11451144

1146-
11471145
let autodiff_items = items
11481146
.iter()
11491147
.filter_map(|item| match *item {
@@ -1156,6 +1154,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Au
11561154
if !target_attrs.apply_autodiff() {
11571155
return None;
11581156
}
1157+
println!("target_id: {:?}", target_id);
11591158

11601159
let target_symbol =
11611160
symbol_name_for_instance_in_crate(tcx, instance.clone(), LOCAL_CRATE);
@@ -1250,9 +1249,6 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Au
12501249

12511250
(tcx.arena.alloc(mono_items), autodiff_items, codegen_units)
12521251
}
1253-
//use rustc_middle::ty::{self, Adt, ParamEnvAnd, Ty};
1254-
//use rustc_target::abi::FieldsShape;
1255-
//use std::iter;
12561252

12571253
pub fn typetree_empty() -> TypeTree {
12581254
TypeTree(vec![])
@@ -1263,19 +1259,14 @@ pub fn typetree_from_ty<'a>(ty: Ty<'a>, tcx: TyCtxt<'a>, depth: usize) -> TypeTr
12631259
if ty.is_fn_ptr() {
12641260
unimplemented!("what to do whith fn ptr?");
12651261
}
1266-
12671262
let inner_ty = ty.builtin_deref(true).unwrap().ty;
12681263
let child = typetree_from_ty(inner_ty, tcx, depth + 1);
1269-
12701264
let tt = Type { offset: -1, kind: Kind::Pointer, size: 8, child };
1271-
//println!("{:depth$} add indirection {:?}", "", tt);
1272-
12731265
return TypeTree(vec![tt]);
12741266
}
12751267

12761268
if ty.is_scalar() {
12771269
assert!(!ty.is_any_ptr());
1278-
12791270
let (kind, size) = if ty.is_integral() {
12801271
(Kind::Integer, 8)
12811272
} else {
@@ -1286,7 +1277,6 @@ pub fn typetree_from_ty<'a>(ty: Ty<'a>, tcx: TyCtxt<'a>, depth: usize) -> TypeTr
12861277
_ => panic!("floatTy scalar that is neither f32 nor f64"),
12871278
}
12881279
};
1289-
12901280
return TypeTree(vec![Type { offset: -1, child: typetree_empty(), kind, size }]);
12911281
}
12921282

@@ -1311,7 +1301,6 @@ pub fn typetree_from_ty<'a>(ty: Ty<'a>, tcx: TyCtxt<'a>, depth: usize) -> TypeTr
13111301
FieldsShape::Arbitrary { offsets: o, memory_index: m } => (o, m),
13121302
_ => panic!(""),
13131303
};
1314-
//println!("{:depth$} combine fields", "");
13151304

13161305
let fields = adt_def.all_fields();
13171306
let fields = fields
@@ -1336,17 +1325,12 @@ pub fn typetree_from_ty<'a>(ty: Ty<'a>, tcx: TyCtxt<'a>, depth: usize) -> TypeTr
13361325
}
13371326
}
13381327

1339-
//inner_tt.offset = offset;
1340-
1341-
//println!("{:depth$} -> {:?}", "", child);
1342-
13431328
Some(child)
13441329
})
13451330
.flatten()
13461331
.collect::<Vec<Type>>();
13471332

13481333
let ret_tt = TypeTree(fields);
1349-
//println!("{:depth$} into {:?}", "", ret_tt);
13501334
return ret_tt;
13511335
} else {
13521336
unimplemented!("adt that isn't a struct");
@@ -1378,8 +1362,6 @@ pub fn typetree_from_ty<'a>(ty: Ty<'a>, tcx: TyCtxt<'a>, depth: usize) -> TypeTr
13781362
.collect(),
13791363
);
13801364

1381-
//println!("{:depth$} repeated array into {:?}", "", tt);
1382-
13831365
return tt;
13841366
}
13851367

@@ -1390,7 +1372,6 @@ pub fn typetree_from_ty<'a>(ty: Ty<'a>, tcx: TyCtxt<'a>, depth: usize) -> TypeTr
13901372
return subtt;
13911373
}
13921374

1393-
//println!("Warning: create empty typetree for {}", ty);
13941375
typetree_empty()
13951376
}
13961377

compiler/rustc_session/src/options.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,8 +1537,6 @@ options! {
15371537
"enables LTO for dylib crate type"),
15381538
emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
15391539
"emit a section containing stack size metadata (default: no)"),
1540-
enzyme_print_activity: bool = (false, parse_bool, [TRACKED],
1541-
"print type trees for functions passed to enzyme"),
15421540
emit_thin_lto: bool = (true, parse_bool, [TRACKED],
15431541
"emit the bc module with thin LTO info (default: yes)"),
15441542
export_executable_symbols: bool = (false, parse_bool, [TRACKED],

0 commit comments

Comments
 (0)