File tree 2 files changed +41
-0
lines changed
2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -93,3 +93,26 @@ let[@zero_alloc strict] test68 x =
93
93
carries the "assume" information of operations that were optimized away.
94
94
So far, we haven't seen the need for it in a real example.
95
95
*)
96
+
97
+ (* CR gyorsh: the check passes on g0 and fails on g1-g3 below, even though the
98
+ generated code is exactly the same in all four cases. The difference is because
99
+ "assume" is not propagated on partial applications. There is no misplaced
100
+ attribute warning. This is the same behavior as for "@inlined" annotations.
101
+ *)
102
+ let [@ inline never][@ local never] f x y = (x,y)
103
+
104
+ let [@ zero_alloc] g0 () =
105
+ let x = (f[@ zero_alloc assume]) () () in
106
+ x
107
+
108
+ let [@ zero_alloc] g1 () =
109
+ let x = ((f[@ zero_alloc assume]) () ) () in
110
+ x
111
+
112
+ let [@ zero_alloc] g2 () =
113
+ let x = ((f () )[@ zero_alloc assume]) () in
114
+ x
115
+
116
+ let [@ zero_alloc] g3 () =
117
+ let x = (((f[@ zero_alloc assume]) () )[@ zero_alloc assume]) () in
118
+ x
Original file line number Diff line number Diff line change @@ -48,3 +48,21 @@ Error: Annotation check for zero_alloc strict failed on function Test_assume_fai
48
48
49
49
File "test_assume_fail.ml", line 85, characters 5-9:
50
50
Error: allocation of 24 bytes
51
+
52
+ File "test_assume_fail.ml", line 108, characters 5-15:
53
+ Error: Annotation check for zero_alloc failed on function Test_assume_fail.g1 (camlTest_assume_fail.g1_HIDE_STAMP)
54
+
55
+ File "test_assume_fail.ml", line 109, characters 10-41:
56
+ Error: called function may allocate (direct tailcall camlTest_assume_fail.f_HIDE_STAMP)
57
+
58
+ File "test_assume_fail.ml", line 112, characters 5-15:
59
+ Error: Annotation check for zero_alloc failed on function Test_assume_fail.g2 (camlTest_assume_fail.g2_HIDE_STAMP)
60
+
61
+ File "test_assume_fail.ml", line 113, characters 10-41:
62
+ Error: called function may allocate (direct tailcall camlTest_assume_fail.f_HIDE_STAMP)
63
+
64
+ File "test_assume_fail.ml", line 116, characters 5-15:
65
+ Error: Annotation check for zero_alloc failed on function Test_assume_fail.g3 (camlTest_assume_fail.g3_HIDE_STAMP)
66
+
67
+ File "test_assume_fail.ml", line 117, characters 10-63:
68
+ Error: called function may allocate (direct tailcall camlTest_assume_fail.f_HIDE_STAMP)
You can’t perform that action at this time.
0 commit comments