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

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -