mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-06 23:17:37 +00:00
Fix LLVM translation of modules.
This commit is contained in:
parent
80a1cd3d1e
commit
fdb842f9e6
@ -418,7 +418,6 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
|
||||
alt-tag.rs \
|
||||
arithmetic-interference.rs \
|
||||
argv.rs \
|
||||
auto-deref.rs \
|
||||
autoderef-full-lval.rs \
|
||||
autoderef-objfn.rs \
|
||||
basic.rs \
|
||||
@ -452,7 +451,6 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
|
||||
generic-drop-glue.rs \
|
||||
generic-exterior-box.rs \
|
||||
generic-fn-infer.rs \
|
||||
generic-fn-twice.rs \
|
||||
generic-fn.rs \
|
||||
generic-obj-with-derived-type.rs \
|
||||
generic-obj.rs \
|
||||
@ -482,8 +480,6 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
|
||||
mutable-alias-vec.rs \
|
||||
mutable-vec-drop.rs \
|
||||
mutual-recursion-group.rs \
|
||||
native-mod.rc \
|
||||
native.rc \
|
||||
obj-as.rs \
|
||||
obj-drop.rs \
|
||||
obj-dtor.rs \
|
||||
|
@ -588,7 +588,7 @@ let trans_crate
|
||||
(* Maps a fn's or block's id to an LLVM metadata node (subprogram or
|
||||
lexical block) representing it. *)
|
||||
let (dbg_llscopes:(node_id, Llvm.llvalue) Hashtbl.t) = Hashtbl.create 0 in
|
||||
let declare_mod_item
|
||||
let rec declare_mod_item
|
||||
(name:Ast.ident)
|
||||
mod_item
|
||||
: unit =
|
||||
@ -616,9 +616,8 @@ let trans_crate
|
||||
| Ast.MOD_ITEM_type _ ->
|
||||
() (* Types get translated with their terms. *)
|
||||
|
||||
| Ast.MOD_ITEM_mod _ ->
|
||||
() (* Modules simply contain other items that are translated
|
||||
on their own. *)
|
||||
| Ast.MOD_ITEM_mod (_, items) ->
|
||||
Hashtbl.iter declare_mod_item items
|
||||
|
||||
| _ ->
|
||||
Common.unimpl (Some id)
|
||||
@ -807,6 +806,17 @@ let trans_crate
|
||||
Ast.sprintf_lval lval)
|
||||
in
|
||||
|
||||
let trans_callee (fn:Ast.lval) : (Llvm.llvalue * Ast.ty) =
|
||||
let fty = Hashtbl.find sem_cx.ctxt_all_lval_types (lval_base_id fn) in
|
||||
if lval_base_is_item sem_cx fn then
|
||||
let fn_item = lval_item sem_cx fn in
|
||||
let llfn = Hashtbl.find llitems (fn_item.id) in
|
||||
(llfn, fty)
|
||||
else
|
||||
(* indirect call to computed slot *)
|
||||
trans_lval fn
|
||||
in
|
||||
|
||||
let trans_atom (atom:Ast.atom) : Llvm.llvalue =
|
||||
iflog (fun _ -> log sem_cx "trans_atom: %a" Ast.sprintf_atom atom);
|
||||
match atom with
|
||||
@ -959,7 +969,7 @@ let trans_crate
|
||||
| Ast.STMT_call (dest, fn, args) ->
|
||||
let llargs = Array.map trans_atom args in
|
||||
let (lldest, _) = trans_lval dest in
|
||||
let (llfn, _) = trans_lval fn in
|
||||
let (llfn, _) = trans_callee fn in
|
||||
let llallargs = Array.append [| lldest; lltask |] llargs in
|
||||
let llrv = build_call llfn llallargs "" llbuilder in
|
||||
Llvm.set_instruction_call_conv Llvm.CallConv.c llrv;
|
||||
@ -1072,13 +1082,22 @@ let trans_crate
|
||||
ignore (Llvm.build_br llbodyblock llinitbuilder)
|
||||
in
|
||||
|
||||
let trans_mod_item
|
||||
(_:Ast.ident)
|
||||
{ node = { Ast.decl_item = (item:Ast.mod_item') }; id = id }
|
||||
let rec trans_mod_item
|
||||
(name:Ast.ident)
|
||||
mod_item
|
||||
: unit =
|
||||
let { node = { Ast.decl_item = (item:Ast.mod_item') }; id = id } =
|
||||
mod_item in
|
||||
match item with
|
||||
Ast.MOD_ITEM_fn fn -> trans_fn fn id
|
||||
| _ -> ()
|
||||
Ast.MOD_ITEM_type _ ->
|
||||
() (* Types get translated with their terms. *)
|
||||
| Ast.MOD_ITEM_mod (_, items) ->
|
||||
Hashtbl.iter trans_mod_item items
|
||||
| Ast.MOD_ITEM_fn fn -> trans_fn fn id
|
||||
| _ -> Common.unimpl (Some id)
|
||||
"LLVM module declaration for: %a"
|
||||
Ast.sprintf_mod_item (name, mod_item)
|
||||
|
||||
in
|
||||
|
||||
let exit_task_glue =
|
||||
|
Loading…
Reference in New Issue
Block a user