Skip to content

Commit cd87823

Browse files
committed
Warn when combining settings for the old optimizer with -YGenBCode
Remove some unnecessary flags files - neg/t4425.flags - run/blame_eye_triple_eee-double.flags - run/blame_eye_triple_eee-float.flags Force tests that use -optimize to GenASM - neg/sealed-final-neg.flags - pos/inline-access-levels.flags - pos/inliner2.flags - pos/sealed-final.flags - pos/t3420.flags - pos/t8410.flags - run/constant-optimization.flags - run/dead-code-elimination.flags - run/elidable-opt.flags - run/finalvar.flags - run/icode-reader-dead-code.scala - run/optimizer-array-load.flags - run/synchronized.flags - run/t3509.flags - run/t3569.flags - run/t4285.flags - run/t4935.flags - run/t5789.scala - run/t6188.flags - run/t7459b-optimize.flags - run/t7582.flags - run/t7582b.flags - run/t8601.flags - run/t8601b.flags - run/t8601c.flags - run/t8601d.flags - run/t8601e.flags - run/t9003.flags Move some tests to the new optimizer - run/classfile-format-51.scala - run/classfile-format-52.scala - run/run-bug4840.flags - run/t2106.flags - run/t6102.flags
1 parent c07442d commit cd87823

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+64
-83
lines changed

