llvm-project
fb89552b - [GlobalISel] Translate byte to ptr bitcasts to `G_INTTOPTR`/`G_PTRTOINT` (#226541)

Commit
3 days ago
[GlobalISel] Translate byte to ptr bitcasts to `G_INTTOPTR`/`G_PTRTOINT` (#226541) Reverts #209557 and fixes the underlying crash it worked around. A `bitcast` from a byte type to a pointer is valid IR and preserves pointer provenance. #209557 replaced it with a `bitcast` to `i64` followed by `inttoptr`, which drops provenance. That's unsound. The crash came from the IRTranslator. It lowered scalar byte to pointer bitcasts to `G_INTTOPTR` and `G_PTRTOINT`, but left vector forms as `G_BITCAST`. The MachineVerifier rejects that when the pointer side is a scalar pointer. We now go through an integer matching the pointer size, and add a `G_BITCAST` first when the shapes differ: ```diff %r = bitcast <2 x b32> %v to ptr -%r:_(p0) = G_BITCAST %v(<2 x i32>) ; bitcast cannot convert between pointers and other types +%i:_(i64) = G_BITCAST %v(<2 x i32>) +%r:_(p0) = G_INTTOPTR %i(i64) ```
Author
Parents
Loading