This is an archive of the discontinued LLVM Phabricator instance.

[Bitcode] Store type IDs for values
ClosedPublic

Authored by nikic on Feb 15 2022, 2:12 AM.

Details

Reviewers
aeubanks
Group Reviewers
Restricted Project
Commits
rGb6eafba296fc: [Bitcode] Store type IDs for values
Summary

This is the next step towards supporting bitcode auto upgrade with opaque pointers. The ValueList now stores the Value* together with its associated type ID, which allows inspecting the original pointer element type of arbitrary values.

This is a largely mechanical change threading the type ID through various places. I've left TODOTypeID placeholders in a number of places where determining the type ID is either non-trivial or requires allocating a new type ID not present in the original bitcode. For this reason, the new type IDs are also not used for anything yet (apart from propagation). They will get used once the TODOs are resolved.

Diff Detail

Event Timeline

nikic created this revision.Feb 15 2022, 2:12 AM
nikic requested review of this revision.Feb 15 2022, 2:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 15 2022, 2:12 AM

could you give an example of what this will be used for?

nikic added inline comments.Feb 17 2022, 10:37 AM
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
5226

@aeubanks For example, here we'd write Ty = getTypeByID(ResTypeID). Similar for other remaining uses of getPointerElementType().

aeubanks accepted this revision.Feb 21 2022, 1:29 PM
aeubanks added inline comments.
llvm/lib/Bitcode/Reader/ValueList.cpp
125

should this also check TyID?

llvm/lib/Bitcode/Reader/ValueList.h
29

could you add a comment about what the unsigned represents?

This revision is now accepted and ready to land.Feb 21 2022, 1:29 PM
nikic marked an inline comment as done.Feb 22 2022, 8:24 AM
nikic added inline comments.
llvm/lib/Bitcode/Reader/ValueList.cpp
125

I'm not entirely sure here, but I think not, as multiple type IDs may encode the same type, and these would be technically compatible.

I'll check this again once the full propagation is implemented, as we can currently get a dummy ID here.

This revision was landed with ongoing or failed builds.Feb 22 2022, 8:27 AM
This revision was automatically updated to reflect the committed changes.