[m-rev.] diff: fix deforest_cc_bug and tricky_try_store

Zoltan Somogyi zs at cs.mu.OZ.AU
Thu Dec 9 13:04:52 AEDT 2004


Fix a code generator bug that manifested itself in profiling grades with
(intermodule) inlining, the symptom being a compiler abort due to a stackvar
out of range (negative slot number). The problem was that we use the type of a
variable to decide whether the variable has a real stack slot or not, but
we were using the original type of an argument of a foreign_proc to decide
whether the argument should be passed or not. Inlining could cause an argument
whose original type is T (e.g. the arguments of cc_multi_equal) to be
instantiated, e.g. to io__state. Since the type of the variable is io__state,
it gets a dummy stack slot; since the original type of the argument is T,
we pass the variable and thus refer to the dummy stack slot.

The fix is the use the actual type of the variable to make the decision,
not the original type of the argument.

This fix fixes the failures of the deforest_cc_bug.m test case in deep
profiling grades and the tricky_try_store.m test case in profiling grades.

compiler/llds.m:
	Add an extra argument to the pragma_c_{in,out}put function symbols
	to hold the actual type of the variable being passed.

	Add field names to those function symbols.

compiler/pragma_c_gen.m:
	Fill in the new argument.

	Clean up some code, mostly by factoring out duplicate code fragments.

compiler/llds_out.m:
	Handle the new argument to decide whether to pass the argument.

compiler/exprn_aux.m:
compiler/livemap.m:
compiler/middle_rec.m:
compiler/opt_util.m:
	Handle the new argument in pragma_c_{in,out}puts.

Zoltan.

cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/exprn_aux.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/exprn_aux.m,v
retrieving revision 1.52
diff -u -b -r1.52 exprn_aux.m
--- compiler/exprn_aux.m	7 Jun 2004 09:06:38 -0000	1.52
+++ compiler/exprn_aux.m	7 Dec 2004 09:03:42 -0000
@@ -537,20 +537,20 @@
 
 exprn_aux__substitute_lval_in_pragma_c_input(OldLval, NewLval, Out0, Out,
 		N0, N) :-
-	Out0 = pragma_c_input(Name, Type, Rval0, MaybeForeign),
+	Out0 = pragma_c_input(Name, VarType, OrigType, Rval0, MaybeForeign),
 	exprn_aux__substitute_lval_in_rval_count(OldLval, NewLval, Rval0, Rval,
 		N0, N),
-	Out = pragma_c_input(Name, Type, Rval, MaybeForeign).
+	Out = pragma_c_input(Name, VarType, OrigType, Rval, MaybeForeign).
 
 :- pred exprn_aux__substitute_lval_in_pragma_c_output(lval::in, lval::in,
 	pragma_c_output::in, pragma_c_output::out, int::in, int::out) is det.
 
 exprn_aux__substitute_lval_in_pragma_c_output(OldLval, NewLval, Out0, Out,
 		N0, N) :-
-	Out0 = pragma_c_output(Lval0, Type, Name, MaybeForeign),
+	Out0 = pragma_c_output(Lval0, VarType, OrigType, Name, MaybeForeign),
 	exprn_aux__substitute_lval_in_lval_count(OldLval, NewLval, Lval0, Lval,
 		N0, N),
-	Out = pragma_c_output(Lval, Type, Name, MaybeForeign).
+	Out = pragma_c_output(Lval, VarType, OrigType, Name, MaybeForeign).
 
 :- pred exprn_aux__substitute_lval_in_rval_count(lval::in, lval::in,
 	rval::in, rval::out, int::in, int::out) is det.
Index: compiler/livemap.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/livemap.m,v
retrieving revision 1.61
diff -u -b -r1.61 livemap.m
--- compiler/livemap.m	14 Jun 2004 04:16:12 -0000	1.61
+++ compiler/livemap.m	7 Dec 2004 09:04:11 -0000
@@ -314,7 +314,7 @@
 
 livemap__build_livemap_pragma_inputs([], !Livevals).
 livemap__build_livemap_pragma_inputs([Input | Inputs], !Livevals) :-
