Comparing constant values of aggregate types for equality

Hi,

This seems to me to be a straight-forward operation and perhaps available within LLVM’s API but I’ve been unable to find any guidance via google / stackoverflow.

I’m looking to do value equality comparison on aggregate types (arrays and structs), and want to have special handling for when they are constant for two use cases:

  • Creating only a single global constant instead of several when their values are equal and won’t be modified

  • Optimizing the value equality operation when both operands are constant

This is trivial with ConstantExpr::getICmp and ConstantExpr::getFCmp for primitive types, and seems straight-forward to do recursively for structs and arrays. So I could roll my own but I’m sure this has been done already?

However I can’t find any standard implementation, can someone point me in the right direction?

Thanks,
/Christer