On Fri, 2021-06-25 at 01:02 +0800, Xi Ruoyao wrote:
> On Thu, 2021-06-24 at 10:48 -0600, Jeff Law wrote:
> > I'd like to know a bit more here.  mips.exp shouldn't care about the
> > options passed to the compiler and to the best of my knowledge 
> > patch itself is wrong, I question if it's necessary and whether or
> > not
> > your just papering over some other issue.
> 
> There is some logic processing options in mips.exp.  Some options are
> overrided for multilib.  It seems the mips.exp was originally designed
> as:
> 
> * MIPS options should go in dg-options
> * Other options should go in dg-additional-options
> 
> In d2148424165 marxin merged some dg-additional-options into dg-
> options,
> exploited the problem.
> 
> And, the "origin" convention seems already broken: there is something
> like -funroll-loops which is not a MIPS option, but accepted by
> mips.exp
> in dg-options.
> 
> Possiblities are:
> 
> (1) this patch
> (2) make mips.exp accept -fno-inline as "if it is a MIPS option"
> (3) refactor mips.exp to pass everything itself doesn't know directly
> to gcc

Attached a diff for mips.exp trying to make it pass everything in dg-
options which is not known by itself directly to the compiler.

The "smallest fix" is simply adding -fno-inline into mips.exp.  However
I don't like it because I agree with you that mips.exp shouldn't care
about dg-options, at least don't do it too much.
-- 
Xi Ruoyao <xry...@mengyan1223.wang>
School of Aerospace Science and Technology, Xidian University
diff --git a/gcc/testsuite/gcc.target/mips/mips.exp b/gcc/testsuite/gcc.target/mips/mips.exp
index 01292316944..3ffcab551be 100644
--- a/gcc/testsuite/gcc.target/mips/mips.exp
+++ b/gcc/testsuite/gcc.target/mips/mips.exp
@@ -247,7 +247,6 @@ set mips_option_groups {
     mips3d "-mips3d|-mno-mips3d"
     pic "-f(no-|)(pic|PIC)"
     cb "-mcompact-branches=.*"
-    profiling "-pg"
     small-data "-G[0-9]+"
     warnings "-w"
     dump "-fdump-.*"
@@ -315,30 +314,6 @@ foreach option {
     lappend mips_option_groups $option "-m$option=.*"
 }
 
-# Add -ffoo/-fno-foo options to mips_option_groups.
-foreach option {
-    common
-    delayed-branch
-    expensive-optimizations
-    fast-math
-    fat-lto-objects
-    finite-math-only
-    fixed-hi
-    fixed-lo
-    lax-vector-conversions
-    omit-frame-pointer
-    optimize-sibling-calls
-    peephole2
-    schedule-insns2
-    split-wide-types
-    tree-vectorize
-    unroll-all-loops
-    unroll-loops
-    ipa-ra
-} {
-    lappend mips_option_groups $option "-f(no-|)$option"
-}
-
 # A list of option groups that have an impact on the ABI.
 set mips_abi_groups {
     abi
@@ -571,6 +546,10 @@ proc mips_original_option { group } {
 proc mips_test_option_p { upstatus group } {
     upvar $upstatus status
 
+    if {[ string equal $group "" ]} {
+        return 0
+    }
+
     return $status(test_option_p,$group)
 }
 
@@ -620,7 +599,12 @@ proc mips_have_test_option_p { upstatus option } {
 proc mips_make_test_option { upstatus option args } {
     upvar $upstatus status
 
-    set group [mips_option_group $option]
+    set group [mips_option_maybe_group $option]
+    if { [string equal $group ""] } {
+	lappend status(raw_option) $option
+	return
+    }
+
     if { ![mips_test_option_p status $group] } {
 	set status(option,$group) $option
 	set status(test_option_p,$group) 1
@@ -741,6 +725,7 @@ proc mips-dg-init {} {
 
     # Start with a fresh option status.
     array unset mips_base_options
+    set mips_base_options(raw_option) {}
     foreach { group regexp } $mips_option_groups {
 	set mips_base_options(option,$group) ""
 	set mips_base_options(explicit_p,$group) 0
@@ -1016,7 +1001,7 @@ proc mips-dg-options { args } {
     # Record the options that this test explicitly needs.
     foreach option [lindex $args 1] {
 	set all_but_p [regexp {^\((.*)\)$} $option dummy option]
-	set group [mips_option_group $option]
+	set group [mips_option_maybe_group $option]
 	if { [mips_test_option_p options $group] } {
 	    set old [mips_option options $group]
 	    error "Inconsistent $group option: $old vs. $option"
@@ -1025,10 +1010,6 @@ proc mips-dg-options { args } {
 	}
     }
 
-    # Handle dependencies between the test options and the optimization ones.
-    mips_option_dependency options "-fno-unroll-loops" "-fno-unroll-all-loops"
-    mips_option_dependency options "-pg" "-fno-omit-frame-pointer"
-
     # Handle dependencies between options on the left of the
     # dependency diagram.
     mips_option_dependency options "-mips16" "-mno-micromips"
@@ -1505,6 +1486,10 @@ proc mips-dg-options { args } {
 	}
     }
 
+    foreach { opt } $options(raw_option) {
+        append extra_tool_flags " " $opt
+    }
+
     # If the test is marked as requiring standard libraries check
     # that the sysroot has support for the current set of test options.
     if { [mips_have_test_option_p options "REQUIRES_STDLIB"] } {

Reply via email to