-	Input = pragma_c_input(_, _, Rval, _),
+	Input = pragma_c_input(_, _, _, Rval, _),
 	( Rval = lval(Lval) ->
 		livemap__insert_proper_liveval(Lval, !Livevals)
 	;
Index: compiler/llds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.307
diff -u -b -r1.307 llds.m
--- compiler/llds.m	14 Jun 2004 04:16:13 -0000	1.307
+++ compiler/llds.m	7 Dec 2004 08:47:52 -0000
@@ -589,26 +589,48 @@
 	% of the input variables for a pragma_c instruction.
 :- type pragma_c_input
 	--->	pragma_c_input(
-			string, % the variable's name
-			type,	% the variable's type
-			rval,	% the variable's value
-			maybe(pragma_c_foreign_type)
-				% if type is a foreign type,
-				% info about that foreign type
+			% The name of the foreign language variable.
+			in_foreign_lang_var_name :: string,
+
+			% The type of the Mercury variable being passed.
+			in_var_type		:: (type),
+
+			% The type of the argument in original foreign_proc
+			% procedure. If the foreign_proc was inlined in some
+			% other procedure, then the in_var_type can be an
+			% instance of in_original_type; otherwise, the two
+			% should be the same.
+			in_original_type	:: (type),
+
+			% The value being passed.
+			in_arg_value		:: rval,
+
+			% If in_original_type is a foreign type, info about
+			% that foreign type.
+			in_maybe_foreign_type	:: maybe(pragma_c_foreign_type)
 		).
 
 	% A pragma_c_output represents the code that stores one of
 	% of the outputs for a pragma_c instruction.
 :- type pragma_c_output
 	--->	pragma_c_output(
-			lval,	% where to put the output val,
-			type,
-			string,
-				% type and name of the variable containing
-				% the output val
-			maybe(pragma_c_foreign_type)
-				% if type is a foreign type,
-				% info about that foreign type
+			% The place where the foreign_proc should put this
+			% output.
+			out_arg_dest		:: lval,
+
+			% The type of the Mercury variable being passed.
+			out_var_type		:: (type),
+
+			% The type of the argument in original foreign_proc
+			% procedure; see in_original_type above.
+			out_original_type	:: (type),
+
+			% The name of the foreign language variable.
+			out_var_name		:: string,
+
+			% If in_original_type is a foreign type, info about
+			% that foreign type.
+			out_maybe_foreign_type	:: maybe(pragma_c_foreign_type)
 		).
 
 :- type pragma_c_foreign_type
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.240
diff -u -b -r1.240 llds_out.m
--- compiler/llds_out.m	19 Nov 2004 05:46:09 -0000	1.240
+++ compiler/llds_out.m	7 Dec 2004 09:05:31 -0000
@@ -2214,7 +2214,7 @@
 
 output_pragma_input_rval_decls([], !DeclSet, !IO).
 output_pragma_input_rval_decls([Input | Inputs], !DeclSet, !IO) :-
-	Input = pragma_c_input(_VarName, _Type, Rval, _),
+	Input = pragma_c_input(_VarName, _VarType, _OrigType, Rval, _),
 	output_rval_decls(Rval, "\t", "\t", 0, _N, !DeclSet, !IO),
 	output_pragma_input_rval_decls(Inputs, !DeclSet, !IO).
 
@@ -2224,8 +2224,9 @@
 
 output_pragma_inputs([], !IO).
 output_pragma_inputs([Input | Inputs], !IO) :-
-	Input = pragma_c_input(_VarName, Type, _Rval, _MaybeForeignTypeInfo),
-	( is_dummy_argument_type(Type) ->
+	Input = pragma_c_input(_VarName, VarType, _OrigType, _Rval,
+		_MaybeForeignTypeInfo),
+	( is_dummy_argument_type(VarType) ->
 		true
 	;
 		output_pragma_input(Input, !IO)
@@ -2237,7 +2238,8 @@
 :- pred output_pragma_input(pragma_c_input::in, io::di, io::uo) is det.
 
 output_pragma_input(Input, !IO) :-
-	Input = pragma_c_input(VarName, Type, Rval, MaybeForeignTypeInfo),
+	Input = pragma_c_input(VarName, _VarType, OrigType, Rval,
+		MaybeForeignTypeInfo),
 	io__write_string("\t", !IO),
 	(
 		MaybeForeignTypeInfo = yes(ForeignTypeInfo),
@@ -2272,10 +2274,10 @@
 		MaybeForeignTypeInfo = no,
 		io__write_string(VarName, !IO),
 		io__write_string(" = ", !IO),
-		( Type = term__functor(term__atom("string"), [], _) ->
+		( OrigType = term__functor(term__atom("string"), [], _) ->
 			output_llds_type_cast(string, !IO),
 			output_rval_as_type(Rval, word, !IO)
-		; Type = term__functor(term__atom("float"), [], _) ->
+		; OrigType = term__functor(term__atom("float"), [], _) ->
 			output_rval_as_type(Rval, float, !IO)
 		;
 			output_rval_as_type(Rval, word, !IO)
@@ -2289,7 +2291,7 @@
 
 output_pragma_output_lval_decls([], !DeclSet, !IO).
 output_pragma_output_lval_decls([O | Outputs], !DeclSet, !IO) :-
-	O = pragma_c_output(Lval, _Type, _VarName, _),
+	O = pragma_c_output(Lval, _VarType, _OrigType, _VarName, _),
 	output_lval_decls(Lval, "\t", "\t", 0, _N, !DeclSet, !IO),
 	output_pragma_output_lval_decls(Outputs, !DeclSet, !IO).
 
@@ -2300,8 +2302,9 @@
 
 output_pragma_outputs([], !IO).
 output_pragma_outputs([Output | Outputs], !IO) :-
-	Output = pragma_c_output(_Lval, Type, _VarName, _MaybeForeignType),
-	( is_dummy_argument_type(Type) ->
+	Output = pragma_c_output(_Lval, VarType, _OrigType, _VarName,
+		_MaybeForeignType),
+	( is_dummy_argument_type(VarType) ->
 		true
 	;
 		output_pragma_output(Output, !IO)
@@ -2313,7 +2316,8 @@
 :- pred output_pragma_output(pragma_c_output::in, io::di, io::uo) is det.
 
 output_pragma_output(Output, !IO) :-
-	Output = pragma_c_output(Lval, Type, VarName, MaybeForeignType),
+	Output = pragma_c_output(Lval, _VarType, OrigType, VarName,
+		MaybeForeignType),
 	io__write_string("\t", !IO),
 	(
 		MaybeForeignType = yes(ForeignTypeInfo),
@@ -2338,12 +2342,12 @@
 		output_lval_as_word(Lval, !IO),
 		io__write_string(" = ", !IO),
 		(
-			Type = term__functor(term__atom("string"), [], _)
+			OrigType = term__functor(term__atom("string"), [], _)
 		->
 			output_llds_type_cast(word, !IO),
 			io__write_string(VarName, !IO)
 		;
-			Type = term__functor(term__atom("float"), [], _)
+			OrigType = term__functor(term__atom("float"), [], _)
 		->
 			io__write_string("MR_float_to_word(", !IO),
 			io__write_string(VarName, !IO),
Index: compiler/middle_rec.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/middle_rec.m,v
retrieving revision 1.100
diff -u -b -r1.100 middle_rec.m
--- compiler/middle_rec.m	14 Jun 2004 04:16:17 -0000	1.100
+++ compiler/middle_rec.m	7 Dec 2004 09:05:42 -0000
@@ -544,7 +544,7 @@
 
 insert_pragma_c_input_registers([], !Used).
 insert_pragma_c_input_registers([Input|Inputs], !Used) :-
-	Input = pragma_c_input(_, _, Rval, _),
+	Input = pragma_c_input(_, _, _, Rval, _),
 	middle_rec__find_used_registers_rval(Rval, !Used),
 	insert_pragma_c_input_registers(Inputs, !Used).
 
@@ -553,7 +553,7 @@
 
 insert_pragma_c_output_registers([], !Used).
 insert_pragma_c_output_registers([Output|Outputs], !Used) :-
-	Output = pragma_c_output(Lval, _, _, _),
+	Output = pragma_c_output(Lval, _, _, _, _),
 	middle_rec__find_used_registers_lval(Lval, !Used),
 	insert_pragma_c_output_registers(Outputs, !Used).
 
Index: compiler/opt_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/opt_util.m,v
retrieving revision 1.126
diff -u -b -r1.126 opt_util.m
--- compiler/opt_util.m	30 Jun 2004 02:48:05 -0000	1.126
+++ compiler/opt_util.m	7 Dec 2004 09:06:05 -0000
@@ -1305,7 +1305,7 @@
 
 pragma_c_inputs_get_rvals([], []).
 pragma_c_inputs_get_rvals([I|Inputs], [R|Rvals]) :-
-	I = pragma_c_input(_Name, _Type, R, _),
+	I = pragma_c_input(_Name, _VarType, _OrigType, R, _),
 	pragma_c_inputs_get_rvals(Inputs, Rvals).
 
 	% extract the lvals from the pragma_c_output
@@ -1314,7 +1314,7 @@
 
 pragma_c_outputs_get_lvals([], []).
 pragma_c_outputs_get_lvals([O|Outputs], [L|Lvals]) :-
-	O = pragma_c_output(L, _Type, _Name, _),
+	O = pragma_c_output(L, _VarType, _OrigType, _Name, _),
 	pragma_c_outputs_get_lvals(Outputs, Lvals).
 
 % determine all the rvals and lvals referenced by a list of instructions
Index: compiler/pragma_c_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/pragma_c_gen.m,v
retrieving revision 1.70
diff -u -b -r1.70 pragma_c_gen.m
--- compiler/pragma_c_gen.m	5 Sep 2004 23:52:37 -0000	1.70
+++ compiler/pragma_c_gen.m	7 Dec 2004 09:58:19 -0000
@@ -390,9 +390,11 @@
 	%
 	% Generate code to <save live variables on stack>
 	%
-	( MayCallMercury = will_not_call_mercury ->
+	(
+		MayCallMercury = will_not_call_mercury,
 		SaveVarsCode = empty
 	;
+		MayCallMercury = may_call_mercury,
 		% The C code might call back Mercury code
 		% which clobbers the succip.
 		code_info__succip_is_used(!CI),
@@ -491,10 +493,12 @@
 	%
 	% Code fragments to obtain and release the global lock
 	%
-	( ThreadSafe = thread_safe ->
+	(
+		ThreadSafe = thread_safe,
 		ObtainLock = pragma_c_raw_code("", live_lvals_info(set__init)),
 		ReleaseLock = pragma_c_raw_code("", live_lvals_info(set__init))
 	;
+		ThreadSafe = not_thread_safe,
 		module_info_pred_info(ModuleInfo, PredId, PredInfo),
 		Name = pred_info_name(PredInfo),
 		c_util__quote_string(Name, MangledName),
@@ -530,9 +534,11 @@
 	%   MR_restore_registers(); /* see notes (1) and (3) above */
 	% #endif
 	%
-	( MayCallMercury = will_not_call_mercury ->
+	(
+		MayCallMercury = will_not_call_mercury,
 		RestoreRegsComp = pragma_c_noop
 	;
+		MayCallMercury = may_call_mercury,
 		RestoreRegsComp = pragma_c_raw_code(
 			"#ifndef MR_CONSERVATIVE_GC\n\t" ++
 				"MR_restore_registers();\n#endif\n",
@@ -1061,16 +1067,8 @@
 :- pred make_c_arg_list(list(foreign_arg)::in, list(arg_info)::in,
 	list(c_arg)::out) is det.
 
-make_c_arg_list(Args, ArgInfos, CArgs) :-
-	(
-		Args = [],
-		ArgInfos = []
-	->
-		CArgs = []
-	;
-		Args = [Arg | ArgTail],
-		ArgInfos = [ArgInfo | ArgInfoTail]
-	->
+make_c_arg_list([], [], []).
+make_c_arg_list([Arg | ArgTail], [ArgInfo | ArgInfoTail], [CArg | CArgTail]) :-
 		Arg = foreign_arg(Var, MaybeNameMode, Type),
 		(
 			MaybeNameMode = yes(Name - _),
@@ -1080,11 +1078,11 @@
 			MaybeName = no
 		),
 		CArg = c_arg(Var, MaybeName, Type, ArgInfo),
-		make_c_arg_list(ArgTail, ArgInfoTail, CArgTail),
-		CArgs = [CArg | CArgTail]
-	;
-		error("pragma_c_gen__make_c_arg_list length mismatch")
-	).
+	make_c_arg_list(ArgTail, ArgInfoTail, CArgTail).
+make_c_arg_list([], [_|_], _) :-
+	error("pragma_c_gen__make_c_arg_list length mismatch").
+make_c_arg_list([_|_], [], _) :-
+	error("pragma_c_gen__make_c_arg_list length mismatch").
 
 %---------------------------------------------------------------------------%
 
@@ -1141,13 +1139,13 @@
 
 pragma_select_out_args([], []).
 pragma_select_out_args([Arg | Rest], Out) :-
-	pragma_select_out_args(Rest, Out0),
+	pragma_select_out_args(Rest, OutTail),
 	Arg = c_arg(_, _, _, ArgInfo),
 	ArgInfo = arg_info(_Loc, Mode),
 	( Mode = top_out ->
-		Out = [Arg | Out0]
+		Out = [Arg | OutTail]
 	;
-		Out = Out0
+		Out = OutTail
 	).
 
 	% pragma_select_in_args returns the list of variables
@@ -1157,13 +1155,13 @@
 
 pragma_select_in_args([], []).
 pragma_select_in_args([Arg | Rest], In) :-
-	pragma_select_in_args(Rest, In0),
+	pragma_select_in_args(Rest, InTail),
 	Arg = c_arg(_, _, _, ArgInfo),
 	ArgInfo = arg_info(_Loc, Mode),
 	( Mode = top_in ->
-		In = [Arg | In0]
+		In = [Arg | InTail]
 	;
-		In = In0
+		In = InTail
 	).
 
 %---------------------------------------------------------------------------%
@@ -1179,8 +1177,7 @@
 % 	- they could clash with the system name space
 %
 
-:- pred var_is_not_singleton(maybe(string), string) is semidet.
-:- mode var_is_not_singleton(in, out) is semidet.
+:- pred var_is_not_singleton(maybe(string)::in, string::out) is semidet.
 
 var_is_not_singleton(yes(Name), Name) :-
 	\+ string__first_char(Name, '_', _).
@@ -1196,16 +1193,16 @@
 
 make_pragma_decls([], _, []).
 make_pragma_decls([Arg | Args], Module, Decls) :-
+	make_pragma_decls(Args, Module, DeclsTail),
 	Arg = c_arg(_Var, ArgName, OrigType, _ArgInfo),
 	( var_is_not_singleton(ArgName, Name) ->
 		OrigTypeString = foreign__to_type_string(c, Module, OrigType),
 		Decl = pragma_c_arg_decl(OrigType, OrigTypeString, Name),
-		make_pragma_decls(Args, Module, Decls1),
-		Decls = [Decl | Decls1]
+		Decls = [Decl | DeclsTail]
 	;
 		% if the variable doesn't occur in the ArgNames list,
 		% it can't be used, so we just ignore it
-		make_pragma_decls(Args, Module, Decls)
+		Decls = DeclsTail
 	).
 
 %---------------------------------------------------------------------------%
@@ -1213,15 +1210,15 @@
 :- pred find_dead_input_vars(list(c_arg)::in, set(prog_var)::in,
 	set(prog_var)::in, set(prog_var)::out) is det.
 
-find_dead_input_vars([], _, DeadVars, DeadVars).
-find_dead_input_vars([Arg | Args], PostDeaths, DeadVars0, DeadVars) :-
+find_dead_input_vars([], _, !DeadVars).
+find_dead_input_vars([Arg | Args], PostDeaths, !DeadVars) :-
 	Arg = c_arg(Var, _MaybeName, _Type, _ArgInfo),
 	( set__member(Var, PostDeaths) ->
-		set__insert(DeadVars0, Var, DeadVars1)
+		set__insert(!.DeadVars, Var, !:DeadVars)
 	;
-		DeadVars1 = DeadVars0
+		true
 	),
-	find_dead_input_vars(Args, PostDeaths, DeadVars1, DeadVars).
+	find_dead_input_vars(Args, PostDeaths, !DeadVars).
 
 %---------------------------------------------------------------------------%
 
@@ -1234,13 +1231,13 @@
 
 get_pragma_input_vars([], [], empty, !CI).
 get_pragma_input_vars([Arg | Args], Inputs, Code, !CI) :-
-	Arg = c_arg(Var, MaybeName, Type, _ArgInfo),
+	Arg = c_arg(Var, MaybeName, OrigType, _ArgInfo),
 	( var_is_not_singleton(MaybeName, Name) ->
+		VarType = variable_type(!.CI, Var),
 		code_info__produce_variable(Var, FirstCode, Rval, !CI),
-		% code_info__produce_variable_in_reg(Var, FirstCode, Lval, !CI)
-		% Rval = lval(Lval),
-		MaybeForeign = get_maybe_foreign_type_info(!.CI, Type),
-		Input = pragma_c_input(Name, Type, Rval, MaybeForeign),
+		MaybeForeign = get_maybe_foreign_type_info(!.CI, OrigType),
+		Input = pragma_c_input(Name, VarType, OrigType, Rval,
+			MaybeForeign),
 		get_pragma_input_vars(Args, Inputs1, RestCode, !CI),
 		Inputs = [Input | Inputs1],
 		Code = tree(FirstCode, RestCode)
@@ -1305,21 +1302,22 @@
 
 place_pragma_output_args_in_regs([], [], [], !CI).
 place_pragma_output_args_in_regs([Arg | Args], [Reg | Regs], Outputs, !CI) :-
-	place_pragma_output_args_in_regs(Args, Regs, Outputs0, !CI),
+	place_pragma_output_args_in_regs(Args, Regs, OutputsTail, !CI),
 	Arg = c_arg(Var, MaybeName, OrigType, _ArgInfo),
 	code_info__release_reg(Reg, !CI),
 	( code_info__variable_is_forward_live(!.CI, Var) ->
 		code_info__set_var_location(Var, Reg, !CI),
 		MaybeForeign = get_maybe_foreign_type_info(!.CI, OrigType),
 		( var_is_not_singleton(MaybeName, Name) ->
-			PragmaCOutput = pragma_c_output(Reg, OrigType,
+			VarType = variable_type(!.CI, Var),
+			PragmaCOutput = pragma_c_output(Reg, VarType, OrigType,
 				Name, MaybeForeign),
-			Outputs = [PragmaCOutput | Outputs0]
+			Outputs = [PragmaCOutput | OutputsTail]
 		;
-			Outputs = Outputs0
+			Outputs = OutputsTail
 		)
 	;
-		Outputs = Outputs0
+		Outputs = OutputsTail
 	).
 place_pragma_output_args_in_regs([_|_], [], _, !CI) :-
 	error("place_pragma_output_args_in_regs: length mismatch").
@@ -1336,17 +1334,18 @@
 
 input_descs_from_arg_info(_, [], []).
 input_descs_from_arg_info(CI, [Arg | Args], Inputs) :-
-	Arg = c_arg(_Var, MaybeName, OrigType, ArgInfo),
+	input_descs_from_arg_info(CI, Args, InputsTail),
+	Arg = c_arg(Var, MaybeName, OrigType, ArgInfo),
 	( var_is_not_singleton(MaybeName, Name) ->
+		VarType = variable_type(CI, Var),
 		ArgInfo = arg_info(N, _),
 		Reg = reg(r, N),
 		MaybeForeign = get_maybe_foreign_type_info(CI, OrigType),
-		Input = pragma_c_input(Name, OrigType, lval(Reg),
+		Input = pragma_c_input(Name, VarType, OrigType, lval(Reg),
 			MaybeForeign),
-		input_descs_from_arg_info(CI, Args, Inputs1),
-		Inputs = [Input | Inputs1]
+		Inputs = [Input | InputsTail]
 	;
-		input_descs_from_arg_info(CI, Args, Inputs)
+		Inputs = InputsTail
 	).
 
 %---------------------------------------------------------------------------%
@@ -1360,16 +1359,18 @@
 
 output_descs_from_arg_info(_, [], []).
 output_descs_from_arg_info(CI, [Arg | Args], Outputs) :-
-	Arg = c_arg(_Var, MaybeName, OrigType, ArgInfo),
-	output_descs_from_arg_info(CI, Args, Outputs0),
+	output_descs_from_arg_info(CI, Args, OutputsTail),
+	Arg = c_arg(Var, MaybeName, OrigType, ArgInfo),
 	( var_is_not_singleton(MaybeName, Name) ->
+		VarType = variable_type(CI, Var),
 		ArgInfo = arg_info(N, _),
 		Reg = reg(r, N),
 		MaybeForeign = get_maybe_foreign_type_info(CI, OrigType),
-		Outputs = [pragma_c_output(Reg, OrigType, Name, MaybeForeign) |
-			Outputs0]
+		Output = pragma_c_output(Reg, VarType, OrigType, Name,
+			MaybeForeign),
+		Outputs = [Output | OutputsTail]
 	;
-		Outputs = Outputs0
+		Outputs = OutputsTail
 	).
 
 %---------------------------------------------------------------------------%
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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