Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not Copy-Propagate static variables #11238

Merged
merged 1 commit into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/dmd/backend/gflow.d
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ private void aecpgenkill(ref GlobalOptimizer go, int flowxx)
n.EV.E1.Eoper == OPvar &&
n.EV.E2.Eoper == OPvar &&
!((n.EV.E1.Ety | n.EV.E2.Ety) & (mTYvolatile | mTYshared)) &&
!((n.EV.E1.EV.Vsym.Sflags | n.EV.E2.EV.Vsym.Sflags) & SFLlivexit) &&
n.EV.E1.EV.Vsym != n.EV.E2.EV.Vsym)
{
n.Nflags |= NFLaecp;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so NFLaecp stands for NFlags.AssignExp CopyPropagration?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was removed by un-merged PR #11098

Expand Down
20 changes: 20 additions & 0 deletions test/runnable/mars1.d
Original file line number Diff line number Diff line change
Expand Up @@ -1959,6 +1959,25 @@ void test20050()

////////////////////////////////////////////////////////////////////////

// http://github.com/dlang/dmd/pull/11238

int testCpStatic1(int y)
{
__gshared int yyy = 7;
auto x = yyy; // no copy-propagation
if (y)
return x;
return x + 3;
}

void testCpStatic()
{
assert(testCpStatic1(1) == 7);
assert(testCpStatic1(0) == 10);
}

////////////////////////////////////////////////////////////////////////

int main()
{
testgoto();
Expand Down Expand Up @@ -2029,6 +2048,7 @@ int main()
testfastpar();
testNegConst();
test20050();
testCpStatic();

printf("Success\n");
return 0;
Expand Down