This needs to take in account the fact that the value can have a non-integer type, for example it can be an address constant. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- sparse-llvm.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sparse-llvm.c b/sparse-llvm.c index 9f362b3ed..41ee1fa1f 100644 --- a/sparse-llvm.c +++ b/sparse-llvm.c @@ -303,6 +303,30 @@ static void pseudo_name(pseudo_t pseudo, char *buf) } } +static LLVMValueRef val_to_value(struct function *fn, unsigned long long val, struct symbol *ctype) +{ + LLVMTypeRef dtype; + LLVMTypeRef itype; + LLVMValueRef result; + + assert(ctype); + dtype = symbol_type(fn->module, ctype); + switch (LLVMGetTypeKind(dtype)) { + case LLVMPointerTypeKind: + itype = LLVMIntType(bits_in_pointer); + result = LLVMConstInt(itype, val, 1); + result = LLVMConstIntToPtr(result, dtype); + break; + case LLVMIntegerTypeKind: + result = LLVMConstInt(dtype, val, 1); + break; + default: + assert(0); + } + + return result; +} + static LLVMValueRef pseudo_to_value(struct function *fn, struct instruction *insn, pseudo_t pseudo) { LLVMValueRef result = NULL; -- 2.11.1 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html