[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] [PATCH] tcc: remove buggy nodata_wanted optimization

From: Michael Matz
Subject: Re: [Tinycc-devel] [PATCH] tcc: remove buggy nodata_wanted optimization
Date: Fri, 23 Feb 2018 14:01:47 +0000 (UTC)
User-agent: Alpine 2.21 (LSU 202 2017-01-01)


On Thu, 22 Feb 2018, Mikulas Patocka wrote:

> I think that that nodata_wanted misoptimization should be removed at all 
> - in the C language, you can jump to any location in the function with 
> goto or switch-case statement - thus reasoning such as "all the 
> variables behind if (0) are unreachable" is incorrect.
> If you wanted to do that optimization correctly, you'd need to build 
> control flow graph, and tcc is just too simple to do that.

You're right that as implemented the non-allocation of variables is wrong.  
But a full CFG isn't needed to fix this, the allocation merely needs to be 
postponed to the first real use.  Unfortunately that is somewhat 
complicated when there are initializers (which matter only for static vars 
in this case, but still).

So, yeah, the easy fix is to remove it, but with more work the 
optimization (or parts of it) could be retained, grischka?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]