Skip to content

Commit 2a8ba2d

Browse files
authored
Custom forward zero (rust-lang#913)
* Custom forward zero * Fix activity analysis of agg
1 parent 5980f31 commit 2a8ba2d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

enzyme/Enzyme/ActivityAnalysis.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ bool ActivityAnalyzer::isConstantValue(TypeResults const &TR, Value *Val) {
10541054

10551055
// This value is certainly an integer (and only and integer, not a pointer or
10561056
// float). Therefore its value is constant
1057-
if (TR.intType(1, Val, /*errIfNotFound*/ false).isIntegral()) {
1057+
if (TR.query(Val)[{-1}] == BaseType::Integer) {
10581058
if (EnzymePrintActivity)
10591059
llvm::errs() << " Value const as integral " << (int)directions << " "
10601060
<< *Val << " "

enzyme/Enzyme/EnzymeLogic.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -2828,8 +2828,11 @@ void createTerminator(DiffeGradientUtils *gutils, BasicBlock *oBB,
28282828
} else if (!gutils->isConstantValue(ret)) {
28292829
toret = gutils->diffe(ret, nBuilder);
28302830
} else {
2831+
IRBuilder<> eB(gutils->inversionAllocs);
28312832
Type *retTy = gutils->getShadowType(ret->getType());
2832-
toret = Constant::getNullValue(retTy);
2833+
auto al = eB.CreateAlloca(retTy);
2834+
ZeroMemory(eB, retTy, al, /*isTape*/ false);
2835+
toret = nBuilder.CreateLoad(al);
28332836
}
28342837

28352838
break;

0 commit comments

Comments
 (0)