Skip to content
Snippets Groups Projects
Forked from cmucl / cmucl
Source project has a limited visibility.
  • rtoy's avatar
    31ddb605
    Port SBCL'S support for detecting when destructive functions (such as · 31ddb605
    rtoy authored
    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.
    31ddb605
    History
    Port SBCL'S support for detecting when destructive functions (such as
    rtoy authored
    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.