Skip to content

Commit 4180259

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 <[email protected]>
1 parent b2a4e64 commit 4180259

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

compiler/optimizer/OMRCFGSimplifier.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,16 +1150,6 @@ bool OMR::CFGSimplifier::simplifyBooleanStore(bool needToDuplicateTree)
11501150
if (trace())
11511151
traceMsg(comp(), " Successor block_%d is single store\n", _next2->getNumber());
11521152

1153-
// Store values cannot be internal pointers
1154-
//
1155-
int32_t valueIndex = store1->getOpCode().isIndirect() ? 1 : 0;
1156-
TR::Node *value1 = store1->getChild(valueIndex);
1157-
TR::Node *value2 = store2->getChild(valueIndex);
1158-
if (value1->isInternalPointer() || value2->isInternalPointer())
1159-
return false;
1160-
if (trace())
1161-
traceMsg(comp(), " Store values are not internal pointers\n");
1162-
11631153
// The stores must be integer stores to the same variable
11641154
//
11651155
if (store1->getOpCodeValue() != store2->getOpCodeValue())
@@ -1171,6 +1161,17 @@ bool OMR::CFGSimplifier::simplifyBooleanStore(bool needToDuplicateTree)
11711161
if (trace())
11721162
traceMsg(comp(), " Store nodes opcode and symref checks out\n");
11731163

1164+
// Store values cannot be internal pointers
1165+
//
1166+
int32_t valueIndex = store1->getOpCode().isIndirect() ? 1 : 0;
1167+
TR::Node *value1 = store1->getChild(valueIndex);
1168+
TR::Node *value2 = store2->getChild(valueIndex);
1169+
if (value1->isInternalPointer() || value2->isInternalPointer())
1170+
return false;
1171+
if (trace())
1172+
traceMsg(comp(), " Store values are not internal pointers\n");
1173+
1174+
11741175
// Indirect stores must have the same base
11751176
//
11761177
if (valueIndex == 1) // indirect store, check base objects

0 commit comments

Comments
 (0)