]> git.eshelyaron.com Git - emacs.git/commitdiff
sanity check against block duplication.
authorAndrea Corallo <akrl@sdf.org>
Sun, 27 Oct 2019 17:14:33 +0000 (18:14 +0100)
committerAndrea Corallo <akrl@sdf.org>
Wed, 1 Jan 2020 10:37:59 +0000 (11:37 +0100)
lisp/emacs-lisp/comp.el

index abcddda38089a7d8e99abdedef920f7c44b47e1b..e5db273a8ed5830b4fc70c621db8ce4a1e35add2 100644 (file)
@@ -507,7 +507,7 @@ Restore the original value afterwards."
       (error "Can't find label %d" label)))
 
 (cl-defun comp-block-maybe-mark-pending (&rest args &key name sp &allow-other-keys)
-  "Create a basic block and mark it as pending.
+  "If necessary create a pending basic block.
 The basic block is returned."
   (if-let ((bb (gethash name (comp-func-blocks comp-func))))
       ;; If was already declared sanity check sp.
@@ -1062,7 +1062,7 @@ This will be called at load-time."
                  do (return (comp-block-name bb))))))
 
 (defun comp-add-pending-block (sp)
-  "Add next basic block to the pending queue.
+  "Create basic block and add it to the pending queue if necessary.
 The block name is returned."
   (let ((next-bb (or (comp-addr-to-bb-name (comp-limplify-pc comp-pass))
                      (comp-new-block-sym))))
@@ -1126,6 +1126,12 @@ The block name is returned."
     (cl-loop for next-bb = (pop (comp-limplify-pending-blocks comp-pass))
              while next-bb
              do (comp-limplify-block next-bb))
+    ;; Sanity check against block duplication.
+    (cl-loop with addr-h = (make-hash-table)
+             for bb being the hash-value in (comp-func-blocks func)
+             for addr = (comp-block-addr bb)
+             do (cl-assert (null (gethash addr addr-h)))
+                (puthash addr t addr-h))
     (comp-limplify-finalize-function func)))
 
 (defun comp-add-func-to-ctxt (func)