for review: bug fix for semidet pragma c_code

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Jan 15 17:52:14 AEDT 1998


On 15-Jan-1998, I wrote:
> On 15-Jan-1998, I wrote:
> > 
> > Fix a bug where semidet pragma c_codes didn't work in non-gc grades.
> 
> More testing revealed that this bug fix happened to trigger another bug.

... and another one.

compiler/frameopt.m:
	Fix a bug in possible_targets/2: the possible targets for
	a `pragma_c' instruction include the label, if it has one.

compiler/opt_util.m:
	Update the comments for component_can_branch_away/2
	to reflect the fact that pragma_c_raw_code components for
	semidet pragma c_codes can branch away.  Also check for the
	special case of an empty string in pragma_c_raw_code.

cvs diff  compiler/frameopt.m compiler/opt_util.m
Index: compiler/frameopt.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/frameopt.m,v
retrieving revision 1.67
diff -u -r1.67 frameopt.m
--- frameopt.m	1998/01/13 10:12:01	1.67
+++ frameopt.m	1998/01/15 06:40:17
@@ -687,7 +687,14 @@
 possible_targets(discard_tickets_to(_), []).
 possible_targets(incr_sp(_, _), []).
 possible_targets(decr_sp(_), []).
-possible_targets(pragma_c(_, _, _, _), []).
+possible_targets(pragma_c(_, _, _, MaybeLabel), List) :-
+	(	
+		MaybeLabel = no,
+		List = []
+	;
+		MaybeLabel = yes(Label),
+		List = [Label]
+	).
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
Index: compiler/opt_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/opt_util.m,v
retrieving revision 1.88
diff -u -r1.88 opt_util.m
--- opt_util.m	1998/01/13 10:13:08	1.88
+++ opt_util.m	1998/01/15 06:45:02
@@ -1012,6 +1012,8 @@
 	% The input and output components get expanded to straight line code.
 	% Some of the raw_code components we generate for nondet pragma C codes
 	% invoke succeed(), which definitely does branch away.
+	% Also the raw_code components for semidet pragma C codes can
+	% branch to a label on failure.
 	% User-written C code cannot branch away because users do not know
 	% how to do that. (They can call other functions, but those functions
 	% will return, so control will still go to the instruction following
@@ -1021,7 +1023,8 @@
 
 opt_util__can_component_branch_away(pragma_c_inputs(_), no).
 opt_util__can_component_branch_away(pragma_c_outputs(_), no).
-opt_util__can_component_branch_away(pragma_c_raw_code(_), yes).
+opt_util__can_component_branch_away(pragma_c_raw_code(Code), CanBranchAway) :-
+	( Code = "" -> CanBranchAway = yes ; CanBranchAway = no ).
 opt_util__can_component_branch_away(pragma_c_user_code(_, _), no).
 
 opt_util__can_instr_fall_through(comment(_), yes).
-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list