You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(122) |
Nov
(152) |
Dec
(69) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(6) |
Feb
(25) |
Mar
(73) |
Apr
(82) |
May
(24) |
Jun
(25) |
Jul
(10) |
Aug
(11) |
Sep
(10) |
Oct
(54) |
Nov
(203) |
Dec
(182) |
| 2004 |
Jan
(307) |
Feb
(305) |
Mar
(430) |
Apr
(312) |
May
(187) |
Jun
(342) |
Jul
(487) |
Aug
(637) |
Sep
(336) |
Oct
(373) |
Nov
(441) |
Dec
(210) |
| 2005 |
Jan
(385) |
Feb
(480) |
Mar
(636) |
Apr
(544) |
May
(679) |
Jun
(625) |
Jul
(810) |
Aug
(838) |
Sep
(634) |
Oct
(521) |
Nov
(965) |
Dec
(543) |
| 2006 |
Jan
(494) |
Feb
(431) |
Mar
(546) |
Apr
(411) |
May
(406) |
Jun
(322) |
Jul
(256) |
Aug
(401) |
Sep
(345) |
Oct
(542) |
Nov
(308) |
Dec
(481) |
| 2007 |
Jan
(427) |
Feb
(326) |
Mar
(367) |
Apr
(255) |
May
(244) |
Jun
(204) |
Jul
(223) |
Aug
(231) |
Sep
(354) |
Oct
(374) |
Nov
(497) |
Dec
(362) |
| 2008 |
Jan
(322) |
Feb
(482) |
Mar
(658) |
Apr
(422) |
May
(476) |
Jun
(396) |
Jul
(455) |
Aug
(267) |
Sep
(280) |
Oct
(253) |
Nov
(232) |
Dec
(304) |
| 2009 |
Jan
(486) |
Feb
(470) |
Mar
(458) |
Apr
(423) |
May
(696) |
Jun
(461) |
Jul
(551) |
Aug
(575) |
Sep
(134) |
Oct
(110) |
Nov
(157) |
Dec
(102) |
| 2010 |
Jan
(226) |
Feb
(86) |
Mar
(147) |
Apr
(117) |
May
(107) |
Jun
(203) |
Jul
(193) |
Aug
(238) |
Sep
(300) |
Oct
(246) |
Nov
(23) |
Dec
(75) |
| 2011 |
Jan
(133) |
Feb
(195) |
Mar
(315) |
Apr
(200) |
May
(267) |
Jun
(293) |
Jul
(353) |
Aug
(237) |
Sep
(278) |
Oct
(611) |
Nov
(274) |
Dec
(260) |
| 2012 |
Jan
(303) |
Feb
(391) |
Mar
(417) |
Apr
(441) |
May
(488) |
Jun
(655) |
Jul
(590) |
Aug
(610) |
Sep
(526) |
Oct
(478) |
Nov
(359) |
Dec
(372) |
| 2013 |
Jan
(467) |
Feb
(226) |
Mar
(391) |
Apr
(281) |
May
(299) |
Jun
(252) |
Jul
(311) |
Aug
(352) |
Sep
(481) |
Oct
(571) |
Nov
(222) |
Dec
(231) |
| 2014 |
Jan
(185) |
Feb
(329) |
Mar
(245) |
Apr
(238) |
May
(281) |
Jun
(399) |
Jul
(382) |
Aug
(500) |
Sep
(579) |
Oct
(435) |
Nov
(487) |
Dec
(256) |
| 2015 |
Jan
(338) |
Feb
(357) |
Mar
(330) |
Apr
(294) |
May
(191) |
Jun
(108) |
Jul
(142) |
Aug
(261) |
Sep
(190) |
Oct
(54) |
Nov
(83) |
Dec
(22) |
| 2016 |
Jan
(49) |
Feb
(89) |
Mar
(33) |
Apr
(50) |
May
(27) |
Jun
(34) |
Jul
(53) |
Aug
(53) |
Sep
(98) |
Oct
(206) |
Nov
(93) |
Dec
(53) |
| 2017 |
Jan
(65) |
Feb
(82) |
Mar
(102) |
Apr
(86) |
May
(187) |
Jun
(67) |
Jul
(23) |
Aug
(93) |
Sep
(65) |
Oct
(45) |
Nov
(35) |
Dec
(17) |
| 2018 |
Jan
(26) |
Feb
(35) |
Mar
(38) |
Apr
(32) |
May
(8) |
Jun
(43) |
Jul
(27) |
Aug
(30) |
Sep
(43) |
Oct
(42) |
Nov
(38) |
Dec
(67) |
| 2019 |
Jan
(32) |
Feb
(37) |
Mar
(53) |
Apr
(64) |
May
(49) |
Jun
(18) |
Jul
(14) |
Aug
(53) |
Sep
(25) |
Oct
(30) |
Nov
(49) |
Dec
(31) |
| 2020 |
Jan
(87) |
Feb
(45) |
Mar
(37) |
Apr
(51) |
May
(99) |
Jun
(36) |
Jul
(11) |
Aug
(14) |
Sep
(20) |
Oct
(24) |
Nov
(40) |
Dec
(23) |
| 2021 |
Jan
(14) |
Feb
(53) |
Mar
(85) |
Apr
(15) |
May
(19) |
Jun
(3) |
Jul
(14) |
Aug
(1) |
Sep
(57) |
Oct
(73) |
Nov
(56) |
Dec
(22) |
| 2022 |
Jan
(3) |
Feb
(22) |
Mar
(6) |
Apr
(55) |
May
(46) |
Jun
(39) |
Jul
(15) |
Aug
(9) |
Sep
(11) |
Oct
(34) |
Nov
(20) |
Dec
(36) |
| 2023 |
Jan
(79) |
Feb
(41) |
Mar
(99) |
Apr
(169) |
May
(48) |
Jun
(16) |
Jul
(16) |
Aug
(57) |
Sep
(19) |
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
|
|
1
|
2
|
|
3
(3) |
4
|
5
|
6
(1) |
7
(1) |
8
|
9
(1) |
|
10
|
11
(2) |
12
(3) |
13
(1) |
14
(1) |
15
|
16
(1) |
|
17
(1) |
18
(14) |
19
(1) |
20
(1) |
21
(3) |
22
(2) |
23
|
|
24
(1) |
25
|
26
(4) |
27
(6) |
28
(2) |
29
|
30
|
|
From: Julian S. <se...@so...> - 2019-11-21 19:06:09
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=95ecbd59f3395fe8eaace0352b5a82dd705de7b4 commit 95ecbd59f3395fe8eaace0352b5a82dd705de7b4 Author: Julian Seward <js...@ac...> Date: Thu Nov 21 20:03:47 2019 +0100 Tidy up ir_opt.c aspects relating to the 'grail' work. In particular: * Rewrite do_minimal_initial_iropt_BB so it doesn't do full constant folding; that is unnecessary expense at this point, and later passes will do it anyway * do_iropt_BB: don't flatten the incoming block, because do_minimal_initial_iropt_BB will have run earlier and done so. But at least for the moment, assert that it really is flat. * VEX/priv/guest_generic_bb_to_IR.c create_self_checks_as_needed: generate flat IR so as not to fail the abovementioned assertion. I believe this completes the target-independent aspects of this work, and also the x86_64 specifics (of which there are very few). Diff: --- VEX/priv/guest_generic_bb_to_IR.c | 82 +++++++++++++--------- VEX/priv/ir_defs.c | 16 ++++- VEX/priv/ir_opt.c | 139 +++++++++++++++++++------------------- VEX/pub/libvex_ir.h | 3 +- 4 files changed, 136 insertions(+), 104 deletions(-) diff --git a/VEX/priv/guest_generic_bb_to_IR.c b/VEX/priv/guest_generic_bb_to_IR.c index 7477641..f890c33 100644 --- a/VEX/priv/guest_generic_bb_to_IR.c +++ b/VEX/priv/guest_generic_bb_to_IR.c @@ -128,7 +128,7 @@ static void create_self_checks_as_needed( Addr base2check; UInt len2check; HWord expectedhW; - IRTemp tistart_tmp, tilen_tmp; + IRTemp tistart_tmp, tilen_tmp, callresult_tmp, exitguard_tmp; HWord VEX_REGPARM(2) (*fn_generic)(HWord, HWord); HWord VEX_REGPARM(1) (*fn_spec)(HWord); const HChar* nm_generic; @@ -161,7 +161,7 @@ static void create_self_checks_as_needed( const Int n_extent_slots = sizeof(vge->base) / sizeof(vge->base[0]); vassert(n_extent_slots == 3); - vassert(selfcheck_idx + (n_extent_slots - 1) * 5 + 4 < irsb->stmts_used); + vassert(selfcheck_idx + (n_extent_slots - 1) * 7 + 6 < irsb->stmts_used); for (Int i = 0; i < vge->n_used; i++) { /* Do we need to generate a check for this extent? */ @@ -297,16 +297,20 @@ static void create_self_checks_as_needed( = guest_word_type==Ity_I32 ? IRConst_U32(len2check) : IRConst_U64(len2check); - IRStmt** stmt0 = &irsb->stmts[selfcheck_idx + i * 5 + 0]; - IRStmt** stmt1 = &irsb->stmts[selfcheck_idx + i * 5 + 1]; - IRStmt** stmt2 = &irsb->stmts[selfcheck_idx + i * 5 + 2]; - IRStmt** stmt3 = &irsb->stmts[selfcheck_idx + i * 5 + 3]; - IRStmt** stmt4 = &irsb->stmts[selfcheck_idx + i * 5 + 4]; + IRStmt** stmt0 = &irsb->stmts[selfcheck_idx + i * 7 + 0]; + IRStmt** stmt1 = &irsb->stmts[selfcheck_idx + i * 7 + 1]; + IRStmt** stmt2 = &irsb->stmts[selfcheck_idx + i * 7 + 2]; + IRStmt** stmt3 = &irsb->stmts[selfcheck_idx + i * 7 + 3]; + IRStmt** stmt4 = &irsb->stmts[selfcheck_idx + i * 7 + 4]; + IRStmt** stmt5 = &irsb->stmts[selfcheck_idx + i * 7 + 5]; + IRStmt** stmt6 = &irsb->stmts[selfcheck_idx + i * 7 + 6]; vassert((*stmt0)->tag == Ist_NoOp); vassert((*stmt1)->tag == Ist_NoOp); vassert((*stmt2)->tag == Ist_NoOp); vassert((*stmt3)->tag == Ist_NoOp); vassert((*stmt4)->tag == Ist_NoOp); + vassert((*stmt5)->tag == Ist_NoOp); + vassert((*stmt6)->tag == Ist_NoOp); *stmt0 = IRStmt_WrTmp(tistart_tmp, IRExpr_Const(base2check_IRConst) ); *stmt1 = IRStmt_WrTmp(tilen_tmp, IRExpr_Const(len2check_IRConst) ); @@ -332,6 +336,8 @@ static void create_self_checks_as_needed( } } + /* Generate the call to the relevant function, and the comparison of + the result against the expected value. */ IRExpr* callexpr = NULL; if (fn_spec) { callexpr = mkIRExprCCall( @@ -352,36 +358,46 @@ static void create_self_checks_as_needed( ); } - *stmt4 - = IRStmt_Exit( - IRExpr_Binop( - host_word_type==Ity_I64 ? Iop_CmpNE64 : Iop_CmpNE32, - callexpr, - host_word_type==Ity_I64 - ? IRExpr_Const(IRConst_U64(expectedhW)) - : IRExpr_Const(IRConst_U32(expectedhW)) - ), - Ijk_InvalICache, - /* Where we must restart if there's a failure: at the - first extent, regardless of which extent the - failure actually happened in. */ - guest_IP_sbstart_IRConst, - offB_GUEST_IP - ); + callresult_tmp = newIRTemp(irsb->tyenv, host_word_type); + *stmt4 = IRStmt_WrTmp(callresult_tmp, callexpr); + + exitguard_tmp = newIRTemp(irsb->tyenv, Ity_I1); + *stmt5 = IRStmt_WrTmp( + exitguard_tmp, + IRExpr_Binop( + host_word_type==Ity_I64 ? Iop_CmpNE64 : Iop_CmpNE32, + IRExpr_RdTmp(callresult_tmp), + host_word_type==Ity_I64 + ? IRExpr_Const(IRConst_U64(expectedhW)) + : IRExpr_Const(IRConst_U32(expectedhW)))); + + *stmt6 = IRStmt_Exit( + IRExpr_RdTmp(exitguard_tmp), + Ijk_InvalICache, + /* Where we must restart if there's a failure: at the + first extent, regardless of which extent the failure + actually happened in. */ + guest_IP_sbstart_IRConst, + offB_GUEST_IP + ); } /* for (i = 0; i < vge->n_used; i++) */ for (Int i = vge->n_used; i < sizeof(vge->base) / sizeof(vge->base[0]); i++) { - IRStmt* stmt0 = irsb->stmts[selfcheck_idx + i * 5 + 0]; - IRStmt* stmt1 = irsb->stmts[selfcheck_idx + i * 5 + 1]; - IRStmt* stmt2 = irsb->stmts[selfcheck_idx + i * 5 + 2]; - IRStmt* stmt3 = irsb->stmts[selfcheck_idx + i * 5 + 3]; - IRStmt* stmt4 = irsb->stmts[selfcheck_idx + i * 5 + 4]; + IRStmt* stmt0 = irsb->stmts[selfcheck_idx + i * 7 + 0]; + IRStmt* stmt1 = irsb->stmts[selfcheck_idx + i * 7 + 1]; + IRStmt* stmt2 = irsb->stmts[selfcheck_idx + i * 7 + 2]; + IRStmt* stmt3 = irsb->stmts[selfcheck_idx + i * 7 + 3]; + IRStmt* stmt4 = irsb->stmts[selfcheck_idx + i * 7 + 4]; + IRStmt* stmt5 = irsb->stmts[selfcheck_idx + i * 7 + 5]; + IRStmt* stmt6 = irsb->stmts[selfcheck_idx + i * 7 + 6]; vassert(stmt0->tag == Ist_NoOp); vassert(stmt1->tag == Ist_NoOp); vassert(stmt2->tag == Ist_NoOp); vassert(stmt3->tag == Ist_NoOp); vassert(stmt4->tag == Ist_NoOp); + vassert(stmt5->tag == Ist_NoOp); + vassert(stmt6->tag == Ist_NoOp); } } } @@ -1260,13 +1276,13 @@ IRSB* bb_to_IR ( /* And a new IR superblock to dump the result into. */ IRSB* irsb = emptyIRSB(); - /* Leave 15 spaces in which to put the check statements for a self - checking translation (up to 3 extents, and 5 stmts required for + /* Leave 21 spaces in which to put the check statements for a self + checking translation (up to 3 extents, and 7 stmts required for each). We won't know until later the extents and checksums of the areas, if any, that need to be checked. */ IRStmt* nop = IRStmt_NoOp(); Int selfcheck_idx = irsb->stmts_used; - for (Int i = 0; i < 3 * 5; i++) + for (Int i = 0; i < 3 * 7; i++) addStmtToIRSB( irsb, nop ); /* If the caller supplied a function to add its own preamble, use @@ -1277,7 +1293,7 @@ IRSB* bb_to_IR ( /* The callback has completed the IR block without any guest insns being disassembled into it, so just return it at this point, even if a self-check was requested - as there - is nothing to self-check. The 15 self-check no-ops will + is nothing to self-check. The 21 self-check no-ops will still be in place, but they are harmless. */ vge->n_used = 1; vge->base[0] = guest_IP_sbstart; @@ -1586,7 +1602,7 @@ IRSB* bb_to_IR ( /* We're almost done. The only thing that might need attending to is that a self-checking preamble may need to be created. If so it gets placed - in the 15 slots reserved above. */ + in the 21 slots reserved above. */ create_self_checks_as_needed( irsb, n_sc_extents, pxControl, callback_opaque, needs_self_check, vge, abiinfo_both, guest_word_type, selfcheck_idx, offB_GUEST_CMSTART, diff --git a/VEX/priv/ir_defs.c b/VEX/priv/ir_defs.c index d687d8f..7b6e847 100644 --- a/VEX/priv/ir_defs.c +++ b/VEX/priv/ir_defs.c @@ -4270,7 +4270,7 @@ static inline Bool isIRAtom_or_VECRET_or_GSPTR ( const IRExpr* e ) return UNLIKELY(is_IRExpr_VECRET_or_GSPTR(e)); } -Bool isFlatIRStmt ( const IRStmt* st ) +inline Bool isFlatIRStmt ( const IRStmt* st ) { Int i; const IRExpr* e; @@ -4374,6 +4374,20 @@ Bool isFlatIRStmt ( const IRStmt* st ) } } +Bool isFlatIRSB ( const IRSB* sb ) +{ + for (Int i = 0; i < sb->stmts_used; i++) { + if (!isFlatIRStmt(sb->stmts[i])) + return False; + } + + if (!isIRAtom(sb->next)) { + return False; + } + + return True; +} + /*---------------------------------------------------------------*/ /*--- Sanity checking ---*/ diff --git a/VEX/priv/ir_opt.c b/VEX/priv/ir_opt.c index ca67712..d3bc989 100644 --- a/VEX/priv/ir_opt.c +++ b/VEX/priv/ir_opt.c @@ -1376,7 +1376,8 @@ static IRExpr* chase1 ( IRExpr** env, IRExpr* e ) return env[(Int)e->Iex.RdTmp.tmp]; } -static IRExpr* fold_Expr ( IRExpr** env, IRExpr* e ) +__attribute__((noinline)) +static IRExpr* fold_Expr_WRK ( IRExpr** env, IRExpr* e ) { Int shift; IRExpr* e2 = e; /* e2 is the result of folding e, if possible */ @@ -2463,7 +2464,7 @@ static IRExpr* fold_Expr ( IRExpr** env, IRExpr* e ) && !debug_only_hack_sameIRExprs_might_assert(e->Iex.Binop.arg1, e->Iex.Binop.arg2) && sameIRExprs(env, e->Iex.Binop.arg1, e->Iex.Binop.arg2)) { - vex_printf("vex iropt: fold_Expr: no ident rule for: "); + vex_printf("vex iropt: fold_Expr_WRK: no ident rule for: "); ppIRExpr(e); vex_printf("\n"); } @@ -2484,7 +2485,7 @@ static IRExpr* fold_Expr ( IRExpr** env, IRExpr* e ) vpanic("fold_Expr: no rule for the above"); # else if (vex_control.iropt_verbosity > 0) { - vex_printf("vex iropt: fold_Expr: no const rule for: "); + vex_printf("vex iropt: fold_Expr_WRK: no const rule for: "); ppIRExpr(e); vex_printf("\n"); } @@ -2492,6 +2493,14 @@ static IRExpr* fold_Expr ( IRExpr** env, IRExpr* e ) # endif } +/* Fold |e| as much as possible, given the bindings in |env|. If no folding is + possible, just return |e|. Also, if |env| is NULL, don't even try to + fold; just return |e| directly. */ +inline +static IRExpr* fold_Expr ( IRExpr** env, IRExpr* e ) +{ + return env == NULL ? e : fold_Expr_WRK(env, e); +} /* Apply the subst to a simple 1-level expression -- guaranteed to be 1-level due to previous flattening pass. */ @@ -2607,32 +2616,36 @@ static IRExpr* subst_Expr ( IRExpr** env, IRExpr* ex ) } -/* Apply the subst to stmt, then fold the result as much as possible. - Much simplified due to stmt being previously flattened. As a - result of this, the stmt may wind up being turned into a no-op. +/* Apply the subst to stmt, then, if |doFolding| is |True|, fold the result as + much as possible. Much simplified due to stmt being previously flattened. + As a result of this, the stmt may wind up being turned into a no-op. */ -static IRStmt* subst_and_fold_Stmt ( IRExpr** env, IRStmt* st ) +static IRStmt* subst_and_maybe_fold_Stmt ( Bool doFolding, + IRExpr** env, IRStmt* st ) { # if 0 - vex_printf("\nsubst and fold stmt\n"); + vex_printf("\nsubst and maybe fold stmt\n"); ppIRStmt(st); vex_printf("\n"); # endif + IRExpr** s_env = env; + IRExpr** f_env = doFolding ? env : NULL; + switch (st->tag) { case Ist_AbiHint: vassert(isIRAtom(st->Ist.AbiHint.base)); vassert(isIRAtom(st->Ist.AbiHint.nia)); return IRStmt_AbiHint( - fold_Expr(env, subst_Expr(env, st->Ist.AbiHint.base)), + fold_Expr(f_env, subst_Expr(s_env, st->Ist.AbiHint.base)), st->Ist.AbiHint.len, - fold_Expr(env, subst_Expr(env, st->Ist.AbiHint.nia)) + fold_Expr(f_env, subst_Expr(s_env, st->Ist.AbiHint.nia)) ); case Ist_Put: vassert(isIRAtom(st->Ist.Put.data)); return IRStmt_Put( st->Ist.Put.offset, - fold_Expr(env, subst_Expr(env, st->Ist.Put.data)) + fold_Expr(f_env, subst_Expr(s_env, st->Ist.Put.data)) ); case Ist_PutI: { @@ -2641,9 +2654,9 @@ static IRStmt* subst_and_fold_Stmt ( IRExpr** env, IRStmt* st ) vassert(isIRAtom(puti->ix)); vassert(isIRAtom(puti->data)); puti2 = mkIRPutI(puti->descr, - fold_Expr(env, subst_Expr(env, puti->ix)), + fold_Expr(f_env, subst_Expr(s_env, puti->ix)), puti->bias, - fold_Expr(env, subst_Expr(env, puti->data))); + fold_Expr(f_env, subst_Expr(s_env, puti->data))); return IRStmt_PutI(puti2); } @@ -2652,7 +2665,7 @@ static IRStmt* subst_and_fold_Stmt ( IRExpr** env, IRStmt* st ) allowed to be more than just a constant or a tmp. */ return IRStmt_WrTmp( st->Ist.WrTmp.tmp, - fold_Expr(env, subst_Expr(env, st->Ist.WrTmp.data)) + fold_Expr(f_env, subst_Expr(s_env, st->Ist.WrTmp.data)) ); case Ist_Store: @@ -2660,8 +2673,8 @@ static IRStmt* subst_and_fold_Stmt ( IRExpr** env, IRStmt* st ) vassert(isIRAtom(st->Ist.Store.data)); return IRStmt_Store( st->Ist.Store.end, - fold_Expr(env, subst_Expr(env, st->Ist.Store.addr)), - fold_Expr(env, subst_Expr(env, st->Ist.Store.data)) + fold_Expr(f_env, subst_Expr(s_env, st->Ist.Store.addr)), + fold_Expr(f_env, subst_Expr(s_env, st->Ist.Store.data)) ); case Ist_StoreG: { @@ -2669,9 +2682,9 @@ static IRStmt* subst_and_fold_Stmt ( IRExpr** env, IRStmt* st ) vassert(isIRAtom(sg->addr)); vassert(isIRAtom(sg->data)); vassert(isIRAtom(sg->guard)); - IRExpr* faddr = fold_Expr(env, subst_Expr(env, sg->addr)); - IRExpr* fdata = fold_Expr(env, subst_Expr(env, sg->data)); - IRExpr* fguard = fold_Expr(env, subst_Expr(env, sg->guard)); + IRExpr* faddr = fold_Expr(f_env, subst_Expr(s_env, sg->addr)); + IRExpr* fdata = fold_Expr(f_env, subst_Expr(s_env, sg->data)); + IRExpr* fguard = fold_Expr(f_env, subst_Expr(s_env, sg->guard)); if (fguard->tag == Iex_Const) { /* The condition on this store has folded down to a constant. */ vassert(fguard->Iex.Const.con->tag == Ico_U1); @@ -2696,9 +2709,9 @@ static IRStmt* subst_and_fold_Stmt ( IRExpr** env, IRStmt* st ) vassert(isIRAtom(lg->addr)); vassert(isIRAtom(lg->alt)); vassert(isIRAtom(lg->guard)); - IRExpr* faddr = fold_Expr(env, subst_Expr(env, lg->addr)); - IRExpr* falt = fold_Expr(env, subst_Expr(env, lg->alt)); - IRExpr* fguard = fold_Expr(env, subst_Expr(env, lg->guard)); + IRExpr* faddr = fold_Expr(f_env, subst_Expr(s_env, lg->addr)); + IRExpr* falt = fold_Expr(f_env, subst_Expr(s_env, lg->alt)); + IRExpr* fguard = fold_Expr(f_env, subst_Expr(s_env, lg->guard)); if (fguard->tag == Iex_Const) { /* The condition on this load has folded down to a constant. */ vassert(fguard->Iex.Const.con->tag == Ico_U1); @@ -2730,13 +2743,15 @@ static IRStmt* subst_and_fold_Stmt ( IRExpr** env, IRStmt* st ) vassert(isIRAtom(cas->dataLo)); cas2 = mkIRCAS( cas->oldHi, cas->oldLo, cas->end, - fold_Expr(env, subst_Expr(env, cas->addr)), - cas->expdHi ? fold_Expr(env, subst_Expr(env, cas->expdHi)) + fold_Expr(f_env, subst_Expr(s_env, cas->addr)), + cas->expdHi ? fold_Expr(f_env, + subst_Expr(s_env, cas->expdHi)) : NULL, - fold_Expr(env, subst_Expr(env, cas->expdLo)), - cas->dataHi ? fold_Expr(env, subst_Expr(env, cas->dataHi)) + fold_Expr(f_env, subst_Expr(s_env, cas->expdLo)), + cas->dataHi ? fold_Expr(f_env, + subst_Expr(s_env, cas->dataHi)) : NULL, - fold_Expr(env, subst_Expr(env, cas->dataLo)) + fold_Expr(f_env, subst_Expr(s_env, cas->dataLo)) ); return IRStmt_CAS(cas2); } @@ -2748,9 +2763,10 @@ static IRStmt* subst_and_fold_Stmt ( IRExpr** env, IRStmt* st ) return IRStmt_LLSC( st->Ist.LLSC.end, st->Ist.LLSC.result, - fold_Expr(env, subst_Expr(env, st->Ist.LLSC.addr)), + fold_Expr(f_env, subst_Expr(s_env, st->Ist.LLSC.addr)), st->Ist.LLSC.storedata - ? fold_Expr(env, subst_Expr(env, st->Ist.LLSC.storedata)) + ? fold_Expr(f_env, + subst_Expr(s_env, st->Ist.LLSC.storedata)) : NULL ); @@ -2763,15 +2779,15 @@ static IRStmt* subst_and_fold_Stmt ( IRExpr** env, IRStmt* st ) d2->args = shallowCopyIRExprVec(d2->args); if (d2->mFx != Ifx_None) { vassert(isIRAtom(d2->mAddr)); - d2->mAddr = fold_Expr(env, subst_Expr(env, d2->mAddr)); + d2->mAddr = fold_Expr(f_env, subst_Expr(s_env, d2->mAddr)); } vassert(isIRAtom(d2->guard)); - d2->guard = fold_Expr(env, subst_Expr(env, d2->guard)); + d2->guard = fold_Expr(f_env, subst_Expr(s_env, d2->guard)); for (i = 0; d2->args[i]; i++) { IRExpr* arg = d2->args[i]; if (LIKELY(!is_IRExpr_VECRET_or_GSPTR(arg))) { vassert(isIRAtom(arg)); - d2->args[i] = fold_Expr(env, subst_Expr(env, arg)); + d2->args[i] = fold_Expr(f_env, subst_Expr(s_env, arg)); } } return IRStmt_Dirty(d2); @@ -2791,7 +2807,7 @@ static IRStmt* subst_and_fold_Stmt ( IRExpr** env, IRStmt* st ) case Ist_Exit: { IRExpr* fcond; vassert(isIRAtom(st->Ist.Exit.guard)); - fcond = fold_Expr(env, subst_Expr(env, st->Ist.Exit.guard)); + fcond = fold_Expr(f_env, subst_Expr(s_env, st->Ist.Exit.guard)); if (fcond->tag == Iex_Const) { /* Interesting. The condition on this exit has folded down to a constant. */ @@ -2822,7 +2838,8 @@ static IRStmt* subst_and_fold_Stmt ( IRExpr** env, IRStmt* st ) } -static IRSB* cprop_BB_wrk ( IRSB* in, Bool mustRetainNoOps ) +__attribute__((noinline)) +static IRSB* cprop_BB_WRK ( IRSB* in, Bool mustRetainNoOps, Bool doFolding ) { Int i; IRSB* out; @@ -2859,7 +2876,7 @@ static IRSB* cprop_BB_wrk ( IRSB* in, Bool mustRetainNoOps ) /* perhaps st2 is already a no-op? */ if (st2->tag == Ist_NoOp && !mustRetainNoOps) continue; - st2 = subst_and_fold_Stmt( env, st2 ); + st2 = subst_and_maybe_fold_Stmt( doFolding, env, st2 ); /* Deal with some post-folding special cases. */ switch (st2->tag) { @@ -2902,7 +2919,7 @@ static IRSB* cprop_BB_wrk ( IRSB* in, Bool mustRetainNoOps ) IRExpr* guard = lg->guard; if (guard->tag == Iex_Const) { /* The guard has folded to a constant, and that - constant must be 1:I1, since subst_and_fold_Stmt + constant must be 1:I1, since subst_and_maybe_fold_Stmt folds out the case 0:I1 by itself. */ vassert(guard->Iex.Const.con->tag == Ico_U1); vassert(guard->Iex.Const.con->Ico.U1 == True); @@ -2990,7 +3007,7 @@ static IRSB* cprop_BB_wrk ( IRSB* in, Bool mustRetainNoOps ) IRSB* cprop_BB ( IRSB* in ) { - return cprop_BB_wrk(in, /*mustRetainNoOps=*/False); + return cprop_BB_WRK(in, /*mustRetainNoOps=*/False, /*doFolding=*/True); } @@ -6657,23 +6674,18 @@ IRSB* do_iropt_BB( static Int n_expensive = 0; Bool hasGetIorPutI, hasVorFtemps; - IRSB *bb, *bb2; n_total++; - /* First flatten the block out, since all other - phases assume flat code. */ - // FIXME this is no longer necessary, since minimal_iropt should have - // flattened it - bb = flatten_BB ( bb0 ); - - if (iropt_verbose) { - vex_printf("\n========= FLAT\n\n" ); - ppIRSB(bb); - } + /* Flatness: this function assumes that the incoming block is already flat. + That's because all blocks that arrive here should already have been + processed by do_minimal_initial_iropt_BB. And that will have flattened + them out. */ + // FIXME Remove this assertion once the 'grail' machinery seems stable + vassert(isFlatIRSB(bb0)); /* If at level 0, stop now. */ - if (vex_control.iropt_level <= 0) return bb; + if (vex_control.iropt_level <= 0) return bb0; /* Now do a preliminary cleanup pass, and figure out if we also need to do 'expensive' optimisations. Expensive optimisations @@ -6681,7 +6693,8 @@ IRSB* do_iropt_BB( If needed, do expensive transformations and then another cheap cleanup pass. */ - bb = cheap_transformations( bb, specHelper, preciseMemExnsFn, pxControl ); + IRSB* bb = cheap_transformations( bb0, specHelper, + preciseMemExnsFn, pxControl ); if (guest_arch == VexArchARM) { /* Translating Thumb2 code produces a lot of chaff. We have to @@ -6736,7 +6749,7 @@ IRSB* do_iropt_BB( /* Now have a go at unrolling simple (single-BB) loops. If successful, clean up the results as much as possible. */ - bb2 = maybe_loop_unroll_BB( bb, guest_addr ); + IRSB* bb2 = maybe_loop_unroll_BB( bb, guest_addr ); if (bb2) { bb = cheap_transformations( bb2, specHelper, preciseMemExnsFn, pxControl ); @@ -6757,22 +6770,7 @@ IRSB* do_iropt_BB( return bb; } -//static Bool alwaysPrecise ( Int minoff, Int maxoff, -// VexRegisterUpdates pxControl ) -//{ -// return True; -//} - -// FIXME make this as cheap as possible -IRSB* do_minimal_initial_iropt_BB( - IRSB* bb0 - //IRExpr* (*specHelper) (const HChar*, IRExpr**, IRStmt**, Int), - //Bool (*preciseMemExnsFn)(Int,Int,VexRegisterUpdates), - //VexRegisterUpdates pxControl, - //Addr guest_addr, - //VexArch guest_arch - ) -{ +IRSB* do_minimal_initial_iropt_BB(IRSB* bb0) { /* First flatten the block out, since all other phases assume flat code. */ IRSB* bb = flatten_BB ( bb0 ); @@ -6781,9 +6779,12 @@ IRSB* do_minimal_initial_iropt_BB( ppIRSB(bb); } + // Remove redundant GETs redundant_get_removal_BB ( bb ); - bb = cprop_BB_wrk ( bb, /*mustRetainNoOps=*/True ); // FIXME - // This is overkill. We only really want constant prop, not folding + + // Do minimal constant prop: copy prop and constant prop only. No folding. + bb = cprop_BB_WRK ( bb, /*mustRetainNoOps=*/True, + /*doFolding=*/False ); // Minor tidying of the block end, to remove a redundant Put of the IP right // at the end: diff --git a/VEX/pub/libvex_ir.h b/VEX/pub/libvex_ir.h index 9120a49..6a854e4 100644 --- a/VEX/pub/libvex_ir.h +++ b/VEX/pub/libvex_ir.h @@ -2388,7 +2388,7 @@ IRExpr* mkIRExprCCall ( IRType retty, /* Convenience functions for atoms (IRExprs which are either Iex_Tmp or * Iex_Const). */ static inline Bool isIRAtom ( const IRExpr* e ) { - return toBool(e->tag == Iex_RdTmp || e->tag == Iex_Const); + return e->tag == Iex_RdTmp || e->tag == Iex_Const; } /* Are these two IR atoms identical? Causes an assertion @@ -3195,6 +3195,7 @@ extern void sanityCheckIRSB ( const IRSB* bb, Bool require_flatness, IRType guest_word_size ); extern Bool isFlatIRStmt ( const IRStmt* ); +extern Bool isFlatIRSB ( const IRSB* ); /* Is this any value actually in the enumeration 'IRType' ? */ extern Bool isPlausibleIRType ( IRType ty ); |
|
From: Mark W. <ma...@so...> - 2019-11-21 09:40:06
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=132681dc195ea76e7d69010114f06699cd3f917c commit 132681dc195ea76e7d69010114f06699cd3f917c Author: Mark Wielaard <ma...@kl...> Date: Thu Nov 21 10:32:43 2019 +0100 none/tests/arm64/Makefile.am: Add atomics_v81 only conditionally The atomics_v81 was added twice to check_PROGRAMS. It should only be added when BUILD_ARMV81_TESTS is set. Diff: --- none/tests/arm64/Makefile.am | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/none/tests/arm64/Makefile.am b/none/tests/arm64/Makefile.am index 223ecdb..78a5742 100644 --- a/none/tests/arm64/Makefile.am +++ b/none/tests/arm64/Makefile.am @@ -16,8 +16,7 @@ check_PROGRAMS = \ cvtf_imm \ fp_and_simd \ integer \ - memory \ - atomics_v81 + memory if BUILD_ARMV8_CRC_TESTS check_PROGRAMS += crc32 |
|
From: Julian S. <se...@so...> - 2019-11-21 07:57:29
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=67c824937830cf4b45ad83d61efbf1d54175e008 commit 67c824937830cf4b45ad83d61efbf1d54175e008 Author: Julian Seward <js...@ac...> Date: Thu Nov 21 08:55:43 2019 +0100 Add statistics printing for the new trace construction algorithm. Diff: --- VEX/priv/guest_generic_bb_to_IR.c | 6 ++++++ VEX/priv/guest_generic_bb_to_IR.h | 2 ++ VEX/priv/main_main.c | 4 ++++ VEX/pub/libvex.h | 6 ++++++ coregrind/m_translate.c | 17 +++++++++++++++++ 5 files changed, 35 insertions(+) diff --git a/VEX/priv/guest_generic_bb_to_IR.c b/VEX/priv/guest_generic_bb_to_IR.c index 16d83a8..7477641 100644 --- a/VEX/priv/guest_generic_bb_to_IR.c +++ b/VEX/priv/guest_generic_bb_to_IR.c @@ -1209,6 +1209,8 @@ IRSB* bb_to_IR ( /*OUT*/VexGuestExtents* vge, /*OUT*/UInt* n_sc_extents, /*OUT*/UInt* n_guest_instrs, /* stats only */ + /*OUT*/UShort* n_uncond_in_trace, /* stats only */ + /*OUT*/UShort* n_cond_in_trace, /* stats only */ /*MOD*/VexRegisterUpdates* pxControl, /*IN*/ void* callback_opaque, /*IN*/ DisOneInstrFn dis_instr_fn, @@ -1252,6 +1254,8 @@ IRSB* bb_to_IR ( vge->n_used = 0; *n_sc_extents = 0; *n_guest_instrs = 0; + *n_uncond_in_trace = 0; + *n_cond_in_trace = 0; /* And a new IR superblock to dump the result into. */ IRSB* irsb = emptyIRSB(); @@ -1375,6 +1379,7 @@ IRSB* bb_to_IR ( add_extent(vge, bb_base, bb_len); update_instr_budget(&instrs_avail, &verbose_mode, bb_instrs_used, bb_verbose_seen); + *n_uncond_in_trace += 1; } // if (be.tag == Be_Uncond) // Try for an extend based on a conditional branch, specifically in the @@ -1567,6 +1572,7 @@ IRSB* bb_to_IR ( add_extent(vge, sx_base, sx_len); update_instr_budget(&instrs_avail, &verbose_mode, sx_instrs_used, sx_verbose_seen); + *n_cond_in_trace += 1; } break; } // if (be.tag == Be_Cond) diff --git a/VEX/priv/guest_generic_bb_to_IR.h b/VEX/priv/guest_generic_bb_to_IR.h index 08d33ad..cad6768 100644 --- a/VEX/priv/guest_generic_bb_to_IR.h +++ b/VEX/priv/guest_generic_bb_to_IR.h @@ -143,6 +143,8 @@ IRSB* bb_to_IR ( /*OUT*/VexGuestExtents* vge, /*OUT*/UInt* n_sc_extents, /*OUT*/UInt* n_guest_instrs, /* stats only */ + /*OUT*/UShort* n_uncond_in_trace, /* stats only */ + /*OUT*/UShort* n_cond_in_trace, /* stats only */ /*MOD*/VexRegisterUpdates* pxControl, /*IN*/ void* callback_opaque, /*IN*/ DisOneInstrFn dis_instr_fn, diff --git a/VEX/priv/main_main.c b/VEX/priv/main_main.c index 0da2b46..5acab9e 100644 --- a/VEX/priv/main_main.c +++ b/VEX/priv/main_main.c @@ -554,6 +554,8 @@ IRSB* LibVEX_FrontEnd ( /*MOD*/ VexTranslateArgs* vta, res->n_sc_extents = 0; res->offs_profInc = -1; res->n_guest_instrs = 0; + res->n_uncond_in_trace = 0; + res->n_cond_in_trace = 0; #ifndef VEXMULTIARCH /* yet more sanity checks ... */ @@ -581,6 +583,8 @@ IRSB* LibVEX_FrontEnd ( /*MOD*/ VexTranslateArgs* vta, irsb = bb_to_IR ( vta->guest_extents, &res->n_sc_extents, &res->n_guest_instrs, + &res->n_uncond_in_trace, + &res->n_cond_in_trace, pxControl, vta->callback_opaque, disInstrFn, diff --git a/VEX/pub/libvex.h b/VEX/pub/libvex.h index 5a6a0e8..5d3733d 100644 --- a/VEX/pub/libvex.h +++ b/VEX/pub/libvex.h @@ -651,6 +651,12 @@ typedef /* Stats only: the number of guest insns included in the translation. It may be zero (!). */ UInt n_guest_instrs; + /* Stats only: the number of unconditional branches incorporated into the + trace. */ + UShort n_uncond_in_trace; + /* Stats only: the number of conditional branches incorporated into the + trace. */ + UShort n_cond_in_trace; } VexTranslateResult; diff --git a/coregrind/m_translate.c b/coregrind/m_translate.c index ae1cfcd..332202a 100644 --- a/coregrind/m_translate.c +++ b/coregrind/m_translate.c @@ -64,6 +64,11 @@ /*--- Stats ---*/ /*------------------------------------------------------------*/ +static ULong n_TRACE_total_constructed = 0; +static ULong n_TRACE_total_guest_insns = 0; +static ULong n_TRACE_total_uncond_branches_followed = 0; +static ULong n_TRACE_total_cond_branches_followed = 0; + static ULong n_SP_updates_new_fast = 0; static ULong n_SP_updates_new_generic_known = 0; static ULong n_SP_updates_die_fast = 0; @@ -77,6 +82,13 @@ static ULong n_PX_VexRegUpdAllregsAtEachInsn = 0; void VG_(print_translation_stats) ( void ) { + VG_(message) + (Vg_DebugMsg, + "translate: %'llu guest insns, %'llu traces, " + "%'llu uncond chased, %llu cond chased\n", + n_TRACE_total_guest_insns, n_TRACE_total_constructed, + n_TRACE_total_uncond_branches_followed, + n_TRACE_total_cond_branches_followed); UInt n_SP_updates = n_SP_updates_new_fast + n_SP_updates_new_generic_known + n_SP_updates_die_fast + n_SP_updates_die_generic_known + n_SP_updates_generic_unknown; @@ -1819,6 +1831,11 @@ Bool VG_(translate) ( ThreadId tid, vg_assert(tres.n_sc_extents >= 0 && tres.n_sc_extents <= 3); vg_assert(tmpbuf_used <= N_TMPBUF); vg_assert(tmpbuf_used > 0); + + n_TRACE_total_constructed += 1; + n_TRACE_total_guest_insns += tres.n_guest_instrs; + n_TRACE_total_uncond_branches_followed += tres.n_uncond_in_trace; + n_TRACE_total_cond_branches_followed += tres.n_cond_in_trace; } /* END new scope specially for 'seg' */ /* Tell aspacem of all segments that have had translations taken |