passes: add an option to pad the stack map to frame size

Add a (hidden) option -gogc-stackmap-pad, to pad the stackmap to
at least the frame size, so we can easily do a conservative scan
of a frame in case of debugging.

Change-Id: I69c6086af03d78fdaaddff68eb5643bd6a8cc750
Reviewed-on: https://go-review.googlesource.com/c/155765
Reviewed-by: Than McIntosh <thanm@google.com>
diff --git a/passes/GC.cpp b/passes/GC.cpp
index 71c29cd..cba387d 100644
--- a/passes/GC.cpp
+++ b/passes/GC.cpp
@@ -28,6 +28,10 @@
 
 using namespace llvm;
 
+// Pad the stackmap to at least the frame size, so we can do a
+// conservative scan of a frame in case of debugging.
+static cl::opt<bool> Padding("gogc-stackmap-pad", cl::Hidden, cl::init(false));
+
 namespace {
 
 class GoGC : public GCStrategy {
@@ -124,6 +128,8 @@
   if (BV.none())
     return Bytes;
   int last = BV.find_last();
+  if (Padding && last < (int)StackSize/PtrSize - 1)
+    last = StackSize/PtrSize - 1; // ensure the stack map has at least frame size
   Size = last + 1;
   Bytes.reserve(last/8 + 1);
   int i;