LLVMReactor: Assert return value type matches function sig.
Bug: b/131914569
Change-Id: I228c8812a49ce3333227e1463c7617f942088a4f
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/30454
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index ad6abb1..11ea23a 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -1080,6 +1080,8 @@
{
RR_DEBUG_INFO_UPDATE_LOC();
+ ASSERT_MSG(::function->getReturnType() == T(Void::getType()), "Return type mismatch");
+
// Code generated after this point is unreachable, so any variables
// being read can safely return an undefined value. We have to avoid
// materializing variables after the terminator ret instruction.
@@ -1092,6 +1094,8 @@
{
RR_DEBUG_INFO_UPDATE_LOC();
+ ASSERT_MSG(::function->getReturnType() == V(v)->getType(), "Return type mismatch");
+
// Code generated after this point is unreachable, so any variables
// being read can safely return an undefined value. We have to avoid
// materializing variables after the terminator ret instruction.