LLVM IR
call void @llvm.dbg.declare(metadata i32* %z, metadata !24, metadata !DIExpression()), !dbg !25
%arraydecay1 = getelementptr inbounds [55 x i8], [55 x i8]* %input, i32 0, i32 0, !dbg !26
%call2 = call i64 @strlen(i8* %arraydecay1) #4, !dbg !28
strlen doc https://www.cplusplus.com/reference/cstring/strlen/
%call2 is the return value of strlen function which is of size_t type. I thought its a struct type but it turned out to be a pointer type, which is of type i64 (i8*)*
How do i de-reference and get the integer value contained in the pointer value.
Edit: I was using wrong operand but the problem is not solved yet. Its not about pointer type, int 64 type conversion that i have issues. See below
CallInst I; //passed by reference
CallSite cs(&I);
if(!cs.getInstruction()){
return;
} else {
for (User* user : cs.getInstruction()->users()) {
if (Instruction* i = dyn_cast<Instruction>(user)) {
Value *v1 = dyn_cast<Value>(i->getOperand(0));
errs() << "Type:==" << *(v1) << "\n";
errs() << "is integer type=" << (v1->getType()->isIntegerTy()) << "\n";
ConstantInt *cint = dyn_cast<ConstantInt>(v1);
if (cint) {
errs() << "constant int" << *cint << "\n";
} else {
errs() << "not a constant int??" << "\n";
}
}
}
}
Type:== %call2 = call i64 @strlen(i8* %arraydecay1) #4, !dbg !28
is integer type=1
not a constant int??