Skip to content

Abstract away FieldArrays when parsing #304

@RyanGlScott

Description

@RyanGlScott

In multiple instances, we have encountered parsing bugs related to the fact that LLVM bitcode can encode certain constructs' operands in multiple ways:

Both of these issues ultimately stem from the way llvm-pretty-bc-parser handles FieldArrays. The upstream LLVM tooling abstracts over FieldArrays for the most part, and the LLVM code which parses bitcode generally does not have to distinguish FieldArray operands from non-FieldArray operands. llvm-pretty-bc-parser, on the other hand, does distinguish between them, which means that the low-level parsing code must explicitly check for the presence of FieldArrays in any construct that might possibly make use of them. This feels like a poor separation of concerns.

I propose that we reconsider our approach to parsing FieldArrays. In particular, I propose that we "flatten" records (in the style of flattenRecord) before parsing operands such that we normalize the representation of records to abstract over whether operands are encoded using arrays or not. (We might even consider having a separate data type from Field that does not contain FieldArray to avoid non-representable states.) As far as I can tell, LLVM's tooling is doing something similar.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions