How to extract the array index value from getelementptr instruction of llvm -
array[5] = 20; equivalent llvm ir
%arrayidx = getelementptr inbounds i32, i32* %2, i64 5 store i32 20, i32* %arrayidx, align 4 how extract 5 llvm ir ?
if have getelementptrinst* gep, can access indices using gep->getoperand(i) (with operand 0 being pointer, , remaining operands being indices). value 5, can check index constantint , if value, this:
if (constantint *ci = dyn_cast<constantint>(gep->getoperand(1)) { uint64_t idx = ci->getzextvalue(); }
Comments
Post a Comment