Safely reading uninitialized memory

Hmm, so reading uninitialized values in LLVM isn't UB; it's undef (LLVM Language Reference Manual — LLVM 18.0.0git documentation). But that doesn't save you, I don't think. In the code from the paper,

is-member(i):
    return sparse[i] < n && dense[sparse[i]] == i

I think that if sparse[i] is potentially undef, so that whole expression can probably become undef, since the guard just becomes undef.

I think what you need is freeze, which has been talked about for LLVM but I don't think it exists yet.