Add the remaining diagnosis messages.
This commit is contained in:
parent
975cb7ad9d
commit
00d23a4535
|
@ -378,7 +378,10 @@
|
|||
#:when (when (and (in-complex-layer? #'e)
|
||||
(for/and ([subexpr (in-list (syntax->list #'(e.args ...)))])
|
||||
(subtypeof? subexpr -Real)))
|
||||
(log-missed-optimization "unexpected complex type" this-syntax))
|
||||
(log-missed-optimization
|
||||
"unexpected complex type"
|
||||
"This expression has a Complex type, despite all its arguments being reals. If you do not want or expect complex numbers as results, you may want to restrict the type of the arguments, which may have a beneficial impact on performance."
|
||||
this-syntax))
|
||||
;; We don't actually want to match.
|
||||
#:when #f
|
||||
#:with real-binding #'#f ; required, otherwise syntax/parse is not happy
|
||||
|
|
|
@ -77,12 +77,7 @@
|
|||
(define (log-float-real-missed-opt stx irritants)
|
||||
(log-missed-optimization
|
||||
"all args float-arg-expr, result not Float"
|
||||
#:msg
|
||||
(format "This expression has type ~a. It would be better optimized if it had a Float type. To fix this, change the irritant~a to have~a Float type~a."
|
||||
(print-res (type-of stx))
|
||||
(if (> (length irritants) 1) "s" "")
|
||||
(if (> (length irritants) 1) "" " a")
|
||||
(if (> (length irritants) 1) "s" "")) ; plural
|
||||
"This expression has a Real type. It would be better optimized if it had a Float type. To fix this, change the circled expression(s) to have Float type(s)."
|
||||
stx irritants))
|
||||
|
||||
(define-syntax-class float-opt-expr
|
||||
|
@ -135,7 +130,8 @@
|
|||
;; which don't perform arithmetic despite returning numbers.
|
||||
[e:arith-expr
|
||||
(log-missed-optimization
|
||||
"exact arithmetic subexpression inside a float expression, extra precision discarded"
|
||||
"exact ops inside float expr"
|
||||
"This expression has a Float type, but the circled subexpression(s) use exact arithmetic. The extra precision of the exact arithmetic will be lost. Using Float types in these subexpression(s) may result in performance gains without significant precision loss."
|
||||
this-syntax subexpr)]
|
||||
[_ #f])))
|
||||
safe-to-opt?)
|
||||
|
|
|
@ -90,8 +90,7 @@
|
|||
|
||||
;; Attempts to merge the incoming missed optimization with existing ones.
|
||||
;; Otherwise, adds the new one to the log.
|
||||
(define (log-missed-optimization kind stx [irritants '()]
|
||||
#:msg [msg kind])
|
||||
(define (log-missed-optimization kind msg stx [irritants '()])
|
||||
;; for convenience, if a single irritant is given, wrap it in a list
|
||||
;; implicitly
|
||||
(let* ([irritants (if (list? irritants) irritants (list irritants))]
|
||||
|
|
|
@ -33,6 +33,12 @@
|
|||
[(tc-result1: (MPair: _ _)) #t]
|
||||
[_ #f]))
|
||||
|
||||
(define (log-pair-missed-opt stx irritant)
|
||||
(log-missed-optimization
|
||||
"car/cdr on a potentially empty list"
|
||||
"According to its type, the circled list could be empty. Access to it cannot be safely optimized. To fix this, restrict the type to non-empty lists, maybe by wrapping this expression in a check for non-emptiness."
|
||||
stx irritant))
|
||||
|
||||
(define-syntax-class pair-opt-expr
|
||||
#:commit
|
||||
(pattern e:pair-derived-opt-expr
|
||||
|
@ -44,19 +50,13 @@
|
|||
;; in this case, we have a potentially empty list, but
|
||||
;; it has to be a list, otherwise, there would have been
|
||||
;; a type error
|
||||
(begin
|
||||
(log-missed-optimization "car/cdr on a potentially empty list"
|
||||
this-syntax #'p)
|
||||
#f))
|
||||
(begin (log-pair-missed-opt this-syntax #'p) #f))
|
||||
#:with opt
|
||||
(begin (log-optimization "pair" this-syntax)
|
||||
#`(op.unsafe #,((optimize) #'p))))
|
||||
(pattern (#%plain-app op:mpair-op p:expr e:expr ...)
|
||||
#:when (or (has-mpair-type? #'p)
|
||||
(begin
|
||||
(log-missed-optimization "mpair op on a potentially empty mlist"
|
||||
this-syntax #'p)
|
||||
#f))
|
||||
(begin (log-pair-missed-opt this-syntax #'p) #f))
|
||||
#:with opt
|
||||
(begin (log-optimization "mutable pair" this-syntax)
|
||||
#`(op.unsafe #,@(syntax-map (optimize) #'(p e ...))))))
|
||||
|
|
Loading…
Reference in New Issue
Block a user