This is an archive of the discontinued LLVM Phabricator instance.

[IR] Don't accept nullptr as GEP element type
ClosedPublic

Authored by nikic on Jul 8 2021, 12:48 PM.

Details

Summary

GetElementPtrInst::Create() (and IRBuilder methods based on it) currently accept nullptr as the element type, and will fetch the element type from the pointer in that case. Remove this fallback, as it is incompatible with opaque pointers. I've removed a handful of leftover calls using this behavior as a preliminary step.

Out-of-tree code affected by this change should either pass a proper type, or can temporarily explicitly call getPointerElementType(), if the newly added assertion is encountered.

Diff Detail

Event Timeline

nikic created this revision.Jul 8 2021, 12:48 PM
nikic requested review of this revision.Jul 8 2021, 12:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 8 2021, 12:48 PM
aeubanks accepted this revision.Jul 8 2021, 1:23 PM
aeubanks added a subscriber: aeubanks.

awesome!

This revision is now accepted and ready to land.Jul 8 2021, 1:23 PM
This revision was automatically updated to reflect the committed changes.