Skip to content

Disconnect blocks with exceptional successors #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,16 @@ flags.sexp: ocaml-stage1-config.status
else \
/bin/echo -n "(:standard)" > ocamlopt_flags.sexp; \
fi
/bin/echo -n "( $$(grep "^OC_CFLAGS=" ocaml/Makefile.config \
| sed 's/^OC_CFLAGS=//') )" > oc_cflags.sexp
/bin/echo -n "( $$(grep "^OC_CPPFLAGS=" ocaml/Makefile.config \
| sed 's/^OC_CPPFLAGS=//') )" > oc_cppflags.sexp
/bin/echo -n "( $$(grep "^SHAREDLIB_CFLAGS=" ocaml/Makefile.config \
| sed 's/^SHAREDLIB_CFLAGS=//') )" > sharedlib_cflags.sexp
# note: it looks like the use of "$(...)" with a command spanning over
# two lines triggers a bug in GNU make 3.81, that will as a consequence
# change the file name. It also looks like the bug is not triggered by
# "`...`".
/bin/echo -n "( `grep \"^OC_CFLAGS=\" ocaml/Makefile.config \
| sed 's/^OC_CFLAGS=//'` )" > oc_cflags.sexp
/bin/echo -n "( `grep \"^OC_CPPFLAGS=\" ocaml/Makefile.config \
| sed 's/^OC_CPPFLAGS=//'` )" > oc_cppflags.sexp
/bin/echo -n "( `grep \"^SHAREDLIB_CFLAGS=\" ocaml/Makefile.config \
| sed 's/^SHAREDLIB_CFLAGS=//'` )" > sharedlib_cflags.sexp

# Most of the installation tree is correctly set up by dune, but we need to
# copy it to the final destination, and rearrange a few things to match
Expand Down
8 changes: 7 additions & 1 deletion backend/cfg/disconnect_block.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ let disconnect cfg_with_layout label =
(* CR-someday gyorsh: if trap handlers can be eliminated, remove this
label from block.exn of other blocks. *)
Misc.fatal_error "Removing trap handler blocks is not supported";
let successors = C.successor_labels ~normal:true ~exn:true cfg block in
let successors = C.successor_labels ~normal:true ~exn:false cfg block in
let has_predecessors = not (Label.Set.is_empty block.predecessors) in
let n = Label.Set.cardinal successors in
let has_more_than_one_successor = n > 1 in
Expand All @@ -65,6 +65,12 @@ let disconnect cfg_with_layout label =
(Label.Set.remove label succ_block.predecessors)
block.predecessors)
successors;
Label.Set.iter
(fun succ ->
let succ_block = C.get_block_exn cfg succ in
assert (Label.Set.mem label succ_block.predecessors);
succ_block.predecessors <- Label.Set.remove label succ_block.predecessors)
(C.successor_labels ~normal:false ~exn:true cfg block);
(* Update predecessor blocks. *)
if n = 1 then
let target_label = Label.Set.min_elt successors in
Expand Down