[PATCH] D127728: [BitcodeReader] Allow reading pointer types from old IR

Sebastian Neubauer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 14 02:09:15 PDT 2022


sebastian-ne created this revision.
sebastian-ne added reviewers: nikic, beanz, tpr, aeubanks.
Herald added a subscriber: hiraditya.
Herald added a project: All.
sebastian-ne requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

When opaque pointers are enabled and old IR with typed pointers is read,
the BitcodeReader automatically upgrades all typed pointers to opaque
pointers. This is a lossy conversion, i.e. when a function argument is a
pointer and unused, it’s impossible to reconstruct the original type
behind the pointer.

There are cases where the type information of pointers is needed. One is
reading DXIL, which is bitcode of old LLVM IR and makes a lot of use of
pointers in function signatures.
We’d like to keep using up-to-date llvm to read in and process DXIL, so
in the face of opaque pointers, we need some way to access the type
information of pointers from the read bitcode.

This patch allows extracting type information by supplying a function to
parseBitcodeFile that gets called for each function signature. This
function can access the type information via the reader’s type IDs and
the getTypeByID and getContainedTypeID functions.
The AccessBitcodeTypeInfo test exemplarily shows how type info from
pointers can be stored in metadata for use after the BitcodeReader
finished.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127728

Files:
  llvm/include/llvm/Bitcode/BitcodeReader.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/unittests/Bitcode/BitReaderTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127728.436711.patch
Type: text/x-patch
Size: 15358 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220614/5fc5a9fd/attachment-0001.bin>


More information about the llvm-commits mailing list