summaryrefslogtreecommitdiff
path: root/asmcomp/deadcode.ml
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2014-05-16 14:37:22 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2014-05-16 14:37:22 +0000
commit657ba73021599ec386f65d4e07ff2d7445d864f4 (patch)
tree21485fe3f74709e2bedbc870b8cc1e71405c6534 /asmcomp/deadcode.ml
parent6d25df3c9bb2b5ea59463cd3832d4b06a02c6b68 (diff)
downloadocaml-657ba73021599ec386f65d4e07ff2d7445d864f4.tar.gz
Liveness & Deadcode: fix i386-specific issue with move instructions accessing
the x87 FP stack, which must not be eliminated. CSEgen: harden against the same x87-specific issue + against reuse of values in fixed hardware registers that were destroyed by a prior operation. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14877 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'asmcomp/deadcode.ml')
-rw-r--r--asmcomp/deadcode.ml7
1 files changed, 5 insertions, 2 deletions
diff --git a/asmcomp/deadcode.ml b/asmcomp/deadcode.ml
index d3d0fcb906..cb93c2869d 100644
--- a/asmcomp/deadcode.ml
+++ b/asmcomp/deadcode.ml
@@ -24,8 +24,11 @@ let rec deadcode i =
(i, Reg.add_set_array i.live i.arg)
| Iop op ->
let (s, before) = deadcode i.next in
- if Proc.op_is_pure op
- && Reg.disjoint_set_array before i.res then begin
+ if Proc.op_is_pure op (* no side effects *)
+ && Reg.disjoint_set_array before i.res (* results are not used after *)
+ && not (Proc.regs_are_volatile i.arg) (* no stack-like hard reg *)
+ && not (Proc.regs_are_volatile i.res) (* is involved *)
+ then begin
assert (Array.length i.res > 0); (* sanity check *)
(s, before)
end else begin