Skip to content

Commit abf4053

Browse files
authored
Add enzyme_active metadata (rust-lang#462)
1 parent d068af2 commit abf4053

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

enzyme/Enzyme/ActivityAnalysis.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,25 @@ bool ActivityAnalyzer::isConstantInstruction(TypeResults &TR, Instruction *I) {
404404
return true;
405405
}
406406

407+
if (auto CI = dyn_cast<CallInst>(I)) {
408+
if (CI->hasFnAttr("enzyme_active")) {
409+
if (EnzymePrintActivity)
410+
llvm::errs() << "forced active " << *I << "\n";
411+
ActiveInstructions.insert(I);
412+
return false;
413+
}
414+
Function *called = getFunctionFromCall(CI);
415+
416+
if (called) {
417+
if (called->hasFnAttribute("enzyme_active")) {
418+
if (EnzymePrintActivity)
419+
llvm::errs() << "forced active " << *I << "\n";
420+
ActiveInstructions.insert(I);
421+
return false;
422+
}
423+
}
424+
}
425+
407426
/// A store into all integral memory is inactive
408427
if (auto SI = dyn_cast<StoreInst>(I)) {
409428
auto StoreSize = SI->getParent()

0 commit comments

Comments
 (0)