This is an archive of the discontinued LLVM Phabricator instance.

[OpaquePtr] Make GEPs work with opaque pointers
ClosedPublic

Authored by aeubanks on May 18 2021, 8:41 PM.

Details

Summary

No verifier changes needed, the verifier currently doesn't check that
the pointer operand's pointee type matches the GEP type. There is a
similar check in GetElementPtrInst::Create() though.

Diff Detail

Event Timeline

aeubanks created this revision.May 18 2021, 8:41 PM
aeubanks requested review of this revision.May 18 2021, 8:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 18 2021, 8:41 PM
dblaikie accepted this revision.May 19 2021, 11:28 AM

Looks OK if that expression cleanup can be done - if it can't be done for some reason, might be worth adding a utility function like isOpaqueOrPointeeTypeMatches that can handle this case.

llvm/include/llvm/IR/Instructions.h
956–958

Could this be written as:

assert(cast<PointerType>(Ptr->getType()->getScalarType())->isOpaqueOrPointeeTypeMatches(PointeeType));

? (similarly above)

This revision is now accepted and ready to land.May 19 2021, 11:28 AM
aeubanks updated this revision to Diff 346522.May 19 2021, 11:37 AM

use isOpaqueOrPointeeTypeMatches()

This revision was automatically updated to reflect the committed changes.