From 489a3d67359779c02f4a0d5a56db3a3bf0e7d357 Mon Sep 17 00:00:00 2001 From: Michael Schwarz Date: Wed, 2 Feb 2022 16:34:00 +0100 Subject: [PATCH 1/4] no merge inlines --- src/mergecil.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mergecil.ml b/src/mergecil.ml index 2da60036b..e98c6767e 100644 --- a/src/mergecil.ml +++ b/src/mergecil.ml @@ -65,7 +65,7 @@ let usePathCompression = false (* Try to merge definitions of inline functions. They can appear in multiple * files and we would like them all to be the same. This can slow down the * merger an order of magnitude !!! *) -let mergeInlines = true +let mergeInlines = false let mergeInlinesRepeat = mergeInlines && true @@ -296,7 +296,7 @@ let tEq: (int * string, typeinfo node) H.t = H.create 111 (* Type names*) let iEq: (int * string, varinfo node) H.t = H.create 111 (* Inlines *) (* Sometimes we want to merge synonyms. We keep some tables indexed by names. - * Each name is mapped to multiple exntries *) + * Each name is mapped to multiple entries *) let vSyn: (string, varinfo node) H.t = H.create 111 (* Not actually used *) let iSyn: (string, varinfo node) H.t = H.create 111 (* Inlines *) let sSyn: (string, compinfo node) H.t = H.create 111 From de8ab17455b96d36cc60ef0ca4a4ce401d9fd5a1 Mon Sep 17 00:00:00 2001 From: Michael Schwarz Date: Fri, 4 Feb 2022 07:39:19 +0100 Subject: [PATCH 2/4] Expose merge_inlines --- src/mergecil.ml | 16 ++++++++-------- src/mergecil.mli | 9 +++++++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/mergecil.ml b/src/mergecil.ml index e98c6767e..94391f416 100644 --- a/src/mergecil.ml +++ b/src/mergecil.ml @@ -65,11 +65,11 @@ let usePathCompression = false (* Try to merge definitions of inline functions. They can appear in multiple * files and we would like them all to be the same. This can slow down the * merger an order of magnitude !!! *) -let mergeInlines = false +let merge_inlines = ref false -let mergeInlinesRepeat = mergeInlines && true +let mergeInlinesRepeat = !merge_inlines && true -let mergeInlinesWithAlphaConvert = mergeInlines && true +let mergeInlinesWithAlphaConvert = !merge_inlines && true (* when true, merge duplicate definitions of externally-visible functions; * this uses a mechanism which is faster than the one for inline functions, @@ -540,7 +540,7 @@ let rec combineTypes (what: combineWhat) oldfidx oldrt fidx rt in if oldva != va then - raise (Failure "(diferent vararg specifiers)"); + raise (Failure "(different vararg specifiers)"); (* If one does not have arguments, believe the one with the * arguments *) let newargs = @@ -879,7 +879,7 @@ let oneFilePass1 (f:file) : unit = if fdec.svar.vstorage <> Static then begin matchVarinfo fdec.svar (l, !currentDeclIdx) end else begin - if fdec.svar.vinline && mergeInlines then + if fdec.svar.vinline && !merge_inlines then (* Just create the nodes for inline functions *) ignore (getNode iEq iSyn !currentFidx fdec.svar.vname fdec.svar (Some (l, !currentDeclIdx))) @@ -1455,7 +1455,7 @@ let oneFilePass2 (f: file) = setFormals fdec fdec.sformals end; (* See if we can remove this inline function *) - if fdec'.svar.vinline && mergeInlines then begin + if fdec'.svar.vinline && !merge_inlines then begin let printout = (* Temporarily turn of printing of lines *) let oldprintln = !lineDirectiveStyle in @@ -1754,7 +1754,7 @@ let merge (files: file list) (newname: string) : file = doMergeSynonyms sSyn sEq matchCompInfo; doMergeSynonyms eSyn eEq matchEnumInfo; doMergeSynonyms tSyn tEq matchTypeInfo; - if mergeInlines then begin + if !merge_inlines then begin (* Copy all the nodes from the iEq to vEq as well. This is needed * because vEq will be used for variable renaming *) H.iter (fun k n -> H.add vEq k n) iEq; @@ -1768,7 +1768,7 @@ let merge (files: file list) (newname: string) : file = dumpGraph "struct and union" sEq; dumpGraph "enum" eEq; dumpGraph "variable" vEq; - if mergeInlines then dumpGraph "inline" iEq; + if !merge_inlines then dumpGraph "inline" iEq; end; (* Make the second pass over the files. This is when we start rewriting the * file *) diff --git a/src/mergecil.mli b/src/mergecil.mli index a864c69a9..7790d746d 100644 --- a/src/mergecil.mli +++ b/src/mergecil.mli @@ -1,11 +1,11 @@ (* * - * Copyright (c) 2001-2002, + * Copyright (c) 2001-2002, * George C. Necula * Scott McPeak * Wes Weimer * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: @@ -38,5 +38,10 @@ (** Set this to true to ignore the merge conflicts *) val ignore_merge_conflicts: bool ref +(** Try to merge definitions of inline functions. They can appear in multiple + * files and we would like them all to be the same. This can slow down the + * merger an order of magnitude !!! *) +val merge_inlines: bool ref + (** Merge a number of CIL files *) val merge: Cil.file list -> string -> Cil.file From c1a7904c0f748517abe4c2f2303cfe159a6d254e Mon Sep 17 00:00:00 2001 From: Michael Schwarz Date: Fri, 4 Feb 2022 07:52:15 +0100 Subject: [PATCH 3/4] Typo --- src/mergecil.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mergecil.ml b/src/mergecil.ml index 94391f416..41abc42a8 100644 --- a/src/mergecil.ml +++ b/src/mergecil.ml @@ -1457,7 +1457,7 @@ let oneFilePass2 (f: file) = (* See if we can remove this inline function *) if fdec'.svar.vinline && !merge_inlines then begin let printout = - (* Temporarily turn of printing of lines *) + (* Temporarily turn off printing of lines *) let oldprintln = !lineDirectiveStyle in lineDirectiveStyle := None; (* Temporarily set the name to all functions in the same way *) From 94c3b9113a53f3103cd74ee6ef0c680382cc7dfa Mon Sep 17 00:00:00 2001 From: Michael Schwarz Date: Fri, 4 Feb 2022 09:20:08 +0100 Subject: [PATCH 4/4] Make `mergeInlinesRepeat` and `mergeInlinesWithAlphaConvert `functions to account for modifications of `merge_inlines` --- src/mergecil.ml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mergecil.ml b/src/mergecil.ml index 41abc42a8..a42dd0159 100644 --- a/src/mergecil.ml +++ b/src/mergecil.ml @@ -67,9 +67,9 @@ let usePathCompression = false * merger an order of magnitude !!! *) let merge_inlines = ref false -let mergeInlinesRepeat = !merge_inlines && true +let mergeInlinesRepeat () = !merge_inlines && true -let mergeInlinesWithAlphaConvert = !merge_inlines && true +let mergeInlinesWithAlphaConvert () = !merge_inlines && true (* when true, merge duplicate definitions of externally-visible functions; * this uses a mechanism which is faster than the one for inline functions, @@ -1481,7 +1481,7 @@ let oneFilePass2 (f: file) = in (* Remember the original type *) let origType = fdec'.svar.vtype in - if mergeInlinesWithAlphaConvert then begin + if mergeInlinesWithAlphaConvert () then begin (* Rename the formals *) List.iter renameOne fdec'.sformals; (* Reflect in the type *) @@ -1493,7 +1493,7 @@ let oneFilePass2 (f: file) = let res = d_global () g' in lineDirectiveStyle := oldprintln; fdec'.svar.vname <- newname; - if mergeInlinesWithAlphaConvert then begin + if mergeInlinesWithAlphaConvert () then begin (* Do the locals in reverse order *) List.iter undoRenameOne (List.rev fdec'.slocals); (* Do the formals in reverse order *) @@ -1526,7 +1526,7 @@ let oneFilePass2 (f: file) = * We should reuse this, but watch for the case when the inline * was already used. *) if H.mem varUsedAlready fdec'.svar.vname then begin - if mergeInlinesRepeat then begin + if mergeInlinesRepeat () then begin repeatPass2 := true end else begin ignore (warn "Inline function %s because it is used before it is defined" fdec'.svar.vname); @@ -1708,7 +1708,7 @@ let oneFilePass2 (f: file) = (* See if we must re-visit the globals in this file because an inline that * is being removed was used before we saw the definition and we decided to * remove it *) - if mergeInlinesRepeat && !repeatPass2 then begin + if mergeInlinesRepeat () && !repeatPass2 then begin if debugMerge || !E.verboseFlag then ignore (E.log "Repeat final merging phase (%d): %s\n" !currentFidx f.fileName);