[m-rev.] for review: work around Darwin PowerPC issue

Ian MacLarty maclarty at cs.mu.OZ.AU
Wed Aug 17 14:02:04 AEST 2005


On Tue, 16 Aug 2005, Zoltan Somogyi wrote:

> On 16-Aug-2005, Ian MacLarty <maclarty at cs.mu.OZ.AU> wrote:
> > > You also said you wanted -fno-loop-optimize only in LLDS grades; neither
> > > the change to the compiler nor to mgnuc implement that test.
> >
> > I thought only the LLDS grades could make use of GCC global registers, and
> > I check if global registers are being used.
>
> The option and shell variable that indicate whether global registers should be
> used in LLDS grades exist and have meaningful values even when compiling in a
> hlc grade; they simply shouldn't be consulted in such cases. Your new code
> does consult them without checking whether they are relevant; that is the
> bug I am pointing out.
>
> You probably want to post the diff again after fixing this.
>

Here it is.  I've checked that both the compiler and mgnuc pass the right
options in the reg.gc and hlc.gc grades on my Mac.

Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.68
diff -u -r1.68 compile_target_code.m
--- compiler/compile_target_code.m	24 Mar 2005 02:00:18 -0000	1.68
+++ compiler/compile_target_code.m	17 Aug 2005 03:14:45 -0000
@@ -661,24 +661,56 @@
 	;
 		WarningOpt = ""
 	),
+	%
+	% The -floop-optimize option is incompatible with the global
+	% register code we generate on Darwin PowerPC.
+	% See the hard_coded/ppc_bug test case for an example
+	% program which fails with this optimization.
+	%
+	globals__io_lookup_string_option(fullarch, FullArch, !IO),
+	(
+		HighLevelCode = no,
+		GCC_Regs = yes,
+		string.prefix(FullArch, "powerpc-apple-darwin")
+	->
+		AppleGCCRegWorkaroundOpt = "-fno-loop-optimize"
+	;
+		AppleGCCRegWorkaroundOpt = ""
+	),

 	% Be careful with the order here!  Some options override others,
 	% e.g. CFLAGS_FOR_REGS must come after OptimizeOpt so that
 	% it can override -fomit-frame-pointer with -fno-omit-frame-pointer.
 	% Also be careful that each option is separated by spaces.
-	string__append_list([CC, " ", SubDirInclOpt, InclOpt,
-		SplitOpt, " ", OptimizeOpt, " ",
-		HighLevelCodeOpt, NestedFunctionsOpt, HighLevelDataOpt,
+	string__append_list([
+		CC, " ",
+		SubDirInclOpt, InclOpt,
+		SplitOpt, " ",
+		OptimizeOpt, " ",
+		HighLevelCodeOpt,
+		NestedFunctionsOpt,
+		HighLevelDataOpt,
 		RegOpt, GotoOpt, AsmOpt,
 		CFLAGS_FOR_REGS, " ", CFLAGS_FOR_GOTOS, " ",
 		CFLAGS_FOR_THREADS, " ", CFLAGS_FOR_PIC, " ",
-		GC_Opt, ProfileCallsOpt, ProfileTimeOpt, ProfileMemoryOpt,
-		ProfileDeepOpt, RecordTermSizesOpt, PIC_Reg_Opt, TagsOpt,
-		NumTagBitsOpt, Target_DebugOpt, LL_DebugOpt,
-		DeclDebugOpt, ExecTraceOpt,
-		UseTrailOpt, ReserveTagOpt, MinimalModelOpt, TypeLayoutOpt,
-		InlineAllocOpt, " ", AnsiOpt, " ", WarningOpt, " ", CFLAGS,
-		" -c ", C_File, " ", NameObjectFile, O_File], Command),
+		GC_Opt,
+		ProfileCallsOpt, ProfileTimeOpt,
+		ProfileMemoryOpt, ProfileDeepOpt,
+		RecordTermSizesOpt,
+		PIC_Reg_Opt,
+		TagsOpt, NumTagBitsOpt,
+		Target_DebugOpt, LL_DebugOpt, DeclDebugOpt, ExecTraceOpt,
+		UseTrailOpt,
+		ReserveTagOpt,
+		MinimalModelOpt,
+		TypeLayoutOpt,
+		InlineAllocOpt, " ",
+		AnsiOpt, " ",
+		AppleGCCRegWorkaroundOpt, " ",
+		WarningOpt, " ",
+		CFLAGS,
+		" -c ", C_File, " ",
+		NameObjectFile, O_File], Command),
 	invoke_system_command(ErrorStream, verbose_commands,
 		Command, Succeeded, !IO).

Index: scripts/mgnuc.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mgnuc.in,v
retrieving revision 1.108
diff -u -r1.108 mgnuc.in
--- scripts/mgnuc.in	3 Jun 2005 04:55:42 -0000	1.108
+++ scripts/mgnuc.in	17 Aug 2005 03:13:03 -0000
@@ -587,6 +587,20 @@
 	esac ;;
 esac

+#
+# The -floop-optimize option is incompatible
+# with the global register code we generated on Darwin PowerPC.
+# See the hard_coded/ppc_bug test case for an example
+# program which fails with this optimization.
+#
+case $FULLARCH in powerpc*apple*darwin*)
+	case $highlevel_code in false)
+		case $global_regs in true)
+			ARCH_OPTS="$ARCH_OPTS -fno-loop-optimize" ;;
+		esac
+	esac
+esac
+
 case $assemble in true)
 	case $verbose in true)
 		echo $AS $AS_OPTS "$@" ;;

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list