@@ -707,6 +707,8 @@ void SwiftPassInvocation::eraseInstruction(SILInstruction *inst) {
707707 }
708708}
709709
710+ // cond_fail removal based on cond_fail message and containing function name.
711+ //
710712// The standard library uses _precondition calls which have a message argument.
711713//
712714// Allow disabling the generated cond_fail by these message arguments.
@@ -728,6 +730,10 @@ void SwiftPassInvocation::eraseInstruction(SILInstruction *inst) {
728730//
729731// The optimizer will remove these cond_fails if the swift frontend is invoked
730732// with -Xllvm -cond-fail-config-file=/path/to/disable_cond_fails.
733+ //
734+ // Additionally, also interpret the lines as function names and check whether
735+ // the current cond_fail is contained in a listed function when considering
736+ // whether to remove it.
731737static llvm::cl::opt<std::string> CondFailConfigFile (
732738 " cond-fail-config-file" , llvm::cl::init(" " ),
733739 llvm::cl::desc(" read the cond_fail message strings to elimimate from file" ));
@@ -750,6 +756,13 @@ bool SILCombiner::shouldRemoveCondFail(CondFailInst &CFI) {
750756 }
751757 fs.close ();
752758 }
759+ // Check whether the cond_fail's containing function was listed in the config
760+ // file.
761+ if (CondFailsToRemove.find (CFI.getFunction ()->getName ().str ()) !=
762+ CondFailsToRemove.end ())
763+ return true ;
764+
765+ // Check whether the cond_fail's message was listed in the config file.
753766 auto message = CFI.getMessage ();
754767 return CondFailsToRemove.find (message.str ()) != CondFailsToRemove.end ();
755768}
0 commit comments