[sledge] Add global merge pass

Summary:
Add a global merge pass that merges globals into a single big global. It
replaces the uses of globals merged, with offsets into the big global.
Function summarisationis a big benefactor of this as it greatly reduces
the number of implicit formals (ie. globals).

Reviewed By: jvillard

Differential Revision: D16260098

fbshipit-source-id: 1b936f02f
master
Timotej Kapus 6 years ago committed by Facebook Github Bot
parent 0ecd73d0f8
commit b5dea36c5e

@ -177,6 +177,7 @@ separation between xlate_intrinsic (which translates an intrinsic function name
- inline asm can take addresses of blocks as args, that can be jumped to
- treating inline asm conservatively requires considering these control flows
** support missing intrinsics
** Try to extract scope for `ConstantExpr` and `ConstantPointerNull` value types
** support vector operations
- by lowering into multiple scalar operations
- most cases handled by Frontend.transform

@ -81,8 +81,11 @@ let ( (scan_names_and_locs : Llvm.llmodule -> unit)
Some (`Fun (Llvm.block_parent (Llvm.instr_parent llv)))
| GlobalVariable | Function -> Some (`Mod (Llvm.global_parent llv))
| UndefValue -> None
| ConstantExpr -> None
| ConstantPointerNull -> None
| _ ->
warn "Unexpected type of llv, might crash: %a" pp_llvalue llv () ;
warn "Unexpected type %a of llv, might crash: %a" pp_llvaluekind
(Llvm.classify_value llv) pp_llvalue llv () ;
Some (`Mod (Llvm.global_parent llv))
in
match maybe_scope with

@ -159,7 +159,14 @@ let llvm_link_opt ~fuzzer ~bitcode_output modules =
(Lazy.force llvm_bin ^ "opt")
[ "-o=" ^ bitcode_output; "-globaldce"; "-globalopt"; "-mergefunc"
; "-constmerge"; "-argpromotion"; "-ipsccp"; "-mem2reg"; "-dce"
; "-globaldce"; "-deadargelim" ] )
; "-globaldce"; "-deadargelim"; "-global-merge-on-const"
; "-global-merge-ignore-single-use=false"
; "-global-merge-group-by-use=false"
(* global-merge-max-offset is set to 0 by default. If a global
variable has larger allocation size than the max-offset, it is
not merged, therefore the global-merge pass is a noop. We set
it to something big, so that it merges as much as possible. *)
; "-global-merge-max-offset=1000000"; "-global-merge" ] )
(** command line interface *)

Loading…
Cancel
Save