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

How to check data type in C++? -

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

sql server - SQL Query returns one result, does not return 0 or NULL result -