# Second pass is used to assign an effective slot to iregsiters
var _pass: Int = 0
+ # Update locality information of r according to the current iroutine
+ fun mark_locality(r: IRegister)
+ do
+ if r._is_local and r._local_iroutine != _current_ir then
+ if r._local_iroutine == null then
+ r._local_iroutine = _current_ir
+ else
+ r._is_local = false
+ end
+ end
+ end
+
redef fun visit_iregister_read(ic: ICode, r: IRegister)
do
var pass = _pass
if pass == 0 then
- if r._is_local and r._local_iroutine != _current_ir then
- if r._local_iroutine == null then
- r._local_iroutine = _current_ir
- else
- r._is_local = false
- end
- end
+ mark_locality(r)
_lasts[r] = ic
r._slot_index = null
else if pass == 1 and _lasts.has_key(r) and _lasts[r] == ic then
do
var pass = _pass
if pass == 0 then
- # Process locality
- if r._is_local and r._local_iroutine != _current_ir then
- if r._local_iroutine == null then
- r._local_iroutine = _current_ir
- else
- r._is_local = false
- end
- end
+ mark_locality(r)
r._slot_index = null
# The first write make it live
if not _firsts.has_key(r) then _firsts[r] = ic
_current_ir = ir
for r in ir.params do
_firsts[r] = self
+ mark_locality(r)
end
super
if res != null then
_lasts[res] = self
+ mark_locality(res)
end
_current_ir = old_ir
else
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2009 Jean Privat <jean@pryen.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import kernel
+
+fun foo
+ !f
+do
+ f
+end
+
+fun test: Int
+do
+ var i = 1
+ i.output
+ foo !f do
+ return 2
+ end
+ abort
+end
+
+test.output