Skip to content

Commit bb70046

Browse files
authored
Add get type analyzer method to C API (rust-lang#673)
* Add get type analyzer method to C API * Add inverted phi type handler
1 parent 1fa0a99 commit bb70046

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

enzyme/Enzyme/CApi.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ void *EnzymeAnalyzeTypes(EnzymeTypeAnalysisRef TAR, CFnTypeInfo CTI,
227227
return (void *)&((TypeAnalysis *)TAR)->analyzeFunction(FTI).analyzer;
228228
}
229229

230+
void *EnzymeGradientUtilsTypeAnalyzer(GradientUtils *G) {
231+
return (void *)&G->my_TR->analyzer;
232+
}
233+
230234
void EnzymeRegisterAllocationHandler(char *Name, CustomShadowAlloc AHandle,
231235
CustomShadowFree FHandle) {
232236
shadowHandlers[std::string(Name)] =

enzyme/Enzyme/EnzymeLogic.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2728,6 +2728,13 @@ void createInvertedTerminator(TypeResults &TR, DiffeGradientUtils *gutils,
27282728
}
27292729
}
27302730
if (!PNfloatType) {
2731+
if (CustomErrorHandler) {
2732+
std::string str;
2733+
raw_string_ostream ss(str);
2734+
ss << "Cannot deduce type of phi " << *orig;
2735+
CustomErrorHandler(str.c_str(), wrap(orig), ErrorType::NoType,
2736+
&TR.analyzer);
2737+
}
27312738
llvm::errs() << *gutils->oldFunc->getParent() << "\n";
27322739
llvm::errs() << *gutils->oldFunc << "\n";
27332740
llvm::errs() << " for orig " << *orig << " saw "

0 commit comments

Comments
 (0)