[master] 8551b1f59 vgc: Advise C compiler not optimize housekeeping subs *only*

Nils Goroll nils.goroll at uplex.de
Mon Feb 8 17:52:04 UTC 2021


commit 8551b1f59f9f4fdebfbaa8dfd9e539d73500d695
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Sun Jan 31 11:17:43 2021 +0100

    vgc: Advise C compiler not optimize housekeeping subs *only*
    
    Before the addition of the okmask, we could only selectively turn off
    optimizations for the built-in housekeeping subs (vcl_init {} /
    vcl_fini {}), not for any custom subs called from there.
    
    The previous commit changed this and turned off optimizations for any
    custom subs called from there.
    
    We pull this tighter again by only turning off optimizations for subs
    which can _only_ be called from housekeeping.
    
    Ref f1c47e4860f213710bd58f0c41fc1f1437d6c461
    Ref #3230

diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c
index 20aac191d..e9fb25b8b 100644
--- a/lib/libvcc/vcc_compile.c
+++ b/lib/libvcc/vcc_compile.c
@@ -200,15 +200,8 @@ vcc_EmitProc(struct vcc *tl, struct proc *p)
 	Fh(tl, 1, "\t.nref\t\t= %d,\n", p->sym->nref);
 	Fh(tl, 1, "\t.called\t\t= %d\n", p->called);
 	Fh(tl, 1, "}};\n");
-	/*
-	 * TODO: v_dont_optimize for custom subs called from vcl_init/fini only
-	 *
-	 * Needs infrastructure similar to that in #3163 : custom subs need a
-	 * mask containing the builtin subs calling the custom sub. If that is
-	 * no larger than VCL_MET_TASK_H, we can enable v_dont_optimize
-	 */
 	Fc(tl, 1, "\nvoid %sv_matchproto_(vcl_func_f)\n",
-	   p->method && p->method->bitval & VCL_MET_TASK_H ?
+	   ((mask & VCL_MET_TASK_H) && (mask & ~VCL_MET_TASK_H) == 0) ?
 	   "v_dont_optimize " : "");
 	Fc(tl, 1, "%s(VRT_CTX)\n{\n", VSB_data(p->cname));
 	vsbm = VSB_new_auto();


More information about the varnish-commit mailing list