[m-rev.] diff: fix bug #455

Julien Fischer jfischer at opturion.com
Sat Apr 21 21:14:16 AEST 2018


Fix bug #455.

compiler/simplify_proc.m:
     Update the list of predicates that can be introduced by the simplification
     pass to include those from the uint, int{8,16,32,64} and uint{8,16,32,64}
     modules.  (The list not being up-to-date was the cause of bug #455.)

tests/hard_coded/Mmakefile:
tests/hard_coded/Mercury.options.m:
tests/hard_coded/bug455_mod_a.m:
tests/hard_coded/bug455_mod_b.m:
tests/hard_coded/bug455_mod_a.exp:
     Add a regression test for the above issue.

Julien.

diff --git a/compiler/simplify_proc.m b/compiler/simplify_proc.m
index 0c551ee01..d9e89f7 100644
--- a/compiler/simplify_proc.m
+++ b/compiler/simplify_proc.m
@@ -784,7 +784,17 @@ simplify_may_introduce_calls(ModuleName, PredName, _Arity) :-
          ; PredName = "state_var_copy"
          )
      ;
-        ModuleName = "int",
+        ( ModuleName = "int"
+        ; ModuleName = "uint"
+        ; ModuleName = "int8"
+        ; ModuleName = "uint8"
+        ; ModuleName = "int16"
+        ; ModuleName = "uint16"
+        ; ModuleName = "int32"
+        ; ModuleName = "uint32"
+        ; ModuleName = "int64"
+        ; ModuleName = "uint64"
+        ),
          ( PredName = "*"
          ; PredName = "unchecked_quotient"
          ; PredName = "unchecked_rem"
diff --git a/tests/hard_coded/Mercury.options b/tests/hard_coded/Mercury.options
index 9a3e37b..7c8c675 100644
--- a/tests/hard_coded/Mercury.options
+++ b/tests/hard_coded/Mercury.options
@@ -14,6 +14,7 @@ MCFLAGS-bug240 =		-O1
  MCFLAGS-bug300 =		--no-const-struct --optimize-constructor-last-call
  MCFLAGS-bug314 =		--trace deep
  MCFLAGS-bug392 =		-O0 --deforestation
+MCFLAGS-bug455_mod_a 		= --intermodule-optimization
  MCFLAGS-checked_nondet_tailcall	= --checked-nondet-tailcalls
  MCFLAGS-checked_nondet_tailcall_noinline = --checked-nondet-tailcalls --no-inlining
  MCFLAGS-cc_and_non_cc_test = 	--no-inlining
diff --git a/tests/hard_coded/Mmakefile b/tests/hard_coded/Mmakefile
index 575c8fe..e7ac86e 100644
--- a/tests/hard_coded/Mmakefile
+++ b/tests/hard_coded/Mmakefile
@@ -40,6 +40,7 @@ ORDINARY_PROGS =	\
  	bug383 \
  	bug392 \
  	bug452 \
+	bug455_mod_a \
  	bug_pack_bits \
  	c89_neg_int \
  	c_write_string \
diff --git a/tests/hard_coded/bug455_mod_a.exp b/tests/hard_coded/bug455_mod_a.exp
index e69de29..80f1cb4 100644
--- a/tests/hard_coded/bug455_mod_a.exp
+++ b/tests/hard_coded/bug455_mod_a.exp
@@ -0,0 +1,10 @@
+62
+62
+62
+62
+62
+62
+62
+62
+62
+62
diff --git a/tests/hard_coded/bug455_mod_a.m b/tests/hard_coded/bug455_mod_a.m
index e69de29..bf3376c 100644
--- a/tests/hard_coded/bug455_mod_a.m
+++ b/tests/hard_coded/bug455_mod_a.m
@@ -0,0 +1,53 @@
+% Regression test for bug #455.
+% Compile with: mmc --intermod-opt -m bug455_ mod_a
+%
+%   Making Mercury/cs/bug455_mod_a.c
+%   Uncaught Mercury exception:
+%   Software Error: check_hlds.simplify.simplify_goal_call: predicate
+%   `check_hlds.simplify.simplify_goal_call.simplify_make_binary_op_goal_expr'/8:
+%   Unexpected: cannot find unchecked_left_shift
+%
+% The problem was that the list of predicates that simplification may introduce
+% did not include the uint and fixed size integers.
+
+:- module bug455_mod_a.
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+:- implementation.
+
+:- import_module bug455_mod_b.
+
+main(!IO) :-
+    write_int(bug455_mod_b.foo_int, !IO),
+    nl(!IO),
+
+    write_int8(bug455_mod_b.foo_int8, !IO),
+    nl(!IO),
+
+    write_int16(bug455_mod_b.foo_int16, !IO),
+    nl(!IO),
+
+    write_int32(bug455_mod_b.foo_int32, !IO),
+    nl(!IO),
+
+    write_int64(bug455_mod_b.foo_int64, !IO),
+    nl(!IO),
+
+    write_uint(bug455_mod_b.foo_uint, !IO),
+    nl(!IO),
+
+    write_uint8(bug455_mod_b.foo_uint8, !IO),
+    nl(!IO),
+
+    write_uint16(bug455_mod_b.foo_uint16, !IO),
+    nl(!IO),
+
+    write_uint32(bug455_mod_b.foo_uint32, !IO),
+    nl(!IO),
+
+    write_uint64(bug455_mod_b.foo_uint64, !IO),
+    nl(!IO).
diff --git a/tests/hard_coded/bug455_mod_b.m b/tests/hard_coded/bug455_mod_b.m
index e69de29..6a8e5fd 100644
--- a/tests/hard_coded/bug455_mod_b.m
+++ b/tests/hard_coded/bug455_mod_b.m
@@ -0,0 +1,38 @@
+:- module bug455_mod_b.
+:- interface.
+
+:- func foo_int = int.
+:- func foo_int8 = int8.
+:- func foo_int16 = int16.
+:- func foo_int32 = int32.
+:- func foo_int64 = int64.
+:- func foo_uint = uint.
+:- func foo_uint8 = uint8.
+:- func foo_uint16 = uint16.
+:- func foo_uint32 = uint32.
+:- func foo_uint64 = uint64.
+
+:- implementation.
+
+:- import_module int.
+:- import_module int8.
+:- import_module int16.
+:- import_module int32.
+:- import_module int64.
+:- import_module uint.
+:- import_module uint8.
+:- import_module uint16.
+:- import_module uint32.
+:- import_module uint64.
+
+foo_int = 0x1f << 1.
+foo_int8 = 0x1f_i8 << 1.
+foo_int16 = 0x1f_i16 << 1.
+foo_int32 = 0x1f_i32 << 1.
+foo_int64 = 0x1f_i64 << 1.
+
+foo_uint = 0x1f_u << 1.
+foo_uint8 = 0x1f_u8 << 1.
+foo_uint16 = 0x1f_u16 << 1.
+foo_uint32 = 0x1f_u32 << 1.
+foo_uint64 = 0x1f_u64 << 1.


More information about the reviews mailing list