When accumulating the GEP offset in BasicAA, we should use the pointer index size rather than the pointer size.
Details
Diff Detail
Event Timeline
llvm/lib/Analysis/BasicAliasAnalysis.cpp | ||
---|---|---|
552 | The use of maximum pointer/index size seems suspect here. Shouldn't we be working in the bitwidth of a single AS at all times? |
llvm/lib/Analysis/BasicAliasAnalysis.cpp | ||
---|---|---|
552 | GEP decomposition looks through address space casts, so the index size can change. It does mostly work with the index size of a single AS and then sext up to the maximum size, though the precise way it does so is not quite correct in some respects (wrt sext/mul commutativity and scale adjustment -- fixing this needs some more preliminary work though). It would certainly make things easier if we could get away with not looking through address space casts, but I'm not sure that's viable. |
llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp | ||
---|---|---|
509 | @aardappel @tlively Is it okay to check the address space zero pointer size here? I don't really want to retain a separate getMaxPointerSize() method for only this usage, which looks like a bit of a hack anyway. |
llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp | ||
---|---|---|
509 | Yes, AS 0 is the correct one to check here. |
llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp | ||
---|---|---|
509 | LGTM |
Thanks, this LGTM and should hopefully avoid some unnecessary extends to 128 bits for CHERI.
I think it would be nice if we could avoid the use of the max pointer/index size here but that is an unrelated change that can be looked into later.
clang-format: please reformat the code