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

Ian MacLarty maclarty at cs.mu.OZ.AU
Tue Aug 16 20:30:25 AEST 2005


For review by anyone.

Estimated hours taken: 1
Branches: main and 0.12

Work around an incompatibility between the C code generated by the Mercury
compiler which uses global registers and the -floop-optimize gcc option on
Darwin PowerPC architectures.

compiler/compile_target_code.m:
scripts/mgnuc.in:
	Disable the -floop-optimize optimization when using global registers
	on Darwin PowerPC.

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	16 Aug 2005 10:14:14 -0000
@@ -661,6 +661,21 @@
 	;
 		WarningOpt = ""
 	),
+	%
+	% 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.
+	%
+	globals__io_lookup_string_option(fullarch, FullArch, !IO),
+	(
+		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
@@ -677,8 +692,9 @@
 		NumTagBitsOpt, Target_DebugOpt, LL_DebugOpt,
 		DeclDebugOpt, ExecTraceOpt,
 		UseTrailOpt, ReserveTagOpt, MinimalModelOpt, TypeLayoutOpt,
-		InlineAllocOpt, " ", AnsiOpt, " ", WarningOpt, " ", CFLAGS,
-		" -c ", C_File, " ", NameObjectFile, O_File], Command),
+		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	16 Aug 2005 10:14:14 -0000
@@ -587,6 +587,18 @@
 	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 $global_regs in
+		true)		ARCH_OPTS="$ARCH_OPTS -fno-loop-optimize" ;;
+	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