From 1fa0a992934a158bcab7f7e896a6859080950b75 Mon Sep 17 00:00:00 2001 From: William Moses Date: Sat, 28 May 2022 19:47:00 -0400 Subject: [PATCH] Add no type error (#672) --- enzyme/Enzyme/AdjointGenerator.h | 7 +++++++ enzyme/Enzyme/Utils.h | 3 ++- enzyme/test/Enzyme/ForwardMode/fmuladd.ll | 6 +++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/enzyme/Enzyme/AdjointGenerator.h b/enzyme/Enzyme/AdjointGenerator.h index 3b722bce4fd7e..dbc5dcb077d95 100644 --- a/enzyme/Enzyme/AdjointGenerator.h +++ b/enzyme/Enzyme/AdjointGenerator.h @@ -2814,6 +2814,13 @@ class AdjointGenerator vd = TypeTree(BaseType::Pointer).Only(0); goto known; } + if (CustomErrorHandler) { + std::string str; + raw_string_ostream ss(str); + ss << "Cannot deduce type of copy " << MTI; + CustomErrorHandler(str.c_str(), wrap(&MTI), ErrorType::NoType, + &TR.analyzer); + } EmitFailure("CannotDeduceType", MTI.getDebugLoc(), &MTI, "failed to deduce type of copy ", MTI); diff --git a/enzyme/Enzyme/Utils.h b/enzyme/Enzyme/Utils.h index b941cfc709d06..755c6c07500c5 100644 --- a/enzyme/Enzyme/Utils.h +++ b/enzyme/Enzyme/Utils.h @@ -69,7 +69,8 @@ class ScalarEvolution; enum class ErrorType { NoDerivative = 0, NoShadow = 1, - IllegalTypeAnalysis = 2 + IllegalTypeAnalysis = 2, + NoType = 3 }; extern "C" { diff --git a/enzyme/test/Enzyme/ForwardMode/fmuladd.ll b/enzyme/test/Enzyme/ForwardMode/fmuladd.ll index c95c0777f1b2b..3737b6d0496a5 100644 --- a/enzyme/test/Enzyme/ForwardMode/fmuladd.ll +++ b/enzyme/test/Enzyme/ForwardMode/fmuladd.ll @@ -20,9 +20,9 @@ declare double @__enzyme_fwddiff(double (double, double, double)*, ...) ; CHECK: define internal double @fwddiffetester(double %x, double %"x'", double %y, double %"y'", double %z, double %"z'") ; CHECK-NEXT: entry: -; CHECK-NEXT: %0 = fmul fast double %y, %"x'" -; CHECK-NEXT: %1 = fmul fast double %x, %"y'" -; CHECK-NEXT: %2 = fadd fast double %1, %0 +; CHECK-DAG: %[[i0:.+]] = fmul fast double %y, %"x'" +; CHECK-DAG: %[[i1:.+]] = fmul fast double %x, %"y'" +; CHECK-NEXT: %2 = fadd fast double %[[i1]], %[[i0]] ; CHECK-NEXT: %3 = fadd fast double %2, %"x'" ; CHECK-NEXT: ret double %3 ; CHECK-NEXT: }