diff options
| author | Manuel Drehwald <git@manuel.drehwald.info> | 2025-01-29 21:31:13 -0500 |
|---|---|---|
| committer | Manuel Drehwald <git@manuel.drehwald.info> | 2025-01-29 21:31:13 -0500 |
| commit | 1f30517d40a9a8fe3b89479891c7a167adb75cbd (patch) | |
| tree | 4da71f0331d185e202236924a854190f913815c7 /compiler/rustc_codegen_llvm/src/builder | |
| parent | ebcf860e7345e3387b4c6961338c77424b43cbd5 (diff) | |
| download | rust-1f30517d40a9a8fe3b89479891c7a167adb75cbd.tar.gz rust-1f30517d40a9a8fe3b89479891c7a167adb75cbd.zip | |
upstream rustc_codegen_ssa/rustc_middle changes for enzyme/autodiff
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/builder')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/builder/autodiff.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/compiler/rustc_codegen_llvm/src/builder/autodiff.rs b/compiler/rustc_codegen_llvm/src/builder/autodiff.rs index 6b17b5f6989..9e8e4e1c567 100644 --- a/compiler/rustc_codegen_llvm/src/builder/autodiff.rs +++ b/compiler/rustc_codegen_llvm/src/builder/autodiff.rs @@ -62,8 +62,8 @@ fn generate_enzyme_call<'ll>( // add outer_fn name to ad_name to make it unique, in case users apply autodiff to multiple // functions. Unwrap will only panic, if LLVM gave us an invalid string. let name = llvm::get_value_name(outer_fn); - let outer_fn_name = std::ffi::CStr::from_bytes_with_nul(name).unwrap().to_str().unwrap(); - ad_name.push_str(outer_fn_name.to_string().as_str()); + let outer_fn_name = std::str::from_utf8(name).unwrap(); + ad_name.push_str(outer_fn_name); // Let us assume the user wrote the following function square: // @@ -255,14 +255,14 @@ fn generate_enzyme_call<'ll>( // have no debug info to copy, which would then be ok. trace!("no dbg info"); } + // Now that we copied the metadata, get rid of dummy code. - llvm::LLVMRustEraseInstBefore(entry, last_inst); - llvm::LLVMRustEraseInstFromParent(last_inst); + llvm::LLVMRustEraseInstUntilInclusive(entry, last_inst); - if cx.val_ty(outer_fn) != cx.type_void() { - builder.ret(call); - } else { + if cx.val_ty(call) == cx.type_void() { builder.ret_void(); + } else { + builder.ret(call); } // Let's crash in case that we messed something up above and generated invalid IR. |
