compiler,runtime: translate memzero calls to LLVM memset intrinsics

This gives the optimizer a bit more information about what the calls do.
This should result in slightly better generated code.

Code size sometimes goes up and sometimes goes down. I blame the code
size going up on the inliner which inlines more functions, because
compiling the smoke tests in the drivers repository with -opt=1 results
in a slight code size reduction in all cases.
This commit is contained in:
Ayke van Laethem
2020-03-26 16:09:48 +01:00
committed by Ron Evans
parent eaa54bc7e3
commit 91d1a23b14
3 changed files with 25 additions and 5 deletions
+3 -5
View File
@@ -41,11 +41,9 @@ func memcpy(dst, src unsafe.Pointer, size uintptr)
func memmove(dst, src unsafe.Pointer, size uintptr)
// Set the given number of bytes to zero.
func memzero(ptr unsafe.Pointer, size uintptr) {
for i := uintptr(0); i < size; i++ {
*(*byte)(unsafe.Pointer(uintptr(ptr) + i)) = 0
}
}
// Calls to this function are converted to LLVM intrinsic calls such as
// llvm.memset.p0i8.i32(ptr, 0, size, false).
func memzero(ptr unsafe.Pointer, size uintptr)
// Compare two same-size buffers for equality.
func memequal(x, y unsafe.Pointer, n uintptr) bool {