Skip to content

Add option -Yno-patmat-opt to disable pm optimizations #2848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class ScalaSettings extends Settings.SettingGroup {
val Yheartbeat = BooleanSetting("-Yheartbeat", "show heartbeat stack trace of compiler operations.")
val Yprintpos = BooleanSetting("-Yprintpos", "show tree positions.")
val YnoDeepSubtypes = BooleanSetting("-Yno-deep-subtypes", "throw an exception on deep subtyping call stacks.")
val YnoPatmatOpt = BooleanSetting("-Yno-patmat-opt", "disable all pattern matching optimizations.")
val YplainPrinter = BooleanSetting("-Yplain-printer", "Pretty-print using a plain printer.")
val YprintSyms = BooleanSetting("-Yprint-syms", "when printing trees print info in symbols instead of corresponding info in trees.")
val YprintDebug = BooleanSetting("-Yprint-debug", "when printing trees, print some extra information useful for debugging.")
Expand Down
21 changes: 11 additions & 10 deletions compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -687,12 +687,12 @@ object PatternMatcher {
val refCount = varRefCount(plan)
val LetPlan(topSym, _) = plan

def toDrop(sym: Symbol) =
initializer.contains(sym) &&
isPatmatGenerated(sym) &&
refCount(sym) <= 1 &&
sym != topSym &&
isPureExpr(initializer(sym))
def toDrop(sym: Symbol) = initializer.get(sym) match {
case Some(rhs) =>
isPatmatGenerated(sym) && refCount(sym) <= 1 && sym != topSym && isPureExpr(rhs)
case none =>
false
}

object Inliner extends PlanTransform {
override val treeMap = new TreeMap {
Expand Down Expand Up @@ -924,10 +924,11 @@ object PatternMatcher {
def translateMatch(tree: Match): Tree = {
var plan = matchPlan(tree)
patmatch.println(i"Plan for $tree: ${show(plan)}")
for ((title, optimization) <- optimizations) {
plan = optimization(plan)
patmatch.println(s"After $title: ${show(plan)}")
}
if (!ctx.settings.YnoPatmatOpt.value)
for ((title, optimization) <- optimizations) {
plan = optimization(plan)
patmatch.println(s"After $title: ${show(plan)}")
}
val result = emit(plan)
checkSwitch(tree, result)
result
Expand Down