[llvm-dev] Cast a function parameter to GEP

Alberto Barbaro via llvm-dev llvm-dev at lists.llvm.org
Fri Mar 8 21:50:04 PST 2019


Hi all,
I'm still working on the Interpreter class and I would like to understand
why an operand cannot be cast to GetElementPtrInst.

My code is something like:

void MyInterpreter::visitCallInst(CallInst& I)
{
    for(int i = 0; i < I.getNumArgOperands(); i++) {
            operand = I.getOperand(i);

            if(GetElementPtrInst* CI =
dyn_cast<GetElementPtrInst>(operand)) {
                errs() << "GEP\n";
            } else {
                operand->dump();
            }
}

The specific output is:

i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str1, i32 0, i32 0)

and str1 is @.str1 = private unnamed_addr constant [7 x i8] c"1.2.34\00",
align 1

I think it does not work because str1 is a "private constant". Is there a
way to solve it?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190309/a72288a4/attachment.html>


More information about the llvm-dev mailing list