@@ -2075,20 +2075,37 @@ OperationLegalizer::legalize(Operation *op,
20752075
20762076 auto &logger = rewriter.getImpl ().logger ;
20772077#endif
2078+
2079+ // Check to see if the operation is ignored and doesn't need to be converted.
2080+ bool isIgnored = rewriter.getImpl ().isOpIgnored (op);
2081+
20782082 LLVM_DEBUG ({
20792083 logger.getOStream () << " \n " ;
20802084 logger.startLine () << logLineComment;
2081- logger.startLine () << " Legalizing operation : '" << op->getName () << " '("
2082- << op << " ) {\n " ;
2085+ logger.startLine () << " Legalizing operation : " ;
2086+ // Do not print the operation name if the operation is ignored. Ignored ops
2087+ // may have been erased and should not be accessed. The pointer can be
2088+ // printed safely.
2089+ if (!isIgnored)
2090+ logger.getOStream () << " '" << op->getName () << " ' " ;
2091+ logger.getOStream () << " (" << op << " ) {\n " ;
20832092 logger.indent ();
20842093
20852094 // If the operation has no regions, just print it here.
2086- if (op->getNumRegions () == 0 ) {
2095+ if (!isIgnored && op->getNumRegions () == 0 ) {
20872096 op->print (logger.startLine (), OpPrintingFlags ().printGenericOpForm ());
20882097 logger.getOStream () << " \n\n " ;
20892098 }
20902099 });
20912100
2101+ if (isIgnored) {
2102+ LLVM_DEBUG ({
2103+ logSuccess (logger, " operation marked 'ignored' during conversion" );
2104+ logger.startLine () << logLineComment;
2105+ });
2106+ return success ();
2107+ }
2108+
20922109 // Check if this operation is legal on the target.
20932110 if (auto legalityInfo = target.isLegal (op)) {
20942111 LLVM_DEBUG ({
@@ -2112,15 +2129,6 @@ OperationLegalizer::legalize(Operation *op,
21122129 return success ();
21132130 }
21142131
2115- // Check to see if the operation is ignored and doesn't need to be converted.
2116- if (rewriter.getImpl ().isOpIgnored (op)) {
2117- LLVM_DEBUG ({
2118- logSuccess (logger, " operation marked 'ignored' during conversion" );
2119- logger.startLine () << logLineComment;
2120- });
2121- return success ();
2122- }
2123-
21242132 // If the operation isn't legal, try to fold it in-place.
21252133 // TODO: Should we always try to do this, even if the op is
21262134 // already legal?
0 commit comments