Skip to content

Commit e6fbd23

Browse files
committed
Force thread arguments to be added, as they will escape, but have not yet -- is there a better way?
1 parent a79065a commit e6fbd23

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/analyses/region.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ struct
187187
let fd = Cilfacade.find_varinfo_fundec f in
188188
match args, fd.sformals with
189189
| [exp], [param] ->
190-
let reg = Reg.assign (Analyses.ask_of_ctx ctx) (var param) exp (ctx.global (), RegMap.bot ()) in
190+
(* The parameter may not have escaped here (for the first thread). *)
191+
let reg = Reg.assign ~thread_arg:true (Analyses.ask_of_ctx ctx) (var param) exp (ctx.global (), RegMap.bot ()) in
191192
[`Lifted (snd reg)]
192193
| _ -> [`Lifted (RegMap.bot ())]
193194
let threadspawn ctx lval f args fctx = ctx.local

src/cdomains/regionDomain.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ struct
195195
let p = RegPart.add s p in
196196
p, closure p m
197197

198-
let assign (ask: Queries.ask) (lval: lval) (rval: exp) (st: t): t =
198+
let assign ?(thread_arg=false) (ask: Queries.ask) (lval: lval) (rval: exp) (st: t): t =
199199
(* let _ = printf "%a = %a\n" (printLval plainCilPrinter) lval (printExp plainCilPrinter) rval in *)
200200
let t = Cilfacade.typeOf rval in
201201
if isPointerType t then begin (* TODO: this currently allows function pointers, e.g. in iowarrior, but should it? *)
@@ -209,7 +209,7 @@ struct
209209
| `Right () -> `Right ()
210210
)
211211
in
212-
match BaseUtil.is_global ask (fst x), deref_x, BaseUtil.is_global ask (fst y) with
212+
match BaseUtil.is_global ask (fst x), deref_x, BaseUtil.is_global ask (fst y) || thread_arg with
213213
| false, false, true ->
214214
p, RegMap.add x (append_offs_y (RegPart.closure p (RS.single_vf y))) m
215215
| false, false, false ->

0 commit comments

Comments
 (0)