From 6038934ed47dfdecef40eb564151fa76f99b1e73 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Thu, 4 Mar 2021 02:56:50 -0500 Subject: [PATCH] Fix a crash in llvm if the sreg of a setret is not set because the methods ends with a throw. --- src/mono/mono/mini/mini-llvm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/mini/mini-llvm.c b/src/mono/mono/mini/mini-llvm.c index 7dcc4b71a810d..3a7cb5b81d3dc 100644 --- a/src/mono/mono/mini/mini-llvm.c +++ b/src/mono/mono/mini/mini-llvm.c @@ -5227,7 +5227,8 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) /* The return type is an LLVM aggregate type, so a bare bitcast cannot be used to do this conversion. */ int width = mono_type_size (sig->ret, NULL); int elems = width / TARGET_SIZEOF_VOID_P; - LLVMValueRef val = LLVMBuildBitCast (builder, values [ins->sreg1], LLVMVectorType (IntPtrType (), elems), ""); + /* The return value might not be set if there is a throw */ + LLVMValueRef val = lhs ? LLVMBuildBitCast (builder, lhs, LLVMVectorType (IntPtrType (), elems), "") : LLVMConstNull (LLVMVectorType (IntPtrType (), elems)); for (int i = 0; i < elems; ++i) { LLVMValueRef element = LLVMBuildExtractElement (builder, val, const_int32 (i), ""); retval = LLVMBuildInsertValue (builder, retval, element, i, "setret_simd_vtype_in_reg");