PATCH for debug/28063 - disabled string merging

Daniel Jacobowitz drow@false.org
Wed Aug 2 13:32:00 GMT 2006


On Tue, Aug 01, 2006 at 11:03:32AM -0700, Janis Johnson wrote:
> Mostly good; fix the comment for WANT_OUTPUT, which says it returns
> the object or assembly file.  Also fix the verbose messages from
> check_no_compiler_messages and check_no_messages_and_pattern, which
> say they're from check_effective_target; I tend to use messages like
> that a lot when debugging the testsuite infrastructure.  OK with those
> changes.

Thanks!  Committed as so.

-- 
Daniel Jacobowitz
CodeSourcery

2006-08-02  Daniel Jacobowitz  <dan@codesourcery.com>

	PR debug/28063
	* dwarf2out.c (prune_unused_types_prune): Move call to
	prune_unused_types_update_strings to cover the parent DIE also.

2006-08-02  Daniel Jacobowitz  <dan@codesourcery.com>

	PR debug/28063
	* gcc.dg/debug/dwarf2/dwarf-merge.c: New test.
	* lib/target-supports.exp (get_compiler_messages): Add WANT_OUTPUT.
	Optionally return assembly text.  Update callers.
	(check_no_compiler_messages): Update verbose messages.
	(check_no_messages_and_pattern): New.
	(check_effective_target_string_merging): New.

Index: testsuite/lib/target-supports.exp
===================================================================
--- testsuite/lib/target-supports.exp	(revision 115852)
+++ testsuite/lib/target-supports.exp	(working copy)
@@ -20,14 +20,20 @@
 
 # This file defines procs for determining features supported by the target.
 
-# Try to compile some code and return the messages printed by the compiler.
+# Try to compile some code and return the messages printed by the compiler,
+# and optionally the contents for assembly files.  Either a string or
+# a list of two strings are returned, depending on WANT_OUTPUT.
 #
 # BASENAME is a basename to use for temporary files.
+# WANT_OUTPUT is a flag which is 0 to request returning just the
+#   compiler messages, or 1 to return the messages and the contents
+#   of the assembly file.  TYPE should be "assembly" if WANT_OUTPUT
+#   is set.
 # TYPE is the type of compilation to perform (see target_compile).
 # CONTENTS gives the contents of the input file.
 # The rest is optional:
 # OPTIONS: additional compiler options to use.
-proc get_compiler_messages {basename type contents args} {
+proc get_compiler_messages {basename want_output type contents args} {
     global tool
 
     if { [llength $args] > 0 } {
@@ -46,9 +52,28 @@ proc get_compiler_messages {basename typ
     close $f
     set lines [${tool}_target_compile $src $output $type "$options"]
     file delete $src
-    remote_file build delete $output
 
-    return $lines
+    if { $want_output } {
+	if { $type != "assembly" } {
+	    error "WANT_OUTPUT can only be used with assembly output"
+	} elseif { ![string match "" $lines] } {
+	    # An error occurred.
+	    set result [list $lines ""]
+	} else {
+	    set text ""
+	    set chan [open "$output"]
+	    while {[gets $chan line] >= 0} {
+		append text "$line\n"
+	    }
+	    close $chan
+	    set result [list $lines $text]
+	}
+    } else {
+	set result $lines
+    }
+
+    remote_file build delete $output
+    return $result
 }
 
 proc current_target_name { } {
@@ -71,13 +96,33 @@ proc check_no_compiler_messages {prop ar
     set target [current_target_name]
     if {![info exists et_cache($prop,target)]
 	|| $et_cache($prop,target) != $target} {
-	verbose "check_effective_target $prop: compiling source for $target" 2
+	verbose "check_no_compiler_messages $prop: compiling source for $target" 2
+	set et_cache($prop,target) $target
+	set et_cache($prop,value) \
+	    [string match "" [eval get_compiler_messages $prop 0 $args]]
+    }
+    set value $et_cache($prop,value)
+    verbose "check_no_compiler_messages $prop: returning $value for $target" 2
+    return $value
+}
+
+# Similar to check_no_compiler_messages, but also verify that the regular
+# expression PATTERN matches the compiler's output.
+proc check_no_messages_and_pattern {prop pattern args} {
+    global et_cache
+
+    set target [current_target_name]
+    if {![info exists et_cache($prop,target)]
+	|| $et_cache($prop,target) != $target} {
+	verbose "check_no_messages_and_pattern $prop: compiling source for $target" 2
 	set et_cache($prop,target) $target
+	set results [eval get_compiler_messages $prop 1 $args]
 	set et_cache($prop,value) \
-	    [string match "" [eval get_compiler_messages $prop $args]]
+	    [expr [string match "" [lindex $results 0]] \
+		 && [regexp $pattern [lindex $results 1]]]
     }
     set value $et_cache($prop,value)
-    verbose "check_effective_target $prop: returning $value for $target" 2
+    verbose "check_no_messages_and_pattern $prop: returning $value for $target" 2
     return $value
 }
 
@@ -1074,7 +1119,7 @@ proc check_effective_target_lp64 { } {
 
 proc check_effective_target_dfp_nocache { } {
     verbose "check_effective_target_dfp_nocache: compiling source" 2
-    set ret [string match "" [get_compiler_messages dfp object {
+    set ret [string match "" [get_compiler_messages dfp 0 object {
         _Decimal32 x; _Decimal64 y; _Decimal128 z;
     }]]
     verbose "check_effective_target_dfp_nocache: returning $ret" 2
@@ -1783,3 +1828,11 @@ proc check_effective_target_short_enums 
     }]
 }
 
+# Return 1 if target supports merging string constants at link time.
+
+proc check_effective_target_string_merging { } {
+    return [check_no_messages_and_pattern string_merging \
+		"rodata\\.str" assembly {
+		    const char *var = "String";
+		} {-O2}]
+}
Index: dwarf2out.c
===================================================================
--- dwarf2out.c	(revision 115853)
+++ dwarf2out.c	(working copy)
@@ -14044,6 +14044,7 @@ prune_unused_types_prune (dw_die_ref die
   dw_die_ref c;
 
   gcc_assert (die->die_mark);
+  prune_unused_types_update_strings (die);
 
   if (! die->die_child)
     return;
@@ -14068,7 +14069,6 @@ prune_unused_types_prune (dw_die_ref die
 
     if (c != prev->die_sib)
       prev->die_sib = c;
-    prune_unused_types_update_strings (c);
     prune_unused_types_prune (c);
   } while (c != die->die_child);
 }



More information about the Gcc-patches mailing list