This is an archive of the discontinued LLVM Phabricator instance.

[llvm-c] Add LLVMGetAggregateElement() function
ClosedPublic

Authored by nikic on Jun 23 2022, 2:53 AM.

Details

Summary

This adds LLVMGetAggregateElement as a wrapper for Constant::getAggregateElement, which allows fetching a struct/array/vector element without handling different possible underlying representations.

As the changed echo test shows, previously you for example had to treat ConstantArray (use LLVMGetOperand) and ConstantDataArray (use LLVMGetElementAsConstant) separately, not to mention all the other possible representations (like PoisonValue).

I've deprecated LLVMGetElementAsConstant in favor of the new function, which is strictly more powerful (but I could be convinced to drop the deprecation).

This is partly motivated by https://reviews.llvm.org/D125795, which drops LLVMConstExtractValue because the underlying constant expression no longer exists. This function could previously be used as a poor man's getAggregateElement().

Diff Detail

Event Timeline

nikic created this revision.Jun 23 2022, 2:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2022, 2:53 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
nikic requested review of this revision.Jun 23 2022, 2:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2022, 2:53 AM
This revision is now accepted and ready to land.Jun 23 2022, 4:24 AM
This revision was landed with ongoing or failed builds.Jun 23 2022, 5:52 AM
This revision was automatically updated to reflect the committed changes.