[DTrace-devel] [PATCH 20/61] Have dt_cg_typecast() copy results from src to dst in default case

eugene.loh at oracle.com eugene.loh at oracle.com
Fri Jul 8 14:45:04 UTC 2022


From: Eugene Loh <eugene.loh at oracle.com>

The dt_cg_typecast() function is written as if results are being
transfered from src to dst.  However, if src and dst types are
compatible and no bit-filling is needed, no such src-to-dst transfer
is performed.  In practice, this is not a problem since callers tend
to set src and dst registers equal to one another, meaning the typecast
operation is done in-place.

Either:

*)  add an explicit src-to-dst transfer for the "default case" (when
src and dst types are compatible and need no bit filling), or

*)  rewrite dt_cg_typecast() to be in-register (typically eliminating
one instruction)

Here, the first solution is used.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
 libdtrace/dt_cg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
index 633e4613..f1893198 100644
--- a/libdtrace/dt_cg.c
+++ b/libdtrace/dt_cg.c
@@ -2576,7 +2576,8 @@ dt_cg_typecast(const dt_node_t *src, const dt_node_t *dst,
 		emit(dlp,  BPF_LOAD(BPF_DW, dst->dn_reg, mst, DMST_SCALARIZER));
 
 		dt_regset_free(drp, mst);
-	}
+	} else
+		emit(dlp, BPF_MOV_REG(dst->dn_reg, src->dn_reg));
 }
 
 /*
-- 
2.18.4




More information about the DTrace-devel mailing list