diff options
author | Cyril SIX <cyril.six@kalray.eu> | 2020-12-08 10:54:53 +0100 |
---|---|---|
committer | Cyril SIX <cyril.six@kalray.eu> | 2020-12-08 10:54:53 +0100 |
commit | 5c426cf3b668d43b2f5294f70ab288654c316405 (patch) | |
tree | 466a3785e5fd4859edfd901ecd362243ed3f494b /backend/Duplicateaux.ml | |
parent | 23da7b35d0edf98f271401ac93a1fa06adb062a2 (diff) | |
download | compcert-kvx-5c426cf3b668d43b2f5294f70ab288654c316405.tar.gz compcert-kvx-5c426cf3b668d43b2f5294f70ab288654c316405.zip |
Fix on find_last_node_before_loop
It was too permissive
Diffstat (limited to 'backend/Duplicateaux.ml')
-rw-r--r-- | backend/Duplicateaux.ml | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/backend/Duplicateaux.ml b/backend/Duplicateaux.ml index c9985dc4..dc95d5b9 100644 --- a/backend/Duplicateaux.ml +++ b/backend/Duplicateaux.ml @@ -732,10 +732,14 @@ let rec find_last_node_before_loop code node trace is_loop_header = get_some @@ PTree.get n is_loop_header && HashedSet.PSet.contains trace n) rtl_succ in match headers with | [] -> ( - let next_nodes = List.filter (fun n -> HashedSet.PSet.contains trace n) - (rtl_successors_pref @@ get_some @@ PTree.get node code) in + let next_nodes = rtl_successors_pref @@ get_some @@ PTree.get node code in match next_nodes with - | [n] -> find_last_node_before_loop code n trace is_loop_header + | [n] -> ( + (* To prevent getting out of the superblock and loop infinitely when the prediction is false *) + if HashedSet.PSet.contains trace n then + find_last_node_before_loop code n trace is_loop_header + else None + ) | _ -> None (* May happen when we predict that a loop is not taken *) ) | [h] -> Some node |