/// <summary> /// Lowers return terminators returning structure values. /// </summary> private static void Lower( SSARewriterContext <FieldRef> context, LoweringData _, ReturnTerminator value) { // Move the block builder to a valid insert position in the source block var blockBuilder = context.GetMethodBuilder()[value.BasicBlock]; blockBuilder.SetupInsertPositionToEnd(); // Assemble return value Value returnValue = value.ReturnValue; var returnType = returnValue.Type.As <StructureType>(value); var newReturnValue = AssembleStructure( context.SpecializeBuilder(blockBuilder), returnType, returnValue); // Replace return terminator with a new terminator context.Builder.Terminator = context.Builder.CreateReturn( value.Location, newReturnValue); }
/// <summary> /// Lowers return terminators returning structure values. /// </summary> private static void Lower( SSARewriterContext <FieldRef> context, LoweringData _, ReturnTerminator value) { Value returnValue = value.ReturnValue; var returnType = returnValue.Type as StructureType; Debug.Assert(returnType != null, "Invalid structure type"); // Assemble a new structure that can be returned var blockBuilder = context.GetMethodBuilder()[value.BasicBlock]; blockBuilder.SetupInsertPosition(returnValue); var newReturnValue = AssembleStructure( context.SpecializeBuilder(blockBuilder), returnType, returnValue); // Replace return and remove return value returnValue.Replace(newReturnValue); }