From 30a82efcf403fed76bf1542e9477047660d5f54d Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Fri, 24 Sep 2021 16:46:05 -0400 Subject: cmd/compile, runtime: track argument stack slot liveness Currently, for stack traces (e.g. at panic or when runtime.Stack is called), we print argument values from the stack. With register ABI, we may never store the argument to stack therefore the argument value on stack may be meaningless. This causes confusion. This CL makes the compiler keep trace of which argument stack slots are meaningful. If it is meaningful, it will be printed in stack traces as before. If it may not be meaningful, it will be printed as the stack value with a question mark ("?"). In general, the value could be meaningful on some code paths but not others depending on the execution, and the compiler couldn't know statically, so we still print the stack value, instead of not printing it at all. Also note that if the argument variable is updated in the function body the printed value may be stale (like before register ABI) but still considered meaningful. Arguments passed on stack are always meaningful therefore always printed without a question mark. Results are never printed, as before. (Due to a bug in the compiler we sometimes don't spill args into their dedicated spill slots (as we should), causing it having fewer meaningful values than it should be.) This increases binary sizes a bit: old new hello 1129760 1142080 +1.09% cmd/go 13932320 14088016 +1.12% cmd/link 6267696 6329168 +0.98% Fixes #45728. Change-Id: I308a0402e5c5ab94ca0953f8bd85a56acd28f58c Reviewed-on: https://go-review.googlesource.com/c/go/+/352057 Trust: Cherry Mui Reviewed-by: Michael Knyszek --- src/runtime/funcdata.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/runtime/funcdata.h') diff --git a/src/runtime/funcdata.h b/src/runtime/funcdata.h index 15f1b5c9a1..a454dcaa69 100644 --- a/src/runtime/funcdata.h +++ b/src/runtime/funcdata.h @@ -11,6 +11,7 @@ #define PCDATA_UnsafePoint 0 #define PCDATA_StackMapIndex 1 #define PCDATA_InlTreeIndex 2 +#define PCDATA_ArgLiveIndex 3 #define FUNCDATA_ArgsPointerMaps 0 /* garbage collector blocks */ #define FUNCDATA_LocalsPointerMaps 1 @@ -18,6 +19,7 @@ #define FUNCDATA_InlTree 3 #define FUNCDATA_OpenCodedDeferInfo 4 /* info for func with open-coded defers */ #define FUNCDATA_ArgInfo 5 +#define FUNCDATA_ArgLiveInfo 6 // Pseudo-assembly statements. -- cgit v1.3