From 733976ac5f6810d34d6ad8708cab4ba03428061b Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Fri, 24 Apr 2009 18:15:49 -0400 Subject: [PATCH] Bugfix: if the last case of a switch did not have a break (or any other find of jump), dead code elimination would fail. --- cfg.scm | 7 ++----- six-comp.scm | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cfg.scm b/cfg.scm index af16115..a8576e3 100644 --- a/cfg.scm +++ b/cfg.scm @@ -317,7 +317,7 @@ (set! prev-bb bb)) (cdr (ast-subasts ast))) (if (null? (bb-succs prev-bb)) ; if the last case didn't end in a break, fall through to the exit - (add-succ prev-bb exit-bb)) + (gen-goto exit-bb)) (bb-succs-set! decision-bb (reverse (bb-succs decision-bb))) ; preserving the order is important in the absence of break (set! case-list (list-named-bbs decision-bb '())) (set! default (keep (lambda (x) (eq? (car x) 'default)) @@ -565,10 +565,7 @@ (case id ((x+y) 'add) ((x-y) 'sub)) (case id ((x+y) 'addc) ((x-y) 'subb))) (car bytes1) (car bytes2) (car bytes3))) - (loop (if (null? bytes1) bytes1 (cdr bytes1)) - (if (null? bytes2) bytes2 (cdr bytes2)) - (cdr bytes3) - #f))))) + (loop (cdr bytes1) (cdr bytes2) (cdr bytes3) #f))))) (define (mul x y type result) ;; finds the appropriate multiplication routine (depending on the length diff --git a/six-comp.scm b/six-comp.scm index cb58d60..5a8417d 100755 --- a/six-comp.scm +++ b/six-comp.scm @@ -58,7 +58,7 @@ (let ((source (read-source filename))) '(pretty-print source) (let* ((ast (parse source))) - '(pretty-print ast) + (pretty-print ast) (let ((cfg (generate-cfg ast))) '(print-cfg-bbs cfg) (pretty-print cfg) -- 2.11.4.GIT