[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] Largish mob update from me
From: |
Michael Matz |
Subject: |
Re: [Tinycc-devel] Largish mob update from me |
Date: |
Tue, 20 Dec 2016 05:59:37 +0100 (CET) |
User-agent: |
Alpine 2.20 (LSU 67 2015-01-07) |
Hello,
On Sun, 18 Dec 2016, grischka wrote:
Ok, I guess the best we can do to make sure the assert of above
will never trigger is to tell the compiler to optimize it out,
like so:
ST_FUNC void g(int c)
{
int ind1;
if (nocode_wanted)
return;
if (nocode_wanted)
tcc_error("internal: code generated but nocode_wanted");
Yes, that's of course the nicest thing as it's the most aggressive way to
ensure no code is emitted. But I had problems with that that I've not
analyzed further back then.
Why I think this is necessary is because I got some regression wrt.
your improved "expr_land/lor()", and I wondered whether maybe the
code was wrong in itself or in its trust on the underlying nocode
machinery. So to find out I needed a machinery that works ;)
Okay, so I was now forced to indeed analyze the problems (miscompiled
the linux kernel) ;) Result:
http://repo.or.cz/tinycc.git/commitdiff/42e2a67f2
There aren't any if's with (nocode_wanted) in tccgen.c anywhere
anymore, exept the 3 mentioned in the patch, and it I'll be happy
if that can stay so.
Unfortunately I had to add one other place where it checks nocode_wanted
and that's in the ugly dealing with VT_CMP/VT_JMP values in vtop. See
testcases in the above, and my comment included here for
citing/discussing:
+ Don't do this when nocode_wanted. vtop might come from
+ !nocode_wanted regions (see 88_codeopt.c) and transforming
+ it to a register without actually generating code is wrong
+ as their value might still be used for real. All values
+ we push under nocode_wanted will eventually be popped
+ again, so that the VT_CMP/VT_JMP value will be in vtop
+ when code is unsuppressed again. */
+ if (vtop >= vstack && !nocode_wanted) {
v = vtop->r & VT_VALMASK;
if (v == VT_CMP || (v & ~1) == VT_JMP)
gv(RC_INT);
I hope I haven't broken anything that you've fixed with your three
nocode_wanted patches but lacking testcases I can't be sure (hint hint) :)
Ciao,
Michael.
Re: [Tinycc-devel] Largish mob update from me, Thomas Preud'homme, 2016/12/17
Re: [Tinycc-devel] Largish mob update from me, Steffen Nurpmeso, 2016/12/21