InlFuncsWithClosures int `help:"allow functions with closures to be inlined" concurrent:"ok"`
InlStaticInit int `help:"allow static initialization of inlined calls" concurrent:"ok"`
Libfuzzer int `help:"enable coverage instrumentation for libfuzzer"`
+ LiteralAllocHash string `help:"hash value for use in debugging literal allocation optimizations" concurrent:"ok"`
LoopVar int `help:"shared (0, default), 1 (private loop variables), 2, private + log"`
LoopVarHash string `help:"for debugging changes in loop behavior. Overrides experiment and loopvar flag."`
LocationLists int `help:"print information about DWARF location list creation"`
if Debug.PGOHash != "" {
PGOHash = NewHashDebug("pgohash", Debug.PGOHash, nil)
}
+ if Debug.LiteralAllocHash != "" {
+ LiteralAllocHash = NewHashDebug("literalalloc", Debug.LiteralAllocHash, nil)
+ }
+
if Debug.MergeLocalsHash != "" {
MergeLocalsHash = NewHashDebug("mergelocals", Debug.MergeLocalsHash, nil)
}
var FmaHash *HashDebug // for debugging fused-multiply-add floating point changes
var LoopVarHash *HashDebug // for debugging shared/private loop variable changes
var PGOHash *HashDebug // for debugging PGO optimization decisions
+var LiteralAllocHash *HashDebug // for debugging literal allocation optimizations
var MergeLocalsHash *HashDebug // for debugging local stack slot merging changes
var VariableMakeHash *HashDebug // for debugging variable-sized make optimizations
base.Fatalf("unexpected BasicLit Kind")
}
if constant.Compare(lit.Val(), token.GEQ, constant.MakeInt64(0)) {
+ if !base.LiteralAllocHash.MatchPos(n.Pos(), nil) {
+ // De-selected by literal alloc optimizations debug hash.
+ return
+ }
// Preserve any side effects of the original expression, then replace it.
assignTemp(*r, n.PtrInit())
*r = lit
if conv.X.Op() != ir.OLITERAL && !conv.X.Type().IsInterface() {
v := ro.StaticValue(conv.X)
if v != nil && v.Op() == ir.OLITERAL && ir.ValidTypeForConst(conv.X.Type(), v.Val()) {
+ if !base.LiteralAllocHash.MatchPos(n.Pos(), nil) {
+ // De-selected by literal alloc optimizations debug hash.
+ return
+ }
if base.Debug.EscapeDebug >= 3 {
base.WarnfAt(n.Pos(), "rewriting OCONVIFACE value from %v (%v) to %v (%v)", conv.X, conv.X.Type(), v, v.Type())
}
if v == nil {
v = n
}
+ optEnabled := func(n ir.Node) bool {
+ // Do this optimization only when enabled for this node.
+ return base.LiteralAllocHash.MatchPos(n.Pos(), nil)
+ }
if (v.Op() == ir.OSTRUCTLIT || v.Op() == ir.OARRAYLIT) && !base.Ctxt.IsFIPS() {
- if ir.IsZero(v) && 0 < v.Type().Size() && v.Type().Size() <= abi.ZeroValSize {
+ if ir.IsZero(v) && 0 < v.Type().Size() && v.Type().Size() <= abi.ZeroValSize && optEnabled(n) {
// This zero value can be represented by the read-only zeroVal.
zeroVal := ir.NewLinksymExpr(v.Pos(), ir.Syms.ZeroVal, n.Type())
vstat := typecheck.Expr(zeroVal).(*ir.LinksymOffsetExpr)
return vstat
}
- if isStaticCompositeLiteral(v) {
+ if isStaticCompositeLiteral(v) && optEnabled(n) {
// v can be directly represented in the read-only data section.
lit := v.(*ir.CompLitExpr)
vstat := readonlystaticname(n.Type())