Skip to content

Instantly share code, notes, and snippets.

@Keno
Created March 19, 2021 02:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Keno/71cf183a0028ece90d93eeb0d7696f83 to your computer and use it in GitHub Desktop.
Save Keno/71cf183a0028ece90d93eeb0d7696f83 to your computer and use it in GitHub Desktop.
struct effects {
// Meaning of concepts:
//
// idempotent - The function will always return the same value when given
// identical argument, irrespective of the heap state. In
// particular, this means that the return value (or any other
// side effect) does not depend on non-constant globals, loads
// from memory, or mutable structs.
//
// effect_free - The function has no side effects at all. In particular,
// the execution or non-execution of the function may not
// be observed. All writes to memory or modification of other
// global state are disallowed.
//
// nothrow - The function will never terminate by throwing an exception.
// Note that exceptions may still be used internally as long
// as they are handled on all paths.
//
// terminates - The function is known to terminate eventually (i.e. will
// never infinite loop).
//
// ipo_safe - All possible optimizations of this function have bitwise-
// equivalent return values. This property can fail e.g.
// for functions that contain reorderable floating point
// operations.
// ALWAYS_FALSE: The property is false for the present function, and
// more precise signature information will never make it true.
//
// ALWAYS_TRUE: The property is true for the present function, including
// for all signatures that are subtypes of the present specialization.
//
// COND_FALSE: The property is false, but the statement causing it to fail
// does not post-dominate, so it is possible for more precise
// signature information to improve the precision (in either
// direction).
//
// UNKNOWN: The function contained unknown calls for which the property could
// not be resolved. For now the same as COND_FALSE, but may be
// distinguished in the future if useful
enum tristate { ALWAYS_FALSE = 0x00, ALWAYS_TRUE = 0x01, COND_FALSE=0x02, UNKNOWN=COND_FALSE };
enum tristate ipo_safe;
// Information computed by inference that is valid to propoagate
// interprocedurally. If ipo_safe is always_true, it is valid to
// substitute the non-ipo versions instead.
enum tristate ipo_idempotent;
enum tristate ipo_effect_free;
enum tristate ipo_nothrow;
enum tristate ipo_terminates;
// Properties that apply to the present CodeInstance. However, it is
// possible for these flags to differ between optimizations unless ipo_safe
// is set to ALWAYS_TRUE. If ipo_safe is not set thusly, these flags are
// legal to use in the optimizer, but inference may not look at them.
enum tristate idempotent;
enum tristate effect_free;
enum tristate nothrow;
enum tristate terminates;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment