Skip to content

Commit 356ff54

Browse files
committed
Disable matching of several patterns in CFG Simplification
Several patterns and corresponding transformations in CFG Simplification have never been fully tested - in particular, simplifyNullToException, simplifySimpleStore, simplifyCondStoreSequence, simplifyInstanceOfTestToCheckcast and simplifyBoundCheckWithThrowException. This change disables those transformations by default, allowing them to be enabled based on the settings of various environment variables. The intention is that they should be more thoroughly tested and then reenabled as that testing and any necessary bug fixes have been completed. This change also fixes some typos in trace messages and changes the declarations of some pointers that hold the results of calls to feGetEnv from 'static char *' to 'static const char *' to emphasize that the strings pointed to will not change. Signed-off-by: Henry Zongaro <zongaro@ca.ibm.com>
1 parent 7783991 commit 356ff54

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

compiler/optimizer/OMRCFGSimplifier.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ bool OMR::CFGSimplifier::simplify()
128128

129129
bool OMR::CFGSimplifier::simplifyIfStructure()
130130
{
131-
logprintf(trace(), comp()->log(), "Attempting if simpliciaton on block_%d\n", _block->getNumber());
131+
logprintf(trace(), comp()->log(), "Attempting if simplification on block_%d\n", _block->getNumber());
132132
// There must be exactly two successors, and they must be real blocks
133133
//
134134
if (_next1 == NULL || _next2 == NULL)
@@ -198,8 +198,9 @@ bool OMR::CFGSimplifier::hasExceptionPoint(TR::Block *block, TR::TreeTop *end)
198198

199199
bool OMR::CFGSimplifier::simplifyInstanceOfTestToCheckcast(bool needToDuplicateTree)
200200
{
201-
static char *disableSimplifyInstanceOfTestToCheckcast = feGetEnv("TR_disableSimplifyInstanceOfTestToCheckcast");
202-
if (disableSimplifyInstanceOfTestToCheckcast != NULL)
201+
static const char *enableSimplifyInstanceOfTestToCheckcast = feGetEnv("TR_enableSimplifyInstanceOfTestToCheckcast");
202+
203+
if (enableSimplifyInstanceOfTestToCheckcast == NULL)
203204
return false;
204205

205206
if (comp()->getOSRMode() == TR::involuntaryOSR)
@@ -359,7 +360,7 @@ bool OMR::CFGSimplifier::simplifyInstanceOfTestToCheckcast(bool needToDuplicateT
359360
//
360361
//
361362
// Simplification:
362-
// BNDCHK (i, length) ----(exp edge) ------
363+
// BNDCHK (length, i) ----(exp edge) ------
363364
// | |
364365
// return |
365366
// |
@@ -369,7 +370,7 @@ bool OMR::CFGSimplifier::simplifyInstanceOfTestToCheckcast(bool needToDuplicateT
369370
// Or,
370371
//
371372
// Simplification:
372-
// BNDCHK (i, length) ----(exp edge) ------
373+
// BNDCHK (length, i) ----(exp edge) ------
373374
// | |
374375
// goto ================= |
375376
// | |
@@ -383,9 +384,10 @@ bool OMR::CFGSimplifier::simplifyInstanceOfTestToCheckcast(bool needToDuplicateT
383384
//
384385
bool OMR::CFGSimplifier::simplifyBoundCheckWithThrowException(bool needToDuplicateTree)
385386
{
386-
static char *disableSimplifyBoundCheckWithThrowException
387-
= feGetEnv("TR_disableSimplifyBoundCheckWithThrowException");
388-
if (disableSimplifyBoundCheckWithThrowException != NULL)
387+
static const char *enableSimplifyBoundCheckWithThrowException
388+
= feGetEnv("TR_enableSimplifyBoundCheckWithThrowException");
389+
390+
if (enableSimplifyBoundCheckWithThrowException == NULL)
389391
return false;
390392

391393
OMR::Logger *log = comp()->log();
@@ -642,7 +644,7 @@ static bool containsIndirectOperation(TR::Compilation *comp, TR::TreeTop *treeto
642644

643645
bool OMR::CFGSimplifier::simplifyCondStoreSequence(bool needToDuplicateTree)
644646
{
645-
static char *enableSimplifyCondStoreSequence = feGetEnv("TR_enableSimplifyCondStoreSequence");
647+
static const char *enableSimplifyCondStoreSequence = feGetEnv("TR_enableSimplifyCondStoreSequence");
646648
if (enableSimplifyCondStoreSequence == NULL)
647649
return false;
648650

@@ -750,7 +752,7 @@ bool OMR::CFGSimplifier::simplifyCondStoreSequence(bool needToDuplicateTree)
750752

751753
bool OMR::CFGSimplifier::simplifySimpleStore(bool needToDuplicateTree)
752754
{
753-
static char *enableSimplifySimpleStore = feGetEnv("TR_enableSimplifySimpleStore");
755+
static const char *enableSimplifySimpleStore = feGetEnv("TR_enableSimplifySimpleStore");
754756
if (enableSimplifySimpleStore == NULL)
755757
return false;
756758

@@ -774,11 +776,11 @@ bool OMR::CFGSimplifier::simplifySimpleStore(bool needToDuplicateTree)
774776
logprintf(trace(), log, " block%d triangle1: %d triangle2: %d diamond: %d\n", _block->getNumber(), triangle1,
775777
triangle2, diamond);
776778

777-
static char *disableSimplifySimpleStoreTriangle = feGetEnv("TR_disableSimplifySimpleStoreTriangle");
779+
static const char *disableSimplifySimpleStoreTriangle = feGetEnv("TR_disableSimplifySimpleStoreTriangle");
778780
if ((triangle1 || triangle2) && disableSimplifySimpleStoreTriangle != NULL)
779781
return false;
780782

781-
static char *disableSimplifySimpleStoreDiamond = feGetEnv("TR_disableSimplifySimpleStoreDiamond");
783+
static const char *disableSimplifySimpleStoreDiamond = feGetEnv("TR_disableSimplifySimpleStoreDiamond");
782784
if ((diamond) && disableSimplifySimpleStoreDiamond != NULL)
783785
return false;
784786

@@ -917,9 +919,9 @@ bool OMR::CFGSimplifier::simplifySimpleStore(bool needToDuplicateTree)
917919

918920
bool OMR::CFGSimplifier::simplifyNullToException(bool needToDuplicateTree)
919921
{
920-
static char *disableSimplifyExplicitNULLTest = feGetEnv("TR_disableSimplifyExplicitNULLTest");
921-
static char *disableSimplifyNullToException = feGetEnv("TR_disableSimplifyNullToException");
922-
if (disableSimplifyExplicitNULLTest != NULL || disableSimplifyNullToException != NULL)
922+
static const char *enableSimplifyExplicitNULLTest = feGetEnv("TR_enableSimplifyExplicitNULLTest");
923+
static const char *enableSimplifyNullToException = feGetEnv("TR_enableSimplifyNullToException");
924+
if (enableSimplifyExplicitNULLTest == NULL || enableSimplifyNullToException == NULL)
923925
return false;
924926

925927
if (comp()->getOSRMode() == TR::involuntaryOSR)
@@ -951,7 +953,7 @@ bool OMR::CFGSimplifier::simplifyNullToException(bool needToDuplicateTree)
951953
return false;
952954

953955
if (!performTransformation(comp(),
954-
"%sReplace ifacmpeq/ifacmpne of NULL node n%dn [%p] to a blcok ending in throw with a NULLCHK to a catch "
956+
"%sReplace ifacmpeq/ifacmpne of NULL node n%dn [%p] to a block ending in throw with a NULLCHK to a catch "
955957
"which goes to block_%d\n",
956958
OPT_DETAILS, compareNode->getGlobalIndex(), compareNode, nullBlock->getNumber()))
957959
return false;

0 commit comments

Comments
 (0)