GNU bug report logs - #54478
unwanted source references showing up w/ -O0 (with patch)

Previous Next

Package: guile;

Reported by: Matt Wette <matt.wette <at> gmail.com>

Date: Sun, 20 Mar 2022 15:12:02 UTC

Severity: normal

To reply to this bug, email your comments to 54478 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#54478; Package guile. (Sun, 20 Mar 2022 15:12:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Matt Wette <matt.wette <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Sun, 20 Mar 2022 15:12:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Matt Wette <matt.wette <at> gmail.com>
To: bug-guile <at> gnu.org
Subject: unwanted source references showing up w/ -O0 (with patch)
Date: Sun, 20 Mar 2022 08:11:10 -0700
In guile-3.0.8, when I compile w/ optimiation-level 0, I am seeing references
to the beginning let-form.   The following illustrates the issue.  Consider

foo.scm:
(define *a* (make-parameter 0))
(define (foo . args)
    (let* ((b (+ (*a*) 1))
           (c (+ (*a*) b 2)))
      (simple-format #t "foo a= ~S\n" (*a*))
      (simple-format #t "foo b= ~S\n" b)
      (simple-format #t "foo c= ~S\n" c)))

and p2.scm:
(use-modules (system base compile))
(use-modules (system vm program))
(use-modules (ice-9 pretty-print))

(compile-and-load "foo.scm" #:optimization-level 0)
(define sources (program-sources-pre-retire foo))
(pretty-print sources)

With guile-3.0.8, I see the followiing output.
Note the references back to line 2.((0 "foo.scm" 1 . 0)
 (20 "foo.scm" 2 . 4)
 (20 "foo.scm" 2 . 15)
 (76 "foo.scm" 2 . 18)
 (132 "foo.scm" 2 . 17)
 (152 "foo.scm" 2 . 23)
 (156 "foo.scm" 2 . 14)
 (176 "foo.scm" 2 . 4)
 (176 "foo.scm" 3 . 15)
 (232 "foo.scm" 3 . 18)
 (288 "foo.scm" 3 . 17)
 (308 "foo.scm" 3 . 23)
 (312 "foo.scm" 3 . 25)
 (316 "foo.scm" 3 . 14)
 (336 "foo.scm" 2 . 4)
 (336 "foo.scm" 4 . 7)
 (392 "foo.scm" 4 . 21)
 (396 "foo.scm" 4 . 24)
 (404 "foo.scm" 4 . 39)
 (460 "foo.scm" 4 . 38)
 (480 "foo.scm" 4 . 6)
 (496 "foo.scm" 2 . 4)
 (496 "foo.scm" 5 . 7)
 (552 "foo.scm" 5 . 21)
 (556 "foo.scm" 5 . 24)
 (564 "foo.scm" 5 . 38)
 (568 "foo.scm" 5 . 6)
 (584 "foo.scm" 6 . 7)
 (640 "foo.scm" 6 . 21)
 (644 "foo.scm" 6 . 24)
 (652 "foo.scm" 6 . 38)
 (656 "foo.scm" 6 . 6))

With the patch shown below, this is what I get:
((0 "foo.scm" 1 . 0)
 (20 "foo.scm" 2 . 4)
 (20 "foo.scm" 2 . 15)
 (76 "foo.scm" 2 . 18)
 (132 "foo.scm" 2 . 17)
 (152 "foo.scm" 2 . 23)
 (156 "foo.scm" 2 . 14)
 (176 "foo.scm" 2 . 4)
 (176 "foo.scm" 3 . 15)
 (232 "foo.scm" 3 . 18)
 (288 "foo.scm" 3 . 17)
 (308 "foo.scm" 3 . 23)
 (312 "foo.scm" 3 . 25)
 (316 "foo.scm" 3 . 14)
 (336 "foo.scm" 4 . 7)
 (392 "foo.scm" 4 . 21)
 (396 "foo.scm" 4 . 24)
 (404 "foo.scm" 4 . 39)
 (460 "foo.scm" 4 . 38)
 (480 "foo.scm" 4 . 6)
 (496 "foo.scm" 5 . 7)
 (552 "foo.scm" 5 . 21)
 (556 "foo.scm" 5 . 24)
 (564 "foo.scm" 5 . 38)
 (568 "foo.scm" 5 . 6)
 (584 "foo.scm" 6 . 7)
 (640 "foo.scm" 6 . 21)
 (644 "foo.scm" 6 . 24)
 (652 "foo.scm" 6 . 38)
 (656 "foo.scm" 6 . 6))


Patch follows.  In a sequence, the source of the forms should be emitted,
not the parent sequence source (start).
--- guile-3.0.8-dist/module/language/tree-il/compile-bytecode.scm	2021-09-30 05:30:38.000000000 -0700
+++ guile-3.0.8-srcfix/module/language/tree-il/compile-bytecode.scm	2022-03-19 09:37:28.126740690 -0700
@@ -910,7 +910,7 @@
     (define (visit-seq exp env ctx)
       (match exp
         (($ <seq> src head tail)
-         (maybe-emit-source src)
+         ;;(maybe-emit-source src)
          (for-effect head env)
          (for-context tail env ctx))))
 






Information forwarded to bug-guile <at> gnu.org:
bug#54478; Package guile. (Sun, 27 Mar 2022 14:28:01 GMT) Full text and rfc822 format available.

Message #8 received at 54478 <at> debbugs.gnu.org (full text, mbox):

From: Matt Wette <matt.wette <at> gmail.com>
To: 54478 <at> debbugs.gnu.org
Subject: Re: unwanted source references
Date: Sun, 27 Mar 2022 07:27:30 -0700
I think the error is in use of "src" arg to make-seq in the following loop,
in ice-9/psyntax.scm, starting at line 1633:

                (let lp ((var-ids var-ids) (vars vars) (vals vals)
                         (tail (expand-tail-expr)))
                  (cond
                   ((null? var-ids) tail)
                   ((not (car var-ids))
                    (lp (cdr var-ids) (cdr vars) (cdr vals)
                        (make-seq src ((car vals)) tail)))
                   (else
                    (let ((var-ids (map (lambda (id)
                                          (if id (syntax->datum id) '_))
                                        (reverse var-ids)))
                          (vars (map (lambda (var) (or var (gen-label)))
                                     (reverse vars)))
                          (vals (map (lambda (expand-expr id)
                                       (if id
                                           (expand-expr)
                                           (make-seq src
                                                     (expand-expr)
                                                     (build-void src))))
                                     (reverse vals) (reverse var-ids))))
                      (build-letrec src #t var-ids vars vals tail)))))





This bug report was last modified 2 years and 242 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.