implement a simple alias analysis

This commit is contained in:
Quentin Carbonneaux 2016-10-04 12:02:39 -04:00
parent 12f9d16c7b
commit 8fdea1dd52
3 changed files with 183 additions and 2 deletions

29
all.h
View file

@ -20,6 +20,7 @@ typedef struct Ins Ins;
typedef struct Phi Phi;
typedef struct Blk Blk;
typedef struct Use Use;
typedef struct Alias Alias;
typedef struct Tmp Tmp;
typedef struct Con Con;
typedef struct Addr Mem;
@ -104,8 +105,8 @@ struct Ref {
enum {
RTmp,
RCon,
RSlot,
RType,
RSlot,
RCall,
RMem,
};
@ -362,6 +363,26 @@ struct Use {
} u;
};
enum {
NoAlias,
MayAlias,
MustAlias
};
struct Alias {
enum {
ABot = 0,
ALoc = 1, /* stack local */
ACon = 2,
AEsc = 3, /* stack escaping */
ASym = 4,
AUnk = 6,
} type;
Ref base;
char label[NString];
int64_t offset;
};
struct Tmp {
char name[NString];
Use *use;
@ -374,6 +395,7 @@ struct Tmp {
bits m;
} hint;
int phi;
Alias alias;
int visit;
};
@ -534,6 +556,11 @@ void fillfron(Fn *);
/* mem.c */
void memopt(Fn *);
/* alias.c */
void fillalias(Fn *);
int alias(Ref, int, Ref, int, int *, Fn *);
int escapes(Ref, Fn *);
/* ssa.c */
void filluse(Fn *);
void fillpreds(Fn *);