Skip to content

Commit

Permalink
Custom forward zero (rust-lang#913)
Browse files Browse the repository at this point in the history
* Custom forward zero

* Fix activity analysis of agg
  • Loading branch information
wsmoses authored Oct 23, 2022
1 parent 5980f31 commit 2a8ba2d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion enzyme/Enzyme/ActivityAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ bool ActivityAnalyzer::isConstantValue(TypeResults const &TR, Value *Val) {

// This value is certainly an integer (and only and integer, not a pointer or
// float). Therefore its value is constant
if (TR.intType(1, Val, /*errIfNotFound*/ false).isIntegral()) {
if (TR.query(Val)[{-1}] == BaseType::Integer) {
if (EnzymePrintActivity)
llvm::errs() << " Value const as integral " << (int)directions << " "
<< *Val << " "
Expand Down
5 changes: 4 additions & 1 deletion enzyme/Enzyme/EnzymeLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2828,8 +2828,11 @@ void createTerminator(DiffeGradientUtils *gutils, BasicBlock *oBB,
} else if (!gutils->isConstantValue(ret)) {
toret = gutils->diffe(ret, nBuilder);
} else {
IRBuilder<> eB(gutils->inversionAllocs);
Type *retTy = gutils->getShadowType(ret->getType());
toret = Constant::getNullValue(retTy);
auto al = eB.CreateAlloca(retTy);
ZeroMemory(eB, retTy, al, /*isTape*/ false);
toret = nBuilder.CreateLoad(al);
}

break;
Expand Down

0 comments on commit 2a8ba2d

Please sign in to comment.