This is an archive of the discontinued LLVM Phabricator instance.

[Bitcode] Fully support opaque pointer auto upgrade
ClosedPublic

Authored by nikic on Feb 24 2022, 4:02 AM.

Details

Reviewers
aeubanks
Group Reviewers
Restricted Project
Commits
rGe3a9f68e2c1d: [Bitcode] Fully support opaque pointer auto upgrade
Summary

This completes the propagation of type IDs through bitcode reading, and switches remaining uses of getPointerElementType() to use contained type IDs.

The main new thing here is that sometimes we need to create a type ID for a type that was not explicitly encoded in bitcode (or we don't know its ID). For such types we create a "virtual" type ID, which is cached based on the type and the contained type IDs. Luckily, we generally only need zero or one contained type IDs, and in the one case where we need two, we can get away with not including it in the cache key.

With this change, we pass the entirety of llvm-test-suite at O3 with opaque pointers.

Diff Detail

Event Timeline

nikic created this revision.Feb 24 2022, 4:02 AM
nikic requested review of this revision.Feb 24 2022, 4:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 24 2022, 4:02 AM
nikic updated this revision to Diff 412640.Mar 3 2022, 2:13 AM

Rebase, some format fixes

Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2022, 2:13 AM

sorta makes sense, but I'm not understanding in what case we'd create a new virtual type id, can you give an example?

llvm/lib/Bitcode/Reader/BitcodeReader.cpp
492

could you give an example here of a case where we need a new type ID not in the bitcode?

nikic added a comment.Mar 3 2022, 10:04 AM

sorta makes sense, but I'm not understanding in what case we'd create a new virtual type id, can you give an example?

For example, if you have a function declaration, the bitcode might encode the function type (and have a type ID for it), but the value itself would be a pointer to a function type, for which there is either no ID, or we don't know about it at this point.

nikic updated this revision to Diff 412756.Mar 3 2022, 10:08 AM

Expand comment a bit.

aeubanks accepted this revision.Mar 3 2022, 10:14 AM
This revision is now accepted and ready to land.Mar 3 2022, 10:14 AM
This revision was landed with ongoing or failed builds.Mar 4 2022, 1:23 AM
This revision was automatically updated to reflect the committed changes.