How can I check if two GEP instructions are semantically equal or not?

Viewed 185

I have two GEP instructions looking like below:

%size = getelementptr inbounds %struct.ArrayInfo, %struct.ArrayInfo* %0, i32 0, i32 0

...
%size = getelementptr inbounds %struct.ArrayInfo, %struct.ArrayInfo* %1, i32 0, i32 0

Essentially these two are accessing the same struct field. Is there a way to check if these two instructions are equivalent in llvm? I tried comparing pointers of GEPOperator (GEPOperator*), but it looks like they are different.

1 Answers

Try isSameOperationAs(). If you cast both size variables in your example to llvm::Instruction and call this method on one with the other as an argument, you'll get a true value.

Related