I had to deal with the same exception a while ago, and if I remember well,
this happens when simplemem tries to simplify an expression that's outside
of a function body.
Creating temporary variables does not work in that context, as those are
meant to be local variables. If you can paste the C code that's triggering
the error, it'd be easier to explain what's going on.
In my case, since I do not explicitly rely on the simplifications in my
project, I modified simplemem to catch the exception and skip the
simplification.
Bellow is the patch with my modifications of simplemem. Note that this works
for me, but it may not work for you depending on what you're doing.
I hope this helps.
Olivier
Index: src/ext/simplemem.ml
===================================================================
--- src/ext/simplemem.ml (revision 11607)
+++ src/ext/simplemem.ml (working copy)
@@ -45,7 +45,11 @@
* constructor.
*)
open Cil
+module E = Errormsg
+
+exception NoScope;;
+
(* current context: where should we put our temporaries? *)
let thefunc = ref None
@@ -63,7 +67,7 @@
let tau = array_to_pointer tau in
match !thefunc with
Some(fundec) -> makeTempVar fundec ~name:("mem_") tau
- | None -> failwith "simplemem: temporary needed outside a function"
+ | None -> raise NoScope (* official simplemem version used to fail here
*)
(* separate loffsets into "scalar addition parts" and "memory parts" *)
let rec separate_loffsets lo =
@@ -86,10 +90,14 @@
handle_loffset (lb,s) m
| Mem(e) ->
begin
- let new_vi = make_temp (typeOf e) in
- assignment_list := (Set((Var(new_vi),NoOffset),e,!currentLoc))
- :: !assignment_list ;
- handle_loffset (Mem(Lval(Var(new_vi),NoOffset)),NoOffset) lo
+ try
+ let new_vi = make_temp (typeOf e) in
+ assignment_list := (Set((Var(new_vi),NoOffset),e,!currentLoc))
+ :: !assignment_list ;
+ handle_loffset (Mem(Lval(Var(new_vi),NoOffset)),NoOffset) lo
+ with NoScope ->
+ assignment_list := [] ;
+ (lb, lo)
end
and handle_loffset lv lo =
match lo with
@@ -103,9 +111,14 @@
method vfunc fundec = (* we must record the current context *)
thefunc := Some(fundec) ;
- DoChildren
+ (* ocr: when exiting the function, reset thefunc to None
+ * just in case some initializaion code outside the function
+ * comes after *)
+ ChangeDoChildrenPost(fundec,
+ (fun fundec -> thefunc := None; fundec))
- method vlval lv = ChangeDoChildrenPost(lv,
+ method vlval lv =
+ ChangeDoChildrenPost(lv,
(fun lv -> handle_lvalue lv))
method unqueueInstr () =
On Sun, Jun 27, 2010 at 5:12 PM, Alexander Maringer <
marin...@mail.fim.uni-passau.de> wrote:
> Dear all,
>
> I have some problems with the option "--dosimplemen" of the
> cilly.asm.exe command at my linux host.
>
> I use ubuntu 9.1 and the latest svn sources.
>
> I also tried Gabriel Kerneis git repository, but I get a compile error:
> "threadpool/threadpool.h: No sich file or directory"
> The cilly.asm.exe is compiled at the abort, but it is not possible to
> compile the normal precompiled linux kernel driver sources.
>
> The compilation of the sources work with the svn sources, but the option
> "dosimplemem" always fails with a "Fatal error: exception
> Failure("simplemem: temporary needed outside a function").
>
> I already grepped the sources to find the point where the exception is
> thrown. This is at line 66 in simplemem.ml.
> I'm not the ocaml-pro, but it seems, that the program cannot create a
> temporary variable. Can anybody help me?
>
> Thanks a lot
>
> Alexander Maringer
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> CIL-users mailing list
> CIL-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/cil-users
>
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
CIL-users mailing list
CIL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cil-users