[sledge] Check for intrinsic calls in used-globals analysis

Summary:
Fixes a bug where are all calls are treated as intrinsics in used
globals analysis, since exec_intrinsic is invoked at _all_ calls
to determine which are intrinsic, not only at call sites known to
target intrinsics.

Reviewed By: jberdine

Differential Revision: D17499406

fbshipit-source-id: 41f7621f2
master
Benno Stein 5 years ago committed by Facebook Github Bot
parent 6592eb609f
commit 637fff5247

@ -43,9 +43,20 @@ let exec_inst st inst =
[%Trace.retn fun {pf} ->
Result.iter ~f:(fun uses -> pf "post:{%a}" pp uses)]
let exec_intrinsic ~skip_throw:_ st _ _ actuals =
let exec_intrinsic ~skip_throw:_ st _ intrinsic actuals =
let name = Var.name intrinsic in
if
List.exists
[ "malloc"; "aligned_alloc"; "calloc"; "posix_memalign"; "realloc"
; "mallocx"; "rallocx"; "xallocx"; "sallocx"; "dallocx"; "sdallocx"
; "nallocx"; "malloc_usable_size"; "mallctl"; "mallctlnametomib"
; "mallctlbymib"; "malloc_stats_print"; "strlen"
; "__cxa_allocate_exception"; "_ZN5folly13usingJEMallocEv" ]
~f:(String.equal name)
then
List.fold actuals ~init:st ~f:(fun s a -> used_globals ~init:s a)
|> fun res -> Some (Ok res)
else None
type from_call = t [@@deriving sexp_of]

Loading…
Cancel
Save