src/compiler/scala/tools/nsc/Global.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
13731373
unitbuf += unit
13741374
compiledFiles += unit.source.file.path
13751375
}
1376-
private def checkDeprecatedSettings(unit: CompilationUnit) {
1376+
private def warnDeprecatedAndConflictingSettings(unit: CompilationUnit) {
13771377
// issue warnings for any usage of deprecated settings
13781378
settings.userSetSettings filter (_.isDeprecated) foreach { s =>
13791379
currentRun.reporting.deprecationWarning(NoPosition, s.name + " is deprecated: " + s.deprecationMessage.get)
@@ -1383,6 +1383,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
13831383
currentRun.reporting.deprecationWarning(NoPosition, settings.target.name + ":" + settings.target.value + " is deprecated and has no effect, setting to " + supportedTarget)
13841384
settings.target.value = supportedTarget
13851385
}
1386+
settings.conflictWarning.foreach(reporter.warning(NoPosition, _))
13861387
}
13871388

13881389
/* An iterator returning all the units being compiled in this run */
@@ -1473,7 +1474,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
14731474
def compileSources(sources: List[SourceFile]) = if (!reporter.hasErrors) {
14741475

14751476
def checkDeprecations() = {
1476-
checkDeprecatedSettings(newCompilationUnit(""))
1477+
warnDeprecatedAndConflictingSettings(newCompilationUnit(""))
14771478
reporting.summarizeErrors()
14781479
}
14791480

@@ -1495,7 +1496,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
14951496
val startTime = currentTime
14961497

14971498
reporter.reset()
1498-
checkDeprecatedSettings(unitbuf.head)
1499+
warnDeprecatedAndConflictingSettings(unitbuf.head)
14991500
globalPhase = fromPhase
15001501

15011502
while (globalPhase.hasNext && !reporter.hasErrors) {

src/compiler/scala/tools/nsc/settings/ScalaSettings.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,23 @@ trait ScalaSettings extends AbsScalaSettings
388388
val Normal = "normal"
389389
val Discard = "discard"
390390
}
391+
392+
def conflictWarning: Option[String] = {
393+
def oldOptimiseFlagsInGenBCode: Option[String] = {
394+
val optFlags: List[Setting] = if (optimise.value) List(optimise) else optimiseSettings.filter(_.value)
395+
if (isBCodeActive && optFlags.nonEmpty) {
396+
val msg = s"""Compiler settings for the 2.11 optimizer (${optFlags.map(_.name).mkString(", ")}) are incompatible with -Ybackend:GenBCode (which is the default in 2.12).
397+
|The optimizer settings are ignored. See -Yopt:help for enabling the new optimizer in 2.12.""".stripMargin
398+
Some(msg)
399+
} else
400+
None
401+
}
402+
403+
List(oldOptimiseFlagsInGenBCode /*, moreToCome */).flatten match {
404+
case Nil => None
405+
case warnings => Some("Conflicting compiler settings were detected. Some settings will be ignored.\n" + warnings.mkString("\n"))
406+
}
407+
}
391408
}
392409

393410
object ClassPathRepresentationType {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
warning: Conflicting compiler settings were detected. Some settings will be ignored.
2+
Compiler settings for the 2.11 optimizer (-optimise) are incompatible with -Ybackend:GenBCode (which is the default in 2.12).
3+
The optimizer settings are ignored. See -Yopt:help for enabling the new optimizer in 2.12.
4+
error: No warnings can be incurred under -Xfatal-warnings.
5+
one warning found
6+
one error found
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-optimise -Ybackend:GenBCode -Xfatal-warnings
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
class C

test/files/neg/sealed-final-neg.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-Xfatal-warnings -Yinline-warnings -optimise
1+
-Xfatal-warnings -Ybackend:GenASM -Yinline-warnings -optimise

test/files/neg/t4425.flags

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimise -Xfatal-warnings -Yinline-warnings
1+
-optimise -Ybackend:GenASM -Xfatal-warnings -Yinline-warnings

test/files/pos/inliner2.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimise -Xfatal-warnings
1+
-optimise -Ybackend:GenASM -Xfatal-warnings

test/files/pos/sealed-final.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-Xfatal-warnings -Yinline-warnings -optimise
1+
-Xfatal-warnings -Yinline-warnings -Ybackend:GenASM -optimise

test/files/pos/t3420.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimise -Xfatal-warnings
1+
-optimise -Ybackend:GenASM -Xfatal-warnings

test/files/pos/t8410.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimise -Xfatal-warnings -deprecation:false -Yinline-warnings:false
1+
-optimise -Ybackend:GenASM -Xfatal-warnings -deprecation:false -Yinline-warnings:false

test/files/run/blame_eye_triple_eee-double.flags

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/files/run/blame_eye_triple_eee-float.flags

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/files/run/classfile-format-51.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Opcodes._
1616
// verify. So the test includes a version check that short-circuites the whole test
1717
// on JDK 6
1818
object Test extends DirectTest {
19-
override def extraSettings: String = "-optimise -usejavacp -d " + testOutput.path + " -cp " + testOutput.path
19+
override def extraSettings: String = "-Yopt:l:classpath -usejavacp -d " + testOutput.path + " -cp " + testOutput.path
2020

2121
def generateClass() {
2222
val invokerClassName = "DynamicInvoker"

test/files/run/classfile-format-52.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Opcodes._
1313
// By its nature the test can only work on JDK 8+ because under JDK 7- the
1414
// interface won't verify.
1515
object Test extends DirectTest {
16-
override def extraSettings: String = "-optimise -usejavacp -d " + testOutput.path + " -cp " + testOutput.path
16+
override def extraSettings: String = "-Yopt:l:classpath -usejavacp -d " + testOutput.path + " -cp " + testOutput.path
1717

1818
def generateInterface() {
1919
val interfaceName = "HasDefaultMethod"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimise
1+
-optimise -Ybackend:GenASM
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimize
1+
-optimize -Ybackend:GenASM

test/files/run/elidable-opt.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimise -Xelide-below 900
1+
-optimise -Ybackend:GenASM -Xelide-below 900

test/files/run/elidable-opt.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/*
2+
* filter: inliner warnings; re-run with
3+
*/
14
import annotation._
25
import elidable._
36

test/files/run/finalvar.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-Yoverride-vars -Yinline
1+
-Yoverride-vars -Yinline -Ybackend:GenASM

test/files/run/icode-reader-dead-code.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ object Test extends DirectTest {
3636

3737
// If inlining fails, the compiler will issue an inliner warning that is not present in the
3838
// check file
39-
compileString(newCompiler("-usejavacp", "-optimise"))(bCode)
39+
compileString(newCompiler("-usejavacp", "-optimise", "-Ybackend:GenASM"))(bCode)
4040
}
4141

4242
def readClass(file: String) = {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimise
1+
-optimise -Ybackend:GenASM

test/files/run/run-bug4840.flags

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/files/run/synchronized.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimize
1+
-optimize -Ybackend:GenASM

test/files/run/t2106.check

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
#partest !-Ybackend:GenASM
21
t2106.scala:7: warning: A::foo()Ljava/lang/Object; is annotated @inline but could not be inlined:
32
The callee A::foo()Ljava/lang/Object; contains the instruction INVOKEVIRTUAL java/lang/Object.clone ()Ljava/lang/Object;
43
that would cause an IllegalAccessError when inlined into class Test$.
54
def main(args: Array[String]): Unit = x.foo
65
^
7-
#partest -Ybackend:GenASM
8-
t2106.scala:7: warning: Could not inline required method foo because access level required by callee not matched by caller.
9-
def main(args: Array[String]): Unit = x.foo
10-
^
11-
t2106.scala:7: warning: At the end of the day, could not inline @inline-marked method foo
12-
def main(args: Array[String]): Unit = x.foo
13-
^

test/files/run/t2106.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimise -Yinline-warnings -Yopt:l:classpath
1+
-Yinline-warnings -Yopt:l:classpath

test/files/run/t3509.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-Yinline
1+
-Yinline -Ybackend:GenASM

test/files/run/t3569.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-Yinline
1+
-Yinline -Ybackend:GenASM

test/files/run/t4285.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimise
1+
-optimise -Ybackend:GenASM

test/files/run/t4935.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimize
1+
-optimize -Ybackend:GenASM

test/files/run/t5789.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import scala.tools.partest.ReplTest
55

66

77
object Test extends ReplTest {
8-
override def extraSettings = "-Yinline"
8+
override def extraSettings = "-Yinline -Ybackend:GenASM"
99
def code = """
1010
val n = 2
1111
() => n

test/files/run/t6102.check

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1 @@
1-
[running phase parser on t6102.scala]
2-
[running phase namer on t6102.scala]
3-
[running phase packageobjects on t6102.scala]
4-
[running phase typer on t6102.scala]
5-
[running phase patmat on t6102.scala]
6-
[running phase superaccessors on t6102.scala]
7-
[running phase extmethods on t6102.scala]
8-
[running phase pickler on t6102.scala]
9-
[running phase refchecks on t6102.scala]
10-
[running phase uncurry on t6102.scala]
11-
[running phase tailcalls on t6102.scala]
12-
[running phase specialize on t6102.scala]
13-
[running phase explicitouter on t6102.scala]
14-
[running phase erasure on t6102.scala]
15-
[running phase posterasure on t6102.scala]
16-
[running phase lazyvals on t6102.scala]
17-
[running phase lambdalift on t6102.scala]
18-
[running phase constructors on t6102.scala]
19-
[running phase flatten on t6102.scala]
20-
[running phase mixin on t6102.scala]
21-
[running phase cleanup on t6102.scala]
22-
[running phase delambdafy on t6102.scala]
23-
[running phase icode on t6102.scala]
24-
#partest -optimise
25-
[running phase inliner on t6102.scala]
26-
[running phase inlinehandlers on t6102.scala]
27-
[running phase closelim on t6102.scala]
28-
[running phase constopt on t6102.scala]
29-
#partest
30-
[running phase dce on t6102.scala]
31-
#partest -Ybackend:GenASM
32-
[running phase jvm on icode]
33-
#partest !-Ybackend:GenASM
34-
[running phase jvm on t6102.scala]
35-
[running phase jvm on t6102.scala]
36-
#partest
371
hello

test/files/run/t6102.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-Ydead-code -Ydebug -Xfatal-warnings
1+
-Yopt:l:classpath -Xfatal-warnings

test/files/run/t6188.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimize
1+
-optimize -Ybackend:GenASM

test/files/run/t7459b-optimize.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimize
1+
-optimize -Ybackend:GenASM

test/files/run/t7582.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimize
1+
-optimize -Ybackend:GenASM

test/files/run/t7582b.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimize
1+
-optimize -Ybackend:GenASM

test/files/run/t8601.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimize
1+
-optimize -Ybackend:GenASM

test/files/run/t8601b.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimize
1+
-optimize -Ybackend:GenASM

test/files/run/t8601c.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimize
1+
-optimize -Ybackend:GenASM

test/files/run/t8601d.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimize
1+
-optimize -Ybackend:GenASM

test/files/run/t8601e.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimize
1+
-optimize -Ybackend:GenASM

test/files/run/t9003.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-optimize
1+
-optimize -Ybackend:GenASM

0 commit comments

Comments
 (0)