Skip to content

Commit d77ff3e

Browse files
committed
[MERGE #5964 @wyrichte] LinearScan::InsertSecondChanceCompensation does not always restore a register saved to the stack at the beginning of a loop.
Merge pull request #5964 from wyrichte:build/wyrichte/regalloc_bug_2 More specifically, the root cause of this issue is that the inner loop of a nested for loop's liveOnBackEdgeSyms would not be populated with a symbol due to DeadStoreOrChangeInstrForScopeObjRemoval not executing during DeadStore's prepass.
2 parents 9eb3b36 + 0823413 commit d77ff3e

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

lib/Backend/BackwardPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4032,7 +4032,7 @@ BackwardPass::DeadStoreOrChangeInstrForScopeObjRemoval(IR::Instr ** pInstrPrev)
40324032
IR::Instr * instr = this->currentInstr;
40334033
Func * currFunc = instr->m_func;
40344034

4035-
if (this->tag == Js::DeadStorePhase && instr->m_func->IsStackArgsEnabled() && !IsPrePass())
4035+
if (this->tag == Js::DeadStorePhase && instr->m_func->IsStackArgsEnabled() && (IsPrePass() || !currentBlock->loop))
40364036
{
40374037
switch (instr->m_opcode)
40384038
{

test/RegAlloc/RegAllocBug_0.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
6+
function f() {
7+
var o_0 = {};
8+
var o_1 = {};
9+
var o_2 = {};
10+
var arr_0 = Array();
11+
o_0.length = 1;
12+
for (var i = 0; i < 2; i++) {
13+
Object.defineProperty(o_2, '', {});
14+
function g(arr_1) {
15+
for (var j = 0; j < 3; j++) {
16+
arr_1[0] = arr_0;
17+
var a = 3, k = 3;
18+
for (; o_0.length * 1214425553.2;
19+
k -= 4) {
20+
a -= 2;
21+
if (a < -5) {
22+
break;
23+
}
24+
if (false) {
25+
b = c;
26+
arguments;
27+
}
28+
}
29+
}
30+
}
31+
g(o_1);
32+
o_2 = o_0;
33+
}
34+
}
35+
f();
36+
print("pass");

test/RegAlloc/rlexe.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<regress-exe>
3+
<test>
4+
<default>
5+
<files>RegAllocBug_0.js</files>
6+
<compile-flags>-mic:1 -off:simplejit</compile-flags>
7+
</default>
8+
</test>
9+
</regress-exe>

test/rlexedirs.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@
154154
<files>Prototypes</files>
155155
</default>
156156
</dir>
157+
<dir>
158+
<default>
159+
<files>RegAlloc</files>
160+
</default>
161+
</dir>
157162
<dir>
158163
<default>
159164
<files>GlobalFunctions</files>

0 commit comments

Comments
 (0)