Skip to content

Commit 84e7fe5

Browse files
authored
Simplify store type handling (rust-lang#742)
1 parent e496dfa commit 84e7fe5

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

enzyme/Enzyme/AdjointGenerator.h

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -940,25 +940,27 @@ class AdjointGenerator
940940
if (valType->isFPOrFPVectorTy()) {
941941
FT = valType->getScalarType();
942942
} else if (!valType->isPointerTy()) {
943-
if (looseTypeAnalysis) {
944-
auto fp = TR.firstPointer(storeSize, orig_ptr, /*errifnotfound*/ false,
945-
/*pointerIntSame*/ true);
946-
if (fp.isKnown()) {
947-
FT = fp.isFloat();
948-
} else if (isa<ConstantInt>(orig_val) ||
949-
valType->isIntOrIntVectorTy()) {
950-
llvm::errs() << "assuming type as integral for store: " << I << "\n";
951-
FT = nullptr;
952-
} else {
953-
TR.firstPointer(storeSize, orig_ptr, /*errifnotfound*/ true,
954-
/*pointerIntSame*/ true);
955-
llvm::errs() << "cannot deduce type of store " << I << "\n";
956-
assert(0 && "cannot deduce");
957-
}
943+
auto fp = TR.firstPointer(storeSize, orig_ptr, /*errifnotfound*/ false,
944+
/*pointerIntSame*/ true);
945+
if (fp.isKnown()) {
946+
FT = fp.isFloat();
947+
} else if (looseTypeAnalysis && (isa<ConstantInt>(orig_val) ||
948+
valType->isIntOrIntVectorTy())) {
949+
llvm::errs() << "assuming type as integral for store: " << I << "\n";
950+
FT = nullptr;
958951
} else {
959-
FT = TR.firstPointer(storeSize, orig_ptr, /*errifnotfound*/ true,
960-
/*pointerIntSame*/ true)
961-
.isFloat();
952+
953+
if (CustomErrorHandler) {
954+
std::string str;
955+
raw_string_ostream ss(str);
956+
ss << "Cannot deduce type of store " << I;
957+
CustomErrorHandler(str.c_str(), wrap(&I), ErrorType::NoType,
958+
&TR.analyzer);
959+
}
960+
EmitFailure("CannotDeduceType", I.getDebugLoc(), &I,
961+
"failed to deduce type of store ", I);
962+
TR.firstPointer(storeSize, orig_ptr, /*errifnotfound*/ true,
963+
/*pointerIntSame*/ true);
962964
}
963965
}
964966

0 commit comments

Comments
 (0)