unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Matt Wette <matt.wette@gmail.com>
To: 54478@debbugs.gnu.org
Subject: bug#54478: unwanted source references showing up w/ -O0 (with patch)
Date: Sun, 20 Mar 2022 08:11:10 -0700	[thread overview]
Message-ID: <4b3857bc-a068-a1c8-4583-73c9d3c909bc@gmail.com> (raw)

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))))
  







             reply	other threads:[~2022-03-20 15:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-20 15:11 Matt Wette [this message]
2022-03-27 14:27 ` bug#54478: unwanted source references Matt Wette

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4b3857bc-a068-a1c8-4583-73c9d3c909bc@gmail.com \
    --to=matt.wette@gmail.com \
    --cc=54478@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).