[llvm-dev] confused GetElementPtr, how to use it properly.
Diana Picus via llvm-dev
llvm-dev at lists.llvm.org
Wed May 11 08:27:49 PDT 2016
Try casting to GetElementPtrConstantExpr.
Hope that helps,
Diana
http://llvm.org/docs/doxygen/html/classllvm_1_1GetElementPtrConstantExpr.html
On 11 May 2016 at 17:04, PeiLIU via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> BasicBlock::iterator bit = BB->begin();
>
> LoadInst *li = = dyn_cast<LoadInst>(bit);
>
> li->dump(); // %tmp6 = load i32* getelementptr inbounds (%struct.node*
> @Node, i32 0, i32 0), align 4, !dbg !59
>
> li->getOperand(0)->dump(); // i32* getelementptr inbounds (%struct.node*
> @Node, i32 0, i32 0), align 4, !dbg !59
>
> GetElementPtrInst *gep = dyn_cast<GetElementPtrInst>(li->getOperand(0));
>
> if (gep != NULL) {
> std::cout << "gep not NULL" << std::endl;
> }
>
> The previous codes' BB is a BasicBlock pointer, I want to get the string
> name Node. I want to use dyn_cast to cast
>
> the value of li->getOperand(0) to a GetElementPtr pointer type, but it is
> likely can not casted by the dyn_cast operation.
>
> The if statement never executed. How it can be implemented? I confused by
> the load instruction? Any advice would be
>
> appreciate, thank you.
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
More information about the llvm-dev
mailing list