The code we had isSafeToLoadUnconditionally was blatantly wrong. This function takes a "Size" argument which is supposed to describe the span loaded from. Instead, the code use the size of the pointer passed (which may be unrelated!) and only checks that span. For any Size > LoadSize, this can and does lead to miscompiles.
Worse, the generic code just a few lines above correctly handles the cases which *are* valid. So, let's delete said code.
(Note: There's another occurrence of the same bug in the same function in the scan code. I'll get that next.)
Removing this exposes a bits vs bytes confusion in SROA + one other test change where the semantics of the test aren't clear to me. I propose to simply change the test output (as in the diff) and move on.
Can we have a test for this? I would hope something where we want to pre-loads a 64 bit pointer but only have a 32 bit access?