Skip to content
Snippets Groups Projects
Commit 31ddb605 authored by rtoy's avatar rtoy
Browse files

Port SBCL'S support for detecting when destructive functions (such as

nreverse) modify constant args and for warning when the result of
destructive functions is not used.

Detecting modification of constant args is done by adding a new IR1
transformation that checks that a function is not destructively
modifying constants or literals.

A new IR1 attribute, important-result, is used to determine if the
result of a function should be used instead of discarded.  (Note:
this means some functions are not detected.  This should probably be
implemented as another transform so the compiler can detect those cases.)

code/error.lisp:
o Add new condition CONSTANT-MODIFIED.

compiler/fndb.lisp:
o Note destructive functions that should not modify constant args
o Note destructive functions whose results should be used.

compiler/ir1opt.lisp:
o Add new function CHECK-IMPORTANT-RESULT to check if the result is
  used.
o Update IR1-OPTIMIZE-COMBINATION to check if a function destructively
  modifies constant args or if the result of a destructive function is
  not used.

compiler/knownfun.lisp:
o Add new IR1 attribute, IMPORTANT-RESULT, to indicate that the result
  of a function should be used.
o Add new FUNCTION-INFO slot, DESTROYED-CONSTANT-ARGS.  This holds a
  function for computing the constant or literal arguments which are
  destructively modified by the function.
o Add support functions for DESTROYED-CONSTANT-ARGS functions.
parent ebda7384
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment