Thread overview
[Issue 12503] Bad optimization with scope(success) and return statement
Apr 09, 2014
Kenji Hara
Jul 29, 2014
yebblies
April 09, 2014
https://issues.dlang.org/show_bug.cgi?id=12503

--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> ---
The lowered code generated by front-end will cause same issue.

void fun(string a)
{
    string b = a;
    bool __os1 = false;
    try
    {
        try
        {
            a = null;
            return ;
        }
        catch (Throwable __o2)
        {
            __os1 = true;
            throw __o2;
        }
    }
    finally
    {
        if (!__os1)
            assert(a != b);
    }
}

void main()
{
    fun("foo");
}

It seems to be caused by "copy propagation" in dmd-backed optimizer, done by copyprop() in dmd/src/backend/gopher.c.

--
July 29, 2014
https://issues.dlang.org/show_bug.cgi?id=12503

yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |yebblies@gmail.com
           Assignee|nobody@puremagic.com        |yebblies@gmail.com

--- Comment #2 from yebblies <yebblies@gmail.com> ---
The glue layer sets up the block successors wrong.

https://github.com/D-Programming-Language/dmd/pull/3826

--
August 15, 2014
https://issues.dlang.org/show_bug.cgi?id=12503

github-bugzilla@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--
August 15, 2014
https://issues.dlang.org/show_bug.cgi?id=12503

--- Comment #3 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/ee659d780bcc2b2d6c29c3930cc122ff481e9465 Fix Issue 12503 - Bad optimization with scope(success) and return statement

The current code only lists the finally block as a successor of the return statement when the return directly inside the finally's try block.

https://github.com/D-Programming-Language/dmd/commit/426845f8efa66f85300fad45396666faf57b24e1 Merge pull request #3826 from yebblies/issue12503

Issue 12503 - Bad optimization with scope(success) and return statement

--
August 29, 2014
https://issues.dlang.org/show_bug.cgi?id=12503

--- Comment #4 from github-bugzilla@puremagic.com ---
Commit pushed to 2.066 at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/31d0aa4f61ed1ab051c4b48bee235d5d3d0002c0 Merge pull request #3826 from yebblies/issue12503

Issue 12503 - Bad optimization with scope(success) and return statement

--