[sledge] fix LLVM assertion failure in xlate_global

Summary:
LLVM.global_initializer casues a cast assertion failure if the value
passed to it is not a GlobalVariable. So we first check if it is a
GlobalVariable and only then ask for an initiliazer.

This is hidden if LLVM is built without assertions.

Reviewed By: jberdine

Differential Revision: D15601632

fbshipit-source-id: e9db23a12
master
Timotej Kapus 6 years ago committed by Facebook Github Bot
parent 5b2a36409c
commit e45a05a574

@ -588,11 +588,14 @@ and xlate_global : x -> Llvm.llvalue -> Global.t =
its own initializer *)
Hashtbl.set memo_global ~key:llg ~data:(Global.mk g typ loc) ;
let init =
match (Llvm.classify_value llg, Llvm.global_initializer llg) with
| GlobalVariable, Some llinit ->
match Llvm.classify_value llg with
| GlobalVariable -> (
match Llvm.global_initializer llg with
| Some llinit ->
let siz = size_of x (Llvm.element_type llt) in
let init = xlate_value x llinit in
Some (init, siz)
| _ -> None )
| _ -> None
in
Global.mk ?init g typ loc

Loading…
Cancel
Save