aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--backend/PrintAsm.ml4
-rw-r--r--cfrontend/C2C.ml23
-rw-r--r--powerpc/AsmToJSON.ml44
3 files changed, 41 insertions, 30 deletions
diff --git a/backend/PrintAsm.ml b/backend/PrintAsm.ml
index 1f100b7e..0e9eadcb 100644
--- a/backend/PrintAsm.ml
+++ b/backend/PrintAsm.ml
@@ -102,7 +102,9 @@ module Printer(Target:TARGET) =
let print_globdef oc (name,gdef) =
match gdef with
- | Gfun (Internal code) -> print_function oc name code
+ | Gfun (Internal code) ->
+ if not (C2C.atom_is_iso_inline_definition name) then
+ print_function oc name code
| Gfun (External ef) -> ()
| Gvar v -> print_var oc name v
diff --git a/cfrontend/C2C.ml b/cfrontend/C2C.ml
index 3bd1eea0..84e24640 100644
--- a/cfrontend/C2C.ml
+++ b/cfrontend/C2C.ml
@@ -40,14 +40,7 @@ let decl_atom : (AST.ident, atom_info) Hashtbl.t = Hashtbl.create 103
let atom_is_static a =
try
- let i = Hashtbl.find decl_atom a in
- (* inline functions can remain in generated code, but should not
- be global, unless explicitly marked "extern" *)
- match i.a_storage with
- | C.Storage_default -> i.a_inline
- | C.Storage_extern -> false
- | C.Storage_static -> true
- | C.Storage_register -> false (* should not happen *)
+ (Hashtbl.find decl_atom a).a_storage = C.Storage_static
with Not_found ->
false
@@ -87,6 +80,20 @@ let atom_is_inline a =
with Not_found ->
false
+(** Iso C99 defines inline definitions of functions as functions
+ with inline specifier and without extern. These functions do
+ not provide an external definition. In the case of non static
+ functions this means that no code should be generated for these
+ functions. *)
+let atom_is_iso_inline_definition a =
+ try
+ let i = Hashtbl.find decl_atom a in
+ match i.a_storage with
+ | C.Storage_default -> i.a_inline
+ | _ -> false
+ with Not_found ->
+ false
+
let atom_location a =
try
(Hashtbl.find decl_atom a).a_loc
diff --git a/powerpc/AsmToJSON.ml b/powerpc/AsmToJSON.ml
index 5304b967..d46b7849 100644
--- a/powerpc/AsmToJSON.ml
+++ b/powerpc/AsmToJSON.ml
@@ -300,27 +300,29 @@ let p_int_opt oc = function
let p_fundef oc (name,f) =
- let alignment = atom_alignof name
- and inline = atom_is_inline name
- and static = atom_is_static name
- and c_section,l_section,j_section = match (atom_sections name) with [a;b;c] -> a,b,c | _ -> assert false in
- output_string oc "{";
- p_jmember oc "Fun Name" p_atom name;
- p_sep oc;
- p_jmember oc "Fun Storage Class" p_storage static;
- p_sep oc;
- p_jmember oc "Fun Alignment" p_int_opt alignment;
- p_sep oc;
- p_jmember oc "Fun Section Code" p_section c_section;
- p_sep oc;
- p_jmember oc "Fun Section Literals" p_section l_section;
- p_sep oc;
- p_jmember oc "Fun Section Jumptable" p_section j_section;
- p_sep oc;
- p_jmember oc "Fun Inline" p_jbool inline;
- p_sep oc;
- p_jmember oc "Fun Code" (fun oc a -> fprintf oc "[%a]" p_instruction a) f.fn_code;
- output_string oc "}\n"
+ if not (is_inline_function name) then begin
+ let alignment = atom_alignof name
+ and inline = atom_is_inline name
+ and static = atom_is_static name
+ and c_section,l_section,j_section = match (atom_sections name) with [a;b;c] -> a,b,c | _ -> assert false in
+ output_string oc "{";
+ p_jmember oc "Fun Name" p_atom name;
+ p_sep oc;
+ p_jmember oc "Fun Storage Class" p_storage static;
+ p_sep oc;
+ p_jmember oc "Fun Alignment" p_int_opt alignment;
+ p_sep oc;
+ p_jmember oc "Fun Section Code" p_section c_section;
+ p_sep oc;
+ p_jmember oc "Fun Section Literals" p_section l_section;
+ p_sep oc;
+ p_jmember oc "Fun Section Jumptable" p_section j_section;
+ p_sep oc;
+ p_jmember oc "Fun Inline" p_jbool inline;
+ p_sep oc;
+ p_jmember oc "Fun Code" (fun oc a -> fprintf oc "[%a]" p_instruction a) f.fn_code;
+ output_string oc "}\n"
+ end
let p_init_data oc = function
| Init_int8 ic -> p_jsingle_object oc "Init_int8" p_int ic