Skip to content

Commit 58ffd81

Browse files
committed
Fix build on LLVM main (13)
1 parent a1ad99a commit 58ffd81

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

enzyme/Enzyme/AdjointGenerator.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2422,9 +2422,17 @@ class AdjointGenerator
24222422
llvm::errs() << *gutils->oldFunc << "\n";
24232423
llvm::errs() << *gutils->newFunc << "\n";
24242424
if (Intrinsic::isOverloaded(ID))
2425+
#if LLVM_VERSION_MAJOR >= 13
24252426
llvm::errs() << "cannot handle (reverse) unknown intrinsic\n"
2426-
<< Intrinsic::getName(ID, {}) << "\n"
2427+
<< Intrinsic::getName(ID, ArrayRef<Type *>(), nullptr,
2428+
nullptr)
2429+
<< "\n"
24272430
<< I;
2431+
#else
2432+
llvm::errs() << "cannot handle (reverse) unknown intrinsic\n"
2433+
<< Intrinsic::getName(ID, ArrayRef<Type *>()) << "\n"
2434+
<< I;
2435+
#endif
24282436
else
24292437
llvm::errs() << "cannot handle (reverse) unknown intrinsic\n"
24302438
<< Intrinsic::getName(ID) << "\n"

enzyme/Enzyme/MustExitScalarEvolution.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,8 +737,12 @@ ScalarEvolution::ExitLimit MustExitScalarEvolution::howManyLessThans(
737737
//
738738
if (!NoWrap) // THIS LINE CHANGED
739739
return getCouldNotCompute();
740+
#if LLVM_VERSION_MAJOR >= 13
741+
} else if (!Stride->isOne() && canIVOverflowOnLT(RHS, Stride, IsSigned))
742+
#else
740743
} else if (!Stride->isOne() &&
741744
doesIVOverflowOnLT(RHS, Stride, IsSigned, NoWrap))
745+
#endif
742746
// Avoid proven overflow cases: this will ensure that the backedge taken
743747
// count will not generate any unsigned overflow. Relaxed no-overflow
744748
// conditions exploit NoWrapFlags, allowing to optimize in presence of
@@ -763,8 +767,13 @@ ScalarEvolution::ExitLimit MustExitScalarEvolution::howManyLessThans(
763767
// (End-Start)/Stride times (rounded up to a multiple of Stride), where Start
764768
// is the LHS value of the less-than comparison the first time it is evaluated
765769
// and End is the RHS.
770+
#if LLVM_VERSION_MAJOR >= 13
771+
const SCEV *BECountIfBackedgeTaken =
772+
computeBECount(getMinusSCEV(End, Start), Stride);
773+
#else
766774
const SCEV *BECountIfBackedgeTaken =
767775
computeBECount(getMinusSCEV(End, Start), Stride, false);
776+
#endif
768777
// If the loop entry is guarded by the result of the backedge test of the
769778
// first loop iteration, then we know the backedge will be taken at least
770779
// once and so the backedge taken count is as above. If not then we use the
@@ -777,7 +786,11 @@ ScalarEvolution::ExitLimit MustExitScalarEvolution::howManyLessThans(
777786
BECount = BECountIfBackedgeTaken;
778787
else {
779788
End = IsSigned ? getSMaxExpr(RHS, Start) : getUMaxExpr(RHS, Start);
789+
#if LLVM_VERSION_MAJOR >= 13
790+
BECount = computeBECount(getMinusSCEV(End, Start), Stride);
791+
#else
780792
BECount = computeBECount(getMinusSCEV(End, Start), Stride, false);
793+
#endif
781794
}
782795

783796
const SCEV *MaxBECount;
@@ -800,4 +813,4 @@ ScalarEvolution::ExitLimit MustExitScalarEvolution::howManyLessThans(
800813
MaxBECount = getConstant(getUnsignedRangeMax(BECount));
801814

802815
return ExitLimit(BECount, MaxBECount, MaxOrZero, Predicates);
803-
}
816+
}

0 commit comments

Comments
 (0)