[llvm-dev] confused GetElementPtr, how to use it properly.

PeiLIU via llvm-dev llvm-dev at lists.llvm.org
Wed May 11 07:04:11 PDT 2016


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160511/b4cccedd/attachment.html>


More information about the llvm-dev mailing list