Add ArithmeticToGEP pass

Introduce the ArithmeticToGEP canonicalisation pass. It detects
pointers (LLVM-typed pointer values, model pointers flagged by the
"revng.pointers" metadata, and pointer-tagged extract values) and
rewrites integer arithmetic computed on top of them as i8 GEPs,
followed by a ptrtoint when the original use needs an integer.

For each obvious pointer the pass also walks backwards through Add
chains and disambiguates the pointer operand of each Add when the
other operand cannot be a pointer, so the rewrite extends to integer
arithmetic that only later flows into a pointer use.
This commit is contained in:
Pietro Fezzardi
2026-05-08 11:37:10 +02:00
parent 9111f127dd
commit cb5702dc04
5 changed files with 1509 additions and 0 deletions
+1
View File
@@ -353,6 +353,7 @@ branches:
- peephole-opt-for-decompilation
- ternary-reduction
- exit-ssa
- arithmetic-to-gep
- pipe: switch-to-statements
arguments: [llvm-functions]
- pipe: pure-llvm-passes-pipe