@@ -293,24 +293,24 @@ object moreCompleteExhaleSupporter extends SymbolicExecutionRules {
293293 val eq = And (eqHelper)
294294 val eqExp = ch.argsExp.map(args => BigAnd (removeKnownToBeTrueExp(args.zip(argsExp.get).map { case (t1, t2) => ast.EqCmp (t1, t2)(permsExp.get.pos, permsExp.get.info, permsExp.get.errT) }.toList, eqHelper.toList)))
295295
296- val (pTaken, pTakenExp) = if (s.functionRecorder != NoopFunctionRecorder || Verifier .config.useFlyweight) {
296+ val takenTerm = Ite (eq, PermMin (ch.perm, pNeeded), NoPerm )
297+ val pTakenExp = permsExp.map(pe => ast.CondExp (eqExp.get, buildMinExp(Seq (ch.permExp.get, pNeededExp.get), ast.Perm ), ast.NoPerm ()(pe.pos, pe.info, pe.errT))(eqExp.get.pos, eqExp.get.info, eqExp.get.errT))
298+ val pTaken = if (takenTerm.isInstanceOf [PermLiteral ] || s.functionRecorder != NoopFunctionRecorder || Verifier .config.useFlyweight) {
297299 // ME: When using Z3 via API, it is beneficial to not use macros, since macro-terms will *always* be different
298300 // (leading to new terms that have to be translated), whereas without macros, we can usually use a term
299301 // that already exists.
300- // During function verification, we should not define macros, since they could contain resullt , which is not
302+ // During function verification, we should not define macros, since they could contain result , which is not
301303 // defined elsewhere.
302- val iteExp = permsExp.map(pe => ast. CondExp (eqExp.get, buildMinExp( Seq (ch.permExp.get, pNeededExp.get), ast. Perm ), ast. NoPerm ()(pe.pos, pe.info, pe.errT))(eqExp.get.pos, eqExp.get.info, eqExp.get.errT))
303- ( Ite (eq, PermMin (ch.perm, pNeeded), NoPerm ), iteExp)
304+ // Also, we don't introduce a macro if the term is a straightforward literal.
305+ takenTerm
304306 } else {
305- val pTakenBody = Ite (eq, PermMin (ch.perm, pNeeded), NoPerm )
306- val pTakenExp = eqExp.map(eq => ast.CondExp (eq, buildMinExp(Seq (ch.permExp.get, pNeededExp.get), ast.Perm ), ast.NoPerm ()())(eq.pos, eq.info, eq.errT))
307307 val pTakenArgs = additionalArgs
308- val pTakenDecl = v.decider.freshMacro(" mce_pTaken" , pTakenArgs, pTakenBody )
308+ val pTakenDecl = v.decider.freshMacro(" mce_pTaken" , pTakenArgs, takenTerm )
309309 val pTakenMacro = Macro (pTakenDecl.id, pTakenDecl.args.map(_.sort), pTakenDecl.body.sort)
310310 currentFunctionRecorder = currentFunctionRecorder.recordFreshMacro(pTakenDecl)
311311 val pTakenApp = App (pTakenMacro, pTakenArgs)
312- v.symbExLog.addMacro(pTakenApp, pTakenBody )
313- ( pTakenApp, pTakenExp)
312+ v.symbExLog.addMacro(pTakenApp, takenTerm )
313+ pTakenApp
314314 }
315315
316316 pSum = PermPlus (pSum, Ite (eq, ch.perm, NoPerm ))
0 commit comments