mbox series

[0/4] tcg: Remove unreachable code

Message ID 20181126230450.672-1-richard.henderson@linaro.org
Headers show
Series tcg: Remove unreachable code | expand

Message

Richard Henderson Nov. 26, 2018, 11:04 p.m. UTC
I've been meaning to add a trivial cleanup pass like this for some time.

There have occasionally been instaces within front ends wherein we want
to raise an invalid operand exception (or some such) deep within a set
of subroutines.  And without a longjmp (or some such) back to the top
level of the translator loop we must return a dummy value so that we
produce valid tcg code following the exception.

While we still probably have to return a dummy value, we can clean up
the dead code that follows the exception.

In addition, when optimization is able to fold a conditional branch,
the original code sequence:

	brcond x,y,$L1
	goto_tb
	mov pc,foo
	exit_tb $1
        set_label $L1
        goto_tb 
        mov pc,bar
        exit_tb $2

The initial brcond is either folded to br, or removed as a never taken
branch, which leaves one of the two sets of goto_tb ... exit_tb unreachable.

With this we can completely remove the code for the dead branch.

While I do not expect this to have any noticable effect, this dead
code could get in the way of some other changes that I'm planning.


r~


Richard Henderson (4):
  tcg: Renumber TCG_CALL_* flags
  tcg: Add TCG_CALL_NO_RETURN
  tcg: Reference count labels
  tcg: Add reachable_code_pass

 include/exec/helper-head.h | 13 ++++++
 include/exec/helper-tcg.h  | 21 ++++++---
 tcg/tcg-op.h               |  1 +
 tcg/tcg.h                  | 11 +++--
 tcg/tcg-op.c               |  2 +
 tcg/tcg.c                  | 96 ++++++++++++++++++++++++++++++++++++++
 6 files changed, 133 insertions(+), 11 deletions(-)

-- 
2.17.2

Comments

no-reply@patchew.org Nov. 28, 2018, 3:27 p.m. UTC | #1
Hi,

This series seems to have some coding style problems. See output below for
more information:

Message-id: 20181126230450.672-1-richard.henderson@linaro.org
Subject: [Qemu-devel] [PATCH 0/4] tcg: Remove unreachable code
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]         patchew/20181128.181700.1038782556965887223.atsushi.nemoto@sord.co.jp -> patchew/20181128.181700.1038782556965887223.atsushi.nemoto@sord.co.jp
Switched to a new branch 'test'
f76b3bd tcg: Add reachable_code_pass
81bb184 tcg: Reference count labels
5599b43 tcg: Add TCG_CALL_NO_RETURN
d27ec83 tcg: Renumber TCG_CALL_* flags

=== OUTPUT BEGIN ===
Checking PATCH 1/4: tcg: Renumber TCG_CALL_* flags...
Checking PATCH 2/4: tcg: Add TCG_CALL_NO_RETURN...
Checking PATCH 3/4: tcg: Reference count labels...
ERROR: spaces prohibited around that ':' (ctx:WxW)
#83: FILE: tcg/tcg.h:249:
+    unsigned id : 15;
                 ^

ERROR: spaces prohibited around that ':' (ctx:WxW)
#84: FILE: tcg/tcg.h:250:
+    unsigned refs : 16;
                   ^

total: 2 errors, 0 warnings, 56 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 4/4: tcg: Add reachable_code_pass...
=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@redhat.com