@@ -155,6 +155,8 @@ const char *show_pseudo(pseudo_t pseudo)
if (pseudo->ident)
sprintf(buf+i, "(%s)", show_ident(pseudo->ident));
break;
+ case PSEUDO_UNDEF:
+ return "UNDEF";
default:
snprintf(buf, 64, "<bad pseudo type %d>", pseudo->type);
}
@@ -21,6 +21,7 @@ DECLARE_PTR_LIST(pseudo_user_list, struct pseudo_user);
enum pseudo_type {
PSEUDO_VOID,
+ PSEUDO_UNDEF,
PSEUDO_REG,
PSEUDO_SYM,
PSEUDO_VAL,
@@ -290,7 +291,7 @@ static inline void add_pseudo_user_ptr(struct pseudo_user *user, struct pseudo_u
static inline int has_use_list(pseudo_t p)
{
- return (p && p->type != PSEUDO_VOID && p->type != PSEUDO_VAL);
+ return (p && p->type != PSEUDO_VOID && p->type != PSEUDO_UNDEF && p->type != PSEUDO_VAL);
}
static inline struct pseudo_user *alloc_pseudo_user(struct instruction *insn, pseudo_t *pp)
@@ -289,6 +289,7 @@ static void pseudo_name(pseudo_t pseudo, char *buf)
assert(0);
break;
case PSEUDO_VAL:
+ case PSEUDO_UNDEF:
assert(0);
break;
case PSEUDO_ARG: {
@@ -372,6 +373,9 @@ static LLVMValueRef pseudo_to_value(struct function *fn, struct instruction *ins
case PSEUDO_VOID:
result = NULL;
break;
+ case PSEUDO_UNDEF:
+ result = LLVMGetUndef(symbol_type(fn->module, insn->type));
+ break;
default:
assert(0);
}
Processing in the middle-end are much easier if undefined values have been clearly identified. Once done, we can then make choices like: - always initialize them to zero - allow arbitraly simplification, - ... Prepare for this by declaring a new type of pseudo: PSEUDO_UNDEF somewhat similar to PSEUDO_VOID. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- linearize.c | 2 ++ linearize.h | 3 ++- sparse-llvm.c | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-)