static Value *mark_julia_type(Value *v, jl_value_t *jt) { if (jt == (jl_value_t*)jl_any_type || v->getType()==jl_pvalue_llvmt) return v; if (has_julia_type(v)) { if (julia_type_of(v) == jt) return v; } else if (julia_type_of_without_metadata(v,false) == jt) { return v; } if (dyn_cast<Instruction>(v) == NULL) v = NoOpInst(v); assert(dyn_cast<Instruction>(v)); char name[3]; int id = jl_type_to_typeid(jt); // store id as base-255 to avoid NUL name[0] = (id%255)+1; name[1] = (id/255)+1; name[2] = '\0'; MDString *md = MDString::get(jl_LLVMContext, name); MDNode *mdn = MDNode::get(jl_LLVMContext, ArrayRef<Value*>(md)); ((Instruction*)v)->setMetadata("julia_type", mdn); return v; }
static Value *tpropagate(Value *a, Value *b) { if (has_julia_type(a)) return mark_julia_type(b, julia_type_of(a)); return b; }