Skip to content

Commit

Permalink
make __enzyme_ names unique
Browse files Browse the repository at this point in the history
  • Loading branch information
ZuseZ4 committed Nov 6, 2024
1 parent 2c2d103 commit 7c52d57
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion compiler/rustc_codegen_llvm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,20 @@ pub(crate) fn add_opt_dbg_helper2<'ll>(
) {
let inputs = attrs.input_activity;
let output = attrs.ret_activity;
let ad_name = match attrs.mode {
let mut ad_name: String = match attrs.mode {
DiffMode::Forward => "__enzyme_fwddiff",
DiffMode::Reverse => "__enzyme_autodiff",
DiffMode::ForwardFirst => "__enzyme_fwddiff",
DiffMode::ReverseFirst => "__enzyme_autodiff",
_ => panic!("Why are we here?"),
}.to_string();
// add tgt name to ad_name to make it unique
let tgt_name = unsafe {
let mut len: usize = 0;
let name = llvm::LLVMGetValueName2(tgt, &mut len as *mut usize);
std::ffi::CStr::from_ptr(name).to_str().unwrap()
};
ad_name.push_str(tgt_name.to_string().as_str());

// Assuming that our val is the fnc square, want to generate the following llvm-ir:
// declare double @__enzyme_autodiff(...)
Expand Down

0 comments on commit 7c52d57

Please sign in to comment.