Skip to content

Commit fcfcd34

Browse files
committed
further fixes
1 parent 5858f5a commit fcfcd34

File tree

3 files changed

+26
-24
lines changed

3 files changed

+26
-24
lines changed

Diff for: compiler/rustc_codegen_llvm/src/builder/autodiff.rs

+23-23
Original file line numberDiff line numberDiff line change
@@ -321,29 +321,29 @@ pub(crate) fn differentiate<'ll>(
321321

322322
// FIXME(ZuseZ4): support SanitizeHWAddress and prevent illegal/unsupported opts
323323

324-
//if let Some(opt_level) = config.opt_level {
325-
// let opt_stage = match cgcx.lto {
326-
// Lto::Fat => llvm::OptStage::PreLinkFatLTO,
327-
// Lto::Thin | Lto::ThinLocal => llvm::OptStage::PreLinkThinLTO,
328-
// _ if cgcx.opts.cg.linker_plugin_lto.enabled() => llvm::OptStage::PreLinkThinLTO,
329-
// _ => llvm::OptStage::PreLinkNoLTO,
330-
// };
331-
// // This is our second opt call, so now we run all opts,
332-
// // to make sure we get the best performance.
333-
// let skip_size_increasing_opts = false;
334-
// trace!("running Module Optimization after differentiation");
335-
// unsafe {
336-
// llvm_optimize(
337-
// cgcx,
338-
// diag_handler.handle(),
339-
// module,
340-
// config,
341-
// opt_level,
342-
// opt_stage,
343-
// skip_size_increasing_opts,
344-
// )?
345-
// };
346-
//}
324+
if let Some(opt_level) = config.opt_level {
325+
let opt_stage = match cgcx.lto {
326+
Lto::Fat => llvm::OptStage::PreLinkFatLTO,
327+
Lto::Thin | Lto::ThinLocal => llvm::OptStage::PreLinkThinLTO,
328+
_ if cgcx.opts.cg.linker_plugin_lto.enabled() => llvm::OptStage::PreLinkThinLTO,
329+
_ => llvm::OptStage::PreLinkNoLTO,
330+
};
331+
// This is our second opt call, so now we run all opts,
332+
// to make sure we get the best performance.
333+
let skip_size_increasing_opts = false;
334+
trace!("running Module Optimization after differentiation");
335+
unsafe {
336+
llvm_optimize(
337+
cgcx,
338+
diag_handler.handle(),
339+
module,
340+
config,
341+
opt_level,
342+
opt_stage,
343+
skip_size_increasing_opts,
344+
)?
345+
};
346+
}
347347
trace!("done with differentiate()");
348348

349349
Ok(())

Diff for: compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ extern "C" {
1212
pub fn LLVMRustDIGetInstMetadata(I: &Value) -> Option<&Metadata>;
1313
pub fn LLVMRustEraseInstFromParent(V: &Value);
1414
pub fn LLVMRustGetTerminator<'a>(B: &BasicBlock) -> &'a Value;
15+
pub fn LLVMDumpModule(M: &Module);
16+
pub fn LLVMDumpValue(V: &Value);
1517
pub fn LLVMRustVerifyFunction(V: &Value, action: LLVMRustVerifierFailureAction) -> Bool;
1618

1719
pub fn LLVMGetFunctionCallConv(F: &Value) -> c_uint;

Diff for: compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ extern "C" void LLVMRustEraseInstBefore(LLVMBasicBlockRef bb, LLVMValueRef I) {
964964
// Make sure we found the Instruction.
965965
assert(It != BB.end());
966966
// We don't want to erase the instruction itself.
967-
It--;
967+
//It--;
968968
// Delete in rev order to ensure no dangling references.
969969
while (It != BB.begin()) {
970970
auto Prev = std::prev(It);

0 commit comments

Comments
 (0)