Skip to content

Commit ed1e5c2

Browse files
committed
Remove lto inline logic
1 parent 36d332b commit ed1e5c2

File tree

4 files changed

+1
-79
lines changed

4 files changed

+1
-79
lines changed

compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,6 @@ pub(crate) fn apply_to_callsite(callsite: &Value, idx: AttributePlace, attrs: &[
2828
}
2929
}
3030

31-
pub(crate) fn has_attr(llfn: &Value, idx: AttributePlace, attr: AttributeKind) -> bool {
32-
llvm::HasAttributeAtIndex(llfn, idx, attr)
33-
}
34-
35-
pub(crate) fn has_string_attr(llfn: &Value, name: &str) -> bool {
36-
llvm::HasStringAttribute(llfn, name)
37-
}
38-
39-
pub(crate) fn remove_from_llfn(llfn: &Value, place: AttributePlace, kind: AttributeKind) {
40-
llvm::RemoveRustEnumAttributeAtIndex(llfn, place, kind);
41-
}
42-
43-
pub(crate) fn remove_string_attr_from_llfn(llfn: &Value, name: &str) {
44-
llvm::RemoveStringAttrFromFn(llfn, name);
45-
}
46-
4731
/// Get LLVM attribute for the provided inline heuristic.
4832
#[inline]
4933
fn inline_attr<'ll>(cx: &CodegenCx<'ll, '_>, inline: InlineAttr) -> Option<&'ll Attribute> {

compiler/rustc_codegen_llvm/src/back/lto.rs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ use crate::back::write::{
2424
self, CodegenDiagnosticsStage, DiagnosticHandlers, bitcode_section_name, save_temp_bitcode,
2525
};
2626
use crate::errors::{LlvmError, LtoBitcodeFromRlib};
27-
use crate::llvm::AttributePlace::Function;
2827
use crate::llvm::{self, build_string};
29-
use crate::{LlvmCodegenBackend, ModuleLlvm, SimpleCx, attributes};
28+
use crate::{LlvmCodegenBackend, ModuleLlvm, SimpleCx};
3029

3130
/// We keep track of the computed LTO cache keys from the previous
3231
/// session to determine which CGUs we can reuse.
@@ -593,31 +592,6 @@ pub(crate) fn run_pass_manager(
593592
}
594593

595594
if cfg!(llvm_enzyme) && enable_ad && !thin {
596-
let cx =
597-
SimpleCx::new(module.module_llvm.llmod(), &module.module_llvm.llcx, cgcx.pointer_size);
598-
599-
for function in cx.get_functions() {
600-
let enzyme_marker = "enzyme_marker";
601-
if attributes::has_string_attr(function, enzyme_marker) {
602-
// Sanity check: Ensure 'noinline' is present before replacing it.
603-
assert!(
604-
attributes::has_attr(function, Function, llvm::AttributeKind::NoInline),
605-
"Expected __enzyme function to have 'noinline' before adding 'alwaysinline'"
606-
);
607-
608-
attributes::remove_from_llfn(function, Function, llvm::AttributeKind::NoInline);
609-
attributes::remove_string_attr_from_llfn(function, enzyme_marker);
610-
611-
assert!(
612-
!attributes::has_string_attr(function, enzyme_marker),
613-
"Expected function to not have 'enzyme_marker'"
614-
);
615-
616-
let always_inline = llvm::AttributeKind::AlwaysInline.create_attr(cx.llcx);
617-
attributes::apply_to_llfn(function, Function, &[always_inline]);
618-
}
619-
}
620-
621595
let opt_stage = llvm::OptStage::FatLTO;
622596
let stage = write::AutodiffStage::PostAD;
623597
if !config.autodiff.contains(&config::AutoDiff::NoPostopt) {

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -716,16 +716,6 @@ impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> {
716716
llvm::LLVMMDStringInContext2(self.llcx(), name.as_ptr() as *const c_char, name.len())
717717
}
718718
}
719-
720-
pub(crate) fn get_functions(&self) -> Vec<&'ll Value> {
721-
let mut functions = vec![];
722-
let mut func = unsafe { llvm::LLVMGetFirstFunction(self.llmod()) };
723-
while let Some(f) = func {
724-
functions.push(f);
725-
func = unsafe { llvm::LLVMGetNextFunction(f) }
726-
}
727-
functions
728-
}
729719
}
730720

731721
impl<'ll, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {

compiler/rustc_codegen_llvm/src/llvm/mod.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,32 +42,6 @@ pub(crate) fn AddFunctionAttributes<'ll>(
4242
}
4343
}
4444

45-
pub(crate) fn HasAttributeAtIndex<'ll>(
46-
llfn: &'ll Value,
47-
idx: AttributePlace,
48-
kind: AttributeKind,
49-
) -> bool {
50-
unsafe { LLVMRustHasAttributeAtIndex(llfn, idx.as_uint(), kind) }
51-
}
52-
53-
pub(crate) fn HasStringAttribute<'ll>(llfn: &'ll Value, name: &str) -> bool {
54-
unsafe { LLVMRustHasFnAttribute(llfn, name.as_c_char_ptr(), name.len()) }
55-
}
56-
57-
pub(crate) fn RemoveStringAttrFromFn<'ll>(llfn: &'ll Value, name: &str) {
58-
unsafe { LLVMRustRemoveFnAttribute(llfn, name.as_c_char_ptr(), name.len()) }
59-
}
60-
61-
pub(crate) fn RemoveRustEnumAttributeAtIndex(
62-
llfn: &Value,
63-
place: AttributePlace,
64-
kind: AttributeKind,
65-
) {
66-
unsafe {
67-
LLVMRustRemoveEnumAttributeAtIndex(llfn, place.as_uint(), kind);
68-
}
69-
}
70-
7145
pub(crate) fn AddCallSiteAttributes<'ll>(
7246
callsite: &'ll Value,
7347
idx: AttributePlace,

0 commit comments

Comments
 (0)