From 635b8c517db4371a7b8972ff319da94559da3120 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Fri, 8 Feb 2019 15:23:12 -0500 Subject: [PATCH] add a flag to indicate which slots are accessed --- src/ast.scm | 6 +++--- src/julia-syntax.scm | 7 ++++++- src/method.c | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ast.scm b/src/ast.scm index 68005a1e4fc47..22425cb51f866 100644 --- a/src/ast.scm +++ b/src/ast.scm @@ -434,7 +434,7 @@ (define (vinfo:capt v) (< 0 (logand (caddr v) 1))) (define (vinfo:asgn v) (< 0 (logand (caddr v) 2))) (define (vinfo:never-undef v) (< 0 (logand (caddr v) 4))) -(define (vinfo:const v) (< 0 (logand (caddr v) 8))) +(define (vinfo:read v) (< 0 (logand (caddr v) 8))) (define (vinfo:sa v) (< 0 (logand (caddr v) 16))) (define (set-bit x b val) (if val (logior x b) (logand x (lognot b)))) ;; record whether var is captured @@ -443,8 +443,8 @@ (define (vinfo:set-asgn! v a) (set-car! (cddr v) (set-bit (caddr v) 2 a))) ;; whether the assignments to var are known to dominate its usages (define (vinfo:set-never-undef! v a) (set-car! (cddr v) (set-bit (caddr v) 4 a))) -;; whether var is const -(define (vinfo:set-const! v a) (set-car! (cddr v) (set-bit (caddr v) 8 a))) +;; whether var is ever read +(define (vinfo:set-read! v a) (set-car! (cddr v) (set-bit (caddr v) 8 a))) ;; whether var is assigned once (define (vinfo:set-sa! v a) (set-car! (cddr v) (set-bit (caddr v) 16 a))) ;; occurs undef: mask 32 diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index 068f88bc04e35..831e42406ffb4 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -2641,7 +2641,12 @@ ;; where var-info-lst is a list of var-info records (define (analyze-vars e env captvars sp) (if (or (atom? e) (quoted? e)) - e + (begin + (if (symbol? e) + (let ((vi (var-info-for e env))) + (if vi + (vinfo:set-read! vi #t)))) + e) (case (car e) ((local-def) ;; a local that we know has an assignment that dominates all usages (let ((vi (var-info-for (cadr e) env))) diff --git a/src/method.c b/src/method.c index 42add352f46a6..7962502d57f1c 100644 --- a/src/method.c +++ b/src/method.c @@ -259,7 +259,7 @@ static void jl_code_info_set_ast(jl_code_info_t *li, jl_expr_t *ast) li->ssaflags = jl_alloc_array_1d(jl_array_uint8_type, 0); // Flags that need to be copied to slotflags - const uint8_t vinfo_mask = 16 | 32 | 64; + const uint8_t vinfo_mask = 8 | 16 | 32 | 64; int i; for (i = 0; i < nslots; i++) { jl_value_t *vi = jl_array_ptr_ref(vis, i);