Skip to content

Commit d6b795c

Browse files
committed
Ensure isInternalPointer can be called for both store nodes
The simplifyBooleanStore method of CFG Simplifier tries to determine whether two stores in different blocks update the same location based on a boolean condition. One of the conditions considers whether either store is storing an internal pointer. However, the code only tested whether the first of the two stores was indirect before deciding whether the first child or second child of both stores needed to have its isInternalPointer flag tested. If the first store was indirect, but the second was direct, that would result in a non-existent second child of the second store being accessed. Similarly, if the first store was direct, but the second was indirect, the first child of the second store would be accessed, rather than the child representing the value to be stored. This change fixes this problem by moving the code that performs these tests after a test of whether the two stores use the same opcode value. At that point, the stores must both be direct stores or both be indirect stores, so the same child index of each will need to have its isInternalPointer flag tested. Signed-off-by: Henry Zongaro <zongaro@ca.ibm.com>
1 parent b5b6582 commit d6b795c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

compiler/optimizer/OMRCFGSimplifier.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,15 +1107,6 @@ bool OMR::CFGSimplifier::simplifyBooleanStore(bool needToDuplicateTree)
11071107
return false;
11081108
logprintf(trace(), log, " Successor block_%d is single store\n", _next2->getNumber());
11091109

1110-
// Store values cannot be internal pointers
1111-
//
1112-
int32_t valueIndex = store1->getOpCode().isIndirect() ? 1 : 0;
1113-
TR::Node *value1 = store1->getChild(valueIndex);
1114-
TR::Node *value2 = store2->getChild(valueIndex);
1115-
if (value1->isInternalPointer() || value2->isInternalPointer())
1116-
return false;
1117-
logprints(trace(), log, " Store values are not internal pointers\n");
1118-
11191110
// The stores must be integer stores to the same variable
11201111
//
11211112
if (store1->getOpCodeValue() != store2->getOpCodeValue())
@@ -1126,6 +1117,15 @@ bool OMR::CFGSimplifier::simplifyBooleanStore(bool needToDuplicateTree)
11261117
return false;
11271118
logprints(trace(), log, " Store nodes opcode and symref checks out\n");
11281119

1120+
// Store values cannot be internal pointers
1121+
//
1122+
int32_t valueIndex = store1->getOpCode().isIndirect() ? 1 : 0;
1123+
TR::Node *value1 = store1->getChild(valueIndex);
1124+
TR::Node *value2 = store2->getChild(valueIndex);
1125+
if (value1->isInternalPointer() || value2->isInternalPointer())
1126+
return false;
1127+
logprints(trace(), log, " Store values are not internal pointers\n");
1128+
11291129
// Indirect stores must have the same base
11301130
//
11311131
if (valueIndex == 1) // indirect store, check base objects

0 commit comments

Comments
 (0)