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

Jannik Silvanus via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 09:59:31 PST 2023


jsilvanus added a comment.

High-level comment regarding how to pass callbacks to parser functions: We have quite a few different parser routines, both for textual IR and bitcode, and special modes (e.g. lazy loaders).
This leads to many places where we would add essentially the same arguments, often with default values. Some functions miss these (e.g. `getLazyBitcodeModule`), because nobody bothered so far to add callback(s) for them.

Maybe we could instead add a `ParserCallbackCollection` that is passed to parser methods and contains the various callbacks available for parsing?



================
Comment at: llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1337-1340
   // If we have a forward reference, the only possible case is when it is to a
   // named struct.  Just create a placeholder for now.
   return TypeList[ID] = createIdentifiedStructType(Context);
 }
----------------
The assumptions here seem to be based on the existing calls from within the parser. If we expose `getTypeByID` and `getContainedTypeID` to callers, these might no longer hold.

Maybe use an additional argument that flags external callbacks, and just return `nullptr` in that case?


================
Comment at: llvm/unittests/Bitcode/BitReaderTest.cpp:307
+// are the argument types.
+Metadata *getTypeMetadataEntry(unsigned TypeID, LLVMContext &Context,
+                               GetTypeByIDTy GetTypeByID,
----------------
static


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127728/new/

https://reviews.llvm.org/D127728



More information about the llvm-commits mailing list