Skip to content

uselistorder is broken for tools which load multiple files #58629

@arsenm

Description

@arsenm

Tools that load multiple files, such as llvm-diff, cannot handle 2 modules using uselistorder. On the parse of the second module, it sees the uses of constants in the first module, and errors when the indexes mismatch. The error is hard for text IR, and silently ignored for bitcode.

The error is failing on this check:

if (Order.size() != Indexes.size() || NumUses > Indexes.size())

The equivalent in the bitcode reader simply drops the uselistorder:

if (Order.size() != Record.size() || NumUses > Record.size())

A simple test which tries to run llvm-diff on the same input shows the issue:

uselistorder.ll:10:1: error: wrong number of indexes, expected 4
uselistorder ptr addrspace(4) null, { 1, 0 }
; RUN: llvm-diff %s %s

define void @func() {
entry:
  %gep0 = getelementptr inbounds i8, ptr addrspace(4) null, i64 12
  %gep1 = getelementptr i8, ptr addrspace(4) null, i64 4
  ret void
}

uselistorder ptr addrspace(4) null, { 1, 0 }

I'm not sure what the right solution is. We could parse these into their own contexts, but llvm-diff needs the two modules to share the context to compare. Alternatively, the bitcode parsing could check if the users belong to the same parent module when counting and sorting

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