Skip to content

Commit

Permalink
Pass if is unnecessary (#2207)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses authored Dec 26, 2024
1 parent 1ca3ceb commit 5954062
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions enzyme/Enzyme/CallDerivatives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ using namespace llvm;

extern "C" {
void (*EnzymeShadowAllocRewrite)(LLVMValueRef, void *, LLVMValueRef, uint64_t,
LLVMValueRef) = nullptr;
LLVMValueRef, uint8_t) = nullptr;
}

void AdjointGenerator::handleMPI(llvm::CallInst &call, llvm::Function *called,
Expand Down Expand Up @@ -3062,9 +3062,12 @@ bool AdjointGenerator::handleKnownCallDerivatives(
if (funcName == "julia.gc_alloc_obj" ||
funcName == "jl_gc_alloc_typed" ||
funcName == "ijl_gc_alloc_typed") {
if (EnzymeShadowAllocRewrite)
if (EnzymeShadowAllocRewrite) {
bool used = unnecessaryInstructions.find(&call) ==
unnecessaryInstructions.end();
EnzymeShadowAllocRewrite(wrap(anti), gutils, wrap(&call),
idx, wrap(prev));
idx, wrap(prev), used);
}
}
}
if (Mode == DerivativeMode::ReverseModeCombined ||
Expand Down Expand Up @@ -3249,9 +3252,12 @@ bool AdjointGenerator::handleKnownCallDerivatives(
if (funcName == "julia.gc_alloc_obj" ||
funcName == "jl_gc_alloc_typed" ||
funcName == "ijl_gc_alloc_typed") {
if (EnzymeShadowAllocRewrite)
if (EnzymeShadowAllocRewrite) {
bool used = unnecessaryInstructions.find(&call) ==
unnecessaryInstructions.end();
EnzymeShadowAllocRewrite(wrap(CI), gutils, wrap(&call), idx,
wrap(prev));
wrap(prev), used);
}
}
idx++;
prev = CI;
Expand Down

0 comments on commit 5954062

Please sign in to comment.