compiler: make heap expression's write barrier conditional

Heap_expression::do_get_backend emits an unconditional write
barrier if the type has pointers and it is not a stack allocation.
This CL changes it to use a write barrier for the assignment only
when write barriers are enabled. While here, also change it to
call gcWriteBarrier instead of typedmemmove for pointer-shaped
types.

For this to work, Function::build needs to be adjusted so that
Heap_expression::do_get_backend is called when there is a parent
block.

Change-Id: Ib9250b23f954022e9f2daeaeb4bac6278cfca6de
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/181540
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 files changed