2 * aliasing.h: Alias Analysis
5 * Massimiliano Mantione (massi@ximian.com)
7 * (C) 2005 Novell, Inc. http://www.novell.com
10 #ifndef __MONO_ALIASING_H__
11 #define __MONO_ALIASING_H__
15 #define MONO_ALIASING_INVALID_VARIABLE_INDEX (-1)
18 * A struct representing the element of a list of local variables.
20 typedef struct MonoLocalVariableList
{
21 /* The index of the local variable */
24 /* Next in the list */
25 struct MonoLocalVariableList
*next
;
26 } MonoLocalVariableList
;
29 * A struct representing the information about the fact that an address
30 * that could be an alias is used.
32 typedef struct MonoAliasUsageInformation
{
33 /* The inst where the address is used */
36 /* The possibly aliased variables. Note that if this field is null */
37 /* it means that any "problematic" variable could be aliased! */
38 MonoLocalVariableList
*affected_variables
;
40 /* Next in the list */
41 struct MonoAliasUsageInformation
*next
;
42 } MonoAliasUsageInformation
;
46 * All the different kinds of locations for a variable's address.
47 * "ANY" means the location is unknown or cannot be handled.
50 MONO_ALIASING_TYPE_ANY
,
51 MONO_ALIASING_TYPE_NO_ALIAS
,
52 MONO_ALIASING_TYPE_LOCAL
,
53 MONO_ALIASING_TYPE_LOCAL_FIELD
56 typedef struct MonoAliasValue
{
62 * A struct representing the aliasing information in a BB.
64 typedef struct MonoAliasingInformationInBB
{
65 /* The BB to which these info are relaed. */
68 /* Info on alias usage. */
69 MonoAliasUsageInformation
*potential_alias_uses
;
70 } MonoAliasingInformationInBB
;
73 * A struct representing the aliasing information in a MonoCompile.
75 typedef struct MonoAliasingInformation
{
76 /* The MonoCompile to which these info are relaed. */
79 /* The pool from where everything is allocated (including this struct). */
82 /* Aliasing info for each BB */
83 MonoAliasingInformationInBB
*bb
;
85 /* The variables whose address has been taken and "lost": any pointer */
86 /* with an unknown value potentially aliases these variables. */
87 MonoLocalVariableList
*uncontrollably_aliased_variables
;
89 /* Used to track the current inst when traversing inst trees in a BB. */
90 MonoAliasUsageInformation
*next_interesting_inst
;
92 /* Array containing one MonoLocalVariableList for each local variable. */
93 MonoLocalVariableList
*variables
;
95 /* Array containing one flag for each local variable stating if it is */
96 /* already in the uncontrollably_aliased_variables list. */
97 gboolean
*variable_is_uncontrollably_aliased
;
99 /* This MonoLocalVariableList is a placeholder for uncontrollably_aliased_variables */
100 /* while the aliasing info are still being collected. */
101 MonoLocalVariableList
*temporary_uncontrollably_aliased_variables
;
103 /* An array of MonoInst* containing all the arguments to the next call. */
104 MonoInst
**arguments
;
105 /* An array of MonoAliasValue containing all the aliases passed to the arguments of the next call. */
106 MonoAliasValue
*arguments_aliases
;
107 /* The total capacity of the "arguments" and "arguments_aliases" arrays. */
108 int arguments_capacity
;
109 /* The number of used elements in the "arguments" and "arguments_aliases" arrays. */
110 int number_of_arguments
;
111 } MonoAliasingInformation
;
113 extern MonoAliasingInformation
*
114 mono_build_aliasing_information (MonoCompile
*cfg
) MONO_INTERNAL
;
116 mono_destroy_aliasing_information (MonoAliasingInformation
*info
) MONO_INTERNAL
;
118 mono_aliasing_initialize_code_traversal (MonoAliasingInformation
*info
, MonoBasicBlock
*bb
) MONO_INTERNAL
;
119 extern MonoLocalVariableList
*
120 mono_aliasing_get_affected_variables_for_inst_traversing_code (MonoAliasingInformation
*info
, MonoInst
*inst
) MONO_INTERNAL
;
121 extern MonoLocalVariableList
*
122 mono_aliasing_get_affected_variables_for_inst (MonoAliasingInformation
*info
, MonoInst
*inst
) MONO_INTERNAL
;
125 mono_aliasing_deadce (MonoAliasingInformation
*info
) MONO_INTERNAL
;
127 #endif /* __MONO_ALIASING_H__ */